private void OnLevelLoaded(alien_level data) { levelName.text = levelLoader.CurrentLevelName; levelNameToLoad.text = levelLoader.CurrentLevelName; mvrIndex.text = "0"; LoadMVR(0); }
void Start() { levelData = CATHODE.AlienLevel.Load(SharedVals.instance.LevelName, SharedVals.instance.PathToEnv); levelGO = new GameObject(SharedVals.instance.LevelName); LoadTextureAssets(); LoadMeshAssets(); LoadMaterialAssets(); LoadFlowgraphAssets(); for (int i = 0; i < levelData.CommandsPAK.EntryPoints.Count; i++) { GameObject flowgraphGO = PrefabUtility.InstantiatePrefab(Resources.Load <GameObject>(GetFlowgraphAssetPath(levelData.CommandsPAK.EntryPoints[i], true))) as GameObject; flowgraphGO.name = levelData.CommandsPAK.EntryPoints[i].name; flowgraphGO.transform.parent = levelGO.transform; } PrefabUtility.SaveAsPrefabAsset(levelGO, "Assets/Resources/" + SharedVals.instance.LevelName + "/" + SharedVals.instance.LevelName + ".prefab"); }
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); }
public static alien_level Load(string LEVEL_NAME, string ENV_PATH) { alien_level Result = new alien_level(); string levelPath = ENV_PATH + "/PRODUCTION/" + LEVEL_NAME; /*** WORLD ***/ Result.ModelsMVR = new CATHODE.Models.ModelsMVR(levelPath + "/WORLD/MODELS.MVR"); Result.CommandsPAK = new CATHODE.Commands.CommandsPAK(levelPath + "/WORLD/COMMANDS.PAK"); Result.RenderableREDS = new CATHODE.Misc.RenderableElementsBIN(levelPath + "/WORLD/REDS.BIN"); Result.ResourcesBIN = new CATHODE.Misc.ResourcesBIN(levelPath + "/WORLD/RESOURCES.BIN"); Result.PhysicsMap = new CATHODE.Misc.PhysicsMAP(levelPath + "/WORLD/PHYSICS.MAP"); Result.EnvironmentMap = new CATHODE.Misc.EnvironmentMapBIN(levelPath + "/WORLD/ENVIRONMENTMAP.BIN"); Result.CollisionMap = new CATHODE.Misc.CollisionMAP(levelPath + "/WORLD/COLLISION.MAP"); Result.EnvironmentAnimation = CATHODE.Misc.EnvironmentAnimationDAT.Load(levelPath + "/WORLD/ENVIRONMENT_ANIMATION.DAT"); //ALPHALIGHT_LEVEL.BIN //BEHAVIOR_TREE.DB //CHARACTERACCESSORYSETS.BIN //COLLISION.BIN //COLLISION.HKX //COLLISION.HKX64 //CUTSCENE_DIRECTOR_DATA.BIN //EXCLUSIVE_MASTER_RESOURCE_INDICES //LEVEL.STR //LIGHTS.BIN //MATERIAL_MAPPINGS.PAK //MORPH_TARGET_DB.BIN //OCCLUDER_TRIANGLE_BVH.BIN //PATH_BARRIER_RESOURCES //PHYSICS.HKX //PHYSICS.HKX64 //RADIOSITY_COLLISION_MAPPING.BIN //SNDNODENETWORK.DAT //SOUNDBANKDATA.DAT //SOUNDDIALOGUELOOKUPS.DAT //SOUNDENVIRONMENTDATA.DAT //SOUNDEVENTDATA.DAT //SOUNDFLASHMODELS.DAT //SOUNDLOADZONES.DAT //STATE_x/ASSAULT_POSITIONS //STATE_x/COVER //STATE_x/CRAWL_SPACE_SPOTTING_POSITIONS //STATE_x/NAV_MESH //STATE_x/SPOTTING_POSITIONS //STATE_x/TRAVERSAL /*** RENDERABLE ***/ Result.ModelsCST = File.ReadAllBytes(levelPath + "/RENDERABLE/LEVEL_MODELS.CST"); Result.ModelsMTL = CATHODE.Models.ModelsMTL.Load(levelPath + "/RENDERABLE/LEVEL_MODELS.MTL"); Result.ModelsPAK = CATHODE.Models.ModelPAK.Load(levelPath + "/RENDERABLE/LEVEL_MODELS.PAK"); Result.ModelsBIN = CATHODE.Models.ModelBIN.Load(levelPath + "/RENDERABLE/MODELS_LEVEL.BIN"); Result.ShadersPAK = CATHODE.Shaders.ShadersPAK.Load(levelPath + "/RENDERABLE/LEVEL_SHADERS_DX11.PAK"); //Result.ShadersBIN = CATHODE.Shaders.ShadersBIN.Load(levelPath + "/RENDERABLE/LEVEL_SHADERS_DX11_BIN.PAK"); Result.ShadersIDXRemap = CATHODE.Shaders.IDXRemap.Load(levelPath + "/RENDERABLE/LEVEL_SHADERS_DX11_IDX_REMAP.PAK"); Result.LevelTextures = CATHODE.Textures.TexturePAK.Load(levelPath + "/RENDERABLE/LEVEL_TEXTURES.ALL.PAK", levelPath + "/RENDERABLE/LEVEL_TEXTURE_HEADERS.ALL.BIN"); //LEVEL_TEXTURES.DX11.PAK //RADIOSITY_INSTANCE_MAP.TXT //RADIOSITY_RUNTIME.BIN //DAMAGE/DAMAGE_MAPPING_INFO.BIN //GALAXY/GALAXY.DEFINITION_BIN //GALAXY/GALAXY.ITEMS_BIN return(Result); }