public void LoadLevel(string level) { LEVEL_NAME = level; if (levelParent != null) { Destroy(levelParent); } //Load level assets Result = CATHODE.AlienLevel.Load(LEVEL_NAME, SharedVals.instance.PathToEnv); //Load all textures - TODO: flip array and load V2 first? - I suspect V1 is first as A:I loads V1s passively throughout, and then V2s by zone LoadedTexturesGlobal = new AlienTexture[GlobalTextures.BIN.Header.EntryCount]; LoadedTexturesLevel = new AlienTexture[Result.LevelTextures.BIN.Header.EntryCount]; bool[] TextureLoadTrackerGlobal = new bool[GlobalTextures.BIN.Header.EntryCount]; bool[] TextureLoadTrackerLevel = new bool[Result.LevelTextures.BIN.Header.EntryCount]; for (int i = 0; i < GlobalTextures.PAK.Header.EntryCount; i++) { int binIndex = GlobalTextures.PAK.Entries[i].BINIndex; LoadedTexturesGlobal[binIndex] = LoadTexture(i, 2, !TextureLoadTrackerGlobal[binIndex]); TextureLoadTrackerGlobal[binIndex] = true; } for (int i = 0; i < Result.LevelTextures.PAK.Header.EntryCount; i++) { int binIndex = Result.LevelTextures.PAK.Entries[i].BINIndex; LoadedTexturesLevel[binIndex] = LoadTexture(i, 0, !TextureLoadTrackerLevel[binIndex]); TextureLoadTrackerLevel[binIndex] = true; } //Load all materials LoadedMaterials = new Material[Result.ModelsMTL.Header.MaterialCount]; for (int i = 0; i < Result.ModelsMTL.Header.MaterialCount; i++) { LoadMaterial(i); } //Load all models LoadedModels = new GameObjectHolder[Result.ModelsBIN.Header.ModelCount]; for (int i = 0; i < Result.ModelsPAK.Models.Count; i++) { LoadModel(i); } //Populate the level with "movers" levelParent = new GameObject(LEVEL_NAME); for (int i = 0; i < Result.ModelsMVR.Entries.Count; i++) { GameObject thisParent = new GameObject("MVR: " + i + "/" + Result.ModelsMVR.Entries[i].REDSIndex + "/" + Result.ModelsMVR.Entries[i].ModelCount); Matrix4x4 m = Result.ModelsMVR.Entries[i].Transform; thisParent.transform.position = m.GetColumn(3); thisParent.transform.rotation = Quaternion.LookRotation(m.GetColumn(2), m.GetColumn(1)); thisParent.transform.localScale = new Vector3(m.GetColumn(0).magnitude, m.GetColumn(1).magnitude, m.GetColumn(2).magnitude); thisParent.transform.parent = levelParent.transform; for (int x = 0; x < Result.ModelsMVR.Entries[i].ModelCount; x++) { CATHODE.Misc.alien_reds_entry RenderableElement = Result.RenderableREDS.Entries[(int)Result.ModelsMVR.Entries[i].REDSIndex + x]; SpawnModel(RenderableElement.ModelIndex, RenderableElement.MaterialLibraryIndex, thisParent); } } //Pull content from COMMANDS //CommandsLoader cmdLoader = gameObject.AddComponent<CommandsLoader>(); //StartCoroutine(cmdLoader.LoadCommandsPAK(levelPath)); LevelLoadCompleted?.Invoke(Result); }
/* Data setters */ public void SetEntry(int i, alien_reds_entry content) { entries[i] = content; }