Example #1
0
        public SpellCastResult ValidateSpellCast(DefaultEntityActorStateContainer state, int spellId)
        {
            if (PendingSpellCastMappable.ContainsKey(state.EntityGuid))
            {
                PendingSpellCastData pendingCast = PendingSpellCastMappable.RetrieveEntity(state.EntityGuid);

                if (!pendingCast.IsSpellcastFinished(TimeService.CurrentLocalTime))
                {
                    return(SpellCastResult.SPELL_FAILED_SPELL_IN_PROGRESS);
                }
            }

            return(SpellCastResult.SPELL_FAILED_SUCCESS);
        }
Example #2
0
        private PendingSpellCastData CreatePendingSpellData(DefaultEntityActorStateContainer state, TryCastSpellMessage message)
        {
            PendingSpellCastData castData = PendingSpellFactory.Create(new PendingSpellCastCreationContext(message.SpellId, state.EntityData.GetEntityGuidValue(EntityObjectField.UNIT_FIELD_TARGET)));

            if (PendingSpellCastMappable.ContainsKey(state.EntityGuid))
            {
                PendingSpellCastMappable.ReplaceObject(state.EntityGuid, castData);
            }
            else
            {
                PendingSpellCastMappable.AddObject(state.EntityGuid, castData);
            }
            return(castData);
        }
Example #3
0
        protected override void HandleMessage(EntityActorMessageContext messageContext, DefaultEntityActorStateContainer state, PlayerMovementStateChangedMessage message)
        {
            //If we started moving then we should check the current spell cast.
            if (message.isMoving)
            {
                if (PendingSpellCastMappable.ContainsKey(state.EntityGuid))
                {
                    PendingSpellCastData castData = PendingSpellCastMappable.RetrieveEntity(state.EntityGuid);

                    if (castData.isInstantCast || castData.isCastCanceled || castData.IsSpellcastFinished(TimeService.CurrentLocalTime))
                    {
                        return;
                    }

                    //Ok, so we're casting and moving. Let's cancel the cast.
                    messageContext.Entity.TellSelf(new CancelSpellCastMessage());
                }
            }
        }