Skip to content

Commit

Permalink
All Json Nodes
Browse files Browse the repository at this point in the history
All Json Nodes
  • Loading branch information
Xlinka authored Jan 21, 2024
2 parents 7ea82f4 + 52b552e commit 6b561c1
Show file tree
Hide file tree
Showing 32 changed files with 1,469 additions and 0 deletions.
71 changes: 71 additions & 0 deletions Bindings/JSON/JsonAddToObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using Elements.Core;
using FrooxEngine;
using FrooxEngine.ProtoFlux;
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution;
using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json;
using Newtonsoft.Json.Linq;


[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })]
public class JsonAddToObjectBinding<T> : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode<FrooxEngineContext, JObject>
{
public readonly SyncRef<INodeObjectOutput<JObject>> Input;
public readonly SyncRef<INodeObjectOutput<string>> Tag;
public readonly SyncRef<INodeObjectOutput<T>> Object;

public override Type NodeType => typeof(JsonAddToObject<T>);

public JsonAddToObject<T> TypedNodeInstance { get; private set; }

public override INode NodeInstance => TypedNodeInstance;

public override int NodeInputCount => base.NodeInputCount + 3;

public override N Instantiate<N>()
{
if (TypedNodeInstance != null)
{
throw new InvalidOperationException("Node has already been instantiated");
}
JsonAddToObject<T> jsonAddToObjectInstance = (TypedNodeInstance = new JsonAddToObject<T>());
return jsonAddToObjectInstance as N;
}

protected override void AssociateInstanceInternal(INode node)
{
if (node is JsonAddToObject<T> typedNodeInstance)
{
TypedNodeInstance = typedNodeInstance;
return;
}
throw new ArgumentException("Node instance is not of type " + typeof(JsonAddToObject<T>));
}

public override void ClearInstance()
{
TypedNodeInstance = null;
}

protected override ISyncRef GetInputInternal(ref int index)
{
ISyncRef inputInternal = base.GetInputInternal(ref index);
if (inputInternal != null)
{
return inputInternal;
}
switch (index)
{
case 0:
return Input;
case 1:
return Tag;
case 2:
return Object;
default:
index -= 3;
return null;
}
}
}
68 changes: 68 additions & 0 deletions Bindings/JSON/JsonAppendToArrayBinding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using Elements.Core;
using FrooxEngine;
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution;
using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json;
using Newtonsoft.Json.Linq;
using FrooxEngine.ProtoFlux;

[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })]
public class JsonAppendToArrayBinding<T> : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode<ExecutionContext, JArray>
{
public readonly SyncRef<INodeObjectOutput<JArray>> Array;
public readonly SyncRef<INodeObjectOutput<T>> Object;

public override Type NodeType => typeof(JsonAppendToArray<T>);

public JsonAppendToArray<T> TypedNodeInstance { get; private set; }

public override INode NodeInstance => TypedNodeInstance;

public override int NodeInputCount => base.NodeInputCount + 2;

public override N Instantiate<N>()
{
if (TypedNodeInstance != null)
{
throw new InvalidOperationException("Node has already been instantiated");
}
JsonAppendToArray<T> jsonAppendToArrayInstance = (TypedNodeInstance = new JsonAppendToArray<T>());
return jsonAppendToArrayInstance as N;
}

protected override void AssociateInstanceInternal(INode node)
{
if (node is JsonAppendToArray<T> typedNodeInstance)
{
TypedNodeInstance = typedNodeInstance;
return;
}
throw new ArgumentException("Node instance is not of type " + typeof(JsonAppendToArray<T>));
}

public override void ClearInstance()
{
TypedNodeInstance = null;
}

protected override ISyncRef GetInputInternal(ref int index)
{
ISyncRef inputInternal = base.GetInputInternal(ref index);
if (inputInternal != null)
{
return inputInternal;
}
switch (index)
{
case 0:
return Array;
case 1:
return Object;
default:
index -= 2;
return null;
}
}
}

62 changes: 62 additions & 0 deletions Bindings/JSON/JsonCountArrayChildrenBinding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using Elements.Core;
using FrooxEngine;
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution;
using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json;
using Newtonsoft.Json.Linq;
using FrooxEngine.ProtoFlux;

[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })]
public class JsonCountArrayChildrenBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ValueFunctionNode<ExecutionContext, int>
{
public readonly SyncRef<INodeObjectOutput<JArray>> Input;

public override Type NodeType => typeof(JsonCountArrayChildrenNode);

public JsonCountArrayChildrenNode 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");
}
JsonCountArrayChildrenNode jsonCountArrayChildrenInstance = (TypedNodeInstance = new JsonCountArrayChildrenNode());
return jsonCountArrayChildrenInstance as N;
}

protected override void AssociateInstanceInternal(INode node)
{
if (node is JsonCountArrayChildrenNode typedNodeInstance)
{
TypedNodeInstance = typedNodeInstance;
return;
}
throw new ArgumentException("Node instance is not of type " + typeof(JsonCountArrayChildrenNode));
}

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 Input;
}
index -= 1;
return null;
}
}
63 changes: 63 additions & 0 deletions Bindings/JSON/JsonCountObjectChildrenBinding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using Elements.Core;
using FrooxEngine;
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution;
using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json;
using Newtonsoft.Json.Linq;
using FrooxEngine.ProtoFlux;


[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })]
public class JsonCountObjectChildrenBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ValueFunctionNode<ExecutionContext, int>
{
public readonly SyncRef<INodeObjectOutput<JObject>> Input;

public override Type NodeType => typeof(JsonCountObjectChildrenNode);

public JsonCountObjectChildrenNode 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");
}
JsonCountObjectChildrenNode jsonCountObjectChildrenInstance = (TypedNodeInstance = new JsonCountObjectChildrenNode());
return jsonCountObjectChildrenInstance as N;
}

protected override void AssociateInstanceInternal(INode node)
{
if (node is JsonCountObjectChildrenNode typedNodeInstance)
{
TypedNodeInstance = typedNodeInstance;
return;
}
throw new ArgumentException("Node instance is not of type " + typeof(JsonCountObjectChildrenNode));
}

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 Input;
}
index -= 1;
return null;
}
}
42 changes: 42 additions & 0 deletions Bindings/JSON/JsonEmptyArrayBinding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using Elements.Core;
using FrooxEngine;
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution;
using Newtonsoft.Json.Linq;
using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json;

[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })]
public class JsonEmptyArrayBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode<ExecutionContext, JArray>
{
public override Type NodeType => typeof(JsonEmptyArrayNode);

public JsonEmptyArrayNode TypedNodeInstance { get; private set; }

public override INode NodeInstance => TypedNodeInstance;

public override int NodeInputCount => 0;

public override N Instantiate<N>()
{
if (TypedNodeInstance != null)
throw new InvalidOperationException("Node has already been instantiated");

TypedNodeInstance = new JsonEmptyArrayNode();
return TypedNodeInstance as N;
}

protected override void AssociateInstanceInternal(INode node)
{
if (node is JsonEmptyArrayNode typedNodeInstance)
TypedNodeInstance = typedNodeInstance;
else
throw new ArgumentException("Node instance is not of type " + typeof(JsonEmptyArrayNode));
}

public override void ClearInstance()
{
TypedNodeInstance = null;
}
}

42 changes: 42 additions & 0 deletions Bindings/JSON/JsonEmptyObjectBinding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using Elements.Core;
using FrooxEngine;
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution;
using Newtonsoft.Json.Linq;
using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json;

[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })]
public class JsonEmptyObjectBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode<ExecutionContext, JObject>
{
public override Type NodeType => typeof(JsonEmptyObjectNode);

public JsonEmptyObjectNode TypedNodeInstance { get; private set; }

public override INode NodeInstance => TypedNodeInstance;

public override int NodeInputCount => 0;

public override N Instantiate<N>()
{
if (TypedNodeInstance != null)
throw new InvalidOperationException("Node has already been instantiated");

TypedNodeInstance = new JsonEmptyObjectNode();
return TypedNodeInstance as N;
}

protected override void AssociateInstanceInternal(INode node)
{
if (node is JsonEmptyObjectNode typedNodeInstance)
TypedNodeInstance = typedNodeInstance;
else
throw new ArgumentException("Node instance is not of type " + typeof(JsonEmptyObjectNode));
}

public override void ClearInstance()
{
TypedNodeInstance = null;
}
}

Loading

0 comments on commit 6b561c1

Please sign in to comment.