-
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.
- Loading branch information
1 parent
2c2fb29
commit b211ec1
Showing
2 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -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<ExecutionContext, bool> | ||
{ | ||
[ContinuouslyChanging] | ||
[NodeCategory("ProtoFlux/Obsidian/Users/Status")] | ||
public class IsUserInSeatedModeNode : ValueFunctionNode<ExecutionContext, bool> | ||
public readonly SyncRef<INodeObjectOutput<User>> 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<N>() | ||
{ | ||
public readonly ObjectInput<User> 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; | ||
} | ||
} |
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,24 @@ | ||
using FrooxEngine; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
namespace FrooxEngine.ProtoFlux.Locomotion | ||
{ | ||
[ContinuouslyChanging] | ||
[NodeCategory("ProtoFlux/Obsidian/Locomotion")] | ||
public class IsUserInSeatedModeNode : ValueFunctionNode<ExecutionContext, bool> | ||
{ | ||
public readonly ObjectInput<User> User; | ||
|
||
protected override bool Compute(ExecutionContext context) | ||
{ | ||
User user = User.Evaluate(context); | ||
if (user == null) | ||
{ | ||
return false; | ||
} | ||
|
||
return user.InputInterface.SeatedMode; | ||
} | ||
} | ||
} |