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
+11 -32
View File
@@ -10,9 +10,9 @@ public class WhileNode : ProgramNode
{
DisplayText = "While";
}
public override NodeResult Execute(Robot robot, double delta)
{
if (selectedItem == null)
{
lastExecutionMessage = "No Item selected";
@@ -20,27 +20,21 @@ public class WhileNode : ProgramNode
}
bool isConditionFulfilled = DetermineCondition();
return isConditionFulfilled? NodeResult.SUCCESS : NodeResult.CONDITIONFALSE;
return isConditionFulfilled ? NodeResult.SUCCESS : NodeResult.CONDITIONFALSE;
}
private bool DetermineCondition()
{
int inventoryAmount = GameData.inventory.GetItemAmount(selectedItem.data.Id);
switch (comparator)
return comparator switch
{
case "is bigger than":
return inventoryAmount > amount;
case "is less than":
return inventoryAmount < amount;
case "is not":
return inventoryAmount != amount;
case "is less than or equal to":
return inventoryAmount <= amount;
case "is bigger than or equal to":
return inventoryAmount >= amount;
default:
return inventoryAmount == amount;
}
"is bigger than" => inventoryAmount > amount,
"is less than" => inventoryAmount < amount,
"is not" => inventoryAmount != amount,
"is less than or equal to" => inventoryAmount <= amount,
"is bigger than or equal to" => inventoryAmount >= amount,
_ => inventoryAmount == amount
};
}
public override ProgramNode Duplicate()
@@ -64,21 +58,6 @@ public class WhileNode : ProgramNode
Dictionary<StringName, ProgramNode> availableNodes
)
{
nextNode = null;
NegativeNode = null;
foreach (Godot.Collections.Dictionary connection in connections)
{
int port = (int)connection["from_port"];
ProgramNode connectedNode = GetConnectedNode(connection, availableNodes);
if (port == 0)
{
nextNode = connectedNode;
}
else
{
NegativeNode = connectedNode;
}
}
SetBranchNodes(connections, availableNodes);
}
}