public void Serialize(GenericWriter writer) { writer.Write((int)1); // version; writer.Write(m_Min); writer.Write(m_Max); writer.Write(Center); writer.Write((int)Width); writer.Write((int)Height); writer.Write((int)List.Length); for (int i = 0; i < List.Length; ++i) { MultiTileEntry ent = List[i]; writer.Write((ushort)ent.m_ItemID); writer.Write((short)ent.m_OffsetX); writer.Write((short)ent.m_OffsetY); writer.Write((short)ent.m_OffsetZ); writer.Write((int)ent.m_Flags); } }
public void Serialize(GenericWriter writer) { writer.Write(1); // version; writer.Write(m_Min); writer.Write(m_Max); writer.Write(m_Center); writer.Write(m_Width); writer.Write(m_Height); writer.Write(m_List.Length); for (int i = 0; i < m_List.Length; ++i) { MultiTileEntry ent = m_List[i]; writer.Write(ent.m_ItemID); writer.Write(ent.m_OffsetX); writer.Write(ent.m_OffsetY); writer.Write(ent.m_OffsetZ); writer.Write(ent.m_Flags); } }
public void Resize(int newWidth, int newHeight) { int oldWidth = m_Width, oldHeight = m_Height; var oldTiles = m_Tiles; int totalLength = 0; var newTiles = new StaticTile[newWidth][][]; for (int x = 0; x < newWidth; ++x) { newTiles[x] = new StaticTile[newHeight][]; for (int y = 0; y < newHeight; ++y) { if (x < oldWidth && y < oldHeight) { newTiles[x][y] = oldTiles[x][y]; } else { newTiles[x][y] = new StaticTile[0]; } totalLength += newTiles[x][y].Length; } } m_Tiles = newTiles; m_List = new MultiTileEntry[totalLength]; m_Width = newWidth; m_Height = newHeight; m_Min = Point2D.Zero; m_Max = Point2D.Zero; int index = 0; for (int x = 0; x < newWidth; ++x) { for (int y = 0; y < newHeight; ++y) { var tiles = newTiles[x][y]; for (int i = 0; i < tiles.Length; ++i) { StaticTile tile = tiles[i]; int vx = x - m_Center.X; int vy = y - m_Center.Y; if (vx < m_Min.m_X) { m_Min.m_X = vx; } if (vy < m_Min.m_Y) { m_Min.m_Y = vy; } if (vx > m_Max.m_X) { m_Max.m_X = vx; } if (vy > m_Max.m_Y) { m_Max.m_Y = vy; } m_List[index++] = new MultiTileEntry((ushort)tile.ID, (short)vx, (short)vy, (short)tile.Z, 1); } } } }
public void Add(int itemID, int x, int y, int z) { #region Stygian Abyss itemID &= TileData.MaxItemValue; itemID |= 0x10000; #endregion int vx = x + m_Center.m_X; int vy = y + m_Center.m_Y; if (vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height) { var oldTiles = m_Tiles[vx][vy]; for (int i = oldTiles.Length - 1; i >= 0; --i) { ItemData data = TileData.ItemTable[itemID & TileData.MaxItemValue]; if (oldTiles[i].Z == z && (oldTiles[i].Height > 0 == data.Height > 0)) { bool newIsRoof = (data.Flags & TileFlag.Roof) != 0; bool oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0; if (newIsRoof == oldIsRoof) { Remove(oldTiles[i].ID, x, y, z); } } } oldTiles = m_Tiles[vx][vy]; var newTiles = new StaticTile[oldTiles.Length + 1]; for (int i = 0; i < oldTiles.Length; ++i) { newTiles[i] = oldTiles[i]; } newTiles[oldTiles.Length] = new StaticTile((ushort)itemID, (sbyte)z); m_Tiles[vx][vy] = newTiles; var oldList = m_List; var newList = new MultiTileEntry[oldList.Length + 1]; for (int i = 0; i < oldList.Length; ++i) { newList[i] = oldList[i]; } newList[oldList.Length] = new MultiTileEntry((ushort)itemID, (short)x, (short)y, (short)z, 1); m_List = newList; if (x < m_Min.m_X) { m_Min.m_X = x; } if (y < m_Min.m_Y) { m_Min.m_Y = y; } if (x > m_Max.m_X) { m_Max.m_X = x; } if (y > m_Max.m_Y) { m_Max.m_Y = y; } } }
public void RemoveXYZH(int x, int y, int z, int minHeight) { var vx = x + m_Center.m_X; var vy = y + m_Center.m_Y; if (vx >= 0 && vx < Width && vy >= 0 && vy < Height) { var oldTiles = Tiles[vx][vy]; for (var i = 0; i < oldTiles.Length; ++i) { var tile = oldTiles[i]; if (tile.Z == z && tile.Height >= minHeight) { var newTiles = new StaticTile[oldTiles.Length - 1]; for (var j = 0; j < i; ++j) { newTiles[j] = oldTiles[j]; } for (var j = i + 1; j < oldTiles.Length; ++j) { newTiles[j - 1] = oldTiles[j]; } Tiles[vx][vy] = newTiles; break; } } var oldList = m_List; for (var i = 0; i < oldList.Length; ++i) { var tile = oldList[i]; if (tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z && TileData.ItemTable[tile.m_ItemID & TileData.MaxItemValue].Height >= minHeight) { var newList = new MultiTileEntry[oldList.Length - 1]; for (var j = 0; j < i; ++j) { newList[j] = oldList[j]; } for (var j = i + 1; j < oldList.Length; ++j) { newList[j - 1] = oldList[j]; } m_List = newList; break; } } } }
public MultiComponentList(BinaryReader reader, int count) { MultiTileEntry[] allTiles = m_List = new MultiTileEntry[count]; for (int i = 0; i < count; ++i) { allTiles[i].m_ItemID = reader.ReadUInt16(); allTiles[i].m_OffsetX = reader.ReadInt16(); allTiles[i].m_OffsetY = reader.ReadInt16(); allTiles[i].m_OffsetZ = reader.ReadInt16(); if (PostHSFormat) { allTiles[i].m_Flags = (TileFlag)reader.ReadUInt64(); } else { allTiles[i].m_Flags = (TileFlag)reader.ReadUInt32(); } MultiTileEntry e = allTiles[i]; if (i == 0 || e.m_Flags != 0) { if (e.m_OffsetX < m_Min.m_X) { m_Min.m_X = e.m_OffsetX; } if (e.m_OffsetY < m_Min.m_Y) { m_Min.m_Y = e.m_OffsetY; } if (e.m_OffsetX > m_Max.m_X) { m_Max.m_X = e.m_OffsetX; } if (e.m_OffsetY > m_Max.m_Y) { m_Max.m_Y = e.m_OffsetY; } } } m_Center = new Point2D(-m_Min.m_X, -m_Min.m_Y); m_Width = m_Max.m_X - m_Min.m_X + 1; m_Height = m_Max.m_Y - m_Min.m_Y + 1; TileList[][] tiles = new TileList[m_Width][]; m_Tiles = new StaticTile[m_Width][][]; for (int x = 0; x < m_Width; ++x) { tiles[x] = new TileList[m_Height]; m_Tiles[x] = new StaticTile[m_Height][]; for (int y = 0; y < m_Height; ++y) { tiles[x][y] = new TileList(); } } for (int i = 0; i < allTiles.Length; ++i) { if (i == 0 || allTiles[i].m_Flags != 0) { int xOffset = allTiles[i].m_OffsetX + m_Center.m_X; int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y; int itemID = (allTiles[i].m_ItemID & TileData.MaxItemValue) | 0x10000; tiles[xOffset][yOffset].Add((ushort)itemID, (sbyte)allTiles[i].m_OffsetZ); } } for (int x = 0; x < m_Width; ++x) { for (int y = 0; y < m_Height; ++y) { m_Tiles[x][y] = tiles[x][y].ToArray(); } } }
public void Add(int itemID, int x, int y, int z) { var vx = x + Center.m_X; var vy = y + Center.m_Y; if (vx >= 0 && vx < Width && vy >= 0 && vy < Height) { var oldTiles = Tiles[vx][vy]; for (var i = oldTiles.Length - 1; i >= 0; --i) { var data = TileData.ItemTable[itemID & TileData.MaxItemValue]; if (oldTiles[i].Z == z && oldTiles[i].Height > 0 == data.Height > 0) { var newIsRoof = (data.Flags & TileFlag.Roof) != 0; var oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0; if (newIsRoof == oldIsRoof) { Remove(oldTiles[i].ID, x, y, z); } } } oldTiles = Tiles[vx][vy]; var newTiles = new StaticTile[oldTiles.Length + 1]; for (var i = 0; i < oldTiles.Length; ++i) { newTiles[i] = oldTiles[i]; } newTiles[oldTiles.Length] = new StaticTile((ushort)itemID, (sbyte)z); Tiles[vx][vy] = newTiles; var oldList = List; var newList = new MultiTileEntry[oldList.Length + 1]; for (var i = 0; i < oldList.Length; ++i) { newList[i] = oldList[i]; } newList[oldList.Length] = new MultiTileEntry( (ushort)itemID, (short)x, (short)y, (short)z, TileFlag.Background ); List = newList; if (x < m_Min.m_X) { m_Min.m_X = x; } if (y < m_Min.m_Y) { m_Min.m_Y = y; } if (x > m_Max.m_X) { m_Max.m_X = x; } if (y > m_Max.m_Y) { m_Max.m_Y = y; } } }
public MultiComponentList(BinaryReader reader, int count) { var allTiles = List = new MultiTileEntry[count]; for (var i = 0; i < count; ++i) { allTiles[i].ItemId = reader.ReadUInt16(); allTiles[i].OffsetX = reader.ReadInt16(); allTiles[i].OffsetY = reader.ReadInt16(); allTiles[i].OffsetZ = reader.ReadInt16(); if (PostHSFormat) { allTiles[i].Flags = (TileFlag)reader.ReadUInt64(); } else { allTiles[i].Flags = (TileFlag)reader.ReadUInt32(); } var e = allTiles[i]; if (i == 0 || e.Flags != 0) { if (e.OffsetX < m_Min.m_X) { m_Min.m_X = e.OffsetX; } if (e.OffsetY < m_Min.m_Y) { m_Min.m_Y = e.OffsetY; } if (e.OffsetX > m_Max.m_X) { m_Max.m_X = e.OffsetX; } if (e.OffsetY > m_Max.m_Y) { m_Max.m_Y = e.OffsetY; } } } Center = new Point2D(-m_Min.m_X, -m_Min.m_Y); Width = m_Max.m_X - m_Min.m_X + 1; Height = m_Max.m_Y - m_Min.m_Y + 1; var tiles = new TileList[Width][]; Tiles = new StaticTile[Width][][]; for (var x = 0; x < Width; ++x) { tiles[x] = new TileList[Height]; Tiles[x] = new StaticTile[Height][]; for (var y = 0; y < Height; ++y) { tiles[x][y] = new TileList(); } } for (var i = 0; i < allTiles.Length; ++i) { if (i == 0 || allTiles[i].Flags != 0) { var xOffset = allTiles[i].OffsetX + Center.m_X; var yOffset = allTiles[i].OffsetY + Center.m_Y; tiles[xOffset][yOffset].Add(allTiles[i].ItemId, (sbyte)allTiles[i].OffsetZ); } } for (var x = 0; x < Width; ++x) { for (var y = 0; y < Height; ++y) { Tiles[x][y] = tiles[x][y].ToArray(); } } }
public MultiComponentList(BinaryReader reader, int count) { int num1; MultiTileEntry entry1; int num2; int num3; int num4; int num5; int num6; int num7; int num8; MultiTileEntry[] entryArray2; this.m_List = (entryArray2 = new MultiTileEntry[count]); MultiTileEntry[] entryArray1 = entryArray2; for (num1 = 0; (num1 < count); ++num1) { entryArray1[num1].m_ItemID = reader.ReadInt16(); entryArray1[num1].m_OffsetX = reader.ReadInt16(); entryArray1[num1].m_OffsetY = reader.ReadInt16(); entryArray1[num1].m_OffsetZ = reader.ReadInt16(); entryArray1[num1].m_Flags = reader.ReadInt32(); entry1 = entryArray1[num1]; if ((num1 == 0) || (entry1.m_Flags != 0)) { if (entry1.m_OffsetX < this.m_Min.m_X) { this.m_Min.m_X = entry1.m_OffsetX; } if (entry1.m_OffsetY < this.m_Min.m_Y) { this.m_Min.m_Y = entry1.m_OffsetY; } if (entry1.m_OffsetX > this.m_Max.m_X) { this.m_Max.m_X = entry1.m_OffsetX; } if (entry1.m_OffsetY > this.m_Max.m_Y) { this.m_Max.m_Y = entry1.m_OffsetY; } } } this.m_Center = new Point2D(-this.m_Min.m_X, -this.m_Min.m_Y); this.m_Width = ((this.m_Max.m_X - this.m_Min.m_X) + 1); this.m_Height = ((this.m_Max.m_Y - this.m_Min.m_Y) + 1); TileList[][] listArrayArray1 = new TileList[this.m_Width][]; this.m_Tiles = new Tile[this.m_Width][][]; for (num2 = 0; (num2 < this.m_Width); ++num2) { listArrayArray1[num2] = new TileList[this.m_Height]; this.m_Tiles[num2] = new Tile[this.m_Height][]; for (num3 = 0; (num3 < this.m_Height); ++num3) { listArrayArray1[num2][num3] = new TileList(); } } for (num4 = 0; (num4 < entryArray1.Length); ++num4) { if ((num4 == 0) || (entryArray1[num4].m_Flags != 0)) { num5 = (entryArray1[num4].m_OffsetX + this.m_Center.m_X); num6 = (entryArray1[num4].m_OffsetY + this.m_Center.m_Y); listArrayArray1[num5][num6].Add(((short)((entryArray1[num4].m_ItemID & 16383) | 16384)), ((sbyte)entryArray1[num4].m_OffsetZ)); } } for (num7 = 0; (num7 < this.m_Width); ++num7) { for (num8 = 0; (num8 < this.m_Height); ++num8) { this.m_Tiles[num7][num8] = listArrayArray1[num7][num8].ToArray(); } } }
public MultiComponentList(BinaryReader reader, int count) { MultiTileEntry[] allTiles = List = new MultiTileEntry[count]; for (int i = 0; i < count; ++i) { allTiles[i].m_ItemID = reader.ReadUInt16(); allTiles[i].m_OffsetX = reader.ReadInt16(); allTiles[i].m_OffsetY = reader.ReadInt16(); allTiles[i].m_OffsetZ = reader.ReadInt16(); allTiles[i].m_Flags = reader.ReadInt32(); if (PostHSFormat) { reader.ReadInt32(); // ?? } MultiTileEntry e = allTiles[i]; if (i == 0 || e.m_Flags != 0) { if (e.m_OffsetX < m_Min.m_X) { m_Min.m_X = e.m_OffsetX; } if (e.m_OffsetY < m_Min.m_Y) { m_Min.m_Y = e.m_OffsetY; } if (e.m_OffsetX > m_Max.m_X) { m_Max.m_X = e.m_OffsetX; } if (e.m_OffsetY > m_Max.m_Y) { m_Max.m_Y = e.m_OffsetY; } } } m_Center = new Point2D(-m_Min.m_X, -m_Min.m_Y); Width = (m_Max.m_X - m_Min.m_X) + 1; Height = (m_Max.m_Y - m_Min.m_Y) + 1; TileList[][] tiles = new TileList[Width][]; Tiles = new StaticTile[Width][][]; for (int x = 0; x < Width; ++x) { tiles[x] = new TileList[Height]; Tiles[x] = new StaticTile[Height][]; for (int y = 0; y < Height; ++y) { tiles[x][y] = new TileList(); } } for (int i = 0; i < allTiles.Length; ++i) { if (i == 0 || allTiles[i].m_Flags != 0) { int xOffset = allTiles[i].m_OffsetX + m_Center.m_X; int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y; tiles[xOffset][yOffset].Add(allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ); } } for (int x = 0; x < Width; ++x) { for (int y = 0; y < Height; ++y) { Tiles[x][y] = tiles[x][y].ToArray(); } } }
public void Remove( int itemID, int x, int y, int z ) { int vx = x + m_Center.m_X; int vy = y + m_Center.m_Y; if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height ) { Tile[] oldTiles = m_Tiles[vx][vy]; for ( int i = 0; i < oldTiles.Length; ++i ) { Tile tile = oldTiles[i]; #region SA if ( (tile.ID & 0x7FFF) == (itemID & 0x7FFF) && tile.Z == z ) { #endregion Tile[] newTiles = new Tile[oldTiles.Length - 1]; for ( int j = 0; j < i; ++j ) newTiles[j] = oldTiles[j]; for ( int j = i + 1; j < oldTiles.Length; ++j ) newTiles[j - 1] = oldTiles[j]; m_Tiles[vx][vy] = newTiles; break; } } MultiTileEntry[] oldList = m_List; for ( int i = 0; i < oldList.Length; ++i ) { MultiTileEntry tile = oldList[i]; #region SA if ( (tile.m_ItemID & 0x7FFF) == (short)(itemID & 0x7FFF) && tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z ) { #endregion MultiTileEntry[] newList = new MultiTileEntry[oldList.Length - 1]; for ( int j = 0; j < i; ++j ) newList[j] = oldList[j]; for ( int j = i + 1; j < oldList.Length; ++j ) newList[j - 1] = oldList[j]; m_List = newList; break; } } } }
public void Add( int itemID, int x, int y, int z ) { #region SA itemID &= 0x7FFF; itemID |= 0x8000; // Note #2 8000 prevented you from walking on them // 4003 | 8000 = C003 & 7FFF = 4003 // 4003 | 4000 = 3 & 7FFF = 3 itemID &= 0x7FFF; #endregion int vx = x + m_Center.m_X; int vy = y + m_Center.m_Y; if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height ) { Tile[] oldTiles = m_Tiles[vx][vy]; for ( int i = oldTiles.Length - 1; i >= 0; --i ) { #region SA ItemData data = TileData.ItemTable[itemID & 0x7FFF]; #endregion if ( oldTiles[i].Z == z && (oldTiles[i].Height > 0 == data.Height > 0 ) ) { bool newIsRoof = ( data.Flags & TileFlag.Roof) != 0; #region SA bool oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & 0x7FFF].Flags & TileFlag.Roof ) != 0; #endregion if ( newIsRoof == oldIsRoof ) Remove( oldTiles[i].ID, x, y, z ); } } oldTiles = m_Tiles[vx][vy]; Tile[] newTiles = new Tile[oldTiles.Length + 1]; for ( int i = 0; i < oldTiles.Length; ++i ) newTiles[i] = oldTiles[i]; newTiles[oldTiles.Length] = new Tile( (short)itemID, (sbyte)z ); m_Tiles[vx][vy] = newTiles; MultiTileEntry[] oldList = m_List; MultiTileEntry[] newList = new MultiTileEntry[oldList.Length + 1]; for ( int i = 0; i < oldList.Length; ++i ) newList[i] = oldList[i]; newList[oldList.Length] = new MultiTileEntry( (short)itemID, (short)x, (short)y, (short)z, 1 ); m_List = newList; if ( x < m_Min.m_X ) m_Min.m_X = x; if ( y < m_Min.m_Y ) m_Min.m_Y = y; if ( x > m_Max.m_X ) m_Max.m_X = x; if ( y > m_Max.m_Y ) m_Max.m_Y = y; } }
// END ALAN MOD public MultiComponentList(BinaryReader reader, int count) { MultiTileEntry[] allTiles = m_List = new MultiTileEntry[count]; for (int i = 0; i < count; ++i) { allTiles[i].m_ItemID = reader.ReadUInt16(); allTiles[i].m_OffsetX = reader.ReadInt16(); allTiles[i].m_OffsetY = reader.ReadInt16(); allTiles[i].m_OffsetZ = reader.ReadInt16(); allTiles[i].m_Flags = reader.ReadInt32(); /* * // BEGIN ALAN PARSING OUT STUFF (THIS IS TEMPORARY) ================================================== * if (allTiles[i].m_Flags == 0) // invisible * { * int[,] transformation = new int[2, 2] { { 1, 0 }, { 0, 1 } }; // transformation matrix * * //Console.WriteLine(allTiles[i].m_ItemID + "\t" + allTiles[i].m_OffsetX + "\t" + allTiles[i].m_OffsetY + "\t" + allTiles[i].m_OffsetZ + "\t" + allTiles[i].m_Flags); * int baseMultiID = 0; // this is the "base" multi (northern undamaged boat) used to rotate from in order to connect the pieces * int damageLevel = 0; * int direction = 0; * if (MultiData.currentMultiID == 24) // orc north BASE * { * if (!MultiEntries.ContainsKey(24)) MultiEntries.Add(24, new MultiEntry(24)); * baseMultiID = 24; transformation = new int[2, 2] { { 1, 0 }, { 0, 1 } }; damageLevel = 0; direction = 0; * } * else if (MultiData.currentMultiID == 25) // orc east * { * baseMultiID = 24; transformation = new int[2, 2] { { 0, -1 }, { 1, 0 } }; damageLevel = 0; direction = 1; * } * else if (MultiData.currentMultiID == 26) // orc south * { * baseMultiID = 24; transformation = new int[2, 2] { { -1, 0 }, { 0, -1 } }; damageLevel = 0; direction =2 ; * } * else if (MultiData.currentMultiID == 27) // orc west * { * baseMultiID = 24; transformation = new int[2, 2] { { 0, 1 }, { -1, 0 } }; damageLevel = 0; direction = 3; * } * else if (MultiData.currentMultiID == 28) // orc north damaged 1 * { * baseMultiID = 24; transformation = new int[2, 2] { { 1, 0 }, { 0, 1 } }; damageLevel = 1; direction = 0; * } * else if (MultiData.currentMultiID == 29) // orc east damaged 1 * { * baseMultiID = 24; transformation = new int[2, 2] { { 0, -1 }, { 1, 0 } }; damageLevel = 1; direction = 1; * } * else if (MultiData.currentMultiID == 30) // orc south damaged 1 * { * baseMultiID = 24; transformation = new int[2, 2] { { -1, 0 }, { 0, -1 } }; damageLevel = 1; direction = 2; * } * else if (MultiData.currentMultiID == 31) // orc west damaged 1 * { * baseMultiID = 24; transformation = new int[2, 2] { { 0, 1 }, { -1, 0 } }; damageLevel = 1; direction = 3; * } * else if (MultiData.currentMultiID == 32) // orc north damaged 2 * { * baseMultiID = 24; transformation = new int[2, 2] { { 1, 0 }, { 0, 1 } }; damageLevel = 2; direction = 0; * } * else if (MultiData.currentMultiID == 33) // orc east damaged 2 * { * baseMultiID = 24; transformation = new int[2, 2] { { 0, -1 }, { 1, 0 } }; damageLevel = 2; direction = 1; * } * else if (MultiData.currentMultiID == 34) // orc south damaged 2 * { * baseMultiID = 24; transformation = new int[2, 2] { { -1, 0 }, { 0, -1 } }; damageLevel = 2; direction = 2; * } * else if (MultiData.currentMultiID == 35) // orc west damaged 2 * { * baseMultiID = 24; transformation = new int[2, 2] { { 0, 1 }, { -1, 0 } }; damageLevel = 2; direction = 3; * } * * * * * * * else if (MultiData.currentMultiID == 36) // gargoyle north BASE * { * if (!MultiEntries.ContainsKey(36)) MultiEntries.Add(36, new MultiEntry(36)); * baseMultiID = 36; transformation = new int[2, 2] { { 1, 0 }, { 0, 1 } }; damageLevel = 0; direction = 0; * } * else if (MultiData.currentMultiID == 37) // gargoyle east * { * baseMultiID = 36; transformation = new int[2, 2] { { 0, -1 }, { 1, 0 } }; damageLevel = 0; direction = 1; * } * else if (MultiData.currentMultiID == 38) // gargoyle south * { * baseMultiID = 36; transformation = new int[2, 2] { { -1, 0 }, { 0, -1 } }; damageLevel = 0; direction = 2; * } * else if (MultiData.currentMultiID == 39) // gargoyle west * { * baseMultiID = 36; transformation = new int[2, 2] { { 0, 1 }, { -1, 0 } }; damageLevel = 0; direction = 3; * } * else if (MultiData.currentMultiID == 40) // gargoyle north damaged 1 * { * baseMultiID = 36; transformation = new int[2, 2] { { 1, 0 }, { 0, 1 } }; damageLevel = 1; direction = 0; * } * else if (MultiData.currentMultiID == 41) // gargoyle east damaged 1 * { * baseMultiID = 36; transformation = new int[2, 2] { { 0, -1 }, { 1, 0 } }; damageLevel = 1; direction = 1; * } * else if (MultiData.currentMultiID == 42) // gargoyle south damaged 1 * { * baseMultiID = 36; transformation = new int[2, 2] { { -1, 0 }, { 0, -1 } }; damageLevel = 1; direction = 2; * } * else if (MultiData.currentMultiID == 43) // gargoyle west damaged 1 * { * baseMultiID = 36; transformation = new int[2, 2] { { 0, 1 }, { -1, 0 } }; damageLevel = 1; direction = 3; * } * else if (MultiData.currentMultiID == 44) // gargoyle north damaged 2 * { * baseMultiID = 36; transformation = new int[2, 2] { { 1, 0 }, { 0, 1 } }; damageLevel = 2; direction = 0; * } * else if (MultiData.currentMultiID == 45) // gargoyle east damaged 2 * { * baseMultiID = 36; transformation = new int[2, 2] { { 0, -1 }, { 1, 0 } }; damageLevel = 2; direction = 1; * } * else if (MultiData.currentMultiID == 46) // gargoyle south damaged 2 * { * baseMultiID = 36; transformation = new int[2, 2] { { -1, 0 }, { 0, -1 } }; damageLevel = 2; direction = 2; * } * else if (MultiData.currentMultiID == 47) // gargoyle west damaged 2 * { * baseMultiID = 36; transformation = new int[2, 2] { { 0, 1 }, { -1, 0 } }; damageLevel = 2; direction = 3; * } * * * * * else if (MultiData.currentMultiID == 48) // tokuno north BASE * { * if (!MultiEntries.ContainsKey(48)) MultiEntries.Add(48, new MultiEntry(48)); * baseMultiID = 48; transformation = new int[2, 2] { { 1, 0 }, { 0, 1 } }; damageLevel = 0; direction = 0; * } * else if (MultiData.currentMultiID == 49) // tokuno east * { * baseMultiID = 48; transformation = new int[2, 2] { { 0, -1 }, { 1, 0 } }; damageLevel = 0; direction = 1; * } * else if (MultiData.currentMultiID == 50) // tokuno south * { * baseMultiID = 48; transformation = new int[2, 2] { { -1, 0 }, { 0, -1 } }; damageLevel = 0; direction = 2; * } * else if (MultiData.currentMultiID == 51) // tokuno west * { * baseMultiID = 48; transformation = new int[2, 2] { { 0, 1 }, { -1, 0 } }; damageLevel = 0; direction = 3; * } * else if (MultiData.currentMultiID == 52) // tokuno north damaged 1 * { * baseMultiID = 48; transformation = new int[2, 2] { { 1, 0 }, { 0, 1 } }; damageLevel = 1; direction = 0; * } * else if (MultiData.currentMultiID == 53) // tokuno east damaged 1 * { * baseMultiID = 48; transformation = new int[2, 2] { { 0, -1 }, { 1, 0 } }; damageLevel = 1; direction = 1; * } * else if (MultiData.currentMultiID == 54) // tokuno south damaged 1 * { * baseMultiID = 48; transformation = new int[2, 2] { { -1, 0 }, { 0, -1 } }; damageLevel = 1; direction = 2; * } * else if (MultiData.currentMultiID == 55) // tokuno west damaged 1 * { * baseMultiID = 48; transformation = new int[2, 2] { { 0, 1 }, { -1, 0 } }; damageLevel = 1; direction = 3; * } * else if (MultiData.currentMultiID == 56) // tokuno north damaged 2 * { * baseMultiID = 48; transformation = new int[2, 2] { { 1, 0 }, { 0, 1 } }; damageLevel = 2; direction = 0; * } * else if (MultiData.currentMultiID == 57) // tokuno east damaged 2 * { * baseMultiID = 48; transformation = new int[2, 2] { { 0, -1 }, { 1, 0 } }; damageLevel = 2; direction = 1; * } * else if (MultiData.currentMultiID == 58) // tokuno south damaged 2 * { * baseMultiID = 48; transformation = new int[2, 2] { { -1, 0 }, { 0, -1 } }; damageLevel = 2; direction = 2; * } * else if (MultiData.currentMultiID == 59) // tokuno west damaged 2 * { * baseMultiID = 48; transformation = new int[2, 2] { { 0, 1 }, { -1, 0 } }; damageLevel = 2; direction = 3; * } * * * * if (MultiEntries.ContainsKey(baseMultiID)) * { * MultiEntry entry = MultiEntries[baseMultiID]; * entry.AddMultiEntryComponent(damageLevel, direction, allTiles[i].m_ItemID, new Point3D(allTiles[i].m_OffsetX, allTiles[i].m_OffsetY, allTiles[i].m_OffsetZ), transformation); * } * else * { * Console.WriteLine("MultiEntries did not yet contain key " + baseMultiID); * } * } * * // END ALAN PARSING OUT STUFF =================================================================== */ if (_PostHSFormat) { reader.ReadInt32(); // ?? } MultiTileEntry e = allTiles[i]; if (i == 0 || e.m_Flags != 0) { if (e.m_OffsetX < m_Min.m_X) { m_Min.m_X = e.m_OffsetX; } if (e.m_OffsetY < m_Min.m_Y) { m_Min.m_Y = e.m_OffsetY; } if (e.m_OffsetX > m_Max.m_X) { m_Max.m_X = e.m_OffsetX; } if (e.m_OffsetY > m_Max.m_Y) { m_Max.m_Y = e.m_OffsetY; } } } m_Center = new Point2D(-m_Min.m_X, -m_Min.m_Y); m_Width = (m_Max.m_X - m_Min.m_X) + 1; m_Height = (m_Max.m_Y - m_Min.m_Y) + 1; TileList[][] tiles = new TileList[m_Width][]; m_Tiles = new StaticTile[m_Width][][]; for (int x = 0; x < m_Width; ++x) { tiles[x] = new TileList[m_Height]; m_Tiles[x] = new StaticTile[m_Height][]; for (int y = 0; y < m_Height; ++y) { tiles[x][y] = new TileList(); } } for (int i = 0; i < allTiles.Length; ++i) { if (i == 0 || allTiles[i].m_Flags != 0) { int xOffset = allTiles[i].m_OffsetX + m_Center.m_X; int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y; tiles[xOffset][yOffset].Add((ushort)allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ); } } for (int x = 0; x < m_Width; ++x) { for (int y = 0; y < m_Height; ++y) { m_Tiles[x][y] = tiles[x][y].ToArray(); } } }
public void Add(int itemID, int x, int y, int z) { int vx = x + Center.X; int vy = y + Center.Y; if (vx >= 0 && vx < Width && vy >= 0 && vy < Height) { Tile[] oldTiles = Tiles[vx][vy]; for (int i = oldTiles.Length - 1; i >= 0; --i) { ItemData data = TileData.ItemTable[itemID & TileData.MaxItemValue]; if (oldTiles[i].Z == z && (oldTiles[i].Height > 0 == data.Height > 0)) { bool newIsRoof = (data.Flags & TileFlag.Roof) != 0; bool oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0; if (newIsRoof == oldIsRoof) { Remove(oldTiles[i].ID, x, y, z); } } } oldTiles = Tiles[vx][vy]; Tile[] newTiles = new Tile[oldTiles.Length + 1]; for (int i = 0; i < oldTiles.Length; ++i) { newTiles[i] = oldTiles[i]; } newTiles[oldTiles.Length] = new Tile((ushort)itemID, (sbyte)z); Tiles[vx][vy] = newTiles; MultiTileEntry[] oldList = List; MultiTileEntry[] newList = new MultiTileEntry[oldList.Length + 1]; for (int i = 0; i < oldList.Length; ++i) { newList[i] = oldList[i]; } newList[oldList.Length] = new MultiTileEntry((ushort)itemID, (short)x, (short)y, (short)z, 1); List = newList; if (x < m_Min.X) { m_Min.X = x; } if (y < m_Min.Y) { m_Min.Y = y; } if (x > m_Max.X) { m_Max.X = x; } if (y > m_Max.Y) { m_Max.Y = y; } } }
public MultiComponentList(GenericReader reader) { int num3; int num4; int num5; int num6; int num7; int num8; int num9; int num10; MultiTileEntry[] entryArray2; int num11 = reader.ReadInt(); if (num11 != 0) { return; } this.m_Min = reader.ReadPoint2D(); this.m_Max = reader.ReadPoint2D(); this.m_Center = reader.ReadPoint2D(); this.m_Width = reader.ReadInt(); this.m_Height = reader.ReadInt(); int num2 = reader.ReadInt(); this.m_List = (entryArray2 = new MultiTileEntry[num2]); MultiTileEntry[] entryArray1 = entryArray2; for (num3 = 0; (num3 < num2); ++num3) { entryArray1[num3].m_ItemID = reader.ReadShort(); entryArray1[num3].m_OffsetX = reader.ReadShort(); entryArray1[num3].m_OffsetY = reader.ReadShort(); entryArray1[num3].m_OffsetZ = reader.ReadShort(); entryArray1[num3].m_Flags = reader.ReadInt(); } TileList[][] listArrayArray1 = new TileList[this.m_Width][]; this.m_Tiles = new Tile[this.m_Width][][]; for (num4 = 0; (num4 < this.m_Width); ++num4) { listArrayArray1[num4] = new TileList[this.m_Height]; this.m_Tiles[num4] = new Tile[this.m_Height][]; for (num5 = 0; (num5 < this.m_Height); ++num5) { listArrayArray1[num4][num5] = new TileList(); } } for (num6 = 0; (num6 < entryArray1.Length); ++num6) { if ((num6 == 0) || (entryArray1[num6].m_Flags != 0)) { num7 = (entryArray1[num6].m_OffsetX + this.m_Center.m_X); num8 = (entryArray1[num6].m_OffsetY + this.m_Center.m_Y); listArrayArray1[num7][num8].Add(((short)((entryArray1[num6].m_ItemID & 16383) | 16384)), ((sbyte)entryArray1[num6].m_OffsetZ)); } } for (num9 = 0; (num9 < this.m_Width); ++num9) { for (num10 = 0; (num10 < this.m_Height); ++num10) { this.m_Tiles[num9][num10] = listArrayArray1[num9][num10].ToArray(); } } }
public MultiComponentList(BinaryReader reader, int count) { var allTiles = m_List = new MultiTileEntry[count]; for (int i = 0; i < count; ++i) { allTiles[i].m_ItemID = reader.ReadUInt16(); allTiles[i].m_OffsetX = reader.ReadInt16(); allTiles[i].m_OffsetY = reader.ReadInt16(); allTiles[i].m_OffsetZ = reader.ReadInt16(); allTiles[i].m_Flags = reader.ReadInt32(); if (_PostHSFormat) { reader.ReadInt32(); // ?? } MultiTileEntry e = allTiles[i]; if (i == 0 || e.m_Flags != 0) { if (e.m_OffsetX < m_Min.m_X) { m_Min.m_X = e.m_OffsetX; } if (e.m_OffsetY < m_Min.m_Y) { m_Min.m_Y = e.m_OffsetY; } if (e.m_OffsetX > m_Max.m_X) { m_Max.m_X = e.m_OffsetX; } if (e.m_OffsetY > m_Max.m_Y) { m_Max.m_Y = e.m_OffsetY; } } } m_Center = new Point2D(-m_Min.m_X, -m_Min.m_Y); m_Width = (m_Max.m_X - m_Min.m_X) + 1; m_Height = (m_Max.m_Y - m_Min.m_Y) + 1; var tiles = new TileList[m_Width][]; m_Tiles = new StaticTile[m_Width][][]; for (int x = 0; x < m_Width; ++x) { tiles[x] = new TileList[m_Height]; m_Tiles[x] = new StaticTile[m_Height][]; for (int y = 0; y < m_Height; ++y) { tiles[x][y] = new TileList(); } } for (int i = 0; i < allTiles.Length; ++i) { if (i == 0 || allTiles[i].m_Flags != 0) { int xOffset = allTiles[i].m_OffsetX + m_Center.m_X; int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y; #region Stygian Abyss //tiles[xOffset][yOffset].Add( (ushort)allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ ); tiles[xOffset][yOffset].Add( (ushort)((allTiles[i].m_ItemID & TileData.MaxItemValue) | 0x10000), (sbyte)allTiles[i].m_OffsetZ); #endregion } } for (int x = 0; x < m_Width; ++x) { for (int y = 0; y < m_Height; ++y) { m_Tiles[x][y] = tiles[x][y].ToArray(); } } }
public void AddFixtures( Mobile from, MultiTileEntry[] list ) { if ( m_Fixtures == null ) m_Fixtures = new ArrayList(); uint keyValue = 0; for ( int i = 0; i < list.Length; ++i ) { MultiTileEntry mte = list[i]; int itemID = mte.m_ItemID & 0x3FFF; if ( itemID >= 0x181D && itemID < 0x1829 ) { HouseTeleporter tp = new HouseTeleporter( itemID ); AddFixture( tp, mte ); } else { BaseDoor door = null; if ( itemID >= 0x675 && itemID < 0x6F5 ) { int type = (itemID - 0x675) / 16; DoorFacing facing = (DoorFacing)(((itemID - 0x675) / 2) % 8); switch ( type ) { case 0: door = new GenericHouseDoor( facing, 0x675, 0xEC, 0xF3 ); break; case 1: door = new GenericHouseDoor( facing, 0x685, 0xEC, 0xF3 ); break; case 2: door = new GenericHouseDoor( facing, 0x695, 0xEB, 0xF2 ); break; case 3: door = new GenericHouseDoor( facing, 0x6A5, 0xEA, 0xF1 ); break; case 4: door = new GenericHouseDoor( facing, 0x6B5, 0xEA, 0xF1 ); break; case 5: door = new GenericHouseDoor( facing, 0x6C5, 0xEC, 0xF3 ); break; case 6: door = new GenericHouseDoor( facing, 0x6D5, 0xEA, 0xF1 ); break; case 7: door = new GenericHouseDoor( facing, 0x6E5, 0xEA, 0xF1 ); break; } } else if ( itemID >= 0x314 && itemID < 0x364 ) { int type = (itemID - 0x314) / 16; DoorFacing facing = (DoorFacing)(((itemID - 0x314) / 2) % 8); switch ( type ) { case 0: door = new GenericHouseDoor( facing, 0x314, 0xED, 0xF4 ); break; case 1: door = new GenericHouseDoor( facing, 0x324, 0xED, 0xF4 ); break; case 2: door = new GenericHouseDoor( facing, 0x334, 0xED, 0xF4 ); break; case 3: door = new GenericHouseDoor( facing, 0x344, 0xED, 0xF4 ); break; case 4: door = new GenericHouseDoor( facing, 0x354, 0xED, 0xF4 ); break; } } else if ( itemID >= 0x824 && itemID < 0x834 ) { DoorFacing facing = (DoorFacing)(((itemID - 0x824) / 2) % 8); door = new GenericHouseDoor( facing, 0x824, 0xEC, 0xF3 ); } else if ( itemID >= 0x839 && itemID < 0x849 ) { DoorFacing facing = (DoorFacing)(((itemID - 0x839) / 2) % 8); door = new GenericHouseDoor( facing, 0x839, 0xEB, 0xF2 ); } else if ( itemID >= 0x84C && itemID < 0x85C ) { DoorFacing facing = (DoorFacing)(((itemID - 0x84C) / 2) % 8); door = new GenericHouseDoor( facing, 0x84C, 0xEC, 0xF3 ); } else if ( itemID >= 0x866 && itemID < 0x876 ) { DoorFacing facing = (DoorFacing)(((itemID - 0x866) / 2) % 8); door = new GenericHouseDoor( facing, 0x866, 0xEB, 0xF2 ); } else if ( itemID >= 0xE8 && itemID < 0xF8 ) { DoorFacing facing = (DoorFacing)(((itemID - 0xE8) / 2) % 8); door = new GenericHouseDoor( facing, 0xE8, 0xED, 0xF4 ); } else if ( itemID >= 0x1FED && itemID < 0x1FFD ) { DoorFacing facing = (DoorFacing)(((itemID - 0x1FED) / 2) % 8); door = new GenericHouseDoor( facing, 0x1FED, 0xEC, 0xF3 ); } else if ( itemID >= 0x241F && itemID < 0x2421 ) { //DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); door = new GenericHouseDoor( DoorFacing.NorthCCW, 0x2415, -1, -1 ); } else if ( itemID >= 0x2423 && itemID < 0x2425 ) { //DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); //This one and the above one are 'special' cases, ie: OSI had the ItemID pattern discombobulated for these door = new GenericHouseDoor( DoorFacing.WestCW, 0x2423, -1, -1 ); } else if ( itemID >= 0x2A05 && itemID < 0x2A1D ) { DoorFacing facing = (DoorFacing)((((itemID - 0x2A05) / 2) % 4) + 8); int sound = ( itemID >= 0x2A0D && itemID < 0x2a15 ) ? 0x539 : -1; door = new GenericHouseDoor( facing, 0x29F5 + (8 * ((itemID - 0x2A05) / 8)), sound, sound ); } if ( door != null ) { if ( keyValue == 0 ) keyValue = CreateKeys( from ); door.Locked = true; door.KeyValue = keyValue; AddDoor( door, mte.m_OffsetX, mte.m_OffsetY, mte.m_OffsetZ ); m_Fixtures.Add( door ); } } } for ( int i = 0; i < m_Fixtures.Count; ++i ) { Item fixture = (Item)m_Fixtures[i]; if ( fixture is HouseTeleporter ) { HouseTeleporter tp = (HouseTeleporter)fixture; for ( int j = 1; j <= m_Fixtures.Count; ++j ) { HouseTeleporter check = m_Fixtures[(i + j) % m_Fixtures.Count] as HouseTeleporter; if ( check != null && check.ItemID == tp.ItemID ) { tp.Target = check; break; } } } else if ( fixture is BaseHouseDoor ) { BaseHouseDoor door = (BaseHouseDoor)fixture; if ( door.Link != null ) continue; DoorFacing linkFacing; int xOffset, yOffset; switch ( door.Facing ) { default: case DoorFacing.WestCW: linkFacing = DoorFacing.EastCCW; xOffset = 1; yOffset = 0; break; case DoorFacing.EastCCW: linkFacing = DoorFacing.WestCW; xOffset = -1; yOffset = 0; break; case DoorFacing.WestCCW: linkFacing = DoorFacing.EastCW; xOffset = 1; yOffset = 0; break; case DoorFacing.EastCW: linkFacing = DoorFacing.WestCCW; xOffset = -1; yOffset = 0; break; case DoorFacing.SouthCW: linkFacing = DoorFacing.NorthCCW; xOffset = 0; yOffset = -1; break; case DoorFacing.NorthCCW: linkFacing = DoorFacing.SouthCW; xOffset = 0; yOffset = 1; break; case DoorFacing.SouthCCW: linkFacing = DoorFacing.NorthCW; xOffset = 0; yOffset = -1; break; case DoorFacing.NorthCW: linkFacing = DoorFacing.SouthCCW; xOffset = 0; yOffset = 1; break; case DoorFacing.SouthSW: linkFacing = DoorFacing.SouthSE; xOffset = 1; yOffset = 0; break; case DoorFacing.SouthSE: linkFacing = DoorFacing.SouthSW; xOffset = -1; yOffset = 0; break; case DoorFacing.WestSN: linkFacing = DoorFacing.WestSS; xOffset = 0; yOffset = 1; break; case DoorFacing.WestSS: linkFacing = DoorFacing.WestSN; xOffset = 0; yOffset = -1; break; } for ( int j = i + 1; j < m_Fixtures.Count; ++j ) { BaseHouseDoor check = m_Fixtures[j] as BaseHouseDoor; if ( check != null && check.Link == null && check.Facing == linkFacing && (check.X - door.X) == xOffset && (check.Y - door.Y) == yOffset && (check.Z == door.Z) ) { check.Link = door; door.Link = check; break; } } } } }
public void Add(int itemID, int x, int y, int z, bool ignoreRoof) { itemID &= 0x3FFF; itemID |= 0x4000; int vx = x + m_Center.m_X; int vy = y + m_Center.m_Y; if (vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height) { Tile[] oldTiles = m_Tiles[vx][vy]; // adam: we added the ignoreRoof override for our StaticHouses if (ignoreRoof == false) { for (int i = oldTiles.Length - 1; i >= 0; --i) { ItemData data = TileData.ItemTable[itemID & 0x3FFF]; if (oldTiles[i].Z == z && (oldTiles[i].Height > 0 == data.Height > 0)) { bool newIsRoof = (data.Flags & TileFlag.Roof) != 0; bool oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & 0x3FFF].Flags & TileFlag.Roof) != 0; if (newIsRoof == oldIsRoof) { Remove(oldTiles[i].ID, x, y, z); } } } } oldTiles = m_Tiles[vx][vy]; Tile[] newTiles = new Tile[oldTiles.Length + 1]; for (int i = 0; i < oldTiles.Length; ++i) { newTiles[i] = oldTiles[i]; } newTiles[oldTiles.Length] = new Tile((short)itemID, (sbyte)z); m_Tiles[vx][vy] = newTiles; MultiTileEntry[] oldList = m_List; MultiTileEntry[] newList = new MultiTileEntry[oldList.Length + 1]; for (int i = 0; i < oldList.Length; ++i) { newList[i] = oldList[i]; } newList[oldList.Length] = new MultiTileEntry((short)itemID, (short)x, (short)y, (short)z, 1); m_List = newList; if (x < m_Min.m_X) { m_Min.m_X = x; } if (y < m_Min.m_Y) { m_Min.m_Y = y; } if (x > m_Max.m_X) { m_Max.m_X = x; } if (y > m_Max.m_Y) { m_Max.m_Y = y; } } }
public MultiComponentList(IGenericReader reader) { var version = reader.ReadInt(); m_Min = reader.ReadPoint2D(); m_Max = reader.ReadPoint2D(); Center = reader.ReadPoint2D(); Width = reader.ReadInt(); Height = reader.ReadInt(); var length = reader.ReadInt(); var allTiles = List = new MultiTileEntry[length]; if (version == 0) { for (var i = 0; i < length; ++i) { int id = reader.ReadShort(); if (id >= 0x4000) { id -= 0x4000; } allTiles[i].ItemId = (ushort)id; allTiles[i].OffsetX = reader.ReadShort(); allTiles[i].OffsetY = reader.ReadShort(); allTiles[i].OffsetZ = reader.ReadShort(); allTiles[i].Flags = (TileFlag)reader.ReadInt(); } } else { for (var i = 0; i < length; ++i) { allTiles[i].ItemId = reader.ReadUShort(); allTiles[i].OffsetX = reader.ReadShort(); allTiles[i].OffsetY = reader.ReadShort(); allTiles[i].OffsetZ = reader.ReadShort(); allTiles[i].Flags = (TileFlag)reader.ReadInt(); } } var tiles = new TileList[Width][]; Tiles = new StaticTile[Width][][]; for (var x = 0; x < Width; ++x) { tiles[x] = new TileList[Height]; Tiles[x] = new StaticTile[Height][]; for (var y = 0; y < Height; ++y) { tiles[x][y] = new TileList(); } } for (var i = 0; i < allTiles.Length; ++i) { if (i == 0 || allTiles[i].Flags != 0) { var xOffset = allTiles[i].OffsetX + Center.m_X; var yOffset = allTiles[i].OffsetY + Center.m_Y; tiles[xOffset][yOffset].Add(allTiles[i].ItemId, (sbyte)allTiles[i].OffsetZ); } } for (var x = 0; x < Width; ++x) { for (var y = 0; y < Height; ++y) { Tiles[x][y] = tiles[x][y].ToArray(); } } }
public void AddFixtures( Mobile from, MultiTileEntry[] list ) { if( m_Fixtures == null ) m_Fixtures = new ArrayList(); uint keyValue = 0; for( int i = 0; i < list.Length; ++i ) { MultiTileEntry mte = list[i]; int itemID = mte.m_ItemID & 0x3FFF; if( itemID >= 0x181D && itemID < 0x1829 ) { HouseTeleporter tp = new HouseTeleporter( itemID ); AddFixture( tp, mte ); } else { BaseDoor door = null; if( itemID >= 0x675 && itemID < 0x6F5 ) { int type = (itemID - 0x675) / 16; DoorFacing facing = (DoorFacing)(((itemID - 0x675) / 2) % 8); switch( type ) { case 0: door = new GenericHouseDoor( facing, 0x675, 0xEC, 0xF3 ); break; case 1: door = new GenericHouseDoor( facing, 0x685, 0xEC, 0xF3 ); break; case 2: door = new GenericHouseDoor( facing, 0x695, 0xEB, 0xF2 ); break; case 3: door = new GenericHouseDoor( facing, 0x6A5, 0xEA, 0xF1 ); break; case 4: door = new GenericHouseDoor( facing, 0x6B5, 0xEA, 0xF1 ); break; case 5: door = new GenericHouseDoor( facing, 0x6C5, 0xEC, 0xF3 ); break; case 6: door = new GenericHouseDoor( facing, 0x6D5, 0xEA, 0xF1 ); break; case 7: door = new GenericHouseDoor( facing, 0x6E5, 0xEA, 0xF1 ); break; } } else if( itemID >= 0x314 && itemID < 0x364 ) { int type = (itemID - 0x314) / 16; DoorFacing facing = (DoorFacing)(((itemID - 0x314) / 2) % 8); //TODO: Change this to just do a 0x314 + type*16 switch( type ) { case 0: door = new GenericHouseDoor( facing, 0x314, 0xED, 0xF4 ); break; case 1: door = new GenericHouseDoor( facing, 0x324, 0xED, 0xF4 ); break; case 2: door = new GenericHouseDoor( facing, 0x334, 0xED, 0xF4 ); break; case 3: door = new GenericHouseDoor( facing, 0x344, 0xED, 0xF4 ); break; case 4: door = new GenericHouseDoor( facing, 0x354, 0xED, 0xF4 ); break; } } else if( itemID >= 0x824 && itemID < 0x834 ) { DoorFacing facing = (DoorFacing)(((itemID - 0x824) / 2) % 8); door = new GenericHouseDoor( facing, 0x824, 0xEC, 0xF3 ); } else if( itemID >= 0x839 && itemID < 0x849 ) { DoorFacing facing = (DoorFacing)(((itemID - 0x839) / 2) % 8); door = new GenericHouseDoor( facing, 0x839, 0xEB, 0xF2 ); } else if( itemID >= 0x84C && itemID < 0x85C ) { DoorFacing facing = (DoorFacing)(((itemID - 0x84C) / 2) % 8); door = new GenericHouseDoor( facing, 0x84C, 0xEC, 0xF3 ); } else if( itemID >= 0x866 && itemID < 0x876 ) { DoorFacing facing = (DoorFacing)(((itemID - 0x866) / 2) % 8); door = new GenericHouseDoor( facing, 0x866, 0xEB, 0xF2 ); } else if( itemID >= 0xE8 && itemID < 0xF8 ) { DoorFacing facing = (DoorFacing)(((itemID - 0xE8) / 2) % 8); door = new GenericHouseDoor( facing, 0xE8, 0xED, 0xF4 ); } else if( itemID >= 0x1FED && itemID < 0x1FFD ) { DoorFacing facing = (DoorFacing)(((itemID - 0x1FED) / 2) % 8); door = new GenericHouseDoor( facing, 0x1FED, 0xEC, 0xF3 ); } else if( itemID >= 0x241F && itemID < 0x2421 ) { //DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); door = new GenericHouseDoor( DoorFacing.NorthCCW, 0x2415, -1, -1 ); } else if( itemID >= 0x2423 && itemID < 0x2425 ) { //DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); //This one and the above one are 'special' cases, ie: OSI had the ItemID pattern discombobulated for these door = new GenericHouseDoor( DoorFacing.WestCW, 0x2423, -1, -1 ); } else if( itemID >= 0x2A05 && itemID < 0x2A1D ) { DoorFacing facing = (DoorFacing)((((itemID - 0x2A05) / 2) % 4) + 8); int sound = (itemID >= 0x2A0D && itemID < 0x2a15) ? 0x539 : -1; door = new GenericHouseDoor( facing, 0x29F5 + (8 * ((itemID - 0x2A05) / 8)), sound, sound ); } else if( itemID == 0x2D46 ) { door = new GenericHouseDoor( DoorFacing.NorthCW, 0x2D46, 0xEA, 0xF1, false ); } else if( itemID == 0x2D48 || itemID == 0x2FE2 ) { door = new GenericHouseDoor( DoorFacing.SouthCCW, itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x2D63 && itemID < 0x2D70 ) { int mod = (itemID - 0x2D63)/2%2; DoorFacing facing = ( ( mod == 0 ) ? DoorFacing.SouthCCW : DoorFacing.WestCCW ); int type = (itemID - 0x2D63) / 4; door = new GenericHouseDoor( facing, 0x2D63 + 4*type + mod*2, 0xEA, 0xF1, false ); } else if( itemID == 0x2FE4 || itemID == 0x31AE ) { door = new GenericHouseDoor( DoorFacing.WestCCW, itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x319C && itemID < 0x31AE ) { //special case for 0x31aa <-> 0x31a8 (a9) int mod = (itemID - 0x319C) / 2 % 2; bool specialCase = (itemID == 0x31AA || itemID == 0x31A8); DoorFacing facing; if ( itemID == 0x31AA || itemID == 0x31A8 ) facing = ((mod == 0) ? DoorFacing.NorthCW : DoorFacing.EastCW); else facing = ((mod == 0) ? DoorFacing.EastCW : DoorFacing.NorthCW); int type = (itemID - 0x319C) / 4; door = new GenericHouseDoor( facing, 0x319C + 4 * type + mod * 2, 0xEA, 0xF1, false ); } /* * ASayre HATE doors. ASayre SMASH WestCCW EastCW SoutCCW NorthCW 0x31AE* 0x31AC 0x2D48* 0x2D46* Elvan Wood Door 0x2d65* 0x31a0 0x2d63* 0x31a2 Elvan White Wooden Door 1 0x2d69* 0x31a4 0x2d67* 0x31a6 Elvan Ornate Door 0x2d6d* 0x31aa 0x2d6b* 0x31a8 Elvan Kia Wood Door 2 0x2fe4* 0x319c 0x2fe2* 0x319e Elvan Moon Door * * */ if( door != null ) { if( keyValue == 0 ) keyValue = CreateKeys( from ); door.Locked = true; door.KeyValue = keyValue; AddDoor( door, mte.m_OffsetX, mte.m_OffsetY, mte.m_OffsetZ ); m_Fixtures.Add( door ); } } } for( int i = 0; i < m_Fixtures.Count; ++i ) { Item fixture = (Item)m_Fixtures[i]; if( fixture is HouseTeleporter ) { HouseTeleporter tp = (HouseTeleporter)fixture; for( int j = 1; j <= m_Fixtures.Count; ++j ) { HouseTeleporter check = m_Fixtures[(i + j) % m_Fixtures.Count] as HouseTeleporter; if( check != null && check.ItemID == tp.ItemID ) { tp.Target = check; break; } } } else if( fixture is BaseHouseDoor ) { BaseHouseDoor door = (BaseHouseDoor)fixture; if( door.Link != null ) continue; DoorFacing linkFacing; int xOffset, yOffset; switch( door.Facing ) { default: case DoorFacing.WestCW: linkFacing = DoorFacing.EastCCW; xOffset = 1; yOffset = 0; break; case DoorFacing.EastCCW: linkFacing = DoorFacing.WestCW; xOffset = -1; yOffset = 0; break; case DoorFacing.WestCCW: linkFacing = DoorFacing.EastCW; xOffset = 1; yOffset = 0; break; case DoorFacing.EastCW: linkFacing = DoorFacing.WestCCW; xOffset = -1; yOffset = 0; break; case DoorFacing.SouthCW: linkFacing = DoorFacing.NorthCCW; xOffset = 0; yOffset = -1; break; case DoorFacing.NorthCCW: linkFacing = DoorFacing.SouthCW; xOffset = 0; yOffset = 1; break; case DoorFacing.SouthCCW: linkFacing = DoorFacing.NorthCW; xOffset = 0; yOffset = -1; break; case DoorFacing.NorthCW: linkFacing = DoorFacing.SouthCCW; xOffset = 0; yOffset = 1; break; case DoorFacing.SouthSW: linkFacing = DoorFacing.SouthSE; xOffset = 1; yOffset = 0; break; case DoorFacing.SouthSE: linkFacing = DoorFacing.SouthSW; xOffset = -1; yOffset = 0; break; case DoorFacing.WestSN: linkFacing = DoorFacing.WestSS; xOffset = 0; yOffset = 1; break; case DoorFacing.WestSS: linkFacing = DoorFacing.WestSN; xOffset = 0; yOffset = -1; break; } for( int j = i + 1; j < m_Fixtures.Count; ++j ) { BaseHouseDoor check = m_Fixtures[j] as BaseHouseDoor; if( check != null && check.Link == null && check.Facing == linkFacing && (check.X - door.X) == xOffset && (check.Y - door.Y) == yOffset && (check.Z == door.Z) ) { check.Link = door; door.Link = check; break; } } } } }
public MultiComponentList(List <MultiTileEntry> list) { var allTiles = List = new MultiTileEntry[list.Count]; for (var i = 0; i < list.Count; ++i) { allTiles[i].ItemId = list[i].ItemId; allTiles[i].OffsetX = list[i].OffsetX; allTiles[i].OffsetY = list[i].OffsetY; allTiles[i].OffsetZ = list[i].OffsetZ; allTiles[i].Flags = list[i].Flags; var e = allTiles[i]; if (i == 0 || e.Flags != 0) { if (e.OffsetX < m_Min.m_X) { m_Min.m_X = e.OffsetX; } if (e.OffsetY < m_Min.m_Y) { m_Min.m_Y = e.OffsetY; } if (e.OffsetX > m_Max.m_X) { m_Max.m_X = e.OffsetX; } if (e.OffsetY > m_Max.m_Y) { m_Max.m_Y = e.OffsetY; } } } Center = new Point2D(-m_Min.m_X, -m_Min.m_Y); Width = m_Max.m_X - m_Min.m_X + 1; Height = m_Max.m_Y - m_Min.m_Y + 1; var tiles = new TileList[Width][]; Tiles = new StaticTile[Width][][]; for (var x = 0; x < Width; ++x) { tiles[x] = new TileList[Height]; Tiles[x] = new StaticTile[Height][]; for (var y = 0; y < Height; ++y) { tiles[x][y] = new TileList(); } } for (var i = 0; i < allTiles.Length; ++i) { if (i == 0 || allTiles[i].Flags != 0) { var xOffset = allTiles[i].OffsetX + Center.m_X; var yOffset = allTiles[i].OffsetY + Center.m_Y; var itemID = (allTiles[i].ItemId & TileData.MaxItemValue) | 0x10000; tiles[xOffset][yOffset].Add((ushort)itemID, (sbyte)allTiles[i].OffsetZ); } } for (var x = 0; x < Width; ++x) { for (var y = 0; y < Height; ++y) { Tiles[x][y] = tiles[x][y].ToArray(); } } }
private MultiComponentList() { Tiles = new StaticTile[0][][]; List = new MultiTileEntry[0]; }
public void Remove(int itemID, int x, int y, int z) { var vx = x + Center.m_X; var vy = y + Center.m_Y; if (vx >= 0 && vx < Width && vy >= 0 && vy < Height) { var oldTiles = Tiles[vx][vy]; for (var i = 0; i < oldTiles.Length; ++i) { var tile = oldTiles[i]; if (tile.ID == itemID && tile.Z == z) { var newTiles = new StaticTile[oldTiles.Length - 1]; for (var j = 0; j < i; ++j) { newTiles[j] = oldTiles[j]; } for (var j = i + 1; j < oldTiles.Length; ++j) { newTiles[j - 1] = oldTiles[j]; } Tiles[vx][vy] = newTiles; break; } } var oldList = List; for (var i = 0; i < oldList.Length; ++i) { var tile = oldList[i]; if (tile.ItemId == itemID && tile.OffsetX == (short)x && tile.OffsetY == (short)y && tile.OffsetZ == (short)z) { var newList = new MultiTileEntry[oldList.Length - 1]; for (var j = 0; j < i; ++j) { newList[j] = oldList[j]; } for (var j = i + 1; j < oldList.Length; ++j) { newList[j - 1] = oldList[j]; } List = newList; break; } } } }
public void Resize(int newWidth, int newHeight) { int oldWidth = Width, oldHeight = Height; StaticTile[][][] oldTiles = Tiles; int totalLength = 0; StaticTile[][][] newTiles = new StaticTile[newWidth][][]; for (int x = 0; x < newWidth; ++x) { newTiles[x] = new StaticTile[newHeight][]; for (int y = 0; y < newHeight; ++y) { if (x < oldWidth && y < oldHeight) { newTiles[x][y] = oldTiles[x][y]; } else { newTiles[x][y] = new StaticTile[0]; } totalLength += newTiles[x][y].Length; } } Tiles = newTiles; List = new MultiTileEntry[totalLength]; Width = newWidth; Height = newHeight; m_Min = Point2D.Zero; m_Max = Point2D.Zero; int index = 0; for (int x = 0; x < newWidth; ++x) { for (int y = 0; y < newHeight; ++y) { StaticTile[] tiles = newTiles[x][y]; for (int i = 0; i < tiles.Length; ++i) { StaticTile tile = tiles[i]; int vx = x - Center.X; int vy = y - Center.Y; if (vx < m_Min.m_X) { m_Min.m_X = vx; } if (vy < m_Min.m_Y) { m_Min.m_Y = vy; } if (vx > m_Max.m_X) { m_Max.m_X = vx; } if (vy > m_Max.m_Y) { m_Max.m_Y = vy; } List[index++] = new MultiTileEntry((ushort)tile.ID, (short)vx, (short)vy, (short)tile.Z, TileFlag.Background); } } } }
public MultiComponentList(List <MultiTileEntry> list) { MultiTileEntry[] allTiles = m_List = new MultiTileEntry[list.Count]; for (int i = 0; i < list.Count; ++i) { allTiles[i].m_ItemID = list[i].m_ItemID; allTiles[i].m_OffsetX = list[i].m_OffsetX; allTiles[i].m_OffsetY = list[i].m_OffsetY; allTiles[i].m_OffsetZ = list[i].m_OffsetZ; allTiles[i].m_Flags = list[i].m_Flags; MultiTileEntry e = allTiles[i]; if (i == 0 || e.m_Flags != 0) { if (e.m_OffsetX < m_Min.m_X) { m_Min.m_X = e.m_OffsetX; } if (e.m_OffsetY < m_Min.m_Y) { m_Min.m_Y = e.m_OffsetY; } if (e.m_OffsetX > m_Max.m_X) { m_Max.m_X = e.m_OffsetX; } if (e.m_OffsetY > m_Max.m_Y) { m_Max.m_Y = e.m_OffsetY; } } } m_Center = new Point2D(-m_Min.m_X, -m_Min.m_Y); m_Width = m_Max.m_X - m_Min.m_X + 1; m_Height = m_Max.m_Y - m_Min.m_Y + 1; TileList[][] tiles = new TileList[m_Width][]; m_Tiles = new StaticTile[m_Width][][]; for (int x = 0; x < m_Width; ++x) { tiles[x] = new TileList[m_Height]; m_Tiles[x] = new StaticTile[m_Height][]; for (int y = 0; y < m_Height; ++y) { tiles[x][y] = new TileList(); } } for (int i = 0; i < allTiles.Length; ++i) { if (i == 0 || allTiles[i].m_Flags != 0) { int xOffset = allTiles[i].m_OffsetX + m_Center.m_X; int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y; int itemID = (allTiles[i].m_ItemID & TileData.MaxItemValue) | 0x10000; tiles[xOffset][yOffset].Add((ushort)itemID, (sbyte)allTiles[i].m_OffsetZ); } } for (int x = 0; x < m_Width; ++x) { for (int y = 0; y < m_Height; ++y) { m_Tiles[x][y] = tiles[x][y].ToArray(); } } }
public void Remove(int itemID, int x, int y, int z) { int vx = x + this.m_Center.m_X; int vy = y + this.m_Center.m_Y; if (vx >= 0 && vx < this.m_Width && vy >= 0 && vy < this.m_Height) { StaticTile[] oldTiles = this.m_Tiles[vx][vy]; for (int i = 0; i < oldTiles.Length; ++i) { StaticTile tile = oldTiles[i]; if (tile.ID == itemID && tile.Z == z) { StaticTile[] newTiles = new StaticTile[oldTiles.Length - 1]; for (int j = 0; j < i; ++j) newTiles[j] = oldTiles[j]; for (int j = i + 1; j < oldTiles.Length; ++j) newTiles[j - 1] = oldTiles[j]; this.m_Tiles[vx][vy] = newTiles; break; } } MultiTileEntry[] oldList = this.m_List; for (int i = 0; i < oldList.Length; ++i) { MultiTileEntry tile = oldList[i]; if (tile.m_ItemID == itemID && tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z) { MultiTileEntry[] newList = new MultiTileEntry[oldList.Length - 1]; for (int j = 0; j < i; ++j) newList[j] = oldList[j]; for (int j = i + 1; j < oldList.Length; ++j) newList[j - 1] = oldList[j]; this.m_List = newList; break; } } } }
public void Resize(int newWidth, int newHeight) { int oldWidth = Width, oldHeight = Height; var oldTiles = Tiles; var totalLength = 0; var newTiles = new StaticTile[newWidth][][]; for (var x = 0; x < newWidth; ++x) { newTiles[x] = new StaticTile[newHeight][]; for (var y = 0; y < newHeight; ++y) { if (x < oldWidth && y < oldHeight) { newTiles[x][y] = oldTiles[x][y]; } else { newTiles[x][y] = new StaticTile[0]; } totalLength += newTiles[x][y].Length; } } Tiles = newTiles; m_List = new MultiTileEntry[totalLength]; Width = newWidth; Height = newHeight; m_Min = Point2D.Zero; m_Max = Point2D.Zero; var index = 0; for (var x = 0; x < newWidth; ++x) { for (var y = 0; y < newHeight; ++y) { var tiles = newTiles[x][y]; foreach (var tile in tiles) { var vx = x - m_Center.X; var vy = y - m_Center.Y; if (vx < m_Min.m_X) { m_Min.m_X = vx; } if (vy < m_Min.m_Y) { m_Min.m_Y = vy; } if (vx > m_Max.m_X) { m_Max.m_X = vx; } if (vy > m_Max.m_Y) { m_Max.m_Y = vy; } m_List[index++] = new MultiTileEntry((ushort)tile.ID, (short)vx, (short)vy, (short)tile.Z, TileFlag.Background); } } } }
public void AddFixtures( Mobile from, MultiTileEntry[] list ) { if( m_Fixtures == null ) m_Fixtures = new List<Item>(); uint keyValue = 0; for( int i = 0; i < list.Length; ++i ) { MultiTileEntry mte = list[i]; int itemID = mte.m_ItemID; if( itemID >= 0x181D && itemID < 0x1829 ) { HouseTeleporter tp = new HouseTeleporter( itemID ); AddFixture( tp, mte ); } else { BaseDoor door = null; if( itemID >= 0x675 && itemID < 0x6F5 ) { int type = (itemID - 0x675) / 16; DoorFacing facing = (DoorFacing)(((itemID - 0x675) / 2) % 8); switch( type ) { case 0: door = new GenericHouseDoor( facing, 0x675, 0xEC, 0xF3 ); break; case 1: door = new GenericHouseDoor( facing, 0x685, 0xEC, 0xF3 ); break; case 2: door = new GenericHouseDoor( facing, 0x695, 0xEB, 0xF2 ); break; case 3: door = new GenericHouseDoor( facing, 0x6A5, 0xEA, 0xF1 ); break; case 4: door = new GenericHouseDoor( facing, 0x6B5, 0xEA, 0xF1 ); break; case 5: door = new GenericHouseDoor( facing, 0x6C5, 0xEC, 0xF3 ); break; case 6: door = new GenericHouseDoor( facing, 0x6D5, 0xEA, 0xF1 ); break; case 7: door = new GenericHouseDoor( facing, 0x6E5, 0xEA, 0xF1 ); break; } } else if( itemID >= 0x314 && itemID < 0x364 ) { int type = (itemID - 0x314) / 16; DoorFacing facing = (DoorFacing)(((itemID - 0x314) / 2) % 8); door = new GenericHouseDoor( facing, 0x314 + ( type * 16 ), 0xED, 0xF4 ); } else if( itemID >= 0x824 && itemID < 0x834 ) { DoorFacing facing = (DoorFacing)(((itemID - 0x824) / 2) % 8); door = new GenericHouseDoor( facing, 0x824, 0xEC, 0xF3 ); } else if( itemID >= 0x839 && itemID < 0x849 ) { DoorFacing facing = (DoorFacing)(((itemID - 0x839) / 2) % 8); door = new GenericHouseDoor( facing, 0x839, 0xEB, 0xF2 ); } else if( itemID >= 0x84C && itemID < 0x85C ) { DoorFacing facing = (DoorFacing)(((itemID - 0x84C) / 2) % 8); door = new GenericHouseDoor( facing, 0x84C, 0xEC, 0xF3 ); } else if( itemID >= 0x866 && itemID < 0x876 ) { DoorFacing facing = (DoorFacing)(((itemID - 0x866) / 2) % 8); door = new GenericHouseDoor( facing, 0x866, 0xEB, 0xF2 ); } else if( itemID >= 0xE8 && itemID < 0xF8 ) { DoorFacing facing = (DoorFacing)(((itemID - 0xE8) / 2) % 8); door = new GenericHouseDoor( facing, 0xE8, 0xED, 0xF4 ); } else if( itemID >= 0x1FED && itemID < 0x1FFD ) { DoorFacing facing = (DoorFacing)(((itemID - 0x1FED) / 2) % 8); door = new GenericHouseDoor( facing, 0x1FED, 0xEC, 0xF3 ); } else if( itemID >= 0x241F && itemID < 0x2421 ) { //DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); door = new GenericHouseDoor( DoorFacing.NorthCCW, 0x2415, -1, -1 ); } else if( itemID >= 0x2423 && itemID < 0x2425 ) { //DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); //This one and the above one are 'special' cases, ie: OSI had the ItemID pattern discombobulated for these door = new GenericHouseDoor( DoorFacing.WestCW, 0x2423, -1, -1 ); } else if( itemID >= 0x2A05 && itemID < 0x2A1D ) { DoorFacing facing = (DoorFacing)((((itemID - 0x2A05) / 2) % 4) + 8); int sound = (itemID >= 0x2A0D && itemID < 0x2a15) ? 0x539 : -1; door = new GenericHouseDoor( facing, 0x29F5 + (8 * ((itemID - 0x2A05) / 8)), sound, sound ); } else if( itemID == 0x2D46 ) { door = new GenericHouseDoor( DoorFacing.NorthCW, 0x2D46, 0xEA, 0xF1, false ); } else if( itemID == 0x2D48 || itemID == 0x2FE2 ) { door = new GenericHouseDoor( DoorFacing.SouthCCW, itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x2D63 && itemID < 0x2D70 ) { int mod = (itemID - 0x2D63)/2%2; DoorFacing facing = ( ( mod == 0 ) ? DoorFacing.SouthCCW : DoorFacing.WestCCW ); int type = (itemID - 0x2D63) / 4; door = new GenericHouseDoor( facing, 0x2D63 + 4*type + mod*2, 0xEA, 0xF1, false ); } else if( itemID == 0x2FE4 || itemID == 0x31AE ) { door = new GenericHouseDoor( DoorFacing.WestCCW, itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x319C && itemID < 0x31AE ) { //special case for 0x31aa <-> 0x31a8 (a9) int mod = (itemID - 0x319C) / 2 % 2; bool specialCase = (itemID == 0x31AA || itemID == 0x31A8); DoorFacing facing; if ( itemID == 0x31AA || itemID == 0x31A8 ) facing = ((mod == 0) ? DoorFacing.NorthCW : DoorFacing.EastCW); else facing = ((mod == 0) ? DoorFacing.EastCW : DoorFacing.NorthCW); int type = (itemID - 0x319C) / 4; door = new GenericHouseDoor( facing, 0x319C + 4 * type + mod * 2, 0xEA, 0xF1, false ); } else if( itemID >= 0x367B && itemID < 0x369B ) { int type = (itemID - 0x367B) / 16; DoorFacing facing = (DoorFacing)(((itemID - 0x367B) / 2) % 8); switch( type ) { case 0: door = new GenericHouseDoor( facing, 0x367B, 0xED, 0xF4 ); break; //crystal case 1: door = new GenericHouseDoor( facing, 0x368B, 0xEC, 0x3E7 ); break; //shadow } } else if( itemID >= 0x409B && itemID < 0x40A3 ) { door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x409B ), itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x410C && itemID < 0x4114 ) { door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x410C ), itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x41C2 && itemID < 0x41CA ) { door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x41C2 ), itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x41CF && itemID < 0x41D7 ) { door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x41CF ), itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x436E && itemID < 0x437E ) { /* These ones had to be different... * Offset 0 2 4 6 8 10 12 14 * DoorFacing 2 3 2 3 6 7 6 7 */ int offset = itemID - 0x436E; DoorFacing facing = (DoorFacing)( ( offset / 2 + 2 * ( ( 1 + offset / 4 ) % 2 ) ) % 8 ); door = new GenericHouseDoor( facing, itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x46DD && itemID < 0x46E5 ) { door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x46DD ), itemID, 0xEB, 0xF2, false ); } else if( itemID >= 0x4D22 && itemID < 0x4D2A ) { door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x4D22 ), itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x50C8 && itemID < 0x50D0 ) { door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x50C8 ), itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x50D0 && itemID < 0x50D8 ) { door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x50D0 ), itemID, 0xEA, 0xF1, false ); } else if( itemID >= 0x5142 && itemID < 0x514A ) { door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x5142 ), itemID, 0xF0, 0xEF, false ); } if( door != null ) { if( keyValue == 0 ) keyValue = CreateKeys( from ); door.Locked = true; door.KeyValue = keyValue; AddDoor( door, mte.m_OffsetX, mte.m_OffsetY, mte.m_OffsetZ ); m_Fixtures.Add( door ); } } } for( int i = 0; i < m_Fixtures.Count; ++i ) { Item fixture = m_Fixtures[i]; if( fixture is HouseTeleporter ) { HouseTeleporter tp = (HouseTeleporter)fixture; for( int j = 1; j <= m_Fixtures.Count; ++j ) { HouseTeleporter check = m_Fixtures[(i + j) % m_Fixtures.Count] as HouseTeleporter; if( check != null && check.ItemID == tp.ItemID ) { tp.Target = check; break; } } } else if( fixture is BaseHouseDoor ) { BaseHouseDoor door = (BaseHouseDoor)fixture; if( door.Link != null ) continue; DoorFacing linkFacing; int xOffset, yOffset; switch( door.Facing ) { default: case DoorFacing.WestCW: linkFacing = DoorFacing.EastCCW; xOffset = 1; yOffset = 0; break; case DoorFacing.EastCCW: linkFacing = DoorFacing.WestCW; xOffset = -1; yOffset = 0; break; case DoorFacing.WestCCW: linkFacing = DoorFacing.EastCW; xOffset = 1; yOffset = 0; break; case DoorFacing.EastCW: linkFacing = DoorFacing.WestCCW; xOffset = -1; yOffset = 0; break; case DoorFacing.SouthCW: linkFacing = DoorFacing.NorthCCW; xOffset = 0; yOffset = -1; break; case DoorFacing.NorthCCW: linkFacing = DoorFacing.SouthCW; xOffset = 0; yOffset = 1; break; case DoorFacing.SouthCCW: linkFacing = DoorFacing.NorthCW; xOffset = 0; yOffset = -1; break; case DoorFacing.NorthCW: linkFacing = DoorFacing.SouthCCW; xOffset = 0; yOffset = 1; break; case DoorFacing.SouthSW: linkFacing = DoorFacing.SouthSE; xOffset = 1; yOffset = 0; break; case DoorFacing.SouthSE: linkFacing = DoorFacing.SouthSW; xOffset = -1; yOffset = 0; break; case DoorFacing.WestSN: linkFacing = DoorFacing.WestSS; xOffset = 0; yOffset = 1; break; case DoorFacing.WestSS: linkFacing = DoorFacing.WestSN; xOffset = 0; yOffset = -1; break; } for( int j = i + 1; j < m_Fixtures.Count; ++j ) { BaseHouseDoor check = m_Fixtures[j] as BaseHouseDoor; if( check != null && check.Link == null && check.Facing == linkFacing && (check.X - door.X) == xOffset && (check.Y - door.Y) == yOffset && (check.Z == door.Z) ) { check.Link = door; door.Link = check; break; } } } } }
public void Remove(int itemID, int x, int y, int z) { int vx = x + m_Center.m_X; int vy = y + m_Center.m_Y; if (vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height) { var oldTiles = m_Tiles[vx][vy]; for (int i = 0; i < oldTiles.Length; ++i) { StaticTile tile = oldTiles[i]; if (tile.ID == itemID && tile.Z == z) { var newTiles = new StaticTile[oldTiles.Length - 1]; for (int j = 0; j < i; ++j) { newTiles[j] = oldTiles[j]; } for (int j = i + 1; j < oldTiles.Length; ++j) { newTiles[j - 1] = oldTiles[j]; } m_Tiles[vx][vy] = newTiles; break; } } var oldList = m_List; for (int i = 0; i < oldList.Length; ++i) { MultiTileEntry tile = oldList[i]; if (tile.m_ItemID == itemID && tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z) { var newList = new MultiTileEntry[oldList.Length - 1]; for (int j = 0; j < i; ++j) { newList[j] = oldList[j]; } for (int j = i + 1; j < oldList.Length; ++j) { newList[j - 1] = oldList[j]; } m_List = newList; break; } } } }
public MultiComponentList(BinaryReader reader, int count) { MultiTileEntry[] allTiles = m_List = new MultiTileEntry[count]; for (int i = 0; i < count; ++i) { allTiles[i].m_ItemID = reader.ReadInt16(); allTiles[i].m_OffsetX = reader.ReadInt16(); allTiles[i].m_OffsetY = reader.ReadInt16(); allTiles[i].m_OffsetZ = reader.ReadInt16(); allTiles[i].m_Flags = reader.ReadInt32(); MultiTileEntry e = allTiles[i]; if (i == 0 || e.m_Flags != 0) { if (e.m_OffsetX < m_Min.m_X) { m_Min.m_X = e.m_OffsetX; } if (e.m_OffsetY < m_Min.m_Y) { m_Min.m_Y = e.m_OffsetY; } if (e.m_OffsetX > m_Max.m_X) { m_Max.m_X = e.m_OffsetX; } if (e.m_OffsetY > m_Max.m_Y) { m_Max.m_Y = e.m_OffsetY; } } } m_Center = new Point2D(-m_Min.m_X, -m_Min.m_Y); m_Width = (m_Max.m_X - m_Min.m_X) + 1; m_Height = (m_Max.m_Y - m_Min.m_Y) + 1; TileList[][] tiles = new TileList[m_Width][]; m_Tiles = new Tile[m_Width][][]; for (int x = 0; x < m_Width; ++x) { tiles[x] = new TileList[m_Height]; m_Tiles[x] = new Tile[m_Height][]; for (int y = 0; y < m_Height; ++y) { tiles[x][y] = new TileList(); } } for (int i = 0; i < allTiles.Length; ++i) { if (i == 0 || allTiles[i].m_Flags != 0) { int xOffset = allTiles[i].m_OffsetX + m_Center.m_X; int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y; tiles[xOffset][yOffset].Add((short)((allTiles[i].m_ItemID & 0x3FFF) | 0x4000), (sbyte)allTiles[i].m_OffsetZ); } } for (int x = 0; x < m_Width; ++x) { for (int y = 0; y < m_Height; ++y) { m_Tiles[x][y] = tiles[x][y].ToArray(); } } }
public void Add( int itemID, int x, int y, int z ) { int vx = x + m_Center.m_X; int vy = y + m_Center.m_Y; if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height ) { StaticTile[] oldTiles = m_Tiles[vx][vy]; for ( int i = oldTiles.Length - 1; i >= 0; --i ) { ItemData data = TileData.ItemTable[itemID & TileData.MaxItemValue]; if ( oldTiles[i].Z == z && (oldTiles[i].Height > 0 == data.Height > 0 ) ) { bool newIsRoof = ( data.Flags & TileFlag.Roof) != 0; bool oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & TileData.MaxItemValue].Flags & TileFlag.Roof ) != 0; if ( newIsRoof == oldIsRoof ) Remove( oldTiles[i].ID, x, y, z ); } } oldTiles = m_Tiles[vx][vy]; StaticTile[] newTiles = new StaticTile[oldTiles.Length + 1]; for ( int i = 0; i < oldTiles.Length; ++i ) newTiles[i] = oldTiles[i]; newTiles[oldTiles.Length] = new StaticTile( (ushort)itemID, (sbyte)z ); m_Tiles[vx][vy] = newTiles; MultiTileEntry[] oldList = m_List; MultiTileEntry[] newList = new MultiTileEntry[oldList.Length + 1]; for ( int i = 0; i < oldList.Length; ++i ) newList[i] = oldList[i]; newList[oldList.Length] = new MultiTileEntry( (ushort)itemID, (short)x, (short)y, (short)z, 1 ); m_List = newList; if ( x < m_Min.m_X ) m_Min.m_X = x; if ( y < m_Min.m_Y ) m_Min.m_Y = y; if ( x > m_Max.m_X ) m_Max.m_X = x; if ( y > m_Max.m_Y ) m_Max.m_Y = y; } }
public void RemoveXYZH( int x, int y, int z, int minHeight ) { int vx = x + m_Center.m_X; int vy = y + m_Center.m_Y; if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height ) { StaticTile[] oldTiles = m_Tiles[vx][vy]; for ( int i = 0; i < oldTiles.Length; ++i ) { StaticTile tile = oldTiles[i]; if ( tile.Z == z && tile.Height >= minHeight ) { StaticTile[] newTiles = new StaticTile[oldTiles.Length - 1]; for ( int j = 0; j < i; ++j ) newTiles[j] = oldTiles[j]; for ( int j = i + 1; j < oldTiles.Length; ++j ) newTiles[j - 1] = oldTiles[j]; m_Tiles[vx][vy] = newTiles; break; } } MultiTileEntry[] oldList = m_List; for ( int i = 0; i < oldList.Length; ++i ) { MultiTileEntry tile = oldList[i]; if ( tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z && TileData.ItemTable[tile.m_ItemID & TileData.MaxItemValue].Height >= minHeight ) { MultiTileEntry[] newList = new MultiTileEntry[oldList.Length - 1]; for ( int j = 0; j < i; ++j ) newList[j] = oldList[j]; for ( int j = i + 1; j < oldList.Length; ++j ) newList[j - 1] = oldList[j]; m_List = newList; break; } } } }
public void AddFixture( Item item, MultiTileEntry mte ) { m_Fixtures.Add( item ); item.MoveToWorld( new Point3D( X + mte.m_OffsetX, Y + mte.m_OffsetY, Z + mte.m_OffsetZ ), Map ); }
public void Resize( int newWidth, int newHeight ) { int oldWidth = m_Width, oldHeight = m_Height; StaticTile[][][] oldTiles = m_Tiles; int totalLength = 0; StaticTile[][][] newTiles = new StaticTile[newWidth][][]; for ( int x = 0; x < newWidth; ++x ) { newTiles[x] = new StaticTile[newHeight][]; for ( int y = 0; y < newHeight; ++y ) { if ( x < oldWidth && y < oldHeight ) newTiles[x][y] = oldTiles[x][y]; else newTiles[x][y] = new StaticTile[0]; totalLength += newTiles[x][y].Length; } } m_Tiles = newTiles; m_List = new MultiTileEntry[totalLength]; m_Width = newWidth; m_Height = newHeight; m_Min = Point2D.Zero; m_Max = Point2D.Zero; int index = 0; for ( int x = 0; x < newWidth; ++x ) { for ( int y = 0; y < newHeight; ++y ) { StaticTile[] tiles = newTiles[x][y]; for ( int i = 0; i < tiles.Length; ++i ) { StaticTile tile = tiles[i]; int vx = x - m_Center.X; int vy = y - m_Center.Y; if ( vx < m_Min.m_X ) m_Min.m_X = vx; if ( vy < m_Min.m_Y ) m_Min.m_Y = vy; if ( vx > m_Max.m_X ) m_Max.m_X = vx; if ( vy > m_Max.m_Y ) m_Max.m_Y = vy; m_List[index++] = new MultiTileEntry( (ushort)tile.ID, (short)vx, (short)vy, (short)tile.Z, 1 ); } } } }
public DesignStateDetailed( int serial, int revision, int xMin, int yMin, int xMax, int yMax, MultiTileEntry[] tiles ) : base(0xD8) { EnsureCapacity( 17 + (tiles.Length * 5) ); Write( (byte) 0x03 ); // Compression Type Write( (byte) 0x00 ); // Unknown Write( (int) serial ); Write( (int) revision ); Write( (short) tiles.Length ); Write( (short) 0 ); // Buffer length : reserved Write( (byte) 0 ); // Plane count : reserved int totalLength = 1; // includes plane count int width = (xMax - xMin) + 1; int height = (yMax - yMin) + 1; if ( m_PlaneBuffers == null ) { m_PlaneBuffers = new byte[9][]; m_PlaneUsed = new bool[9]; for ( int i = 0; i < m_PlaneBuffers.Length; ++i ) m_PlaneBuffers[i] = new byte[0x400]; m_StairBuffers = new byte[6][]; for ( int i = 0; i < m_StairBuffers.Length; ++i ) m_StairBuffers[i] = new byte[MaxItemsPerStairBuffer * 5]; } else { for ( int i = 0; i < m_PlaneUsed.Length; ++i ) m_PlaneUsed[i] = false; Clear( m_PlaneBuffers[0], width * height * 2 ); for ( int i = 0; i < 4; ++i ) { Clear( m_PlaneBuffers[1 + i], (width - 1) * (height - 2) * 2 ); Clear( m_PlaneBuffers[5 + i], width * (height - 1) * 2 ); } } int totalStairsUsed = 0; for ( int i = 0; i < tiles.Length; ++i ) { MultiTileEntry mte = tiles[i]; int x = mte.m_OffsetX - xMin; int y = mte.m_OffsetY - yMin; int z = mte.m_OffsetZ; bool floor = ( TileData.ItemTable[mte.m_ItemID & 0x3FFF].Height <= 0 ); int plane, size; switch ( z ) { case 0: plane = 0; break; case 7: plane = 1; break; case 27: plane = 2; break; case 47: plane = 3; break; case 67: plane = 4; break; default: { int stairBufferIndex = ( totalStairsUsed / MaxItemsPerStairBuffer ); byte[] stairBuffer = m_StairBuffers[stairBufferIndex]; int byteIndex = (totalStairsUsed % MaxItemsPerStairBuffer) * 5; stairBuffer[byteIndex++] = (byte) ((mte.m_ItemID >> 8) & 0x3F); stairBuffer[byteIndex++] = (byte) mte.m_ItemID; stairBuffer[byteIndex++] = (byte) mte.m_OffsetX; stairBuffer[byteIndex++] = (byte) mte.m_OffsetY; stairBuffer[byteIndex++] = (byte) mte.m_OffsetZ; ++totalStairsUsed; continue; } } if ( plane == 0 ) { size = height; } else if ( floor ) { size = height - 2; x -= 1; y -= 1; } else { size = height - 1; plane += 4; } int index = ((x * size) + y) * 2; if ( x < 0 || y < 0 || y >= size || (index + 1) >= 0x400 ) { int stairBufferIndex = ( totalStairsUsed / MaxItemsPerStairBuffer ); byte[] stairBuffer = m_StairBuffers[stairBufferIndex]; int byteIndex = (totalStairsUsed % MaxItemsPerStairBuffer) * 5; stairBuffer[byteIndex++] = (byte) ((mte.m_ItemID >> 8) & 0x3F); stairBuffer[byteIndex++] = (byte) mte.m_ItemID; stairBuffer[byteIndex++] = (byte) mte.m_OffsetX; stairBuffer[byteIndex++] = (byte) mte.m_OffsetY; stairBuffer[byteIndex++] = (byte) mte.m_OffsetZ; ++totalStairsUsed; } else { m_PlaneUsed[plane] = true; m_PlaneBuffers[plane][index] = (byte) ((mte.m_ItemID >> 8) & 0x3F); m_PlaneBuffers[plane][index + 1] = (byte) mte.m_ItemID; } } int planeCount = 0; for ( int i = 0; i < m_PlaneBuffers.Length; ++i ) { if ( !m_PlaneUsed[i] ) continue; ++planeCount; int size = 0; if ( i == 0 ) size = width * height * 2; else if ( i < 5 ) size = (width - 1) * (height - 2) * 2; else size = width * (height - 1) * 2; byte[] inflatedBuffer = m_PlaneBuffers[i]; int deflatedLength = m_DeflatedBuffer.Length; ZLibError ce = ZLib.compress2( m_DeflatedBuffer, ref deflatedLength, inflatedBuffer, size, ZLibCompressionLevel.Z_DEFAULT_COMPRESSION ); if ( ce != ZLibError.Z_OK ) { log.ErrorFormat("ZLib error: {0} (#{1})", ce, (int)ce); deflatedLength = 0; size = 0; } Write( (byte) (0x20 | i) ); Write( (byte) size ); Write( (byte) deflatedLength ); Write( (byte) (((size >> 4) & 0xF0) | ((deflatedLength >> 8) & 0xF)) ); Write( m_DeflatedBuffer, 0, deflatedLength ); totalLength += 4 + deflatedLength; } int totalStairBuffersUsed = ( totalStairsUsed + (MaxItemsPerStairBuffer - 1) ) / MaxItemsPerStairBuffer; for ( int i = 0; i < totalStairBuffersUsed; ++i ) { ++planeCount; int count = ( totalStairsUsed - (i * MaxItemsPerStairBuffer) ); if ( count > MaxItemsPerStairBuffer ) count = MaxItemsPerStairBuffer; int size = count * 5; byte[] inflatedBuffer = m_StairBuffers[i]; int deflatedLength = m_DeflatedBuffer.Length; ZLibError ce = ZLib.compress2( m_DeflatedBuffer, ref deflatedLength, inflatedBuffer, size, ZLibCompressionLevel.Z_DEFAULT_COMPRESSION ); if ( ce != ZLibError.Z_OK ) { log.ErrorFormat("ZLib error: {0} (#{1})", ce, (int)ce); deflatedLength = 0; size = 0; } Write( (byte) (9 + i) ); Write( (byte) size ); Write( (byte) deflatedLength ); Write( (byte) (((size >> 4) & 0xF0) | ((deflatedLength >> 8) & 0xF)) ); Write( m_DeflatedBuffer, 0, deflatedLength ); totalLength += 4 + deflatedLength; } m_Stream.Seek( 15, System.IO.SeekOrigin.Begin ); Write( (short) totalLength ); // Buffer length Write( (byte) planeCount ); // Plane count }
public void Add(int itemID, int x, int y, int z, bool ignoreRoof) { itemID &= 0x3FFF; itemID |= 0x4000; int vx = x + m_Center.m_X; int vy = y + m_Center.m_Y; if (vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height) { Tile[] oldTiles = m_Tiles[vx][vy]; // adam: we added the ignoreRoof override for our StaticHouses if (ignoreRoof == false) for (int i = oldTiles.Length - 1; i >= 0; --i) { ItemData data = TileData.ItemTable[itemID & 0x3FFF]; if (oldTiles[i].Z == z && (oldTiles[i].Height > 0 == data.Height > 0)) { bool newIsRoof = (data.Flags & TileFlag.Roof) != 0; bool oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & 0x3FFF].Flags & TileFlag.Roof) != 0; if (newIsRoof == oldIsRoof) Remove(oldTiles[i].ID, x, y, z); } } oldTiles = m_Tiles[vx][vy]; Tile[] newTiles = new Tile[oldTiles.Length + 1]; for (int i = 0; i < oldTiles.Length; ++i) newTiles[i] = oldTiles[i]; newTiles[oldTiles.Length] = new Tile((short)itemID, (sbyte)z); m_Tiles[vx][vy] = newTiles; MultiTileEntry[] oldList = m_List; MultiTileEntry[] newList = new MultiTileEntry[oldList.Length + 1]; for (int i = 0; i < oldList.Length; ++i) newList[i] = oldList[i]; newList[oldList.Length] = new MultiTileEntry((short)itemID, (short)x, (short)y, (short)z, 1); m_List = newList; if (x < m_Min.m_X) m_Min.m_X = x; if (y < m_Min.m_Y) m_Min.m_Y = y; if (x > m_Max.m_X) m_Max.m_X = x; if (y > m_Max.m_Y) m_Max.m_Y = y; } }