Exemplo n.º 1
0
    /// <summary>
    /// Triggers an event
    /// </summary>
    /// <param name="_event"> The event type</param>
    /// <param name="_shouldRegisterSender"> The object that is invoking the event</param>
    public static void Invoke(CustomEvent _event, bool _shouldRegisterSender)
    {
        UnityEvent thisEvent = null;

        if (Instance.m_EventDictionary.TryGetValue(_event.GetName(), out thisEvent))
        {
            if (_shouldRegisterSender)
            {
                Instance.m_RegisteredSender = _event.GetSender();
                Debug.Log("|| Sender set to " + Instance.m_RegisteredSender);
            }

            Debug.Log("|| " + _event.GetName() + " Invoked");
            thisEvent.Invoke();

            // Register this event as the last event
            Instance.m_LastEvent = _event.GetName();
        }
    }