1
0
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:
Thor Brigsted 2017-10-21 12:01:34 +02:00
parent 2dc7450661
commit d3a057b9af

View File

@ -1,7 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
/// <summary> Base class for all nodes </summary>
@ -16,12 +14,13 @@ public abstract class Node : ScriptableObject {
Always
}
/// <summary> Name of the node </summary>
/// <summary> Parent <see cref="NodeGraph"/> </summary>
[SerializeField] public NodeGraph graph;
/// <summary> Position on the <see cref="NodeGraph"/> </summary>
[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>
[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>();
public int InputCount { get { return inputs.Count; } }
@ -65,6 +64,8 @@ public abstract class Node : ScriptableObject {
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) {
Debug.LogWarning("No GetValue(NodePort port) override defined for " + GetType());
return null;
@ -77,21 +78,7 @@ public abstract class Node : ScriptableObject {
/// <param name="from">Output</param> <param name="to">Input</param>
public virtual void OnCreateConnection(NodePort from, NodePort to) { }
public int GetInputId(NodePort input) {
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;
}
/// <summary> Disconnect everything from this node </summary>
public void ClearConnections() {
for (int i = 0; i < inputs.Count; i++) {
inputs[i].ClearConnections();