From 2c2fb29503aa8f0e287f304d8ef33e1ff33a6724 Mon Sep 17 00:00:00 2001 From: LeCloutPanda <53411604+LeCloutPanda@users.noreply.github.com> Date: Thu, 4 Apr 2024 08:11:41 +1100 Subject: [PATCH 1/3] Create IsUserInSeatedMode.cs Hand over the slushie --- Bindings/User/IsUserInSeatedMode.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Bindings/User/IsUserInSeatedMode.cs diff --git a/Bindings/User/IsUserInSeatedMode.cs b/Bindings/User/IsUserInSeatedMode.cs new file mode 100644 index 0000000..0eaffe6 --- /dev/null +++ b/Bindings/User/IsUserInSeatedMode.cs @@ -0,0 +1,19 @@ +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace FrooxEngine.ProtoFlux.Locomotion +{ + [ContinuouslyChanging] + [NodeCategory("ProtoFlux/Obsidian/Users/Status")] + public class IsUserInSeatedModeNode : ValueFunctionNode + { + public readonly ObjectInput User; + + protected override bool Compute(ExecutionContext context) + { + User user = User.Evaluate(context); + return user == null ? false : user.InputInterface.SeatedMode; + } + } +} \ No newline at end of file From b211ec11f0baab6da116741d388bc9f535ae5af2 Mon Sep 17 00:00:00 2001 From: LeCloutPanda <53411604+LeCloutPanda@users.noreply.github.com> Date: Thu, 4 Apr 2024 08:13:40 +1100 Subject: [PATCH 2/3] Woops did it wrong --- Bindings/User/IsUserInSeatedMode.cs | 60 +++++++++++++++++--- ProtoFlux/Users/Status/IsUserInSeatedMode.cs | 24 ++++++++ 2 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 ProtoFlux/Users/Status/IsUserInSeatedMode.cs diff --git a/Bindings/User/IsUserInSeatedMode.cs b/Bindings/User/IsUserInSeatedMode.cs index 0eaffe6..d61c173 100644 --- a/Bindings/User/IsUserInSeatedMode.cs +++ b/Bindings/User/IsUserInSeatedMode.cs @@ -1,19 +1,61 @@ -using FrooxEngine; +using System; +using Elements.Core; +using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; +using FrooxEngine.ProtoFlux.Locomotion; -namespace FrooxEngine.ProtoFlux.Locomotion +[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Locomotion" })] +public class IsUserInSeatedMode : FrooxEngine.ProtoFlux.Runtimes.Execution.ValueFunctionNode { - [ContinuouslyChanging] - [NodeCategory("ProtoFlux/Obsidian/Users/Status")] - public class IsUserInSeatedModeNode : ValueFunctionNode + public readonly SyncRef> User; + + public override Type NodeType => typeof(IsUserInSeatedModeNode); + + public IsUserInSeatedModeNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 1; + + public override N Instantiate() { - public readonly ObjectInput User; + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + IsUserInSeatedModeNode isUserInSeatedModeNodeInstance = (TypedNodeInstance = new IsUserInSeatedModeNode()); + return isUserInSeatedModeNodeInstance as N; + } - protected override bool Compute(ExecutionContext context) + protected override void AssociateInstanceInternal(INode node) + { + if (node is IsUserInSeatedModeNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(IsUserInSeatedModeNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + if (index == 0) { - User user = User.Evaluate(context); - return user == null ? false : user.InputInterface.SeatedMode; + return User; } + index -= 1; + return null; } } \ No newline at end of file diff --git a/ProtoFlux/Users/Status/IsUserInSeatedMode.cs b/ProtoFlux/Users/Status/IsUserInSeatedMode.cs new file mode 100644 index 0000000..98d7191 --- /dev/null +++ b/ProtoFlux/Users/Status/IsUserInSeatedMode.cs @@ -0,0 +1,24 @@ +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace FrooxEngine.ProtoFlux.Locomotion +{ + [ContinuouslyChanging] + [NodeCategory("ProtoFlux/Obsidian/Locomotion")] + public class IsUserInSeatedModeNode : ValueFunctionNode + { + public readonly ObjectInput User; + + protected override bool Compute(ExecutionContext context) + { + User user = User.Evaluate(context); + if (user == null) + { + return false; + } + + return user.InputInterface.SeatedMode; + } + } +} \ No newline at end of file From ccdc82cfe5091367de8b380ab50d935d8249f807 Mon Sep 17 00:00:00 2001 From: LeCloutPanda <53411604+LeCloutPanda@users.noreply.github.com> Date: Thu, 4 Apr 2024 08:14:31 +1100 Subject: [PATCH 3/3] There we go done for real this time --- ProtoFlux/Users/Status/IsUserInSeatedMode.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ProtoFlux/Users/Status/IsUserInSeatedMode.cs b/ProtoFlux/Users/Status/IsUserInSeatedMode.cs index 98d7191..8ecd617 100644 --- a/ProtoFlux/Users/Status/IsUserInSeatedMode.cs +++ b/ProtoFlux/Users/Status/IsUserInSeatedMode.cs @@ -13,12 +13,7 @@ public class IsUserInSeatedModeNode : ValueFunctionNode protected override bool Compute(ExecutionContext context) { User user = User.Evaluate(context); - if (user == null) - { - return false; - } - - return user.InputInterface.SeatedMode; + return user == null ? false : user.InputInterface.SeatedMode; } } } \ No newline at end of file