summaryrefslogtreecommitdiff
path: root/Runtime/Graphs/UnityEngine.Graphs/MonoBehaviourEventDummies/OnTriggerEventDummy.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Graphs/UnityEngine.Graphs/MonoBehaviourEventDummies/OnTriggerEventDummy.cs
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/Graphs/UnityEngine.Graphs/MonoBehaviourEventDummies/OnTriggerEventDummy.cs')
-rw-r--r--Runtime/Graphs/UnityEngine.Graphs/MonoBehaviourEventDummies/OnTriggerEventDummy.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/Runtime/Graphs/UnityEngine.Graphs/MonoBehaviourEventDummies/OnTriggerEventDummy.cs b/Runtime/Graphs/UnityEngine.Graphs/MonoBehaviourEventDummies/OnTriggerEventDummy.cs
new file mode 100644
index 0000000..992f240
--- /dev/null
+++ b/Runtime/Graphs/UnityEngine.Graphs/MonoBehaviourEventDummies/OnTriggerEventDummy.cs
@@ -0,0 +1,40 @@
+using System;
+using UnityEngine;
+using System.Collections.Generic;
+
+namespace UnityEngine.Graphs.LogicGraph
+{
+ // For now we do triggers by attaching this MonoBehaviour to needed gameobjects. Class then sends events to logic graph nodes.
+ public class OnTriggerEventDummy : ColliderDummyBase
+ {
+ public delegate void TriggerOutDelegate (Collider other);
+ private TriggerOutDelegate m_OnEnter;
+ private TriggerOutDelegate m_OnExit;
+ private TriggerOutDelegate m_OnStay;
+
+ public static void AttachToCollider(ColliderNodes.OnTriggerEvent node)
+ {
+ var attached = AttachToCollider(node.self, typeof(OnTriggerEventDummy)) as OnTriggerEventDummy;
+ attached.m_OnEnter += node.EnterDummy;
+ attached.m_OnExit += node.ExitDummy;
+ attached.m_OnStay += node.StayDummy;
+ }
+
+ public void OnTriggerEnter(Collider other)
+ {
+ if (m_OnEnter != null)
+ m_OnEnter (other);
+ }
+ public void OnTriggerExit(Collider other)
+ {
+ if (m_OnExit != null)
+ m_OnExit(other);
+ }
+ public void OnTriggerStay(Collider other)
+ {
+ if (m_OnStay != null)
+ m_OnStay (other);
+ }
+ }
+}
+