Exemple #1
0
            internal void RefreshOrCreateAura(AuraInfo auraInfo, SpellInfo spellInfo, Unit originalCaster)
            {
                var ownedAura = FindOwnedAura();

                if (ownedAura != null && ownedAura.AuraInfo.HasAttribute(AuraAttributes.StackSameAuraInMultipleSlots))
                {
                    ownedAura = null;
                }

                if (ownedAura == null)
                {
                    ownedAura = new Aura(auraInfo, spellInfo, unit, originalCaster);
                    ownedAuras.Add(ownedAura);
                    ownedAurasById.Insert(ownedAura.AuraInfo.Id, ownedAura);

                    Logging.LogAura($"Added owned aura {ownedAura.AuraInfo.name} for target: {unit.Name}");

                    RemoveNonStackableAuras(ownedAura);
                }
                else
                {
                    ownedAura.Refresh();
                }

                if (ownedAura.IsRemoved)
                {
                    return;
                }

                int duration = ownedAura.MaxDuration;

                duration = originalCaster.Spells.ModifyAuraDuration(ownedAura.AuraInfo, unit, duration);

                if (duration != ownedAura.Duration)
                {
                    ownedAura.UpdateDuration(duration, duration);
                }

                ownedAura.UpdateTargets();

                Aura FindOwnedAura()
                {
                    if (ownedAurasById.TryGetValue(auraInfo.Id, out List <Aura> ownedAuraList))
                    {
                        foreach (Aura aura in ownedAuraList)
                        {
                            if (aura.CasterId == originalCaster.Id)
                            {
                                return(aura);
                            }
                        }
                    }

                    return(null);
                }
            }
Exemple #2
0
            internal bool IsImmuneToAura(AuraInfo auraInfo, Unit caster)
            {
                foreach (AuraEffectInfo auraEffect in auraInfo.AuraEffects)
                {
                    if (!IsImmuneToAuraEffect(auraEffect, caster))
                    {
                        return(false);
                    }
                }

                return(true);
            }
Exemple #3
0
            internal void RefreshOrCreateAura(AuraInfo auraInfo, SpellInfo spellInfo, Unit originalCaster, Spell spell, int overrideDuration = -1)
            {
                var  ownedAura = FindOwnedAura();
                bool refreshed = false;

                if (ownedAura != null && ownedAura.AuraInfo.HasAttribute(AuraAttributes.StackSameAuraInMultipleSlots))
                {
                    ownedAura = null;
                }

                if (ownedAura == null)
                {
                    ownedAura = new Aura(auraInfo, spellInfo, unit, originalCaster);
                    ownedAuras.Add(ownedAura);
                    ownedAurasById.Insert(ownedAura.AuraInfo.Id, ownedAura);

                    Logging.LogAura($"Added owned aura {ownedAura.AuraInfo.name} for target: {unit.Name}");

                    RemoveNonStackableAuras(ownedAura);
                }
                else
                {
                    ownedAura.Refresh();
                    refreshed = true;
                }

                if (ownedAura.IsRemoved)
                {
                    return;
                }

                (int, int)duration = originalCaster.Spells.CalculateAuraDuration(ownedAura.AuraInfo, unit, spell, refreshed ? ownedAura : null, overrideDuration);
                ownedAura.UpdateDuration(duration.Item1, duration.Item2);
                ownedAura.UpdateTargets();

                Aura FindOwnedAura()
                {
                    if (ownedAurasById.TryGetValue(auraInfo.Id, out List <Aura> ownedAuraList))
                    {
                        foreach (Aura aura in ownedAuraList)
                        {
                            if (aura.CasterId == originalCaster.Id)
                            {
                                return(aura);
                            }
                        }
                    }

                    return(null);
                }
            }
        internal bool CanStackWith(Aura existingAura)
        {
            if (this == existingAura)
            {
                return(true);
            }

            bool sameCaster = CasterId == existingAura.CasterId;

            if (!sameCaster && AuraInfo == existingAura.AuraInfo && !AuraInfo.HasAttribute(AuraAttributes.StackForAnyCasters))
            {
                return(false);
            }

            return(true);
        }
        internal Aura(AuraInfo auraInfo, SpellInfo spellInfo, [NotNull] Unit owner, [NotNull] Unit caster)
        {
            AuraInfo        = auraInfo;
            SpellInfo       = spellInfo;
            casterReference = caster.SelfReference;
            Owner           = owner;
            CasterId        = caster.Id;

            UpdateDuration(auraInfo.Duration, auraInfo.MaxDuration);
            UpdateCharges(AuraInfo.Charges);

            effectInfos.AddRange(auraInfo.AuraEffects);

            for (int index = 0; index < effectInfos.Count; index++)
            {
                AuraEffect newEffect = effectInfos[index].CreateEffect(this, Caster, index);
                newEffect.CalculateValue();
                effects.Add(newEffect);
            }

            Logging.LogAura($"Created aura {AuraInfo.name} for target: {Owner.Name}, current count: {++AuraAliveCount}");
        }
Exemple #6
0
 internal bool IsImmuneToAura(AuraInfo auraInfo, Unit caster)
 {
     return(false);
 }
Exemple #7
0
 internal bool IsImmunedToDamage(AuraInfo auraInfo)
 {
     return(false);
 }
 internal int ModifyAuraDuration(AuraInfo auraInfo, Unit target, int duration)
 {
     return(duration);
 }