public virtual Item Dupe( Item item, int amount ) { item.Visible = Visible; item.Movable = Movable; item.LootType = LootType; item.Direction = Direction; item.Hue = Hue; item.ItemID = ItemID; item.Location = Location; item.Layer = Layer; item.Name = Name; item.Weight = Weight; item.Amount = amount; item.Map = Map; if ( Parent is Mobile ) { ((Mobile)Parent).AddItem( item ); } else if ( Parent is Item ) { ((Item)Parent).AddItem( item ); } item.Delta( ItemDelta.Update ); return item; }
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 ); }
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 ); }
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(); }
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); }