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
+47 -25
View File
@@ -3,35 +3,57 @@ using System.Collections.Generic;
public abstract class ProgramNode
{
public ProgramNode nextNode;
public ProgramNode NegativeNode;
public string DisplayText;
public string lastExecutionMessage;
public ProgramNode nextNode;
public ProgramNode NegativeNode;
public string DisplayText;
public string lastExecutionMessage;
public abstract NodeResult Execute(Robot robot, double delta);
public abstract ProgramNode Duplicate();
public abstract string Save();
public abstract NodeResult Execute(Robot robot, double delta);
public abstract ProgramNode Duplicate();
public abstract string Save();
public virtual void SetNextNode(
List<Godot.Collections.Dictionary> connections,
Dictionary<StringName, ProgramNode> availableNodes
)
{
nextNode = null;
public virtual void SetNextNode(
List<Godot.Collections.Dictionary> connections,
Dictionary<StringName, ProgramNode> availableNodes
)
{
nextNode = null;
if (connections.Count <= 0) return;
if (connections.Count <= 0) return;
nextNode = GetConnectedNode(connections[0], availableNodes);
}
nextNode = GetConnectedNode(connections[0], availableNodes);
}
protected ProgramNode GetConnectedNode(
Godot.Collections.Dictionary connection,
Dictionary<StringName, ProgramNode> availableNodes
)
{
StringName nodeName = connection["to_node"].AsStringName();
if (!availableNodes.ContainsKey(nodeName)) return null;
protected void SetBranchNodes(
List<Godot.Collections.Dictionary> connections,
Dictionary<StringName, ProgramNode> availableNodes
)
{
nextNode = null;
NegativeNode = null;
return availableNodes[nodeName];
}
foreach (Godot.Collections.Dictionary connection in connections)
{
ProgramNode connectedNode = GetConnectedNode(connection, availableNodes);
if ((int)connection["from_port"] == 0)
{
nextNode = connectedNode;
}
else
{
NegativeNode = connectedNode;
}
}
}
protected ProgramNode GetConnectedNode(
Godot.Collections.Dictionary connection,
Dictionary<StringName, ProgramNode> availableNodes
)
{
StringName nodeName = connection["to_node"].AsStringName();
if (!availableNodes.ContainsKey(nodeName)) return null;
return availableNodes[nodeName];
}
}