-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create New node Is User in Noclip
- Loading branch information
Showing
7 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ExecutionContext, bool> | ||
{ | ||
public readonly SyncRef<INodeObjectOutput<User>> 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<N>() | ||
{ | ||
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; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ExecutionContext, bool> | ||
{ | ||
public readonly ObjectInput<User> User; | ||
|
||
protected override bool Compute(ExecutionContext context) | ||
{ | ||
User user = User.Evaluate(context); | ||
if (user == null) | ||
{ | ||
return false; | ||
} | ||
|
||
LocomotionController locomotionController = user.Root?.GetRegisteredComponent<LocomotionController>(); | ||
if (locomotionController == null) | ||
{ | ||
return false; | ||
} | ||
|
||
return locomotionController.ActiveModule.GetType() == typeof(NoclipLocomotion); | ||
} | ||
} | ||
} |