public void BuildMap(WadFile wad, string mapname, bool benchmark = false) { this.benchmark = benchmark; this.wad = wad; textureTable = wad.textureTable; // Graphics setup. TODO: Move this to DoomGraphic, or somewhere else graphic related. paletteLookup = new Palette(wad.GetLump("PLAYPAL")).GetLookupTexture(); colormapLookup = new Colormap(wad.GetLump("COLORMAP")).GetLookupTexture(); doomMaterial = new Material(Shader.Find("Doom/Texture")); doomMaterial.SetTexture("_Palette", paletteLookup); doomMaterial.SetTexture("_Colormap", colormapLookup); pngMaterial = new Material(Shader.Find("Doom/Unlit Truecolor Texture")); skyMaterial = new Material(Shader.Find("Doom/Sky")); skyMaterial.SetTexture("_Palette", paletteLookup); skyMaterial.SetTexture("_RenderMap", GetTexture(skyName)); spriteMaterial = new Material(Shader.Find("Doom/Texture")); spriteMaterial.SetTexture("_Palette", paletteLookup); spriteMaterial.SetTexture("_Colormap", colormapLookup); map = MapData.Load(wad, mapname); if (map == null) { throw new Exception("Loading map failed."); } st = new SectorTriangulation(map, benchmark); levelObject = new GameObject(mapname); geoObject = new GameObject("Geometry"); thingsObject = new GameObject("Things"); geoObject.transform.SetParent(levelObject.transform); thingsObject.transform.SetParent(levelObject.transform); // Build thing information unclaimedThings = new List <int>(); for (int i = 0; i < map.things.Length; i++) { unclaimedThings.Add(i); } thingSectors = new Dictionary <int, Sector>(); CoroutineRunner cr = levelObject.AddComponent <CoroutineRunner>(); cr.dmb = this; cr.map = map; linesDone = false; sectorsDone = false; cr.StartCoroutine(cr.BuildLines()); cr.StartCoroutine(cr.BuildSectors()); levelObject.transform.localScale = new Vector3(SCALE, SCALE * 1.2f, SCALE); }