diff --git a/Scripts/DSL/CodingWindow.cs b/Scripts/DSL/CodingWindow.cs index 9552f52..6853943 100644 --- a/Scripts/DSL/CodingWindow.cs +++ b/Scripts/DSL/CodingWindow.cs @@ -92,9 +92,13 @@ public partial class CodingWindow : PanelContainer string errorMessage = ""; bool didCompile; - for (int i = 1; i < editorWindow.GetChildCount(); i++) + for (int i = 0; i < editorWindow.GetChildCount(); i++) { - editorWindow.GetChild(i - 1).node.LinkNode(editorWindow.GetChild(i).node); + if (i + 1 < editorWindow.GetChildCount()) + { + editorWindow.GetChild(i).node.LinkNode(editorWindow.GetChild(i + 1).node); + } + editorWindow.GetChild(i).node.ReadParameters(editorWindow.GetChild(i)); } ProgramInterpreter interpreter = new ProgramInterpreter(editorWindow.GetChild(0).node); diff --git a/Scripts/DSL/Nodes/CraftNode.cs b/Scripts/DSL/Nodes/CraftNode.cs index a2d2069..91e7302 100644 --- a/Scripts/DSL/Nodes/CraftNode.cs +++ b/Scripts/DSL/Nodes/CraftNode.cs @@ -18,4 +18,9 @@ public class CraftNode : ProgramNode return true; } } + + public override void ReadParameters(NodeDisplay display) + { + // + } } \ No newline at end of file diff --git a/Scripts/DSL/Nodes/HarvestNode.cs b/Scripts/DSL/Nodes/HarvestNode.cs index 2f62a65..e4a865d 100644 --- a/Scripts/DSL/Nodes/HarvestNode.cs +++ b/Scripts/DSL/Nodes/HarvestNode.cs @@ -18,4 +18,9 @@ public class HarvestNode : ProgramNode return true; } } + + public override void ReadParameters(NodeDisplay display) + { + // + } } \ No newline at end of file diff --git a/Scripts/DSL/Nodes/MoveNode.cs b/Scripts/DSL/Nodes/MoveNode.cs index a631152..c9d8247 100644 --- a/Scripts/DSL/Nodes/MoveNode.cs +++ b/Scripts/DSL/Nodes/MoveNode.cs @@ -3,14 +3,16 @@ using Godot; public class MoveNode : ProgramNode { public Vector3 startPosition; - public Vector3 targetPosition; + public Vector3I targetPosition; public MoveNode() { DisplayText = "Move"; } public override bool Execute(Robot robot) { - robot.Position = targetPosition; + startPosition = robot.Position; + GD.Print(targetPosition); + robot.Position = GameData.map[targetPosition.Y].tiles[targetPosition.X, targetPosition.Z].Position; if (nextNode != null) { return nextNode.Execute(robot); @@ -20,4 +22,17 @@ public class MoveNode : ProgramNode return true; } } + + public override void ReadParameters(NodeDisplay display) + { + HBoxContainer valueContainer = display.GetNode("./EditorDisplay/HBoxContainer/"); + + GD.Print(valueContainer.GetNode("./CoordinateX").Value); + int posX = (int)valueContainer.GetNode("./CoordinateX").Value; + int posY = (int)valueContainer.GetNode("./CoordinateY").Value; + int posZ = (int)valueContainer.GetNode("./CoordinateZ").Value; + targetPosition = new Vector3I(posX, posY, posZ); + } + + } \ No newline at end of file diff --git a/Scripts/DSL/Nodes/ProgramNode.cs b/Scripts/DSL/Nodes/ProgramNode.cs index dc6f663..f05a01e 100644 --- a/Scripts/DSL/Nodes/ProgramNode.cs +++ b/Scripts/DSL/Nodes/ProgramNode.cs @@ -10,6 +10,7 @@ public abstract class ProgramNode } public abstract bool Execute(Robot robot); + public abstract void ReadParameters(NodeDisplay display); public void LinkNode(ProgramNode nextNode) { this.nextNode = nextNode; diff --git a/Scripts/Helpers/GameData.cs b/Scripts/Helpers/GameData.cs index 2e57624..dd7d39c 100644 --- a/Scripts/Helpers/GameData.cs +++ b/Scripts/Helpers/GameData.cs @@ -3,6 +3,7 @@ using Godot; public partial class GameData { + public static Layer[] map; //Current layer the player wants to see public static int currentLayer = 0; //The layer that is currently visible diff --git a/Scripts/WorldGeneration/World.cs b/Scripts/WorldGeneration/World.cs index c6603ea..c11944e 100644 --- a/Scripts/WorldGeneration/World.cs +++ b/Scripts/WorldGeneration/World.cs @@ -13,7 +13,6 @@ public partial class World : Node3D PackedScene layerPrefab = ResourceLoader.LoadLayerPrefab(); private Dictionary multiMeshes = new(); private Dictionary meshLibrary = new(); - Layer[] map; Layer layerNode; private MultiMeshHandler multiMeshHandler;