internal static void ReadContainerData(BinaryReader reader, ContainerTables tables) { int i = reader.ReadInt32(); while (i > 0) { int j = reader.ReadInt32(); int position = reader.ReadByte(); int slot = reader.ReadUInt16(); Tile left = Main.tile[i, j]; Tile right = Main.tile[i + 1, j]; if (left.active() && right.active() && (left.type == TileID.Mannequin || left.type == TileID.Womannequin) && left.type == right.type && (left.frameX == 0 || left.frameX == 36) && right.frameX == left.frameX + 18 && left.frameY / 18 == position && left.frameY == right.frameY) { if (position == 0) { slot = tables.headSlots[slot]; } else if (position == 1) { slot = tables.bodySlots[slot]; } else if (position == 2) { slot = tables.legSlots[slot]; } left.frameX += (short)(100 * slot); } i = reader.ReadInt32(); } }
internal static void ReadContainers(BinaryReader reader) { byte[] flags = new byte[1]; reader.Read(flags, 0, reader.ReadByte()); if ((flags[0] & 1) == 1) { var tables = ContainerTables.Create(); int count = reader.ReadUInt16(); for (int k = 0; k < count; k++) { int slot = reader.ReadUInt16(); string modName = reader.ReadString(); string name = reader.ReadString(); Mod mod = ModLoader.GetMod(modName); tables.headSlots[slot] = mod?.GetItem(name).item.headSlot ?? 0; } count = reader.ReadUInt16(); for (int k = 0; k < count; k++) { int slot = reader.ReadUInt16(); string modName = reader.ReadString(); string name = reader.ReadString(); Mod mod = ModLoader.GetMod(modName); tables.bodySlots[slot] = mod?.GetItem(name).item.bodySlot ?? 0; } count = reader.ReadUInt16(); for (int k = 0; k < count; k++) { int slot = reader.ReadUInt16(); string modName = reader.ReadString(); string name = reader.ReadString(); Mod mod = ModLoader.GetMod(modName); tables.legSlots[slot] = mod?.GetItem(name).item.legSlot ?? 0; } ReadContainerData(reader, tables); } //legacy load //Let's not care anymore. /*if ((flags[0] & 2) == 2) { * int count = reader.ReadInt32(); * for (int k = 0; k < count; k++) { * int id = reader.ReadInt32(); * TEItemFrame itemFrame = TileEntity.ByID[id] as TEItemFrame; * ItemIO.LoadLegacy(itemFrame.item, reader, true); * } * }*/ }
internal static ContainerTables Create() { ContainerTables tables = new ContainerTables(); tables.headSlots = new Dictionary <int, int>(); tables.bodySlots = new Dictionary <int, int>(); tables.legSlots = new Dictionary <int, int>(); return(tables); }
internal static ContainerTables Create() { ContainerTables tables = new ContainerTables { headSlots = new Dictionary <int, int>(), bodySlots = new Dictionary <int, int>(), legSlots = new Dictionary <int, int>() }; return(tables); }
internal static void ReadContainers(BinaryReader reader) { byte[] flags = new byte[1]; reader.Read(flags, 0, reader.ReadByte()); if ((flags[0] & 1) == 1) { ContainerTables tables = ContainerTables.Create(); int count = reader.ReadUInt16(); for (int k = 0; k < count; k++) { int slot = reader.ReadUInt16(); string modName = reader.ReadString(); string name = reader.ReadString(); Mod mod = ModLoader.GetMod(modName); tables.headSlots[slot] = mod == null ? 0 : mod.GetItem(name).item.headSlot; } count = reader.ReadUInt16(); for (int k = 0; k < count; k++) { int slot = reader.ReadUInt16(); string modName = reader.ReadString(); string name = reader.ReadString(); Mod mod = ModLoader.GetMod(modName); tables.bodySlots[slot] = mod == null ? 0 : mod.GetItem(name).item.bodySlot; } count = reader.ReadUInt16(); for (int k = 0; k < count; k++) { int slot = reader.ReadUInt16(); string modName = reader.ReadString(); string name = reader.ReadString(); Mod mod = ModLoader.GetMod(modName); tables.legSlots[slot] = mod == null ? 0 : mod.GetItem(name).item.legSlot; } ReadContainerData(reader, tables); } if ((flags[0] & 2) == 2) { int count = reader.ReadInt32(); for (int k = 0; k < count; k++) { int id = reader.ReadInt32(); TEItemFrame itemFrame = TileEntity.ByID[id] as TEItemFrame; ItemIO.ReadModItem(itemFrame.item, reader); itemFrame.item.stack = reader.ReadInt32(); } } }
internal static void ReadContainers(BinaryReader reader) { byte[] flags = new byte[1]; reader.Read(flags, 0, reader.ReadByte()); if ((flags[0] & 1) == 1) { var tables = ContainerTables.Create(); int count = reader.ReadUInt16(); for (int k = 0; k < count; k++) { tables.headSlots[reader.ReadUInt16()] = ModContent.TryFind(reader.ReadString(), reader.ReadString(), out ModItem item) ? item.item.headSlot : 0; } count = reader.ReadUInt16(); for (int k = 0; k < count; k++) { tables.bodySlots[reader.ReadUInt16()] = ModContent.TryFind(reader.ReadString(), reader.ReadString(), out ModItem item) ? item.item.bodySlot : 0; } count = reader.ReadUInt16(); for (int k = 0; k < count; k++) { tables.legSlots[reader.ReadUInt16()] = ModContent.TryFind(reader.ReadString(), reader.ReadString(), out ModItem item) ? item.item.legSlot : 0; } ReadContainerData(reader, tables); } //legacy load //Let's not care anymore. /*if ((flags[0] & 2) == 2) { * int count = reader.ReadInt32(); * for (int k = 0; k < count; k++) { * int id = reader.ReadInt32(); * TEItemFrame itemFrame = TileEntity.ByID[id] as TEItemFrame; * ItemIO.LoadLegacy(itemFrame.item, reader, true); * } * }*/ }
internal static ContainerTables Create() { ContainerTables tables = new ContainerTables(); tables.headSlots = new Dictionary<int, int>(); tables.bodySlots = new Dictionary<int, int>(); tables.legSlots = new Dictionary<int, int>(); return tables; }