Ejemplo n.º 1
0
 /// <summary>
 /// Register a listener to a group of keys.
 /// </summary>
 public void AddListener(IEnumerable <string> keys, DataChangeAction eventCallback)
 {
     foreach (var key in keys)
     {
         AddListener(key, eventCallback);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Register a key binding callback.
        /// </summary>
        protected void BindBlackboard <ValueType>(string key, Action <ValueType> onUpdateCallback)
        {
            if (Blackboard == null)
            {
                Debug.LogError("Failed to find a valid Blackboard to bind key!");
            }

            DataChangeAction onChangeAction = (k, v, b) => onUpdateCallback(b.Get <ValueType>(k));

            Blackboard.AddListener(key, onChangeAction);

            registeredListeners.Add(new UIBindListener(key, onChangeAction));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Remove a listener from a key.
        /// </summary>
        public void RemoveListener(string key, DataChangeAction eventCallback)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException("key", "Invalid key name to remove callback!");
            }

            if (eventCallback == null)
            {
                return;
            }

            if (!blackboardEvents.ContainsKey(key))
            {
                return;
            }

            blackboardEvents[key].RemoveListener(eventCallback);
        }