mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 09:46:03 +08:00
Cleaned Node.cs
This commit is contained in:
parent
2dc7450661
commit
d3a057b9af
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
/// <summary> Base class for all nodes </summary>
|
/// <summary> Base class for all nodes </summary>
|
||||||
@ -16,12 +14,13 @@ public abstract class Node : ScriptableObject {
|
|||||||
Always
|
Always
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Name of the node </summary>
|
/// <summary> Parent <see cref="NodeGraph"/> </summary>
|
||||||
[SerializeField] public NodeGraph graph;
|
[SerializeField] public NodeGraph graph;
|
||||||
|
/// <summary> Position on the <see cref="NodeGraph"/> </summary>
|
||||||
[SerializeField] public Vector2 position;
|
[SerializeField] public Vector2 position;
|
||||||
/// <summary> Input <see cref="NodePort"/>s. It is recommended not to modify these at hand. Instead, see <see cref="InputAttribute"/> </summary>
|
/// <summary> Input <see cref="NodePort"/>s. It is recommended not to modify these at hand. Instead, see <see cref="InputAttribute"/> </summary>
|
||||||
[SerializeField] public List<NodePort> inputs = new List<NodePort>();
|
[SerializeField] public List<NodePort> inputs = new List<NodePort>();
|
||||||
/// <summary> Output <see cref="NodePort"/>s. It is recommended not to modify these at hand. Instead, see <see cref="InputAttribute"/> </summary>
|
/// <summary> Output <see cref="NodePort"/>s. It is recommended not to modify these at hand. Instead, see <see cref="OutputAttribute"/> </summary>
|
||||||
[SerializeField] public List<NodePort> outputs = new List<NodePort>();
|
[SerializeField] public List<NodePort> outputs = new List<NodePort>();
|
||||||
|
|
||||||
public int InputCount { get { return inputs.Count; } }
|
public int InputCount { get { return inputs.Count; } }
|
||||||
@ -65,6 +64,8 @@ public abstract class Node : ScriptableObject {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Returns a value based on requested port output. Should be overridden before used. </summary>
|
||||||
|
/// <param name="port">The requested port.</param>
|
||||||
public virtual object GetValue(NodePort port) {
|
public virtual object GetValue(NodePort port) {
|
||||||
Debug.LogWarning("No GetValue(NodePort port) override defined for " + GetType());
|
Debug.LogWarning("No GetValue(NodePort port) override defined for " + GetType());
|
||||||
return null;
|
return null;
|
||||||
@ -77,21 +78,7 @@ public abstract class Node : ScriptableObject {
|
|||||||
/// <param name="from">Output</param> <param name="to">Input</param>
|
/// <param name="from">Output</param> <param name="to">Input</param>
|
||||||
public virtual void OnCreateConnection(NodePort from, NodePort to) { }
|
public virtual void OnCreateConnection(NodePort from, NodePort to) { }
|
||||||
|
|
||||||
public int GetInputId(NodePort input) {
|
/// <summary> Disconnect everything from this node </summary>
|
||||||
for (int i = 0; i < inputs.Count; i++) {
|
|
||||||
if (input == inputs[i]) return i;
|
|
||||||
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
public int GetOutputId(NodePort output) {
|
|
||||||
for (int i = 0; i < outputs.Count; i++) {
|
|
||||||
if (output == outputs[i]) return i;
|
|
||||||
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearConnections() {
|
public void ClearConnections() {
|
||||||
for (int i = 0; i < inputs.Count; i++) {
|
for (int i = 0; i < inputs.Count; i++) {
|
||||||
inputs[i].ClearConnections();
|
inputs[i].ClearConnections();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user