using Godot; public class HarvestNode : ProgramNode { public HarvestNode() { DisplayText = "Harvest"; TooltipText = "Harvests one unit from the resource on the robot's current tile and adds the result to the shared inventory."; } public override NodeResult Execute(Robot robot, double delta) { Vector3I mapIndex = Pathfinding.GetClosestStartPoint(robot.Position); Tile tile = GameData.map[mapIndex.Y].tiles[mapIndex.X, mapIndex.Z]; if (!tile.containsResource || tile.resource == null) { lastExecutionMessage = "No resource on this tile"; return NodeResult.FAILURE; } if (!tile.resource.CanExtract()) { lastExecutionMessage = "Resource is depleted and not endless or you haven't unlocked it yet"; return NodeResult.SUCCESS; } if (!tile.resource.Extract(delta)) return NodeResult.RUNNING; SoundManager.PlayMining(); if (!GameData.inventory.AddItem(new Item { data = tile.resource.item }, 1)) { lastExecutionMessage = "Not enough space"; return NodeResult.FAILURE; } lastExecutionMessage = ""; return NodeResult.SUCCESS; } public override ProgramNode Duplicate() { return new HarvestNode(); } public override string Save() { return $"Name: {DisplayText}"; } }