using Godot; using System.Collections.Generic; public class ForNode : ProgramNode { public int amountExecuted; public int amount; public ForNode() { DisplayText = "For"; TooltipText = "Repeats the connected branch (Top slot) for the configured amount of executions before continuing through the negative output. (Bottom slot)"; } public override NodeResult Execute(Robot robot, double delta) { bool isConditionFulfilled = DetermineCondition(); if (isConditionFulfilled) { amountExecuted = 0; } amountExecuted++; return isConditionFulfilled ? NodeResult.CONDITIONFALSE : NodeResult.SUCCESS; } private bool DetermineCondition() { return amountExecuted >= amount; } public override ProgramNode Duplicate() { ForNode duplicate = new ForNode() { amount = amount, amountExecuted = 0 }; return duplicate; } public override string Save() { return $"Name: {DisplayText}, AmountExecuted: {amountExecuted}, Amount: {amount}"; } public override void SetNextNode( List connections, Dictionary availableNodes ) { SetBranchNodes(connections, availableNodes); } }