Texture2D GetFlat(string name) { name = name.ToUpper(); if (flatCache == null) { flatCache = new Dictionary <string, Texture2D>(); } if (flatCache.ContainsKey(name)) { return(flatCache[name]); } DoomFlat flat; if (wad.Contains(name)) { Texture2D output; DataType type = wad.DetectType(name); if (type == DataType.DoomFlat) { flat = new DoomFlat(wad.GetLump(name)); output = flat.ToRenderMap(); lastTexturePNG = false; } else if (type == DataType.PNG) { output = new Texture2D(2, 2, TextureFormat.ARGB32, false); ImageConversion.LoadImage(output, wad.GetLump(name)); output.filterMode = FilterMode.Point; lastTexturePNG = true; } else { throw new Exception("Unknown flat type: " + name); } flatCache.Add(name, output); return(output); } else { if (textureTable.Contains(name)) { return(DoomGraphic.BuildTexture(name, wad, textureTable)); } } throw new Exception("Cannot find flat: " + name); }
Texture2D GetTexture(string name, bool tryUpper = true) { if (textureTable.Contains(name)) { lastTexturePNG = false; return(DoomGraphic.BuildTexture(name, wad, textureTable)); } else { if (wad.Contains(name)) { DataType type = wad.DetectType(name); if (type == DataType.DoomFlat) { lastTexturePNG = false; return(new DoomFlat(wad.GetLump(name)).ToRenderMap()); } else if (type == DataType.PNG) { Texture2D image = new Texture2D(2, 2, TextureFormat.ARGB32, false); ImageConversion.LoadImage(image, wad.GetLump(name)); image.filterMode = FilterMode.Point; lastTexturePNG = true; return(image); } else { throw new Exception("Unknown texture type: " + name); } } else { if (tryUpper) { return(GetTexture(name.ToUpper(), false)); } throw new Exception("Cannot find texture: " + name); } } }
Texture2D GetTexture(string name) { return(DoomGraphic.BuildTexture(name, wad, textureTable)); }