mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Added NodePort.GetInputSum
This commit is contained in:
parent
4fcaede3b0
commit
49c12ec87e
@ -55,7 +55,6 @@ public class NodePort {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary> Return the output value of this node through its parent nodes GetValue override method. </summary>
|
/// <summary> Return the output value of this node through its parent nodes GetValue override method. </summary>
|
||||||
/// <returns> <see cref="Node.GetValue(NodePort)"/> </returns>
|
/// <returns> <see cref="Node.GetValue(NodePort)"/> </returns>
|
||||||
public object GetOutputValue() {
|
public object GetOutputValue() {
|
||||||
@ -105,6 +104,30 @@ public class NodePort {
|
|||||||
return value != null;
|
return value != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Return the sum of all inputs. </summary>
|
||||||
|
/// <returns> <see cref="NodePort.GetOutputValue"/> </returns>
|
||||||
|
public float GetInputSum(float fallback) {
|
||||||
|
object[] objs = GetInputValues();
|
||||||
|
if (objs.Length == 0) return fallback;
|
||||||
|
float result = 0;
|
||||||
|
for (int i = 0; i < objs.Length; i++) {
|
||||||
|
if (objs[i] is float) result += (float)objs[i];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Return the sum of all inputs. </summary>
|
||||||
|
/// <returns> <see cref="NodePort.GetOutputValue"/> </returns>
|
||||||
|
public int GetInputSum(int fallback) {
|
||||||
|
object[] objs = GetInputValues();
|
||||||
|
if (objs.Length == 0) return fallback;
|
||||||
|
int result = 0;
|
||||||
|
for (int i = 0; i < objs.Length; i++) {
|
||||||
|
if (objs[i] is int) result += (int)objs[i];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary> Connect this <see cref="NodePort"/> to another </summary>
|
/// <summary> Connect this <see cref="NodePort"/> to another </summary>
|
||||||
/// <param name="port">The <see cref="NodePort"/> to connect to</param>
|
/// <param name="port">The <see cref="NodePort"/> to connect to</param>
|
||||||
public void Connect(NodePort port) {
|
public void Connect(NodePort port) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user