Kaynağa Gözat

Added Vector3 Generic Event

James Peret 2 yıl önce
ebeveyn
işleme
db8907f328
2 değiştirilmiş dosya ile 40 ekleme ve 0 silme
  1. 1 0
      Readme.md
  2. 39 0
      Runtime/EventManager/GenericEvents.cs

+ 1 - 0
Readme.md

@@ -28,6 +28,7 @@ This contains the base code that other packages will use. It includes code for t
 ##### v0.2.7
 - Added Tag Attribute
 - Added Layer Attribute
+- Added Vector3 Generic Event
 
 ##### v0.2.6
 - Added the Cronometer utility

+ 39 - 0
Runtime/EventManager/GenericEvents.cs

@@ -360,6 +360,45 @@ namespace KairoEngine.Core
         }
         #endregion
 
+        #region Vector3_Event
+        
+        public static Dictionary<string, System.Action<Vector3>> listVector3 = new Dictionary<string, System.Action<Vector3>>();
+        
+        public static void StartListening(string title, System.Action<Vector3> listener)
+        {
+            System.Action<Vector3> action = null;
+            if (listVector3.TryGetValue(title, out action))
+            {
+                action += listener;
+                listVector3[title] = action;
+            }
+            else
+            {
+                action += listener;
+                listVector3.Add(title, action);
+            }
+        }
+
+        public static void StopListening(string title, System.Action<Vector3> listener)
+        {
+            System.Action<Vector3> action = null;
+            if (listVector3.TryGetValue(title, out action))
+            {
+                action -= listener;
+                listVector3[title] = action;
+            }
+        }
+
+        public static void Trigger(string title, Vector3 value)
+        {
+            System.Action<Vector3> action = null;
+            if (listVector3.TryGetValue(title, out action))
+            {
+                if(action != null) action(value);
+            }
+        }
+        #endregion
+
         #region String_Vector3_Event
         
         public static Dictionary<string, System.Action<string, Vector3>> listStringVector3 = new Dictionary<string, System.Action<string, Vector3>>();