Esempio n. 1
0
        public virtual void AddItem( Item item )
        {
            if ( item == null || item.Deleted || item.m_Parent == this )
            {
                return;
            }
            else if ( item == this )
            {
                log.FatalFormat("Adding item to itself: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )",
                                this.Serial.Value, this.GetType().Name,
                                item.Serial.Value, item.GetType().Name);
                return;
            }
            else if ( IsChildOf( item ) )
            {
                log.FatalFormat("Adding parent item to child: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )",
                                this.Serial.Value, this.GetType().Name,
                                item.Serial.Value, item.GetType().Name);
                return;
            }
            else if ( item.m_Parent is Mobile )
            {
                ((Mobile)item.m_Parent).RemoveItem( item );
            }
            else if ( item.m_Parent is Item )
            {
                ((Item)item.m_Parent).RemoveItem( item );
            }
            else
            {
                item.SendRemovePacket();
            }

            item.Parent = this;
            item.Map = m_Map;

            if ( m_Items == null )
                m_Items = new ArrayList( 4 );

            int oldCount = m_Items.Count;
            m_Items.Add( item );

            TotalItems = (TotalItems - oldCount) + m_Items.Count + item.TotalItems - (item.IsVirtualItem ? 1 : 0);
            TotalWeight += item.TotalWeight + item.PileWeight;
            TotalGold += item.TotalGold;

            item.Delta( ItemDelta.Update );

            item.OnAdded( this );
            OnItemAdded( item );
        }
Esempio n. 2
0
        public virtual void RemoveItem( Item item )
        {
            if ( m_Items != null && m_Items.Contains( item ) )
            {
                item.SendRemovePacket();

                int oldCount = m_Items.Count;

                m_Items.Remove( item );

                TotalItems = (TotalItems - oldCount) + m_Items.Count - item.TotalItems + (item.IsVirtualItem ? 1 : 0);
                TotalWeight -= item.TotalWeight + item.PileWeight;
                TotalGold -= item.TotalGold;

                item.Parent = null;

                item.OnRemoved( this );
                OnItemRemoved( item );
            }
        }
Esempio n. 3
0
        public void AddItem( Item item )
        {
            if ( item == null || item.Deleted )
                return;

            if ( item.Parent == this )
                return;
            else if ( item.Parent is Mobile )
                ((Mobile)item.Parent).RemoveItem( item );
            else if ( item.Parent is Item )
                ((Item)item.Parent).RemoveItem( item );
            else
                item.SendRemovePacket();

            item.Parent = this;
            item.Map = m_Map;

            m_Items.Add( item );

            if ( !(item is BankBox) )
            {
                TotalWeight += item.TotalWeight + item.PileWeight;
                TotalGold += item.TotalGold;
            }

            item.Delta( ItemDelta.Update );

            item.OnAdded( this );
            OnItemAdded( item );

            if ( item.PhysicalResistance != 0 || item.FireResistance != 0 || item.ColdResistance != 0 ||
                item.PoisonResistance != 0 || item.EnergyResistance != 0 )
                UpdateResistances();
        }
Esempio n. 4
0
        public void RemoveItem( Item item )
        {
            if ( item == null || m_Items == null )
                return;

            if ( m_Items.Contains( item ) )
            {
                item.SendRemovePacket();

                m_Items.Remove( item );

                if ( !(item is BankBox) )
                {
                    TotalWeight -= item.TotalWeight + item.PileWeight;
                    TotalGold -= item.TotalGold;
                }

                item.Parent = null;

                item.OnRemoved( this );
                OnItemRemoved( item );

                if ( item.PhysicalResistance != 0 || item.FireResistance != 0 || item.ColdResistance != 0 ||
                    item.PoisonResistance != 0 || item.EnergyResistance != 0 )
                    UpdateResistances();
            }
        }
Esempio n. 5
0
        public void RemoveItem( Item item )
        {
            if ( item == null || m_EquippedItems == null )
                return;

            if ( m_EquippedItems.Contains( item ) )
            {
                item.SendRemovePacket();

                m_EquippedItems.Remove( item );

                if ( !( item is BankBox ) )
                {
                    TotalWeight -= item.TotalWeight + item.PileWeight;

                    if ( !( item is Container && ( (Container) item ).UseLockedRestriction && ( (Container) item ).IsLockedContainer ) )
                    {
                        if ( ( TotalGold - item.TotalGold ) > 0 )
                            TotalGold -= item.TotalGold;
                        else
                            TotalGold = 0;
                    }
                }

                item.Parent = null;

                item.OnRemoved( this );
                OnItemRemoved( item );

                if ( item.PhysicalResistance != 0 || item.FireResistance != 0 || item.ColdResistance != 0 ||
                    item.PoisonResistance != 0 || item.EnergyResistance != 0 )
                    UpdateResistances();
            }
        }
Esempio n. 6
0
        public virtual void RemoveItem( Item item )
        {
            if ( m_Items != null && m_Items.Contains( item ) )
            {
                item.SendRemovePacket();

                int oldCount = m_Items.Count;

                m_Items.Remove( item );

                TotalItems = ( TotalItems - oldCount ) + m_Items.Count - item.TotalItems + ( item.IsVirtualItem ? 1 : 0 );
                TotalWeight -= item.TotalWeight + item.PileWeight;

                if ( !( item is Container && ( (Container) item ).UseLockedRestriction && ( (Container) item ).IsLockedContainer ) )
                {
                    if ( ( TotalGold - item.TotalGold ) > 0 )
                        TotalGold -= item.TotalGold;
                    else
                        TotalGold = 0;
                }

                item.Parent = null;

                item.OnRemoved( this );
                OnItemRemoved( item );
            }
        }
Esempio n. 7
0
        public virtual void AddItem( Item item )
        {
            if ( item == null || item.Deleted || item.m_Parent == this )
            {
                return;
            }
            else if ( item == this )
            {
                Console.WriteLine( "Warning: Adding item to itself: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )", this.Serial.Value, this.GetType().Name, item.Serial.Value, item.GetType().Name );
                Console.WriteLine( new System.Diagnostics.StackTrace() );
                return;
            }
            else if ( IsChildOf( item ) )
            {
                Console.WriteLine( "Warning: Adding parent item to child: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )", this.Serial.Value, this.GetType().Name, item.Serial.Value, item.GetType().Name );
                Console.WriteLine( new System.Diagnostics.StackTrace() );
                return;
            }
            else if ( item.m_Parent is Mobile )
            {
                ( (Mobile) item.m_Parent ).RemoveItem( item );
            }
            else if ( item.m_Parent is Item )
            {
                ( (Item) item.m_Parent ).RemoveItem( item );
            }
            else
            {
                item.SendRemovePacket();
            }

            item.Parent = this;
            item.Map = m_Map;

            if ( m_Items == null )
                m_Items = new List<Item>( 4 );

            int oldCount = m_Items.Count;
            m_Items.Add( item );

            TotalItems = ( TotalItems - oldCount ) + m_Items.Count + item.TotalItems - ( item.IsVirtualItem ? 1 : 0 );
            TotalWeight += item.TotalWeight + item.PileWeight;

            if ( !( item is Container && ( (Container) item ).UseLockedRestriction && ( (Container) item ).IsLockedContainer ) )
                TotalGold += item.TotalGold;

            item.Delta( ItemDelta.Update );

            item.OnAdded( this );
            OnItemAdded( item );
        }
Esempio n. 8
0
		public virtual void RemoveItem(Item item) // needs FreezeDried modifications
		{
			CheckRehydrate();

			if (m_Items != null && m_Items.Contains(item))
			{
				item.SendRemovePacket();

				int oldCount = m_Items.Count;

				m_Items.Remove(item);

				TotalItems = (TotalItems - oldCount) + m_Items.Count - item.TotalItems + (item.IsVirtualItem ? 1 : 0);
				TotalWeight -= item.TotalWeight + item.PileWeight;
				TotalGold -= item.TotalGold;

				item.Parent = null;

				item.OnRemoved(this);
				OnItemRemoved(item);
			}
		}
Esempio n. 9
0
		public virtual void AddItem(Item item) // FreezeDried needs modifications
		{
			if (item == null || item.Deleted || item.m_Parent == this)
			{
				return;
			}
			if (item == this)
			{
				Console.WriteLine("Warning: Adding item to itself: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )", this.Serial.Value, this.GetType().Name, item.Serial.Value, item.GetType().Name);
				Console.WriteLine(new System.Diagnostics.StackTrace());
				return;
			}
			if (IsChildOf(item))
			{
				Console.WriteLine("Warning: Adding parent item to child: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )", this.Serial.Value, this.GetType().Name, item.Serial.Value, item.GetType().Name);
				Console.WriteLine(new System.Diagnostics.StackTrace());
				return;
			}

			CheckRehydrate();

			if (item.m_Parent is Mobile)
			{
				((Mobile)item.m_Parent).RemoveItem(item);
			}
			else if (item.m_Parent is Item)
			{
				((Item)item.m_Parent).RemoveItem(item);
			}
			else
			{
				item.SendRemovePacket();
			}

			item.Parent = this;
			item.Map = m_Map;

			if (m_Items == null)
				m_Items = new ArrayList(4);

			int oldCount = m_Items.Count;
			m_Items.Add(item);

			TotalItems = (TotalItems - oldCount) + m_Items.Count + item.TotalItems - (item.IsVirtualItem ? 1 : 0);
			TotalWeight += item.TotalWeight + item.PileWeight;
			TotalGold += item.TotalGold;

			item.Delta(ItemDelta.Update);

			item.OnAdded(this);
			OnItemAdded(item);
		}