From d1f20e6ad61f627d89981ee462a49a9902a16da2 Mon Sep 17 00:00:00 2001 From: LeCloutPanda <53411604+LeCloutPanda@users.noreply.github.com> Date: Thu, 4 Apr 2024 09:43:27 +1100 Subject: [PATCH 1/4] Added more crap Don't know if it works or not but good luck. --- .../Interaction/FindGrabbableFromSlot.cs | 19 +++++++++++ ProtoFlux/Slots/CreateEmptySlot.cs | 33 +++++++++++++++++++ ProtoFlux/Users/Avatar/AvatarRootSlot.cs | 24 ++++++++++++++ ProtoFlux/Users/Status/IsUserInSeatedMode.cs | 4 +-- 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 ProtoFlux/Interaction/FindGrabbableFromSlot.cs create mode 100644 ProtoFlux/Slots/CreateEmptySlot.cs create mode 100644 ProtoFlux/Users/Avatar/AvatarRootSlot.cs diff --git a/ProtoFlux/Interaction/FindGrabbableFromSlot.cs b/ProtoFlux/Interaction/FindGrabbableFromSlot.cs new file mode 100644 index 0000000..ee40b6f --- /dev/null +++ b/ProtoFlux/Interaction/FindGrabbableFromSlot.cs @@ -0,0 +1,19 @@ +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Users.Avatar +{ + [ContinuouslyChanging] + [NodeCategory("ProtoFlux/Obsidian/Avatar")] + public class FindGrabbableFromSlot : ObjectFunctionNode + { + public readonly ObjectInput Slot; + + protected override IGrabbable Compute(ExecutionContext context) + { + Slot slot = Slot.Evaluate(context); + return slot == null ? null : slot.GetComponentInParents(); + } + } +} \ No newline at end of file diff --git a/ProtoFlux/Slots/CreateEmptySlot.cs b/ProtoFlux/Slots/CreateEmptySlot.cs new file mode 100644 index 0000000..4767bfd --- /dev/null +++ b/ProtoFlux/Slots/CreateEmptySlot.cs @@ -0,0 +1,33 @@ +using FrooxEngine; +using FrooxEngine.ProtoFlux; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Users.Avatar +{ + [ContinuouslyChanging] + [NodeCategory("ProtoFlux/Obsidian/Slots")] + public class CreateEmptySlot : ActionBreakableFlowNode + { + public readonly ObjectInput Parent; + public readonly ObjectInput Name; + public readonly ObjectInput Tag; + public readonly ValueInput Persistent; + public readonly ValueInput Active; + + public readonly ObjectOutput Slot; + + protected override bool Do(FrooxEngineContext context) + { + Slot slot = context.LocalUser.LocalUserSpace.AddSlot(); + slot.Parent = Parent.Evaluate(context); + slot.Name = Name.Evaluate(context); + slot.Tag = Tag.Evaluate(context); + slot.PersistentSelf = Persistent.Evaluate(context); + slot.ActiveSelf = Active.Evaluate(context); + + Slot.Write(slot, context); + return true; + } + } +} \ No newline at end of file diff --git a/ProtoFlux/Users/Avatar/AvatarRootSlot.cs b/ProtoFlux/Users/Avatar/AvatarRootSlot.cs new file mode 100644 index 0000000..e186e32 --- /dev/null +++ b/ProtoFlux/Users/Avatar/AvatarRootSlot.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using FrooxEngine; +using FrooxEngine.CommonAvatar; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Users.Avatar +{ + [ContinuouslyChanging] + [NodeCategory("ProtoFlux/Obsidian/Avatar")] + public class AvatarRootSlot : ObjectFunctionNode + { + public readonly ObjectInput User; + + protected override Slot Compute(ExecutionContext context) + { + User user = User.Evaluate(context); + Slot slot = user.Root.Slot; + List list = new List(); + slot.GetFirstDirectComponentsInChildren(list); + return user == null || list.Count == 0 ? null : list[0].Slot; + } + } +} \ No newline at end of file diff --git a/ProtoFlux/Users/Status/IsUserInSeatedMode.cs b/ProtoFlux/Users/Status/IsUserInSeatedMode.cs index 8ecd617..eadbbd9 100644 --- a/ProtoFlux/Users/Status/IsUserInSeatedMode.cs +++ b/ProtoFlux/Users/Status/IsUserInSeatedMode.cs @@ -2,10 +2,10 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace FrooxEngine.ProtoFlux.Locomotion +namespace FrooxEngine.ProtoFlux.Status { [ContinuouslyChanging] - [NodeCategory("ProtoFlux/Obsidian/Locomotion")] + [NodeCategory("ProtoFlux/Obsidian/Status")] public class IsUserInSeatedModeNode : ValueFunctionNode { public readonly ObjectInput User; From 4897091f2e61a51e5fb3a1b27885fc2f542b5ad7 Mon Sep 17 00:00:00 2001 From: LeCloutPanda <53411604+LeCloutPanda@users.noreply.github.com> Date: Thu, 11 Apr 2024 12:22:12 +1000 Subject: [PATCH 2/4] Removed/Changed using lines --- Bindings/User/IsUserInSeatedModeBinding.cs | 3 +-- ProtoFlux/Users/Status/IsUserInSeatedMode.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Bindings/User/IsUserInSeatedModeBinding.cs b/Bindings/User/IsUserInSeatedModeBinding.cs index 0ba168f..17c8441 100644 --- a/Bindings/User/IsUserInSeatedModeBinding.cs +++ b/Bindings/User/IsUserInSeatedModeBinding.cs @@ -1,10 +1,9 @@ using System; -using Elements.Core; using FrooxEngine; using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -using FrooxEngine.ProtoFlux.Locomotion; +using FrooxEngine.ProtoFlux.Status; [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Locomotion" })] public class IsUserInSeatedModeBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ValueFunctionNode diff --git a/ProtoFlux/Users/Status/IsUserInSeatedMode.cs b/ProtoFlux/Users/Status/IsUserInSeatedMode.cs index eadbbd9..b5ee204 100644 --- a/ProtoFlux/Users/Status/IsUserInSeatedMode.cs +++ b/ProtoFlux/Users/Status/IsUserInSeatedMode.cs @@ -1,5 +1,4 @@ -using FrooxEngine; -using ProtoFlux.Core; +using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; namespace FrooxEngine.ProtoFlux.Status From 99f5dbf2c9abf2adc78cdf59e425b37ef1d68bd9 Mon Sep 17 00:00:00 2001 From: LeCloutPanda <53411604+LeCloutPanda@users.noreply.github.com> Date: Sun, 28 Apr 2024 01:41:08 +1000 Subject: [PATCH 3/4] Added things --- .../ProtoFlux/Actions/TweenPosition.cs | 61 +++++++++++++++++++ .../ProtoFlux/Actions/TweenRotation.cs | 61 +++++++++++++++++++ .../ProtoFlux/Actions/TweenScale.cs | 61 +++++++++++++++++++ .../ProtoFlux/Devices/ViveTrackerBattery.cs | 2 +- .../ProtoFlux/Strings/CountSubstring.cs | 2 +- .../ProtoFlux/Strings/DecodeBase64Node.cs | 2 +- .../ProtoFlux/Strings/DecodeMorseNode.cs | 2 +- .../ProtoFlux/Strings/EncodeBase64Node.cs | 2 +- .../ProtoFlux/Strings/EncodeMD5.cs | 2 +- .../ProtoFlux/Strings/EncodeMorse.cs | 2 +- .../ProtoFlux/Strings/EncodeSHA256.cs | 2 +- ProjectObsidian/ProtoFlux/Strings/HMAC.cs | 2 +- .../ProtoFlux/Strings/HammingDistanceNode.cs | 2 +- .../Strings/HammingDistanceNonNullableNode.cs | 2 +- .../Users/Status/IsUserInNoclipNode.cs | 2 +- .../Users/Status/IsUserInSeatedMode.cs | 2 +- 16 files changed, 196 insertions(+), 13 deletions(-) create mode 100644 ProjectObsidian/ProtoFlux/Actions/TweenPosition.cs create mode 100644 ProjectObsidian/ProtoFlux/Actions/TweenRotation.cs create mode 100644 ProjectObsidian/ProtoFlux/Actions/TweenScale.cs diff --git a/ProjectObsidian/ProtoFlux/Actions/TweenPosition.cs b/ProjectObsidian/ProtoFlux/Actions/TweenPosition.cs new file mode 100644 index 0000000..0a26348 --- /dev/null +++ b/ProjectObsidian/ProtoFlux/Actions/TweenPosition.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using Elements.Core; +using FrooxEngine; +using FrooxEngine.ProtoFlux; +using ProtoFlux.Core; + +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(FrooxEngineContext 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..6d42bdd --- /dev/null +++ b/ProjectObsidian/ProtoFlux/Actions/TweenRotation.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using Elements.Core; +using FrooxEngine; +using FrooxEngine.ProtoFlux; +using ProtoFlux.Core; + +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(FrooxEngineContext 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..1c72d9a --- /dev/null +++ b/ProjectObsidian/ProtoFlux/Actions/TweenScale.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using Elements.Core; +using FrooxEngine; +using FrooxEngine.ProtoFlux; +using ProtoFlux.Core; + +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(FrooxEngineContext 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; + } + } +} diff --git a/ProjectObsidian/ProtoFlux/Devices/ViveTrackerBattery.cs b/ProjectObsidian/ProtoFlux/Devices/ViveTrackerBattery.cs index 868b8df..3f0b5c1 100644 --- a/ProjectObsidian/ProtoFlux/Devices/ViveTrackerBattery.cs +++ b/ProjectObsidian/ProtoFlux/Devices/ViveTrackerBattery.cs @@ -9,7 +9,7 @@ using ProtoFlux.Runtimes.Execution; using Obsidian; -namespace ProtoFlux.Runtimes.Execution.Nodes.FrooxEngine.Input; +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Devices; [NodeCategory("Obsidian/Devices")] public class ViveTrackerBattery : VoidNode diff --git a/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs b/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs index b6181f0..f3f81af 100644 --- a/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs +++ b/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs @@ -4,7 +4,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.Strings +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Strings { [NodeCategory("Obsidian/String")] public class CountSubstringNode : ValueFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs b/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs index f27806f..93733ca 100644 --- a/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs +++ b/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs @@ -5,7 +5,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.Strings +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Strings { [NodeCategory("Obsidian/String")] public class DecodeBase64Node : ObjectFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs b/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs index 37350ec..2501b93 100644 --- a/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs +++ b/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs @@ -6,7 +6,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.Strings +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Strings { [NodeCategory("Obsidian/String")] public class DecodeMorseNode : ObjectFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs index cf147ef..7861080 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs @@ -5,7 +5,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.Strings +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Strings { [NodeCategory("Obsidian/String")] public class EncodeBase64Node : ObjectFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs index 48de7be..573b164 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs @@ -6,7 +6,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.Strings +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Strings { [NodeCategory("Obsidian/String")] public class EncodeMD5Node : ObjectFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs index cbe50aa..212277c 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs @@ -6,7 +6,7 @@ using ProtoFlux.Runtimes.Execution; using Obsidian; -namespace ProtoFlux.Runtimes.Execution.Nodes.Strings +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Strings { [NodeCategory("Obsidian/String")] public class EncodeMorseNode : ObjectFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs index bf5065e..0bedce3 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs @@ -6,7 +6,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.Strings +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Strings { [NodeCategory("Obsidian/String")] public class EncodeSha256Node : ObjectFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Strings/HMAC.cs b/ProjectObsidian/ProtoFlux/Strings/HMAC.cs index b758901..398ac08 100644 --- a/ProjectObsidian/ProtoFlux/Strings/HMAC.cs +++ b/ProjectObsidian/ProtoFlux/Strings/HMAC.cs @@ -6,7 +6,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.Strings +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Strings { public enum HashFunction { diff --git a/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNode.cs b/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNode.cs index edcee5c..0a6dd1d 100644 --- a/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNode.cs +++ b/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNode.cs @@ -4,7 +4,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.Strings +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Strings { [NodeCategory("Obsidian/String")] public class HammingDistanceNode : ObjectFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs b/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs index e0dd806..b4daba7 100644 --- a/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs +++ b/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs @@ -4,7 +4,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.Strings +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Strings { [NodeCategory("Obsidian/String")] public class HammingDistanceNonNullableNode : ValueFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Users/Status/IsUserInNoclipNode.cs b/ProjectObsidian/ProtoFlux/Users/Status/IsUserInNoclipNode.cs index 9529250..dfefc82 100644 --- a/ProjectObsidian/ProtoFlux/Users/Status/IsUserInNoclipNode.cs +++ b/ProjectObsidian/ProtoFlux/Users/Status/IsUserInNoclipNode.cs @@ -3,7 +3,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.FrooxEngine.Locomotion +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Locomotion { [ContinuouslyChanging] [NodeCategory("Obsidian/Locomotion")] diff --git a/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs b/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs index 0b4862b..6d905de 100644 --- a/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs +++ b/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs @@ -3,7 +3,7 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -namespace ProtoFlux.Runtimes.Execution.Nodes.FrooxEngine.Locomotion +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Locomotion { [ContinuouslyChanging] [NodeCategory("Obsidian/Locomotion")] From cca27f2bc728089430f3268f6b8324948a8d88a6 Mon Sep 17 00:00:00 2001 From: LeCloutPanda <53411604+LeCloutPanda@users.noreply.github.com> Date: Thu, 2 May 2024 04:55:18 +1000 Subject: [PATCH 4/4] Added more Tween Nodes Added TweenPosition, TweenRotation, TweenScale. More to come soon. --- .../ProtoFlux/Actions/TweenPosition.cs | 61 +++++++++++++++++++ .../ProtoFlux/Actions/TweenRotation.cs | 61 +++++++++++++++++++ .../ProtoFlux/Actions/TweenScale.cs | 61 +++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 ProjectObsidian/ProtoFlux/Actions/TweenPosition.cs create mode 100644 ProjectObsidian/ProtoFlux/Actions/TweenRotation.cs create mode 100644 ProjectObsidian/ProtoFlux/Actions/TweenScale.cs 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; + } + } +}