Exemple #1
0
        /// <summary>
        /// Adds a new effect to the list
        /// </summary>
        /// <param name="effect">The effect to add</param>
        public void Add(IConcentrationEffect effect)
        {
            BeginChanges();

            if (m_concSpells == null)
            {
                m_concSpells = new ArrayList(20);
            }

            lock (m_concSpells)             // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this)
            {
                if (m_concSpells.Contains(effect))
                {
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("(" + m_owner.Name + ") effect already applied " + effect.Name);
                    }
                }
                else
                {
                    // no conc spells are always last in the list
                    if (m_concSpells.Count > 0)
                    {
                        IConcentrationEffect lastEffect = (IConcentrationEffect)m_concSpells[m_concSpells.Count - 1];
                        if (lastEffect.Concentration > 0)
                        {
                            m_concSpells.Add(effect);
                        }
                        else
                        {
                            m_concSpells.Insert(m_concSpells.Count - 1, effect);
                        }
                    }
                    else
                    {
                        m_concSpells.Add(effect);
                    }

                    if (effect.Concentration > 0)
                    {
                        m_usedConcPoints += effect.Concentration;
                        m_concSpellsCount++;
                    }
                }
            }
            CommitChanges();
        }
            /// <summary>
            /// Called on every timer tick
            /// </summary>
            protected override void OnTick()
            {
                var player = (GamePlayer)m_actionSource;

                IConcentrationEffect effect = null;

                lock (player.ConcentrationEffects)
                {
                    if (m_index < player.ConcentrationEffects.Count)
                    {
                        effect = player.ConcentrationEffects[m_index];
                        player.ConcentrationEffects.Remove(effect);
                    }
                }

                effect?.Cancel(true);
            }
        public override void SendConcentrationList()
        {
            if (m_gameClient.Player == null)
            {
                return;
            }

            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.ConcentrationList)))
            {
                lock (m_gameClient.Player.ConcentrationEffects)
                {
                    pak.WriteByte((byte)(m_gameClient.Player.ConcentrationEffects.Count));
                    pak.WriteByte(0);                     // unknown
                    pak.WriteByte(0);                     // unknown
                    pak.WriteByte(0);                     // unknown

                    for (int i = 0; i < m_gameClient.Player.ConcentrationEffects.Count; i++)
                    {
                        IConcentrationEffect effect = m_gameClient.Player.ConcentrationEffects[i];
                        pak.WriteByte((byte)i);
                        pak.WriteByte(0);                         // unknown
                        pak.WriteByte(effect.Concentration);
                        pak.WriteShort(effect.Icon);
                        if (effect.Name.Length > 14)
                        {
                            pak.WritePascalString(effect.Name.Substring(0, 12) + "..");
                        }
                        else
                        {
                            pak.WritePascalString(effect.Name);
                        }
                        if (effect.OwnerName.Length > 14)
                        {
                            pak.WritePascalString(effect.OwnerName.Substring(0, 12) + "..");
                        }
                        else
                        {
                            pak.WritePascalString(effect.OwnerName);
                        }
                    }
                }
                SendTCP(pak);
            }

            SendStatusUpdate();             // send status update for convinience, mostly the conc has changed
        }
		/// <summary>
		/// Adds a new effect to the list
		/// </summary>
		/// <param name="effect">The effect to add</param>
		public void Add(IConcentrationEffect effect)
		{
			BeginChanges();

			if (m_concSpells == null)
				m_concSpells = new ArrayList(20);

			lock (m_concSpells) // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this)
			{
				if (m_concSpells.Contains(effect))
				{
					if (log.IsWarnEnabled)
						log.Warn("(" + m_owner.Name + ") effect already applied " + effect.Name);
				}
				else
				{
					// no conc spells are always last in the list
					if (m_concSpells.Count > 0)
					{
						IConcentrationEffect lastEffect = (IConcentrationEffect)m_concSpells[m_concSpells.Count - 1];
						if (lastEffect.Concentration > 0)
						{
							m_concSpells.Add(effect);
						}
						else
						{
							m_concSpells.Insert(m_concSpells.Count - 1, effect);
						}
					}
					else
					{
						m_concSpells.Add(effect);
					}

					if (effect.Concentration > 0)
					{
						m_usedConcPoints += effect.Concentration;
						m_concSpellsCount++;
					}
				}
			}
			CommitChanges();
		}
Exemple #5
0
        /// <summary>
        /// Removes an effect from the list
        /// </summary>
        /// <param name="effect">The effect to remove</param>
        public void Remove(IConcentrationEffect effect)
        {
            if (m_concSpells == null)
            {
                return;
            }

            lock (m_concSpells)             // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this)
            {
                if (m_concSpells.Contains(effect))
                {
                    BeginChanges();
                    m_concSpells.Remove(effect);
                    if (effect.Concentration > 0)
                    {
                        m_usedConcPoints -= effect.Concentration;
                        m_concSpellsCount--;
                    }
                    CommitChanges();
                }
            }
        }
		/// <summary>
		/// Removes an effect from the list
		/// </summary>
		/// <param name="effect">The effect to remove</param>
		public void Remove(IConcentrationEffect effect)
		{
			if (m_concSpells == null)
				return;

			lock (m_concSpells) // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this)
			{
				if (m_concSpells.Contains(effect))
				{
					BeginChanges();
					m_concSpells.Remove(effect);
					if (effect.Concentration > 0)
					{
						m_usedConcPoints -= effect.Concentration;
						m_concSpellsCount--;
					}
					CommitChanges();
				}
			}
		}