Added more symbols to the game, added gates blocking pathfinding and improved DSL feedback system with enum for better control and UX
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
public enum NodeResult
|
||||
{
|
||||
SUCCESS,
|
||||
FAILURE,
|
||||
RUNNING
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dpp7ycquabyq8
|
||||
@@ -6,7 +6,7 @@ public class CraftNode : ProgramNode
|
||||
{
|
||||
DisplayText = "Craft";
|
||||
}
|
||||
public override bool Execute(Robot robot, double delta)
|
||||
public override NodeResult Execute(Robot robot, double delta)
|
||||
{
|
||||
GD.Print("Craft");
|
||||
if (nextNode != null)
|
||||
@@ -15,7 +15,7 @@ public class CraftNode : ProgramNode
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
return NodeResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public class HarvestNode : ProgramNode
|
||||
{
|
||||
DisplayText = "Harvest";
|
||||
}
|
||||
public override bool Execute(Robot robot, double delta)
|
||||
public override NodeResult Execute(Robot robot, double delta)
|
||||
{
|
||||
GD.Print("Harvest");
|
||||
if (nextNode != null)
|
||||
@@ -15,7 +15,7 @@ public class HarvestNode : ProgramNode
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
return NodeResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,14 @@ public class MoveNode : ProgramNode
|
||||
{
|
||||
DisplayText = "Move";
|
||||
}
|
||||
public override bool Execute(Robot robot, double delta)
|
||||
public override NodeResult Execute(Robot robot, double delta)
|
||||
{
|
||||
pathPoints ??= [.. Pathfinding.GetPath(Pathfinding.GetClosestStartPoint(robot.Position), targetPosition)];
|
||||
|
||||
if (pathPoints.Count <= 0)
|
||||
{
|
||||
lastExecutionMessage = "No path available";
|
||||
return NodeResult.FAILURE;
|
||||
}
|
||||
startPosition = robot.Position;
|
||||
Vector3 target = pathPoints[0] - startPosition;
|
||||
float distance = target.Length();
|
||||
@@ -32,11 +36,12 @@ public class MoveNode : ProgramNode
|
||||
pathPoints.Remove(pathPoints[0]);
|
||||
if (pathPoints.Count <= 0)
|
||||
{
|
||||
pathPoints = null;
|
||||
return true;
|
||||
lastExecutionMessage = "";
|
||||
return NodeResult.SUCCESS;
|
||||
}
|
||||
|
||||
return false;
|
||||
lastExecutionMessage = "";
|
||||
return NodeResult.RUNNING;
|
||||
}
|
||||
|
||||
Vector3 direction = target / distance;
|
||||
@@ -47,14 +52,12 @@ public class MoveNode : ProgramNode
|
||||
}
|
||||
robot.GlobalPosition += direction * (float)delta * GameData.robotSpeed;
|
||||
|
||||
return false;
|
||||
return NodeResult.RUNNING;
|
||||
}
|
||||
|
||||
public override void ReadParameters(NodeDisplay display)
|
||||
{
|
||||
HBoxContainer valueContainer = display.GetNode<HBoxContainer>("./EditorDisplay/HBoxContainer/");
|
||||
|
||||
GD.Print(valueContainer.GetNode<SpinBox>("./CoordinateX").Value);
|
||||
int posX = (int)valueContainer.GetNode<SpinBox>("./CoordinateX").Value;
|
||||
int posY = (int)valueContainer.GetNode<SpinBox>("./CoordinateY").Value;
|
||||
int posZ = (int)valueContainer.GetNode<SpinBox>("./CoordinateZ").Value;
|
||||
|
||||
@@ -4,8 +4,9 @@ public abstract class ProgramNode
|
||||
{
|
||||
public ProgramNode nextNode;
|
||||
public string DisplayText;
|
||||
public string lastExecutionMessage;
|
||||
|
||||
public abstract bool Execute(Robot robot, double delta);
|
||||
public abstract NodeResult Execute(Robot robot, double delta);
|
||||
public abstract void ReadParameters(NodeDisplay display);
|
||||
public abstract ProgramNode Duplicate();
|
||||
}
|
||||
Reference in New Issue
Block a user