public Multi(ArrayList list) { this.m_MultiID = 0; int count = list.Count; int index = 0; this.m_xMin = 1000; this.m_yMin = 1000; this.m_xMax = -1000; this.m_yMax = -1000; for (; index < count; ++index) { MultiItem multiItem = (MultiItem)list[index]; if ((int)multiItem.X < this.m_xMin) { this.m_xMin = (int)multiItem.X; } if ((int)multiItem.Y < this.m_yMin) { this.m_yMin = (int)multiItem.Y; } if ((int)multiItem.X > this.m_xMax) { this.m_xMax = (int)multiItem.X; } if ((int)multiItem.Y > this.m_yMax) { this.m_yMax = (int)multiItem.Y; } } this.m_List = list; this.UpdateRadar(); }
public Multi(int MultiID) { this.m_MultiID = MultiID; ArrayList arrayList = Engine.Multis.Load(MultiID); int count = arrayList.Count; int index = 0; this.m_xMin = 1000; this.m_yMin = 1000; this.m_xMax = -1000; this.m_yMax = -1000; for (; index < count; ++index) { MultiItem multiItem = (MultiItem)arrayList[index]; if ((int)multiItem.X < this.m_xMin) { this.m_xMin = (int)multiItem.X; } if ((int)multiItem.Y < this.m_yMin) { this.m_yMin = (int)multiItem.Y; } if ((int)multiItem.X > this.m_xMax) { this.m_xMax = (int)multiItem.X; } if ((int)multiItem.Y > this.m_yMax) { this.m_yMax = (int)multiItem.Y; } } this.m_List = arrayList; this.UpdateRadar(); }
public bool Remove(int x, int y, int z, int itemID) { if (x < this.m_xMin || y < this.m_yMin || (x > this.m_xMax || y > this.m_yMax)) { return(false); } bool flag = false; for (int index = 0; index < this.m_List.Count; ++index) { MultiItem multiItem = (MultiItem)this.m_List[index]; if ((int)multiItem.X == x && (int)multiItem.Y == y && ((int)multiItem.Z == z && (int)multiItem.ItemID == itemID)) { this.m_List.RemoveAt(index--); flag = true; } } return(flag); }
private unsafe ArrayList ReadFromDisk(int multiID) { BinaryReader binaryReader = new BinaryReader(Engine.FileManager.OpenMUL(Files.MultiIdx)); binaryReader.BaseStream.Seek((long)(multiID * 12), SeekOrigin.Begin); int num = binaryReader.ReadInt32(); int length1 = binaryReader.ReadInt32(); binaryReader.Close(); if (num == -1) { return(new ArrayList()); } Stream stream = Engine.FileManager.OpenMUL(Files.MultiMul); stream.Seek((long)num, SeekOrigin.Begin); byte[] buffer = new byte[length1]; UnsafeMethods.ReadFile((FileStream)stream, buffer, 0, buffer.Length); stream.Close(); int length2 = length1 / sizeof(MultiItem); MultiItem[] multiItemArray = new MultiItem[length2]; fixed(byte *numPtr = buffer) { MultiItem *multiItemPtr1 = (MultiItem *)numPtr; MultiItem *multiItemPtr2 = multiItemPtr1 + length2; fixed(MultiItem *multiItemPtr3 = multiItemArray) { MultiItem *multiItemPtr4 = multiItemPtr3; while (multiItemPtr1 < multiItemPtr2) { *multiItemPtr4++ = *multiItemPtr1++; } } } return(new ArrayList((ICollection)multiItemArray)); }
public void Add(int itemID, int x, int y, int z) { if (x < this.m_xMin || y < this.m_yMin || (x > this.m_xMax || y > this.m_yMax)) { return; } for (int index = 0; index < this.m_List.Count; ++index) { MultiItem multiItem = (MultiItem)this.m_List[index]; if ((int)multiItem.X == x && (int)multiItem.Y == y && ((int)multiItem.Z == z && (int)Map.GetHeight((int)multiItem.ItemID) > 0 == (int)Map.GetHeight(itemID) > 0)) { this.m_List.RemoveAt(index--); } } this.m_List.Add((object)new MultiItem() { Flags = 1, ItemID = (short)itemID, X = (short)x, Y = (short)y, Z = (short)z }); }
public static unsafe void LoadDeflated(int xMin, int yMin, int xMax, int yMax, byte[] buffer, ArrayList list) { int num1 = yMax - yMin + 1; fixed(byte *numPtr1 = buffer) { IntPtr num2 = new IntPtr(1); byte * numPtr2 = numPtr1 + num2.ToInt64(); int num3 = (int)numPtr1[0]; for (int index1 = 0; index1 < num3; ++index1) { int num4 = (int)*numPtr2 >> 4 & 15; int num5 = (int)*numPtr2 & 15; int length1 = (int)numPtr2[1] | (int)numPtr2[3] << 4 & 3840; int length2 = (int)numPtr2[2] | (int)numPtr2[3] << 8 & 3840; numPtr2 += 4; if (CustomMultiEntry.m_InflateBuffer == null || CustomMultiEntry.m_InflateBuffer.Length < length1) CustomMultiEntry.m_InflateBuffer = new byte[length1]; fixed(byte *numPtr3 = CustomMultiEntry.m_InflateBuffer) { IntPtr ptr = (IntPtr)numPtr3; var localPtr = (byte *)ptr; byte[] numArray = new byte[length2]; for (int index2 = 0; index2 < numArray.Length; ++index2) { numArray[index2] = *numPtr2++; } ZLib.Decompress(CustomMultiEntry.m_InflateBuffer, ref length1, numArray, numArray.Length); byte *numPtr4 = localPtr + length1; switch (num4) { case 0: while (localPtr < numPtr4) { MultiItem multiItem = new MultiItem(); multiItem.Flags = 1; multiItem.ItemID = (short)(localPtr[0] << 8 | localPtr[1]); multiItem.X = (short)localPtr[2]; multiItem.Y = (short)localPtr[3]; multiItem.Z = (short)localPtr[4]; localPtr += 5; if ((int)multiItem.ItemID != 0) { list.Add((object)multiItem); } } break; case 1: int num6 = 0; switch (num5) { case 0: num6 = 0; break; case 1: case 5: num6 = 7; break; case 2: case 6: num6 = 27; break; case 3: case 7: num6 = 47; break; case 4: case 8: num6 = 67; break; } while (localPtr < numPtr4) { MultiItem multiItem = new MultiItem(); multiItem.Flags = 1; multiItem.ItemID = (short)((int)localPtr[0] << 8 | (int)localPtr[1]); multiItem.X = (short)(sbyte)localPtr[2]; multiItem.Y = (short)(sbyte)localPtr[3]; multiItem.Z = (short)(sbyte)num6; localPtr += 4; if ((int)multiItem.ItemID != 0) { list.Add((object)multiItem); } } break; case 2: int num7 = 0; switch (num5) { case 0: num7 = 0; break; case 1: case 5: num7 = 7; break; case 2: case 6: num7 = 27; break; case 3: case 7: num7 = 47; break; case 4: case 8: num7 = 67; break; } int num8; int num9; int num10; if (num5 <= 0) { num8 = xMin; num9 = yMin; num10 = num1 + 1; } else if (num5 <= 4) { num8 = xMin + 1; num9 = yMin + 1; num10 = num1 - 1; } else { num8 = xMin; num9 = yMin; num10 = num1; } int num11 = 0; while (localPtr < numPtr4) { short num12 = (short)((int)localPtr[0] << 8 | (int)localPtr[1]); ++num11; localPtr += 2; if ((int)num12 != 0) { list.Add((object)new MultiItem() { Flags = 1, ItemID = num12, X = (short)(num8 + (num11 - 1) / num10), Y = (short)(sbyte)(num9 + (num11 - 1) % num10), Z = (short)(sbyte)num7 }); } } break; } } } } }
public void UpdateRadar() { int length1 = this.m_xMax - this.m_xMin + 1; int length2 = this.m_yMax - this.m_yMin + 1; if (length1 <= 0 || length2 <= 0) { return; } int[][] numArray1 = new int[length2][]; int[][] numArray2 = new int[length2][]; this.m_Inside = new sbyte[length2][]; this.m_RunUO_Inside = new sbyte[length2][]; this.m_Radar = new short[length2][]; for (int index1 = 0; index1 < length2; ++index1) { this.m_Radar[index1] = new short[length1]; this.m_Inside[index1] = new sbyte[length1]; this.m_RunUO_Inside[index1] = new sbyte[length1]; numArray1[index1] = new int[length1]; numArray2[index1] = new int[length1]; for (int index2 = 0; index2 < length1; ++index2) { numArray1[index1][index2] = int.MinValue; } for (int index2 = 0; index2 < length1; ++index2) { numArray2[index1][index2] = int.MinValue; } for (int index2 = 0; index2 < length1; ++index2) { this.m_Inside[index1][index2] = sbyte.MaxValue; } for (int index2 = 0; index2 < length1; ++index2) { this.m_RunUO_Inside[index1][index2] = sbyte.MaxValue; } } for (int index1 = 0; index1 < this.m_List.Count; ++index1) { MultiItem multiItem = (MultiItem)this.m_List[index1]; int index2 = (int)multiItem.X - this.m_xMin; int index3 = (int)multiItem.Y - this.m_yMin; if (index2 >= 0 && index2 < length1 && (index3 >= 0 && index3 < length2)) { int num1 = (int)multiItem.Z; int num2 = num1 + (int)Map.GetHeight((int)multiItem.ItemID); int num3 = numArray2[index3][index2]; int num4 = numArray1[index3][index2]; int num5 = (int)multiItem.ItemID; if ((num2 > num4 || num2 == num4 && num1 > num3) && (num5 != 1 && num5 != 6038 && (num5 != 8612 && num5 != 8600)) && (num5 != 8636 && num5 != 8601)) { this.m_Radar[index3][index2] = multiItem.ItemID; numArray2[index3][index2] = num1; numArray1[index3][index2] = num2; } if (!Map.GetTileFlags((int)multiItem.ItemID)[(TileFlag)268435456L]) { int num6 = (int)multiItem.ItemID & 16383; sbyte num7 = (sbyte)multiItem.Z; if ((int)num7 < (int)this.m_Inside[index3][index2]) { this.m_Inside[index3][index2] = num7; } if ((num6 < 2965 || num6 > 3086) && (num6 < 3139 || num6 > 3140) && (int)num7 < (int)this.m_RunUO_Inside[index3][index2]) { this.m_RunUO_Inside[index3][index2] = num7; } } } } }
public void Update(MapPackage map) { int count1 = this.m_Items.Count; if (count1 == 0) { return; } int length1 = map.cells.GetLength(0); int length2 = map.cells.GetLength(1); int num1 = map.CellX; int num2 = map.CellY; int num3 = num1 + length1; int num4 = num2 + length2; int houseLevel = Options.Current.HouseLevel; for (int index1 = 0; index1 < count1; ++index1) { Item obj = (Item)this.m_Items[index1]; if (obj.InWorld) { CustomMultiEntry customMulti = CustomMultiLoader.GetCustomMulti(obj.Serial, obj.Revision); Multi multi = (Multi)null; if (customMulti != null) { multi = customMulti.Multi; } if (multi == null) { multi = obj.Multi; } if (multi != null) { int xMin; int yMin; int xMax; int yMax; multi.GetBounds(out xMin, out yMin, out xMax, out yMax); xMin += obj.X; yMin += obj.Y; xMax += obj.X; yMax += obj.Y; if (xMin < num3 && xMax >= num1 && (yMin < num4 && yMax >= num2)) { ArrayList list = multi.List; int count2 = list.Count; int num5 = int.MinValue | index1; for (int index2 = 0; index2 < count2; ++index2) { MultiItem multiItem = (MultiItem)list[index2]; if (multiItem.Flags != 0 || index2 == 0) { int num6 = obj.X + (int)multiItem.X; int num7 = obj.Y + (int)multiItem.Y; int index3 = num6 - num1; int index4 = num7 - num2; if (index3 >= 0 && index3 < length1 && (index4 >= 0 && index4 < length2)) { bool flag = true; int num8 = (int)multiItem.ItemID; if (flag) { map.cells[index3, index4].Add((object)StaticItem.Instantiate((short)num8, multiItem.ItemID, (sbyte)(obj.Z + (int)multiItem.Z), num5 | index2 << 16)); } } } } } } } } }