-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from paradoxical-autumn/main
While nodes with iteration & UserFromUserRef
- Loading branch information
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ExecutionContext> | ||
{ | ||
public ValueInput<bool> Condition; | ||
public AsyncCall LoopStart; | ||
public AsyncCall LoopIteration; | ||
public Continuation LoopEnd; | ||
public readonly ValueOutput<int> i; | ||
private int iter; | ||
|
||
protected override async Task<IOperation> 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<int>(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ExecutionContext> | ||
{ | ||
public ValueInput<bool> Condition; | ||
public Call LoopStart; | ||
public Call LoopIteration; | ||
public Call LoopEnd; | ||
public readonly ValueOutput<int> 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<int>(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<FrooxEngineContext, User> | ||
{ | ||
public readonly ObjectInput<UserRef> UserRef; | ||
|
||
protected override User Compute(FrooxEngineContext context) | ||
{ | ||
UserRef userRef = UserRef.Evaluate(context); | ||
return userRef.Target; | ||
} | ||
} | ||
} |