public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); Component = reader.ReadItem() as BeaconItem; if (Component != null) { Component.Beacon = this; } int count = reader.ReadInt(); for (int i = 0; i < count; i++) { Item item = reader.ReadItem(); if (item != null) { if (Rubble == null) { Rubble = new List <Item>(); } Rubble.Add(item); } } }
private void AddRubble(Item i, Point3D p) { i.MoveToWorld(p, this.Map); if (Rubble == null) { Rubble = new List <Item>(); } Rubble.Add(i); }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write(0); writer.Write(Component); writer.Write(Rubble == null ? 0 : Rubble.Count); if (Rubble != null) { Rubble.ForEach(i => writer.Write(i)); } }
public override void Delete() { base.Delete(); if (Rubble != null) { List <Item> rubble = new List <Item>(Rubble); rubble.ForEach(i => i.Delete()); rubble.ForEach(i => Rubble.Remove(i)); rubble.Clear(); rubble.TrimExcess(); } }
public bool Destroy() { if (this == null || this.Deleted) { return(false); } if (OnBeforeDestroyed()) { if (m_Child != null && !m_Child.Deleted && !m_Child.Alive) { Rubble rubble = new Rubble(m_DestroyedID, this.Name); if (rubble != null && !rubble.Deleted && this.Map != null && this.Map != Map.Internal) { rubble.MoveToWorld(this.Location, this.Map); } OnDestroyed(); if (m_Child != null) { m_Child.Delete(); } Delete(); return(true); } else { Rubble rubble = new Rubble(m_DestroyedID, this.Name); //Static rubble = new Static(m_DestroyedID); if (rubble != null && !rubble.Deleted && this.Map != null && this.Map != Map.Internal) { rubble.MoveToWorld(this.Location, this.Map); } OnDestroyed(); Delete(); return(true); } } return(false); }
public override bool OnBeforeDestroyed() { List <Item> delete = new List <Item>(); if (Rubble != null) { foreach (Item i in Rubble.Where(item => item.Z > this.Z)) { i.Delete(); delete.Add(i); } delete.ForEach(i => Rubble.Remove(i)); } DoEffects(); if (Component != null) { Component.ItemID = 1; Component.Visible = false; } Visible = false; delete.Clear(); delete.TrimExcess(); AddRubble(new Static(634), new Point3D(this.X - 2, this.Y, this.Z)); AddRubble(new Static(633), new Point3D(this.X - 2, this.Y + 1, this.Z)); AddRubble(new Static(635), new Point3D(this.X + 2, this.Y - 2, this.Z)); AddRubble(new Static(632), new Point3D(this.X + 3, this.Y - 2, this.Z)); AddRubble(new Static(634), new Point3D(this.X + 2, this.Y, this.X)); AddRubble(new Static(633), new Point3D(this.X + 2, this.Y + 1, this.Z)); return(true); }
public bool Destroy( ) { if( this == null || this.Deleted ) return false; if( OnBeforeDestroyed( ) ) { if( m_Child != null && !m_Child.Deleted && !m_Child.Alive ) { Rubble rubble = new Rubble( m_DestroyedID, this.Name ); if( rubble != null && !rubble.Deleted && this.Map != null && this.Map != Map.Internal ) { rubble.MoveToWorld( this.Location, this.Map ); } WoodenBox lootbox = new WoodenBox( ); lootbox.Name = this.Name + " Loot Box"; OnDestroyed( lootbox ); if( lootbox != null && !lootbox.Deleted ) { if( DropsLoot ) lootbox.MoveToWorld( new Point3D( this.X, this.Y, this.Z ), this.Map ); else lootbox.Delete( ); } if( m_Child != null ) m_Child.Delete( ); Delete( ); return true; } else { Static rubble = new Static( m_DestroyedID ); if( rubble != null && !rubble.Deleted && this.Map != null && this.Map != Map.Internal ) rubble.MoveToWorld( this.Location, this.Map ); WoodenBox lootbox = new WoodenBox( ); lootbox.Name = this.Name + " Loot Box"; OnDestroyed( lootbox ); if( lootbox != null && !lootbox.Deleted ) { if( DropsLoot ) lootbox.MoveToWorld( new Point3D( this.X, this.Y, this.Z ), this.Map ); else lootbox.Delete( ); } Delete( ); return true; } } return false; }
public bool Destroy() { if (this == null || this.Deleted) return false; if (OnBeforeDestroyed()) { if (m_Child != null && !m_Child.Deleted && !m_Child.Alive) { Rubble rubble = new Rubble(m_DestroyedID, this.Name); if (rubble != null && !rubble.Deleted && this.Map != null && this.Map != Map.Internal) { rubble.MoveToWorld(this.Location, this.Map); } OnDestroyed(); if (m_Child != null) m_Child.Delete(); Delete(); return true; } else { Rubble rubble = new Rubble(m_DestroyedID, this.Name); //Static rubble = new Static(m_DestroyedID); if (rubble != null && !rubble.Deleted && this.Map != null && this.Map != Map.Internal) rubble.MoveToWorld(this.Location, this.Map); OnDestroyed(); Delete(); return true; } } return false; }
public bool Destroy( ) { if (this == null || this.Deleted) { return(false); } if (OnBeforeDestroyed( )) { if (m_Child != null && !m_Child.Deleted && !m_Child.Alive) { Rubble rubble = new Rubble(m_DestroyedID, this.Name); if (rubble != null && !rubble.Deleted && this.Map != null && this.Map != Map.Internal) { rubble.MoveToWorld(this.Location, this.Map); } WoodenBox lootbox = new WoodenBox( ); lootbox.Name = this.Name + " Loot Box"; OnDestroyed(lootbox); if (lootbox != null && !lootbox.Deleted) { if (DropsLoot) { lootbox.MoveToWorld(new Point3D(this.X, this.Y, this.Z), this.Map); } else { lootbox.Delete( ); } } if (m_Child != null) { m_Child.Delete( ); } Delete( ); return(true); } else { Static rubble = new Static(m_DestroyedID); if (rubble != null && !rubble.Deleted && this.Map != null && this.Map != Map.Internal) { rubble.MoveToWorld(this.Location, this.Map); } WoodenBox lootbox = new WoodenBox( ); lootbox.Name = this.Name + " Loot Box"; OnDestroyed(lootbox); if (lootbox != null && !lootbox.Deleted) { if (DropsLoot) { lootbox.MoveToWorld(new Point3D(this.X, this.Y, this.Z), this.Map); } else { lootbox.Delete( ); } } Delete( ); return(true); } } return(false); }