mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
22 lines
620 B
C#
22 lines
620 B
C#
namespace XNode.Examples.LogicToy {
|
|
/// <summary> Base node for the LogicToy system </summary>
|
|
public abstract class LogicNode : Node {
|
|
public abstract bool on { get; }
|
|
|
|
protected abstract void OnTrigger();
|
|
|
|
public void SendPulse(NodePort port) {
|
|
// Loop through port connections
|
|
int connectionCount = port.ConnectionCount;
|
|
for (int i = 0; i < connectionCount; i++) {
|
|
NodePort connectedPort = port.GetConnection(i);
|
|
|
|
// Get connected ports logic node
|
|
LogicNode logicNode = connectedPort.node as LogicNode;
|
|
|
|
// Trigger it
|
|
if (logicNode != null) logicNode.OnTrigger();
|
|
}
|
|
}
|
|
}
|
|
} |