123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace KairoEngine.Core
- {
- public static class GenericEventsStoryExtensions
- {
- public static Dictionary<string, System.Action<StoryStepData>> list = new Dictionary<string, System.Action<StoryStepData>>();
-
- public static void StartListening(this GenericEvents e, string title, System.Action<StoryStepData> listener)
- {
- System.Action<StoryStepData> action = null;
- if (list.TryGetValue(title, out action))
- {
- action += listener;
- list[title] = action;
- }
- else
- {
- action += listener;
- list.Add(title, action);
- }
- }
- public static void StopListening(this GenericEvents e,string title, System.Action<StoryStepData> listener)
- {
- System.Action<StoryStepData> action = null;
- if (list.TryGetValue(title, out action))
- {
- action -= listener;
- list[title] = action;
- }
- }
- public static void Trigger(this GenericEvents e, string title, StoryStepData storyStepData)
- {
- System.Action<StoryStepData> action = null;
- if (list.TryGetValue(title, out action))
- {
- if(action != null) action(storyStepData);
- }
- }
- }
- }
|