Added new nodes to DSL for a wider variety of commands and scripts.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using Godot;
|
||||
|
||||
public class ForNode : ProgramNode
|
||||
{
|
||||
public int amountExecuted;
|
||||
public int amount;
|
||||
public ForNode()
|
||||
{
|
||||
DisplayText = "For";
|
||||
}
|
||||
public override NodeResult Execute(Robot robot, double delta)
|
||||
{
|
||||
bool isConditionFulfilled = DetermineCondition();
|
||||
amountExecuted++;
|
||||
return isConditionFulfilled? NodeResult.SUCCESS : NodeResult.CONDITIONFALSE;
|
||||
}
|
||||
|
||||
private bool DetermineCondition()
|
||||
{
|
||||
return amountExecuted < amount;
|
||||
}
|
||||
|
||||
public override void ReadParameters(NodeDisplay display)
|
||||
{
|
||||
HBoxContainer valueContainer = display.GetNode<HBoxContainer>("./EditorDisplay/HBoxContainer/");
|
||||
amount = (int)valueContainer.GetNode<SpinBox>("./Amount").Value;
|
||||
}
|
||||
|
||||
public override ProgramNode Duplicate()
|
||||
{
|
||||
ForNode duplicate = new ForNode()
|
||||
{
|
||||
amount = amount,
|
||||
amountExecuted = 0
|
||||
};
|
||||
return duplicate;
|
||||
}
|
||||
|
||||
public override void Setup(NodeDisplay display)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override string Save()
|
||||
{
|
||||
return $"Name: {DisplayText}, AmountExecuted: {amountExecuted}, Amount: {amount}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user