Example #1
0
        private void SetBlockage(InteractionKind kind, IBaseInteraction receiver)
        {
            if (!listeners.ContainsKey(receiver))
            {
                Debug.LogError($"{receiver} has no listener set on {this} when setting blocker for {kind}");
                return;
            }

            foreach (var listener in listeners[receiver])
            {
                dependencies.Add(listener, kind);
            }
        }
Example #2
0
        /// <summary>
        /// Manually subscribe an interaction to an event kind.<br/>
        /// Useful when setting up interactions from non unity classes.<br/>
        /// You probably don't need this if you don't know what you're doing.
        /// </summary>
        /// <param name="kind">The kind to subscribe to</param>
        /// <param name="receiver">The interaction to subscribe</param>
        public void Subscribe(InteractionKind kind, IBaseInteraction receiver)
        {
            if (!receivers.ContainsKey(kind))
            {
                receivers.Add(kind, new List <IBaseInteraction>());
            }
            receivers[kind].Add(receiver);

            if (!listeners.ContainsKey(receiver))
            {
                listeners.Add(receiver, new List <InteractionKind>());
            }
            listeners[receiver].Add(kind);
        }
Example #3
0
 /// <summary>
 /// Manually unsubscribe an interaction from an event kind.<br/>
 /// Useful when setting up interactions from non unity classes.<br/>
 /// You probably don't need this if you don't know what you're doing.
 /// </summary>
 /// <param name="kind">The kind to unsubscribe from</param>
 /// <param name="receiver">The interaction to unsubscribe</param>
 public void Unsubscribe(InteractionKind kind, IBaseInteraction receiver)
 {
     if (receivers.ContainsKey(kind))
     {
         receivers[kind].Remove(receiver);
         if (receivers[kind].Count == 0)
         {
             receivers.Remove(kind);
         }
     }
     if (listeners.ContainsKey(receiver))
     {
         listeners[receiver].Remove(kind);
         if (listeners[receiver].Count == 0)
         {
             listeners.Remove(receiver);
         }
     }
 }