Пример #1
0
 public SubSpellEventArgs(ISubSpellHandler handler, SubSpellEvent e, Query q, IEnumerable <Target> targets)
 {
     Handler        = handler;
     Event          = e;
     Query          = q;
     QueriedTargets = targets;
 }
Пример #2
0
        private void FireEvent(SubSpellEvent eventType, Target defaultOrigin)
        {
            // Send non-targeted event to effect
            SubSpell.EffectHandler?.OnEvent(new SubSpellEventArgs(this, eventType));

            for (var eventIndex = 0; eventIndex < SubSpell.FireSubSpellEvents.Length; eventIndex++)
            {
                // Filter SubSpell events
                var e = SubSpell.FireSubSpellEvents[eventIndex];
                if (e.Type != eventType)
                {
                    continue;
                }

                QueryTargets(Queried, e.Query, defaultOrigin);

                // Targeted event
                SubSpell.EffectHandler?.OnEvent(new SubSpellEventArgs(this, eventType, e.Query, Queried));

                // New source of SubSpell
                var newSsSource = ResolveTarget(e.SubSpellSource, ResolveTarget(e.Query.Origin, defaultOrigin));

                foreach (var target in Queried)
                {
                    #if DEBUG
                    TargetUtility.DebugDraw(target, Color.yellow);
                    #endif
                    if (target.Type == TargetType.Character)
                    {
                        if (e.Query.ExcludeAlreadyAffected &&
                            _spellHandler.AffectedCharacters.Contains(target.Character))
                        {
                            continue;
                        }

                        if (e.TrackAffectedCharacters)
                        {
                            _spellHandler.AffectedCharacters.Add(target.Character);
                        }

                        if (e.ApplyBuffToTarget != null)
                        {
                            target.Character.ApplyBuff(
                                e.ApplyBuffToTarget,
                                SpellHandler.Source.Character,
                                Stacks,
                                this);
                        }
                    }

                    // SubSpell firing
                    if (e.FireSubSpell != null)
                    {
                        // Before adding SubSpell we first need to figure out what
                        // new sources and targets will be.
                        // Because some SubSpells overrides targeting
                        var newTarget = ResolveTarget(e.SubSpellTarget, target);

                        // Fire child sub spell
                        // Queue it to the spell processor
                        _spellHandler.CastSubSpell(e.FireSubSpell, newSsSource, newTarget);
                    }
                }
            }
        }
Пример #3
0
 public SubSpellEventArgs(ISubSpellHandler handler, SubSpellEvent e)
     : this(handler, e, default, default)
 {
 }