Exemplo n.º 1
0
 void OnRemove()
 {
     if (m_record != null)
     {
         m_record.DeleteLater();
         m_record = null;
     }
 }
Exemplo n.º 2
0
 private void OnRemove()
 {
     if (m_record == null)
     {
         return;
     }
     m_record.DeleteLater();
     m_record = null;
 }
Exemplo n.º 3
0
 private void OnRemove()
 {
     if (this.m_record == null)
     {
         return;
     }
     this.m_record.DeleteLater();
     this.m_record = (AuraRecord)null;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Need to guarantee that all Auras that have ever been created will also be removed
 /// </summary>
 internal void Cleanup()
 {
     IsActivated = false;
     if (m_record != null)
     {
         var record = m_record;
         m_record = null;
         record.Recycle();
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Need to guarantee that all Auras that have ever been created will also be removed
        /// </summary>
        internal void Cleanup()
        {
            IsActivated = false;
            if (m_record == null)
            {
                return;
            }
            AuraRecord record = m_record;

            m_record = null;
            record.Recycle();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Need to guarantee that all Auras that have ever been created will also be removed
        /// </summary>
        internal void Cleanup()
        {
            this.IsActivated = false;
            if (this.m_record == null)
            {
                return;
            }
            AuraRecord record = this.m_record;

            this.m_record = (AuraRecord)null;
            record.Recycle();
        }
Exemplo n.º 7
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();
 }
Exemplo n.º 8
0
 internal void SaveNow()
 {
     if (m_record == null)
     {
         var owner = m_auras.Owner;
         if (!(owner is Character))
         {
             // We currently only support Aura saving for Characters
             throw new InvalidOperationException(string.Format("Tried to save non-Player Aura {0} on: {1}", this, owner));
         }
         m_record = AuraRecord.ObtainAuraRecord(this);
     }
     else
     {
         m_record.SyncData(this);
     }
     m_record.Save();
 }
Exemplo n.º 9
0
        internal void SaveNow()
        {
            if (this.m_record == null)
            {
                Unit owner = this.m_auras.Owner;
                if (!(owner is Character))
                {
                    throw new InvalidOperationException(string.Format("Tried to save non-Player Aura {0} on: {1}",
                                                                      (object)this, (object)owner));
                }
                this.m_record = AuraRecord.ObtainAuraRecord(this);
            }
            else
            {
                this.m_record.SyncData(this);
            }

            this.m_record.Save();
        }
Exemplo n.º 10
0
		/// <summary>
		/// Called after Character entered world
		/// </summary>
		internal void PlayerInitialize(AuraRecord[] records)
		{
			foreach (var record in records)
			{
				var index = GetFreeIndex(record.IsBeneficial);

				if (index == InvalidIndex)			// no more free index fields
				{
					record.DeleteLater();
					continue;
				}

				var caster = record.GetCasterInfo(m_owner.Region);
				var handlers = AuraHandler.CreateEffectHandlers(record.Spell, caster, m_owner, record.IsBeneficial);

				if (handlers == null)				// couldn't create handlers
				{
					record.DeleteLater();
					continue;
				}

				var aura = new Aura(this, caster, record, handlers, index);
				AddAura(aura);
			}
		}
Exemplo n.º 11
0
        /// <summary>
        /// Loads this Character from DB when logging in.
        /// </summary>
        /// <remarks>Requires IO-Context.</remarks>
        internal protected void Load()
        {
            var nativeModel = m_archetype.Race.GetModel(m_record.Gender);

            NativeDisplayId = nativeModel.DisplayId;
            var model = nativeModel;

            if (m_record.DisplayId != model.DisplayId)
            {
                model = UnitMgr.GetModelInfo(m_record.DisplayId) ?? nativeModel;
            }
            Model = model;

            // set FreeTalentPoints silently
            UpdateFreeTalentPointsSilently(0);
            if (m_record.JustCreated)
            {
                // newly created Character
                SpecProfiles = new[] { SpecProfile.NewSpecProfile(this, 0) };

                if (m_zone != null)
                {
                    SetZoneExplored(m_zone.Template, true);
                }

                //m_record.FreeTalentPoints = 0;

                // Honor and Arena
                m_record.KillsTotal             = 0u;
                m_record.HonorToday             = 0u;
                m_record.HonorYesterday         = 0u;
                m_record.LifetimeHonorableKills = 0u;
                m_record.HonorPoints            = 0u;
                m_record.ArenaPoints            = 0u;
            }
            else
            {
                // existing Character
                try
                {
                    //Set Playerfields for glyphs on load
                    InitGlyphsForLevel();
                    // load & validate SpecProfiles
                    SpecProfiles = SpecProfile.LoadAllOfCharacter(this);
                    if (SpecProfiles.Length == 0)
                    {
                        log.Warn("Character had no SpecProfiles: {0}", this);
                        SpecProfiles = new[] { SpecProfile.NewSpecProfile(this, 0) };
                    }
                    if (m_record.CurrentSpecIndex >= SpecProfiles.Length)
                    {
                        log.Warn("Character had invalid CurrentSpecIndex: {0} ({1})", this, m_record.CurrentSpecIndex);
                        m_record.CurrentSpecIndex = 0;
                    }

                    // load all the rest
                    m_achievements.Load();
                    ((PlayerSpellCollection)m_spells).LoadSpellsAndTalents();
                    ((PlayerSpellCollection)m_spells).LoadCooldowns();
                    m_skills.Load();
                    m_mailAccount.Load();
                    m_reputations.Load();
                    var auras = AuraRecord.LoadAuraRecords(EntityId.Low);
                    AddPostUpdateMessage(() => m_auras.InitializeAuras(auras));

                    if (QuestMgr.Loaded)
                    {
                        LoadQuests();
                    }

                    if (m_record.FinishedQuests != null)
                    {
                        m_questLog.FinishedQuests.AddRange(m_record.FinishedQuests);
                    }
                }
                catch (Exception e)
                {
                    RealmDBMgr.OnDBError(e);
                    throw new Exception(string.Format("Failed to load Character \"{0}\" for Client: {1}", this, Client), e);
                }

                SetExploredZones();

                //Add existing talents to the character
                ((PlayerSpellCollection)m_spells).PlayerInitialize();

                // calculate amount of spent talent points per tree
                m_talents.CalcSpentTalentPoints();

                // update RestState
                if (m_record.RestTriggerId != 0 &&
                    (m_restTrigger = AreaTriggerMgr.GetTrigger((uint)m_record.RestTriggerId)) != null)
                {
                    RestState = RestState.Resting;
                }

                if (m_record.LastLogout != null)
                {
                    var now = DateTime.Now;
                    RestXp += RestGenerator.GetRestXp(now - m_record.LastLogout.Value, this);

                    m_lastRestUpdate = now;
                }
                else
                {
                    m_lastRestUpdate = DateTime.Now;
                }

                m_taxiNodeMask.Mask = m_record.TaxiMask;

                // Honor and Arena
                KillsTotal             = m_record.KillsTotal;
                HonorToday             = m_record.HonorToday;
                HonorYesterday         = m_record.HonorYesterday;
                LifetimeHonorableKills = m_record.LifetimeHonorableKills;
                HonorPoints            = m_record.HonorPoints;
                ArenaPoints            = m_record.ArenaPoints;
            }

            // Set FreeTalentPoints, after SpecProfile was loaded
            var freePointsForLevel = m_talents.GetFreeTalentPointsForLevel(m_record.Level);

            m_talents.UpdateFreeTalentPointsSilently(freePointsForLevel);

            // Load pets (if any)
            LoadPets();

            //foreach (var skill in m_skills)
            //{
            //    if (skill.SkillLine.Category == SkillCategory.ArmorProficiency) {
            //        CharacterHandler.SendProfiency(m_client, ItemClass.Armor, (uint)skill.SkillLine.Id);
            //    }
            //}

            // this prevents a the Char from re-sending a value update when being pushed to world AFTER creation
            ResetUpdateInfo();
        }