diff --git a/Bindings/User/IsUserInSeatedMode.cs b/Bindings/User/IsUserInSeatedMode.cs new file mode 100644 index 0000000..d61c173 --- /dev/null +++ b/Bindings/User/IsUserInSeatedMode.cs @@ -0,0 +1,61 @@ +using System; +using Elements.Core; +using FrooxEngine; +using FrooxEngine.ProtoFlux; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using FrooxEngine.ProtoFlux.Locomotion; + +[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Locomotion" })] +public class IsUserInSeatedMode : FrooxEngine.ProtoFlux.Runtimes.Execution.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() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + IsUserInSeatedModeNode isUserInSeatedModeNodeInstance = (TypedNodeInstance = new IsUserInSeatedModeNode()); + return isUserInSeatedModeNodeInstance as N; + } + + 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) + { + 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..8ecd617 --- /dev/null +++ b/ProtoFlux/Users/Status/IsUserInSeatedMode.cs @@ -0,0 +1,19 @@ +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); + return user == null ? false : user.InputInterface.SeatedMode; + } + } +} \ No newline at end of file