summaryrefslogtreecommitdiff
path: root/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2022-06-28 09:40:37 +0800
committerchai <chaifix@163.com>2022-06-28 09:40:37 +0800
commit49b25e755b70ec412feaaf0b898d6f7e09d2bea6 (patch)
tree3c5f4260f30d1c2d7196db93153700d7ddec3157 /Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs
parentc92269331692feca2c276649f6c4ee8911f1f859 (diff)
+node example
Diffstat (limited to 'Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs')
-rw-r--r--Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs
new file mode 100644
index 00000000..2bb7dc03
--- /dev/null
+++ b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace XNode.Examples.StateGraph {
+ public class StateNode : Node {
+
+ [Input] public Empty enter;
+ [Output] public Empty exit;
+
+ public void MoveNext() {
+ StateGraph fmGraph = graph as StateGraph;
+
+ if (fmGraph.current != this) {
+ Debug.LogWarning("Node isn't active");
+ return;
+ }
+
+ NodePort exitPort = GetOutputPort("exit");
+
+ if (!exitPort.IsConnected) {
+ Debug.LogWarning("Node isn't connected");
+ return;
+ }
+
+ StateNode node = exitPort.Connection.node as StateNode;
+ node.OnEnter();
+ }
+
+ public void OnEnter() {
+ StateGraph fmGraph = graph as StateGraph;
+ fmGraph.current = this;
+ }
+
+ [Serializable]
+ public class Empty { }
+ }
+} \ No newline at end of file