|
@@ -1,42 +1,58 @@
|
|
using PixiEditor.ChangeableDocument.Changeables.Graph.Context;
|
|
using PixiEditor.ChangeableDocument.Changeables.Graph.Context;
|
|
|
|
+using PixiEditor.ChangeableDocument.Changeables.Graph.Interfaces;
|
|
using PixiEditor.ChangeableDocument.Rendering;
|
|
using PixiEditor.ChangeableDocument.Rendering;
|
|
|
|
|
|
namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.Utility;
|
|
namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.Utility;
|
|
|
|
|
|
[NodeInfo("RepeatStart")]
|
|
[NodeInfo("RepeatStart")]
|
|
[PairNode(typeof(RepeatNodeEnd), "RepeatZone", true)]
|
|
[PairNode(typeof(RepeatNodeEnd), "RepeatZone", true)]
|
|
-public class RepeatNodeStart : Node
|
|
|
|
|
|
+public class RepeatNodeStart : Node, IExecutionFlowNode
|
|
{
|
|
{
|
|
- public FuncInputProperty<int, RepeatFuncContext> Iterations { get; }
|
|
|
|
- public FuncInputProperty<object, RepeatFuncContext> Input { get; }
|
|
|
|
- public FuncOutputProperty<int, RepeatFuncContext> CurrentIteration { get; }
|
|
|
|
- public FuncOutputProperty<object, RepeatFuncContext> Output { get; }
|
|
|
|
|
|
+ public InputProperty<int> Iterations { get; }
|
|
|
|
+ public InputProperty<object> Input { get; }
|
|
|
|
+ public OutputProperty<int> CurrentIteration { get; }
|
|
|
|
+ public OutputProperty<object> Output { get; }
|
|
|
|
|
|
public RepeatNodeStart()
|
|
public RepeatNodeStart()
|
|
{
|
|
{
|
|
- Iterations = CreateFuncInput<int, RepeatFuncContext>("Iterations", "ITERATIONS", 1);
|
|
|
|
- Input = CreateFuncInput<object, RepeatFuncContext>("Input", "INPUT", null);
|
|
|
|
- CurrentIteration = CreateFuncOutput<int, RepeatFuncContext>("CurrentIteration", "CURRENT_ITERATION", GetIteration);
|
|
|
|
- Output = CreateFuncOutput<object, RepeatFuncContext>("Output", "OUTPUT", GetOutput);
|
|
|
|
|
|
+ Iterations = CreateInput<int>("Iterations", "ITERATIONS", 1);
|
|
|
|
+ Input = CreateInput<object>("Input", "INPUT", null);
|
|
|
|
+ CurrentIteration = CreateOutput<int>("CurrentIteration", "CURRENT_ITERATION", 0);
|
|
|
|
+ Output = CreateOutput<object>("Output", "OUTPUT", null);
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnExecute(RenderContext context)
|
|
protected override void OnExecute(RenderContext context)
|
|
{
|
|
{
|
|
- RepeatFuncContext funcContext = new RepeatFuncContext(1);
|
|
|
|
|
|
+ Output.Value = Input.Value;
|
|
|
|
+ CurrentIteration.Value = 0;
|
|
}
|
|
}
|
|
|
|
|
|
- private int GetIteration(RepeatFuncContext context)
|
|
|
|
|
|
+ public override Node CreateCopy()
|
|
{
|
|
{
|
|
- return context.CurrentIteration;
|
|
|
|
|
|
+ return new RepeatNodeStart();
|
|
}
|
|
}
|
|
|
|
|
|
- private object GetOutput(RepeatFuncContext context)
|
|
|
|
- {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
|
|
+ public HashSet<IReadOnlyNode> HandledNodes => CalculateHandledNodes();
|
|
|
|
|
|
- public override Node CreateCopy()
|
|
|
|
|
|
+ private HashSet<IReadOnlyNode> CalculateHandledNodes()
|
|
{
|
|
{
|
|
- return new RepeatNodeStart();
|
|
|
|
|
|
+ HashSet<IReadOnlyNode> handled = new();
|
|
|
|
+
|
|
|
|
+ TraverseForwards(node =>
|
|
|
|
+ {
|
|
|
|
+ if (node is RepeatNodeEnd)
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (node != this)
|
|
|
|
+ {
|
|
|
|
+ handled.Add(node);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return handled;
|
|
}
|
|
}
|
|
}
|
|
}
|