예제 #1
0
        /// <summary>
        /// Stores the event at the specified index. If we are passing a null UnityEvent,
        /// the index may be cleared and returned
        /// </summary>
        /// <param name="rIndex">Index to store the UnityEvent at</param>
        /// <param name="rObject">ReactorActionEvent to store</param>
        public int StoreUnityEvent(int rIndex, ReactorActionEvent rObject)
        {
            int lIndex = rIndex;

            if (rObject == null)
            {
                if (lIndex >= 0 && lIndex < _StoredUnityEvents.Count)
                {
                    _StoredUnityEvents[lIndex] = null;
                }

                lIndex = -1;
            }
            else
            {
                if (lIndex == -1)
                {
                    lIndex = _StoredUnityEvents.Count;
                    _StoredUnityEvents.Add(null);
                }

                _StoredUnityEvents[lIndex] = rObject;
            }

            return(lIndex);
        }
예제 #2
0
        /// <summary>
        /// Called when the reactor is first activated
        /// </summary>
        /// <returns>Determines if other reactors should process.</returns>
        public override bool Activate()
        {
            base.Activate();

            // Grab and invoke the event
            if (_StoredUnityEventIndex >= 0 && _StoredUnityEventIndex < mActorCore._StoredUnityEvents.Count)
            {
                ReactorActionEvent lEvent = mActorCore._StoredUnityEvents[_StoredUnityEventIndex];
                if (lEvent != null)
                {
                    lEvent.Invoke(this);
                }
            }

            // Disable the reactor
            Deactivate();

            // Allow other reactors to continue
            return(true);
        }