public void getPouch(ref byte[] Data) { InventoryItem[] items = new InventoryItem[PouchDataSize]; for (int i = 0; i < items.Length; i++) { items[i] = new InventoryItem { Index = BitConverter.ToUInt16(Data, Offset + i*4), Count = BitConverter.ToUInt16(Data, Offset + i*4 + 2) ^ (ushort)SecurityKey }; } Items = items; }
public void GetPouchG1(ref byte[] Data) { InventoryItem[] items = new InventoryItem[PouchDataSize]; if (Type == InventoryType.TMHMs) { int slot = 0; for (int i = 0; i < items.Length; i++) { if (Data[Offset + i] != 0) { items[slot++] = new InventoryItem { Index = LegalItems[i], Count = Data[Offset + i] } } ; } while (slot < items.Length) { items[slot++] = new InventoryItem { Index = 0, Count = 0 } } ; } else { int numStored = Data[Offset]; if (numStored > PouchDataSize) // uninitialized yellow (0xFF), sanity check for out-of-bounds values { numStored = 0; } for (int i = 0; i < numStored; i++) { switch (Type) { case InventoryType.KeyItems: items[i] = new InventoryItem { Index = Data[Offset + i + 1], Count = 1 }; break; default: items[i] = new InventoryItem { Index = Data[Offset + i * 2 + 1], Count = Data[Offset + i * 2 + 2] }; break; } } for (int i = numStored; i < items.Length; i++) { items[i] = new InventoryItem { Index = 0, Count = 0 }; } } Items = items; }
public void getPouch7(ref byte[] Data) { InventoryItem[] items = new InventoryItem[PouchDataSize]; for (int i = 0; i < items.Length; i++) { // 10bit itemID // 10bit count // 12bit flags/reserved uint val = BitConverter.ToUInt32(Data, Offset + i*4); items[i] = new InventoryItem { Index = (int)(val & 0x3FF), Count = (int)(val >> 10 & 0x3FF), New = (val & 0x40000000) != 0, // 30th bit is "NEW" FreeSpace = (val & 0x100000) != 0, // 22th bit is "FREE SPACE" }; } Items = items; OriginalItems = Items.Select(i => i.Clone()).ToArray(); }
public void getPouchG1(ref byte[] Data) { InventoryItem[] items = new InventoryItem[PouchDataSize]; if (Type == InventoryType.TMHMs) { int slot = 0; for (int i = 0; i < items.Length; i++) { if (Data[Offset + i] != 0) items[slot++] = new InventoryItem { Index = LegalItems[i], Count = Data[Offset+i] }; } while (slot < items.Length) items[slot++] = new InventoryItem { Index = 0, Count = 0 }; } else { int numStored = Data[Offset]; for (int i = 0; i < numStored; i++) { switch (Type) { case InventoryType.KeyItems: items[i] = new InventoryItem { Index = Data[Offset + i + 1], Count = 1 }; break; default: items[i] = new InventoryItem { Index = Data[Offset + i * 2 + 1], Count = Data[Offset + i * 2 + 2] }; break; } } for (int i = numStored; i < items.Length; i++) { items[i] = new InventoryItem { Index = 0, Count = 0 }; } } Items = items; }