Ejemplo n.º 1
0
        /// <summary>Removes this Aura from the player</summary>
        public void Remove(bool cancelled = true)
        {
            if (!IsAdded)
            {
                return;
            }
            IsAdded = false;
            Unit owner = m_auras.Owner;

            if (owner == null)
            {
                LogManager.GetCurrentClassLogger()
                .Warn("Tried to remove Aura {0} but it's owner does not exist anymore.");
            }
            else
            {
                if (m_controller != null)
                {
                    m_controller.OnRemove(owner, this);
                }
                AuraCollection auras = m_auras;
                if (CasterUnit != null)
                {
                    m_spell.NotifyAuraRemoved(this);
                }
                auras.Remove(this);
                Deactivate(cancelled);
                OnRemove();
                if (!m_spell.IsAreaAura || !(owner.EntityId == CasterReference.EntityId))
                {
                    return;
                }
                owner.CancelAreaAura(m_spell);
            }
        }
Ejemplo n.º 2
0
 internal Aura(AuraCollection auras, ObjectReference caster, AuraRecord record, List <AuraEffectHandler> handlers,
               byte index)
 {
     m_record          = record;
     m_auras           = auras;
     m_spell           = record.Spell;
     m_beneficial      = record.IsBeneficial;
     Id                = m_spell.GetAuraUID(m_beneficial);
     m_handlers        = handlers;
     m_CasterReference = caster;
     m_index           = index;
     m_auraLevel       = (byte)record.Level;
     m_stackCount      = record.StackCount;
     SetupValues();
     m_duration = record.MillisLeft;
     SetupTimer();
 }
Ejemplo n.º 3
0
 /// <summary>Creates a new Aura</summary>
 /// <param name="auras"></param>
 /// <param name="casterReference">Information about who casted</param>
 /// <param name="spell">The spell that this Aura represents</param>
 /// <param name="handlers">All handlers must have the same AuraUID</param>
 internal Aura(AuraCollection auras, ObjectReference casterReference, Spell spell,
               List <AuraEffectHandler> handlers, byte index, bool beneficial)
 {
     m_auras           = auras;
     m_spell           = spell;
     m_beneficial      = beneficial;
     Id                = spell.GetAuraUID(beneficial);
     m_handlers        = handlers;
     m_CasterReference = casterReference;
     m_index           = index;
     m_auraLevel       = (byte)casterReference.Level;
     m_stackCount      = (byte)m_spell.InitialStackCount;
     if (m_stackCount > 0 && casterReference.UnitMaster != null)
     {
         m_stackCount =
             casterReference.UnitMaster.Auras.GetModifiedInt(SpellModifierType.Charges, m_spell,
                                                             m_stackCount);
     }
     SetupValues();
 }
Ejemplo n.º 4
0
		protected EditorFigurine(MapEditor editor, NPCSpawnPoint spawnPoint)
		{
			if (_sharedAuras == null)
			{
				_sharedAuras = new AuraCollection(this);
			}

			m_auras = _sharedAuras;
			Editor = editor;
			m_SpawnPoint = spawnPoint;

			var entry = m_SpawnPoint.SpawnEntry.Entry;
			GenerateId(entry.Id);

			UnitFlags = UnitFlags.SelectableNotAttackable | UnitFlags.Possessed;
			DynamicFlags = UnitDynamicFlags.TrackUnit;
			EmoteState = EmoteType.StateDead;
			NPCFlags |= NPCFlags.Gossip;
			Model = entry.GetRandomModel();
			EntryId = entry.Id;

			// speed must be > 0
			// because of the way the client works
			const float speed = 1f;
			m_runSpeed = speed;
			m_swimSpeed = speed;
			m_swimBackSpeed = speed;
			m_walkSpeed = speed;
			m_walkBackSpeed = speed;
			m_flightSpeed = speed;
			m_flightBackSpeed = speed;

			SetInt32(UnitFields.MAXHEALTH, int.MaxValue);
			SetInt32(UnitFields.BASE_HEALTH, int.MaxValue);
			SetInt32(UnitFields.HEALTH, int.MaxValue);

			// just make a smaller version of the creature to be spawned
			SetFloat(ObjectFields.SCALE_X, entry.Scale * DefaultScale);

			m_evades = true;
		}
Ejemplo n.º 5
0
		public override void Dispose(bool disposing)
		{
			if (m_auras == null)
			{
				// already disposed
				return;
			}

			if (m_Movement != null)
			{
				m_Movement.m_owner = null;
				m_Movement = null;
			}

			base.Dispose(disposing);

			m_attackTimer = null;

			if (m_target != null)
			{
				OnTargetNull();
				m_target = null;
			}

			if (m_regenTimer != null)
			{
				m_regenTimer.Dispose();
			}

			if (m_brain != null)
			{
				m_brain.Dispose();
				m_brain = null;
			}

			if (m_spells != null)
			{
				m_spells.Owner = null;
				m_spells = null;
			}

			m_auras.Owner = null;
			m_auras = null;

			if (m_areaAura != null)
			{
				m_areaAura.Holder = null;
				m_areaAura = null;
			}

			m_charm = null;
			m_channeled = null;
		}
Ejemplo n.º 6
0
		public override void Dispose(bool disposing)
		{
			if (m_auras == null)
			{
				// already disposed
				return;
			}

			if (m_Movement != null)
			{
				m_Movement.m_owner = null;
				m_Movement = null;
			}

			base.Dispose(disposing);

			m_attackTimer = null;
			m_target = null;

			if (m_brain != null)
			{
				m_brain.Dispose();
				m_brain = null;
			}
			
			m_spells.Recycle();
			m_spells = null;

			m_auras.Owner = null;
			m_auras = null;

			m_charm = null;
			m_channeled = null;
		}
Ejemplo n.º 7
0
		protected Unit()
		{
			Type |= ObjectTypes.Unit;

			// auras
			m_auras = new AuraCollection(this);

			// combat
			m_isInCombat = false;
			m_attackTimer = new TimerEntry(0.0f, 0.0f, CombatTick);

			CastSpeedFactor = 1f;

			ResetMechanicDefaults();

			m_flying = m_waterWalk = m_hovering = m_featherFalling = 0;
			m_canMove = m_canInteract = m_canHarm = m_canCastSpells = true;
		}