diff --git a/ProjectObsidian/ProtoFlux/Flow/AsyncWhileWithIteration.cs b/ProjectObsidian/ProtoFlux/Flow/AsyncWhileWithIteration.cs new file mode 100644 index 0000000..135699f --- /dev/null +++ b/ProjectObsidian/ProtoFlux/Flow/AsyncWhileWithIteration.cs @@ -0,0 +1,40 @@ +using ProtoFlux.Core; +using System.Threading.Tasks; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Flow +{ + [NodeCategory("Obsidian/Flow")] + [NodeName("AsyncWhile With I", false)] + public class AsyncWhileWithIteration : AsyncActionNode + { + public ValueInput Condition; + public AsyncCall LoopStart; + public AsyncCall LoopIteration; + public Continuation LoopEnd; + public readonly ValueOutput i; + private int iter; + + protected override async Task RunAsync(ExecutionContext context) + { + iter = 0; + await LoopStart.ExecuteAsync(context); + while (Condition.Evaluate(context, defaultValue: false)) + { + i.Write(iter, context); + if (context.AbortExecution) + { + throw new ExecutionAbortedException(base.Runtime as IExecutionRuntime, this, LoopIteration.Target, isAsync: true); + } + await LoopIteration.ExecuteAsync(context); + iter++; + } + return LoopEnd.Target; + } + + public AsyncWhileWithIteration() + { + i = new ValueOutput(this); + } + } +} \ No newline at end of file diff --git a/ProjectObsidian/ProtoFlux/Flow/WhileWithIteration.cs b/ProjectObsidian/ProtoFlux/Flow/WhileWithIteration.cs new file mode 100644 index 0000000..e86a3ff --- /dev/null +++ b/ProjectObsidian/ProtoFlux/Flow/WhileWithIteration.cs @@ -0,0 +1,39 @@ +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Flow +{ + [NodeCategory("Obsidian/Flow")] + [NodeName("While With I", false)] + public class WhileWithIteration : ActionNode + { + public ValueInput Condition; + public Call LoopStart; + public Call LoopIteration; + public Call LoopEnd; + public readonly ValueOutput i; + private int iter; + + protected override IOperation Run(ExecutionContext context) + { + iter = 0; + LoopStart.Execute(context); + while (Condition.Evaluate(context, defaultValue: false)) + { + i.Write(iter, context); + if (context.AbortExecution) + { + throw new ExecutionAbortedException(base.Runtime as IExecutionRuntime, this, LoopIteration.Target, isAsync: false); + } + LoopIteration.Execute(context); + iter++; + } + return LoopEnd.Target; + } + + public WhileWithIteration() + { + i = new ValueOutput(this); + } + } +} \ No newline at end of file diff --git a/ProjectObsidian/ProtoFlux/Users/UserFromUserRef.cs b/ProjectObsidian/ProtoFlux/Users/UserFromUserRef.cs new file mode 100644 index 0000000..616b4f8 --- /dev/null +++ b/ProjectObsidian/ProtoFlux/Users/UserFromUserRef.cs @@ -0,0 +1,21 @@ +using FrooxEngine.ProtoFlux; +using ProtoFlux.Core; +using FrooxEngine; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Users +{ + [ContinuouslyChanging] + [NodeCategory("Obsidian/Users")] + [NodeName("User From UserRef")] + public class UserFromUserRef : ObjectFunctionNode + { + public readonly ObjectInput UserRef; + + protected override User Compute(FrooxEngineContext context) + { + UserRef userRef = UserRef.Evaluate(context); + return userRef.Target; + } + } +} \ No newline at end of file