/// <summary>
        /// Subscribe to a specific event type (only be notified of a specific event type)
        /// </summary>
        public Subscription Subscribe(Action <ScriptableEvent> action, ScriptableEvent eventType)
        {
            var publisher = eventPublisherCatalog.Find(eventType);

            publisher.Subscribe(action);
            return(Subscription.Create(publisher, action));
        }
 public void RaiseEvent(ScriptableEvent eventType)
 {
     if (debug)
     {
         Debug.Log("EVENT: " + eventType.name);
     }
     //    Raise general events
     eventPublisher.RaiseEvent(eventType);
     //    Raise subscribed events
     eventPublisherCatalog.Find(eventType).RaiseEvent(eventType);
 }
Esempio n. 3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUI.enabled = Application.isPlaying;

            ScriptableEvent e = target as ScriptableEvent;

            if (GUILayout.Button("Raise"))
            {
                e.Raise();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Register an event to be reset at the end of a frame
        /// </summary>
        /// <param name="scriptableEvent">Event to be reset</param>
        public static void RegisterEventForReset(ScriptableEvent scriptableEvent)
        {
            if (Instance != null)
            {
                Instance.StartCoroutine(ResetOnEndOfFrame());
            }
            else
            {
                throw new System.Exception("Event Tracker is not yet ready");
            }

            IEnumerator ResetOnEndOfFrame()
            {
                yield return(new WaitForEndOfFrame());

                scriptableEvent.Reset();
            }
        }
Esempio n. 5
0
    public void StartTimer(double timeToTrigger, ScriptableEvent targetEvent, DateTimeValue nextEventValue, bool keepAlive)
    {
        if (keepAlive)
        {
            DontDestroyOnLoad(this);
        }

        timeTrigger         = timeToTrigger;
        dateTimeInitializer = nextEventValue;
        eventTarget         = targetEvent;

        if (currentRoutine != null)
        {
            return;
        }

        Init();

        currentRoutine = StartCoroutine(RunTimerEvent());
    }
Esempio n. 6
0
 private void OnRaisedEvent(ScriptableEvent scriptableEvent)
 {
     unityEvent.Invoke();
 }
 public void OnDisable()
 {
     ScriptableEvent?.RemoveListener(this);
 }
 public void OnEnable()
 {
     ScriptableEvent?.AddListener(this);
 }
Esempio n. 9
0
 public void RaiseEvent(ScriptableEvent eventType)
 {
     onEvent(eventType);
 }