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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user