/// <summary> /// Creates a new texture pool /// </summary> /// <param name="wad"></param> /// <param name="texture1"></param> /// <param name="pnames"></param> public WadTexturePool(WadFile wad, Lump texture1, Lump pnames) { this.wad = wad; int count = pnames.ReadInt32(0); textures = new Dictionary <string, Graphic>(count); for (int i = 0; i < count; i++) { string name = pnames.ReadString(i * 8 + 4, 8); int index = name.IndexOf('\0'); if (index != -1) { name = name.Remove(index); } textures.Add(name, new Graphic(wad, name)); } count = texture1.ReadInt32(0); mapTextures = new Dictionary <string, MapTexture>(count); using (MemoryStream stream = texture1.GetByteStream()) { for (int i = 0; i < count; i++) { long position = stream.Position; stream.Position = texture1.ReadInt32(4 + i * 4); MapTexture texture = new MapTexture(this, stream); mapTextures.Add(texture.Name, texture); stream.Position = position; } } }
/// <summary> /// Creates a new doom graphic /// </summary> /// <param name="lump"></param> /// <param name="pallete"></param> public DoomGraphic(Lump lump, DoomPallete pallete) { Width = (ushort)lump.ReadInt16(0); Height = (ushort)lump.ReadInt16(2); OffsetX = lump.ReadInt16(4); OffsetY = lump.ReadInt16(6); columns = new int[Width]; for (int i = 0; i < Width; i++) { int index = lump.ReadInt32(8 + i * 4); columns[i] = index; } this.pallete = pallete; this.lump = lump.CopyRaw(); }