From 2f67955b66ffc9a49ead347358d531c4ca80f15d Mon Sep 17 00:00:00 2001 From: xLinka Date: Sun, 21 Jan 2024 19:03:42 +0000 Subject: [PATCH 1/2] Move all bindings --- .../Bindings => Bindings}/Math/Physics/CentipetalForceBinding.cs | 0 .../Bindings => Bindings}/Math/Physics/DragCalculationBinding.cs | 0 .../Bindings => Bindings}/Math/Physics/KineticFrictionBinding.cs | 0 .../Bindings => Bindings}/Math/Physics/RefractNodeBinding.cs | 0 {ProtoFlux/Bindings => Bindings}/Utility/writetolog.cs | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {ProtoFlux/Bindings => Bindings}/Math/Physics/CentipetalForceBinding.cs (100%) rename {ProtoFlux/Bindings => Bindings}/Math/Physics/DragCalculationBinding.cs (100%) rename {ProtoFlux/Bindings => Bindings}/Math/Physics/KineticFrictionBinding.cs (100%) rename {ProtoFlux/Bindings => Bindings}/Math/Physics/RefractNodeBinding.cs (100%) rename {ProtoFlux/Bindings => Bindings}/Utility/writetolog.cs (100%) diff --git a/ProtoFlux/Bindings/Math/Physics/CentipetalForceBinding.cs b/Bindings/Math/Physics/CentipetalForceBinding.cs similarity index 100% rename from ProtoFlux/Bindings/Math/Physics/CentipetalForceBinding.cs rename to Bindings/Math/Physics/CentipetalForceBinding.cs diff --git a/ProtoFlux/Bindings/Math/Physics/DragCalculationBinding.cs b/Bindings/Math/Physics/DragCalculationBinding.cs similarity index 100% rename from ProtoFlux/Bindings/Math/Physics/DragCalculationBinding.cs rename to Bindings/Math/Physics/DragCalculationBinding.cs diff --git a/ProtoFlux/Bindings/Math/Physics/KineticFrictionBinding.cs b/Bindings/Math/Physics/KineticFrictionBinding.cs similarity index 100% rename from ProtoFlux/Bindings/Math/Physics/KineticFrictionBinding.cs rename to Bindings/Math/Physics/KineticFrictionBinding.cs diff --git a/ProtoFlux/Bindings/Math/Physics/RefractNodeBinding.cs b/Bindings/Math/Physics/RefractNodeBinding.cs similarity index 100% rename from ProtoFlux/Bindings/Math/Physics/RefractNodeBinding.cs rename to Bindings/Math/Physics/RefractNodeBinding.cs diff --git a/ProtoFlux/Bindings/Utility/writetolog.cs b/Bindings/Utility/writetolog.cs similarity index 100% rename from ProtoFlux/Bindings/Utility/writetolog.cs rename to Bindings/Utility/writetolog.cs From 2faf97b04bfcff8c229e6ad27ee1d7514875d769 Mon Sep 17 00:00:00 2001 From: xLinka Date: Sun, 21 Jan 2024 19:32:17 +0000 Subject: [PATCH 2/2] Is User In Noclip Node --- Bindings/User/IsUserInNoclipBinding.cs | 61 ++++++++++++++++++++++++++ ProtoFlux/Users/IsUserInNoclipNode.cs | 30 +++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 Bindings/User/IsUserInNoclipBinding.cs create mode 100644 ProtoFlux/Users/IsUserInNoclipNode.cs diff --git a/Bindings/User/IsUserInNoclipBinding.cs b/Bindings/User/IsUserInNoclipBinding.cs new file mode 100644 index 0000000..3be4145 --- /dev/null +++ b/Bindings/User/IsUserInNoclipBinding.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 IsUserInNoClipBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ValueFunctionNode +{ + public readonly SyncRef> User; + + public override Type NodeType => typeof(IsUserInNoClipNode); + + public IsUserInNoClipNode 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"); + } + IsUserInNoClipNode isUserInNoClipNodeInstance = (TypedNodeInstance = new IsUserInNoClipNode()); + return isUserInNoClipNodeInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is IsUserInNoClipNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(IsUserInNoClipNode)); + } + + 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; + } +} diff --git a/ProtoFlux/Users/IsUserInNoclipNode.cs b/ProtoFlux/Users/IsUserInNoclipNode.cs new file mode 100644 index 0000000..d80afb0 --- /dev/null +++ b/ProtoFlux/Users/IsUserInNoclipNode.cs @@ -0,0 +1,30 @@ +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace FrooxEngine.ProtoFlux.Locomotion +{ + [ContinuouslyChanging] + [NodeCategory("ProtoFlux/Obsidian/Locomotion")] + public class IsUserInNoClipNode : ValueFunctionNode + { + public readonly ObjectInput User; + + protected override bool Compute(ExecutionContext context) + { + User user = User.Evaluate(context); + if (user == null) + { + return false; + } + + LocomotionController locomotionController = user.Root?.GetRegisteredComponent(); + if (locomotionController == null) + { + return false; + } + + return locomotionController.ActiveModule.GetType() == typeof(NoclipLocomotion); + } + } +}