Reworked DSL for better architecture, implemented wall-phasing movement.
This commit is contained in:
+15
-17
@@ -7,6 +7,7 @@ public partial class CodingWindow : PanelContainer
|
||||
[Export] VBoxContainer codeBlocks;
|
||||
[Export] VBoxContainer editorWindow;
|
||||
public Dictionary<ProgramNode, PackedScene> DSLNodes;
|
||||
Robot robot;
|
||||
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
@@ -19,11 +20,13 @@ public partial class CodingWindow : PanelContainer
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
//TODO: If robot that was pressed has a script, load script
|
||||
if (Input.IsActionJustPressed("codingwindow"))
|
||||
{
|
||||
Visible = !Visible;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ShowWindow(Robot robot)
|
||||
{
|
||||
Visible = true;
|
||||
this.robot = robot;
|
||||
}
|
||||
|
||||
//Move, Harvest, Craft
|
||||
@@ -57,23 +60,18 @@ public partial class CodingWindow : PanelContainer
|
||||
|
||||
public void CompileProgram()
|
||||
{
|
||||
bool didCompile;
|
||||
List<ProgramNode> nodes = new List<ProgramNode>();
|
||||
|
||||
for (int i = 0; i < editorWindow.GetChildCount(); i++)
|
||||
{
|
||||
if (i + 1 < editorWindow.GetChildCount())
|
||||
{
|
||||
editorWindow.GetChild<NodeDisplay>(i).node.LinkNode(editorWindow.GetChild<NodeDisplay>(i + 1).node);
|
||||
}
|
||||
editorWindow.GetChild<NodeDisplay>(i).node.ReadParameters(editorWindow.GetChild<NodeDisplay>(i));
|
||||
nodes.Add(editorWindow.GetChild<NodeDisplay>(i).node.Duplicate());
|
||||
if (i != 0)
|
||||
{
|
||||
nodes[i-1].nextNode = nodes[i];
|
||||
}
|
||||
}
|
||||
|
||||
ProgramInterpreter interpreter = new ProgramInterpreter(editorWindow.GetChild<NodeDisplay>(0).node);
|
||||
didCompile = interpreter.Execute(GameData.robots[0]);
|
||||
|
||||
if (!didCompile)
|
||||
{
|
||||
|
||||
}
|
||||
robot.SetupExecution(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user