diff --git a/ProjectObsidian/ProtoFlux/Actions/TweenPosition.cs b/ProjectObsidian/ProtoFlux/Actions/TweenPosition.cs new file mode 100644 index 0000000..182de91 --- /dev/null +++ b/ProjectObsidian/ProtoFlux/Actions/TweenPosition.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Actions +{ + [NodeCategory("Obsidian/Actions")] + public class TweenPosition : AsyncActionNode + { + public ValueInput To; + public ValueInput From; + [Core.DefaultValueAttribute(1f)] + public ValueInput Duration; + [Core.DefaultValueAttribute(CurvePreset.Smooth)] + public ValueInput Curve; + public ValueInput ProportionalDuration; + public ObjectInput Target; + public AsyncCall OnStarted; + public Continuation OnDone; + + protected override async Task RunAsync(ExecutionContext context) + { + IField field = Target.Evaluate(context).Position_Field; + if (field == null) + { + return null; + } + float3 val = field.Value; + float3 val2 = field.Value; + if (To.Source != null) + { + val2 = To.Evaluate(context); + } + if (From.Source != null) + { + val = From.Evaluate(context); + } + float num = Duration.Evaluate(context, 1f); + bool num2 = ProportionalDuration.Evaluate(context, defaultValue: false); + CurvePreset curve = Curve.Evaluate(context, CurvePreset.Smooth); + if (num2 && Coder.SupportsDistance) + { + float num3 = Coder.Distance(val, val2); + if (num3.IsValid()) + { + num *= num3; + } + } + TaskCompletionSource completion = new TaskCompletionSource(); + field.TweenFromTo(val, val2, num, curve, null, delegate + { + completion.SetResult(result: true); + }); + await OnStarted.ExecuteAsync(context); + await completion.Task; + return OnDone.Target; + } + } +} diff --git a/ProjectObsidian/ProtoFlux/Actions/TweenRotation.cs b/ProjectObsidian/ProtoFlux/Actions/TweenRotation.cs new file mode 100644 index 0000000..70ec4ef --- /dev/null +++ b/ProjectObsidian/ProtoFlux/Actions/TweenRotation.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Actions +{ + [NodeCategory("Obsidian/Actions")] + public class TweenRotation : AsyncActionNode + { + public ValueInput To; + public ValueInput From; + [Core.DefaultValueAttribute(1f)] + public ValueInput Duration; + [Core.DefaultValueAttribute(CurvePreset.Smooth)] + public ValueInput Curve; + public ValueInput ProportionalDuration; + public ObjectInput Target; + public AsyncCall OnStarted; + public Continuation OnDone; + + protected override async Task RunAsync(ExecutionContext context) + { + IField field = Target.Evaluate(context).Rotation_Field; + if (field == null) + { + return null; + } + floatQ val = field.Value; + floatQ val2 = field.Value; + if (To.Source != null) + { + val2 = To.Evaluate(context); + } + if (From.Source != null) + { + val = From.Evaluate(context); + } + float num = Duration.Evaluate(context, 1f); + bool num2 = ProportionalDuration.Evaluate(context, defaultValue: false); + CurvePreset curve = Curve.Evaluate(context, CurvePreset.Smooth); + if (num2 && Coder.SupportsDistance) + { + float num3 = Coder.Distance(val, val2); + if (num3.IsValid()) + { + num *= num3; + } + } + TaskCompletionSource completion = new TaskCompletionSource(); + field.TweenFromTo(val, val2, num, curve, null, delegate + { + completion.SetResult(result: true); + }); + await OnStarted.ExecuteAsync(context); + await completion.Task; + return OnDone.Target; + } + } +} diff --git a/ProjectObsidian/ProtoFlux/Actions/TweenScale.cs b/ProjectObsidian/ProtoFlux/Actions/TweenScale.cs new file mode 100644 index 0000000..29e8e43 --- /dev/null +++ b/ProjectObsidian/ProtoFlux/Actions/TweenScale.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Actions +{ + [NodeCategory("Obsidian/Actions")] + public class TweenScale: AsyncActionNode + { + public ValueInput To; + public ValueInput From; + [Core.DefaultValueAttribute(1f)] + public ValueInput Duration; + [Core.DefaultValueAttribute(CurvePreset.Smooth)] + public ValueInput Curve; + public ValueInput ProportionalDuration; + public ObjectInput Target; + public AsyncCall OnStarted; + public Continuation OnDone; + + protected override async Task RunAsync(ExecutionContext context) + { + IField field = Target.Evaluate(context).Scale_Field; + if (field == null) + { + return null; + } + float3 val = field.Value; + float3 val2 = field.Value; + if (To.Source != null) + { + val2 = To.Evaluate(context); + } + if (From.Source != null) + { + val = From.Evaluate(context); + } + float num = Duration.Evaluate(context, 1f); + bool num2 = ProportionalDuration.Evaluate(context, defaultValue: false); + CurvePreset curve = Curve.Evaluate(context, CurvePreset.Smooth); + if (num2 && Coder.SupportsDistance) + { + float num3 = Coder.Distance(val, val2); + if (num3.IsValid()) + { + num *= num3; + } + } + TaskCompletionSource completion = new TaskCompletionSource(); + field.TweenFromTo(val, val2, num, curve, null, delegate + { + completion.SetResult(result: true); + }); + await OnStarted.ExecuteAsync(context); + await completion.Task; + return OnDone.Target; + } + } +}