Big project cleanup with overhaul of file responsibilities (KISS) and code (DRY, YAGNI)

This commit is contained in:
2026-05-14 11:17:02 +02:00
parent bd6cdeb97b
commit 300c8f5a42
54 changed files with 2030 additions and 1745 deletions
+39 -42
View File
@@ -2,51 +2,48 @@ using Godot;
public class HarvestNode : ProgramNode
{
public HarvestNode()
{
DisplayText = "Harvest";
}
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];
public HarvestNode()
{
DisplayText = "Harvest";
}
if (!tile.containsResource)
{
lastExecutionMessage = "No resource on this tile";
return NodeResult.FAILURE;
}
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.resource.CanExtract())
{
lastExecutionMessage = "Resource is depleted and not endless or you haven't unlocked it yet";
return NodeResult.SUCCESS;
}
if (!tile.containsResource || tile.resource == null)
{
lastExecutionMessage = "No resource on this tile";
return NodeResult.FAILURE;
}
if (tile.resource.Extract(delta))
{
SoundManager.PlayMining();
if (!GameData.inventory.AddItem(new Item {data = tile.resource.item}, 1))
{
lastExecutionMessage = "Not enough space";
return NodeResult.FAILURE;
}
else
{
return NodeResult.SUCCESS;
}
}
return NodeResult.RUNNING;
}
if (!tile.resource.CanExtract())
{
lastExecutionMessage = "Resource is depleted and not endless or you haven't unlocked it yet";
return NodeResult.SUCCESS;
}
public override ProgramNode Duplicate()
{
HarvestNode duplicate = new HarvestNode();
return duplicate;
}
if (!tile.resource.Extract(delta)) return NodeResult.RUNNING;
public override string Save()
{
return $"Name: {DisplayText}";
}
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}";
}
}