Exemple #1
0
        public IEnumerable <IActorRef> SingleTargetEnemySnapshotTarget([NotNull] IPendingSpellCastData pendingSpellData)
        {
            if (pendingSpellData == null)
            {
                throw new ArgumentNullException(nameof(pendingSpellData));
            }

            yield return(ActorReferenceMappable.RetrieveEntity(pendingSpellData.SnapshotEntityTarget));
        }
Exemple #2
0
        public IEnumerable <IActorRef> ComputeAllyTargets([NotNull] IPendingSpellCastData pendingSpellData, [NotNull] DefaultEntityActorStateContainer actorState)
        {
            if (pendingSpellData == null)
            {
                throw new ArgumentNullException(nameof(pendingSpellData));
            }
            if (actorState == null)
            {
                throw new ArgumentNullException(nameof(actorState));
            }

            //TODO: Handle hostility calculation. Right now it just only supports player targeting, and opts to self target if targeting a creature.
            yield return(pendingSpellData.SnapshotEntityTarget.EntityType == EntityType.Player ? ActorReferenceMappable.RetrieveEntity(pendingSpellData.SnapshotEntityTarget) : ActorReferenceMappable.RetrieveEntity(actorState.EntityGuid));
        }
Exemple #3
0
        public void DispatchSpellCast([NotNull] IPendingSpellCastData pendingSpellCast, DefaultEntityActorStateContainer casterData)
        {
            if (pendingSpellCast == null)
            {
                throw new ArgumentNullException(nameof(pendingSpellCast));
            }

            if (!SpellDataCollection.ContainsSpellDefinition(pendingSpellCast.SpellId))
            {
                throw new InvalidOperationException($"Tried to cast Spell: {pendingSpellCast.SpellId} but no definition exists.");
            }

            IActorRef casterActorReference           = ActorReferenceMappable.RetrieveEntity(casterData.EntityGuid);
            SpellDefinitionDataModel spellDefinition = SpellDataCollection.GetSpellDefinition(pendingSpellCast.SpellId);

            //Each spell can have N effects with individual unique targeting attributes.
            //So we need to handle each spell effect seperately, compute their effects/targets
            //and send an effect application message to the involved actors.
            foreach (SpellEffectIndex effectIndex in spellDefinition.EnumerateSpellEffects())
            {
                SpellEffectDefinitionDataModel effectDefinition = SpellDataCollection.GetSpellEffectDefinition(spellDefinition.GetSpellEffectId(effectIndex));

                SpellEffectTargetContext targetContext = EffectTargetSelectorFactory
                                                         .Create(effectDefinition)
                                                         .CalculateTargets(spellDefinition, effectDefinition, casterData, pendingSpellCast);

                ApplySpellEffectMessage spellEffectApplicationMessage = SpellEffectApplicationMessageFactory.Create(new SpellEffectApplicationMessageCreationContext(casterData.EntityGuid, pendingSpellCast.SpellId, effectIndex));

                //For each actor target in the target context
                //we need to send the spell application message for handling
                foreach (var target in targetContext.SpellEffectTargets)
                {
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.Debug($"Entity: {casterData.EntityGuid} casted spell with effect that targets Target: {target.Path.Name}");
                    }

                    target.Tell(spellEffectApplicationMessage, casterActorReference);
                }
            }
        }
Exemple #4
0
 public ImmediateCastSpellMessage([NotNull] IPendingSpellCastData pendingSpellData)
 {
     PendingSpellData = pendingSpellData ?? throw new ArgumentNullException(nameof(pendingSpellData));
 }
Exemple #5
0
 public abstract SpellEffectTargetContext CalculateTargets(SpellDefinitionDataModel spellDefinition, SpellEffectDefinitionDataModel spellEffect, DefaultEntityActorStateContainer actorState, IPendingSpellCastData pendingSpellCast);
Exemple #6
0
        public override SpellEffectTargetContext CalculateTargets([NotNull] SpellDefinitionDataModel spellDefinition, [NotNull] SpellEffectDefinitionDataModel spellEffect, [NotNull] DefaultEntityActorStateContainer actorState, [NotNull] IPendingSpellCastData pendingSpellCast)
        {
            if (spellDefinition == null)
            {
                throw new ArgumentNullException(nameof(spellDefinition));
            }
            if (spellEffect == null)
            {
                throw new ArgumentNullException(nameof(spellEffect));
            }
            if (actorState == null)
            {
                throw new ArgumentNullException(nameof(actorState));
            }
            if (pendingSpellCast == null)
            {
                throw new ArgumentNullException(nameof(pendingSpellCast));
            }

            return(new SpellEffectTargetContext(ComputeAllyTargets(pendingSpellCast, actorState)));
        }