Exemple #1
0
        internal void InitAddonData(INPCDataHolder dataHolder)
        {
            this.DataHolder = dataHolder;
            NPCEntry entry = dataHolder.Entry;

            if (!string.IsNullOrEmpty(this.AuraIdStr))
            {
                SpellId[] spellIdArray = ((IEnumerable <string>) this.AuraIdStr.Split(new char[1]
                {
                    ' '
                }, StringSplitOptions.RemoveEmptyEntries)).TransformArray <string, SpellId>(
                    (Func <string, SpellId>)(idStr =>
                {
                    uint result;
                    if (!uint.TryParse(idStr.Trim(), out result))
                    {
                        LogManager.GetCurrentClassLogger()
                        .Warn("Invalidly formatted Aura ({0}) in AuraString for SpawnEntry: {1}",
                              (object)idStr, (object)this);
                    }
                    return((SpellId)result);
                }));
                if (spellIdArray != null)
                {
                    this.Auras = new List <Spell>(spellIdArray.Length);
                    foreach (SpellId spellId in spellIdArray)
                    {
                        Spell spell = SpellHandler.Get(spellId);
                        if (spell != null)
                        {
                            if (!spell.IsAura || spell.Durations.Min > 0 && spell.Durations.Min < int.MaxValue)
                            {
                                if (entry.Spells == null || !entry.Spells.ContainsKey(spell.SpellId))
                                {
                                    entry.AddSpell(spell);
                                }
                            }
                            else
                            {
                                this.Auras.Add(spell);
                            }
                        }
                    }
                }
            }

            if (this.Auras != null)
            {
                return;
            }
            this.Auras = new List <Spell>(2);
        }
Exemple #2
0
        internal void InitAddonData(INPCDataHolder dataHolder)
        {
            DataHolder = dataHolder;

            var entry = dataHolder.Entry;

            if (!string.IsNullOrEmpty(AuraIdStr))
            {
                var auraIds = AuraIdStr.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).TransformArray(idStr =>
                {
                    uint id;
                    if (!uint.TryParse(idStr.Trim(), out id))
                    {
                        LogManager.GetCurrentClassLogger().Warn("Invalidly formatted Aura ({0}) in AuraString for SpawnEntry: {1}", idStr, this);
                    }
                    return((SpellId)id);
                });
                if (auraIds != null)
                {
                    Auras = new List <Spell>(auraIds.Length);
                    foreach (var auraId in auraIds)
                    {
                        var spell = SpellHandler.Get(auraId);
                        if (spell != null)
                        {
                            if (!spell.IsAura || (spell.Durations.Min > 0 && spell.Durations.Min < int.MaxValue))
                            {
                                // not permanent -> cast as Spell
                                if (entry.Spells == null || !entry.Spells.ContainsKey(spell.SpellId))
                                {
                                    entry.AddSpell(spell);
                                }
                            }
                            else
                            {
                                Auras.Add(spell);
                            }
                        }
                    }
                }
            }
            if (Auras == null)
            {
                Auras = new List <Spell>(2);
            }
        }
Exemple #3
0
		internal void InitAddonData(INPCDataHolder dataHolder)
		{
			DataHolder = dataHolder;

			var entry = dataHolder.Entry;
			if (!string.IsNullOrEmpty(AuraIdStr))
			{
				var auraIds = AuraIdStr.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).TransformArray(idStr =>
				{
					uint id;
					if (!uint.TryParse(idStr.Trim(), out id))
					{
						LogManager.GetCurrentClassLogger().Warn("Invalidly formatted Aura ({0}) in AuraString for SpawnEntry: {1}", idStr, this);
					}
					return (SpellId)id;
				});
				if (auraIds != null)
				{
					Auras = new List<Spell>(auraIds.Length);
					foreach (var auraId in auraIds)
					{
						var spell = SpellHandler.Get(auraId);
						if (spell != null)
						{
							if (!spell.IsAura || (spell.Durations.Min > 0 && spell.Durations.Min < int.MaxValue))
							{
								// not permanent -> cast as Spell
								if (entry.Spells == null || !entry.Spells.ContainsKey(spell.SpellId))
								{
									entry.AddSpell(spell);
								}
							}
							else
							{
								Auras.Add(spell);
							}
						}
					}
				}
			}
			if (Auras == null)
			{
				Auras = new List<Spell>(2);
			}
		}