public static void Parse(Packet p) { uint BuffedUID = p.ReadUInt32(); uint BuffRefID = p.ReadUInt32(); uint SkillUID = p.ReadUInt32(); if (SkillUID != 0) { if (Client.Info.UniqueID == BuffedUID) { if (Client.State.Buffs.ContainsKey(SkillUID)) { Client.State.Buffs.Remove(SkillUID); } Client.State.Buffs.Add(SkillUID, new Information.Spells.Skill(BuffRefID, 0)); } else if (Client.NearbyCharacters.ContainsKey(BuffedUID)) { if (Client.NearbyCharacters[BuffedUID].State.Buffs.ContainsKey(SkillUID)) { Client.NearbyCharacters[BuffedUID].State.Buffs.Remove(SkillUID); } Client.NearbyCharacters[BuffedUID].State.Buffs.Add(SkillUID, new Information.Spells.Skill(BuffRefID, 0)); } OnBuffAdded?.Invoke(new BuffStartedEventArgs() { BuffedCharacterUniqueID = BuffedUID, BuffObjectRefID = BuffRefID, SkillUniqueID = SkillUID }); } }
/// <summary> /// Fired, when new buff added or old deleted. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ActiveBuffs_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (ActiveBuff newBuff in e.NewItems) { newBuff.OnReset += Buff_OnReset; } // Case, when we are starting up and all skills are added with AddRange call. if (e.NewItems.Count != 1) { return; } if (Client != null) // check for tests. { SendAddBuff((ActiveBuff)e.NewItems[0]); } OnBuffAdded?.Invoke(this, (ActiveBuff)e.NewItems[0]); } if (e.Action == NotifyCollectionChangedAction.Remove) { if (Client != null) { SendRemoveBuff((ActiveBuff)e.OldItems[0]); } OnBuffRemoved?.Invoke(this, (ActiveBuff)e.OldItems[0]); } }