Пример #1
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);
        }
Пример #2
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);
        }
Пример #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());
                }
            }
        }
Пример #4
0
        protected override void HandleMessage(EntityActorMessageContext messageContext, DefaultEntityActorStateContainer state, TryCastSpellMessage message)
        {
            //Validate the cast before we starer it at all.
            SpellCastResult spellCastAttemptValidationResult = SpellCastValidator.ValidateSpellCast(state, message.SpellId);

            if (spellCastAttemptValidationResult != SpellCastResult.SPELL_FAILED_SUCCESS)
            {
                messageContext.Entity.TellSelf(new SpellCastFailedMessage(spellCastAttemptValidationResult, message.SpellId));
                return;
            }

            //We also need to check if we're moving. If the generator isn't finished then that means we're actually moving.
            if (state.EntityGuid.EntityType == EntityType.Player)            //only players should get successful callbacks
            {
                messageContext.Entity.TellSelf(new SpellCastFailedMessage(SpellCastResult.SPELL_FAILED_SUCCESS, message.SpellId));
            }

            PendingSpellCastData castData = CreatePendingSpellData(state, message);

            SetCastingEntityState(state, message);

            DispatchPendingSpellCast(messageContext, castData);
        }
Пример #5
0
 public PendingSpellCastFinishedWaitingMessage([NotNull] PendingSpellCastData pending)
 {
     Pending = pending ?? throw new ArgumentNullException(nameof(pending));
 }
Пример #6
0
 private static void DispatchPendingSpellCast(EntityActorMessageContext messageContext, PendingSpellCastData castData)
 {
     //Instant casts can just directly send.
     if (castData.isInstantCast)
     {
         messageContext.Entity.TellSelf(new PendingSpellCastFinishedWaitingMessage(castData));
     }
     else
     {
         messageContext.ContinuationScheduler.ScheduleTellOnce(castData.CastTime, messageContext.Entity, new PendingSpellCastFinishedWaitingMessage(castData), messageContext.Entity, castData.PendingCancel);
     }
 }