Esempio n. 1
0
        /// <summary>
        /// Pulls an object from the pool.
        /// </summary>
        /// <returns></returns>
        public new static MagicMessage Allocate()
        {
            // Grab the next available object
            MagicMessage lInstance = sPool.Allocate();

            // Reset the sent flags. We do this so messages are flagged as 'completed'
            // by default.
            lInstance.IsSent    = false;
            lInstance.IsHandled = false;

            // For this type, guarentee we have something
            // to hand back tot he caller
            if (lInstance == null)
            {
                lInstance = new MagicMessage();
            }
            return(lInstance);
        }
Esempio n. 2
0
        /// <summary>
        /// Called when the action is first activated
        /// <param name="rPreviousSpellActionState">State of the action prior to this one activating</param>
        public override void Activate(int rPreviousSpellActionState = -1, object rData = null)
        {
            base.Activate(rPreviousSpellActionState, rData);

            MotionController lMotionController = _Spell.Owner.GetComponent <MotionController>();

            if (lMotionController != null)
            {
                MagicMessage lMessage = MagicMessage.Allocate();
                lMessage.ID = MessageID;

                lMotionController.SendMessage(lMessage);

                lMessage.Release();
            }

            base.Deactivate();
        }
Esempio n. 3
0
        /// <summary>
        /// Returns an element back to the pool.
        /// </summary>
        /// <param name="rEdge"></param>
        public static void Release(MagicMessage rInstance)
        {
            if (rInstance == null)
            {
                return;
            }

            // We should never release an instance unless we're
            // sure we're done with it. So clearing here is fine
            rInstance.Clear();

            // Reset the sent flags. We do this so messages are flagged as 'completed'
            // and removed by default.
            rInstance.IsSent    = true;
            rInstance.IsHandled = true;

            // Make it available to others.
            sPool.Release(rInstance);
        }
Esempio n. 4
0
        /// <summary>
        /// Activates the action on a single target
        /// </summary>
        /// <param name="rTarget">Target to activate on</param>
        protected bool ActivateInstance(GameObject rTarget)
        {
            if (rTarget == null)
            {
                return(false);
            }

            IActorCore lActorCore = rTarget.GetComponent <IActorCore>();

            if (lActorCore == null)
            {
                return(true);
            }

            MagicMessage lMessage = MagicMessage.Allocate();

            lMessage.Data = this;

            bool lIsAffected = lActorCore.TestAffected(lMessage);

            lMessage.Release();

            return(lIsAffected);
        }