public LevelVariables GetLevelVariables() { if (gameplayHeader.levelVarPointer == 0) { return(null); } byte[] levelVarBlock = ReadBlock(fileStream, gameplayHeader.levelVarPointer, 0x50); var levelVariables = new LevelVariables(levelVarBlock); return(levelVariables); }
public void Initialize(IServiceProvider serviceProvider, LevelVariables variables, GraphicsDevice graphicsDevice,Options options) { this.options = options; string[] data = variables.Dictionary[LV.InteractiveObjects].Split(':'); foreach (string iObject in data) { if (!string.IsNullOrEmpty(iObject.Trim())) { string[] temp = iObject.Split(','); try { InteractiveObjectsIDs id = (InteractiveObjectsIDs)Enum.Parse(typeof(InteractiveObjectsIDs), temp[0]); string objectData = ""; for (int i = 1; i < temp.Length - 1; i++) { objectData += temp[i] + ","; } objectData += temp[temp.Length - 1]; switch (id) { case InteractiveObjectsIDs.JumpPad: JumpPad pad = new JumpPad(); pad.Initialize(serviceProvider, options, graphicsDevice, objectData); interactiveObjects.Add(pad); break; } } catch (Exception e) { DebugManager.AddItem("Failed to load InteractiveObject: " + iObject + "\n" + e.Message, this.ToString(), new StackTrace(e), System.Drawing.Color.Red); FileManager.WriteInErrorLog(this.ToString(), "Failed to load InteractiveObject: " + iObject + "\n" + e.Message, e.GetType()); } } } }
//Engine file constructor public Level(string enginePath) { path = Path.GetDirectoryName(enginePath); // Engine elements using (EngineParser engineParser = new EngineParser(enginePath)) { game = engineParser.GetGameType(); //REMOVE THESE ASAP!!!!!111 renderDefBytes = engineParser.GetRenderDefBytes(); collBytesEngine = engineParser.GetCollisionBytes(); billboardBytes = engineParser.GetBillboardBytes(); soundConfigBytes = engineParser.GetSoundConfigBytes(); LOGGER.Debug("Parsing skybox..."); skybox = engineParser.GetSkyboxModel(); LOGGER.Debug("Success"); LOGGER.Debug("Parsing moby models..."); mobyModels = engineParser.GetMobyModels(); LOGGER.Debug("Added {0} moby models", mobyModels.Count); LOGGER.Debug("Parsing tie models..."); tieModels = engineParser.GetTieModels(); LOGGER.Debug("Added {0} tie models", tieModels.Count); LOGGER.Debug("Parsing shrub models..."); shrubModels = engineParser.GetShrubModels(); LOGGER.Debug("Added {0} shrub models", shrubModels.Count); LOGGER.Debug("Parsing weapons..."); gadgetModels = engineParser.GetGadgets(); LOGGER.Debug("Added {0} weapons", gadgetModels.Count); LOGGER.Debug("Parsing textures..."); textures = engineParser.GetTextures(); LOGGER.Debug("Added {0} textures", textures.Count); LOGGER.Debug("Parsing ties..."); ties = engineParser.GetTies(tieModels); LOGGER.Debug("Added {0} ties", ties.Count); LOGGER.Debug("Parsing Shrubs..."); shrubs = engineParser.GetShrubs(shrubModels); LOGGER.Debug("Added {0} shrubs", shrubs.Count); LOGGER.Debug("Parsing Lights..."); lights = engineParser.GetLights(); LOGGER.Debug("Added {0} lights", lights.Count); LOGGER.Debug("Parsing terrain elements..."); terrainEngine = engineParser.GetTerrainModel(); LOGGER.Debug("Added {0} terrain elements", terrainEngine.fragments.Count); LOGGER.Debug("Parsing player animations..."); playerAnimations = engineParser.GetPlayerAnimations((MobyModel)mobyModels[0]); LOGGER.Debug("Added {0} player animations", playerAnimations.Count); uiElements = engineParser.GetUiElements(); LOGGER.Debug("Added {0} ui elements", uiElements.Count); lightConfig = engineParser.GetLightConfig(); textureConfigMenus = engineParser.GetTextureConfigMenu(); collisionEngine = engineParser.GetCollisionModel(); unk3 = engineParser.GetUnk3Bytes(); unk4 = engineParser.GetUnk4Bytes(); unk5 = engineParser.GetUnk5Bytes(); unk8 = engineParser.GetUnk8Bytes(); unk9 = engineParser.GetUnk9Bytes(); } // Gameplay elements using (GameplayParser gameplayParser = new GameplayParser(game, path + @"/gameplay_ntsc")) { LOGGER.Debug("Parsing Level variables..."); levelVariables = gameplayParser.GetLevelVariables(); LOGGER.Debug("Parsing mobs..."); mobs = gameplayParser.GetMobies(mobyModels); LOGGER.Debug("Added {0} mobs", mobs.Count); LOGGER.Debug("Parsing splines..."); splines = gameplayParser.GetSplines(); LOGGER.Debug("Added {0} splines", splines.Count); LOGGER.Debug("Parsing languages..."); english = gameplayParser.GetEnglish(); ukenglish = gameplayParser.GetUkEnglish(); french = gameplayParser.GetFrench(); german = gameplayParser.GetGerman(); spanish = gameplayParser.GetSpanish(); italian = gameplayParser.GetItalian(); japanese = gameplayParser.GetJapanese(); korean = gameplayParser.GetKorean(); LOGGER.Debug("Parsing other gameplay assets..."); unk6 = gameplayParser.GetUnk6(); unk7 = gameplayParser.GetUnk7(); unk12 = gameplayParser.GetUnk12(); unk13 = gameplayParser.GetUnk13(); unk14 = gameplayParser.GetUnk14(); unk16 = gameplayParser.GetUnk16(); unk17 = gameplayParser.GetUnk17(); unk18 = gameplayParser.GetUnk18(); tieData = gameplayParser.GetTieData(ties.Count); shrubData = gameplayParser.GetShrubData(shrubs.Count); tieGroupData = gameplayParser.GetTieGroups(); shrubGroupData = gameplayParser.GetShrubGroups(); areasData = gameplayParser.GetAreasData(); directionalLights = gameplayParser.GetDirectionalLights(); type0Cs = gameplayParser.GetType0Cs(); spheres = gameplayParser.GetSpheres(); cylinders = gameplayParser.GetCylinders(); type4Cs = gameplayParser.GetType4Cs(); type7Cs = gameplayParser.GetType7Cs(); type80s = gameplayParser.GetType80(); type88s = gameplayParser.GetType88s(); type50s = gameplayParser.GetType50s(); type5Cs = gameplayParser.GetType5Cs(); pVars = gameplayParser.GetPvars(mobs); cuboids = gameplayParser.GetCuboids(); gameCameras = gameplayParser.GetGameCameras(); mobyIds = gameplayParser.GetMobyIds(); tieIds = gameplayParser.GetTieIds(); shrubIds = gameplayParser.GetShrubIds(); occlusionData = gameplayParser.GetOcclusionData(); } terrainChunks = new List <Terrain>(); collisionChunks = new List <Model>(); collBytesChunks = new List <byte[]>(); for (int i = 0; i < 5; i++) { var chunkPath = Path.Join(path, @"chunk" + i + ".ps3"); if (!File.Exists(chunkPath)) { continue; } using (ChunkParser chunkParser = new ChunkParser(chunkPath, game)) { terrainChunks.Add(chunkParser.GetTerrainModels()); collisionChunks.Add(chunkParser.GetCollisionModel()); collBytesChunks.Add(chunkParser.GetCollBytes()); } } List <string> armorPaths = ArmorHeader.FindArmorFiles(game, enginePath); armorModels = new List <Model>(); armorTextures = new List <List <Texture> >(); foreach (string armor in armorPaths) { LOGGER.Debug("Looking for armor data in {0}", armor); List <Texture> tex; MobyModel model; using (ArmorParser parser = new ArmorParser(game, armor)) { tex = parser.GetTextures(); model = parser.GetArmor(); } string vram = armor.Replace(".ps3", ".vram"); using (VramParser parser = new VramParser(vram)) { parser.GetTextures(tex); } if (model != null) { armorModels.Add(model); } armorTextures.Add(tex); } string gadgetPath = GadgetHeader.FindGadgetFile(game, enginePath); gadgetTextures = new List <Texture>(); if (gadgetPath != "") { LOGGER.Debug("Looking for gadget data in {0}", gadgetPath); using (GadgetParser parser = new GadgetParser(game, gadgetPath)) { gadgetModels.AddRange(parser.GetModels()); gadgetTextures.AddRange(parser.GetTextures()); } using (VramParser parser = new VramParser(gadgetPath.Replace(".ps3", ".vram"))) { parser.GetTextures(gadgetTextures); } } List <string> missionPaths = MissionHeader.FindMissionFiles(game, enginePath); missions = new List <Mission>(); for (int i = 0; i < missionPaths.Count; i++) { string missionPath = missionPaths[i]; string vramPath = missionPath.Replace(".ps3", ".vram"); if (!File.Exists(vramPath)) { LOGGER.Warn("Could not find .vram file for {0}", missionPath); continue; } LOGGER.Debug("Looking for mission data in {0}", missionPath); Mission mission = new Mission(i); using (MissionParser parser = new MissionParser(game, missionPath)) { mission.models = parser.GetModels(); mission.textures = parser.GetTextures(); } using (VramParser parser = new VramParser(vramPath)) { parser.GetTextures(mission.textures); } missions.Add(mission); } using (VramParser vramParser = new VramParser(path + @"/vram.ps3")) { vramParser.GetTextures(textures); } LOGGER.Info("Level parsing done"); valid = true; }
//Engine file constructor public Level(string enginePath) { path = Path.GetDirectoryName(enginePath); // Engine elements using (EngineParser engineParser = new EngineParser(enginePath)) { game = engineParser.DetectGame(); //REMOVE THESE ASAP!!!!!111 renderDefBytes = engineParser.GetRenderDefBytes(); collBytes = engineParser.GetCollisionBytes(); billboardBytes = engineParser.GetBillboardBytes(); soundConfigBytes = engineParser.GetSoundConfigBytes(); Console.WriteLine("Parsing skybox..."); skybox = engineParser.GetSkyboxModel(); Console.WriteLine("Success"); Console.WriteLine("Parsing moby models..."); mobyModels = engineParser.GetMobyModels(); Console.WriteLine("Added " + mobyModels.Count + " moby models"); Console.WriteLine("Parsing tie models..."); tieModels = engineParser.GetTieModels(); Console.WriteLine("Added " + tieModels.Count + " tie models"); Console.WriteLine("Parsing shrub models..."); shrubModels = engineParser.GetShrubModels(); Console.WriteLine("Added " + shrubModels.Count + " shrub models"); Console.WriteLine("Parsing weapons..."); weaponModels = engineParser.GetWeapons(); Console.WriteLine("Added " + weaponModels.Count + " weapons"); Console.WriteLine("Parsing textures..."); textures = engineParser.GetTextures(); Console.WriteLine("Added " + textures.Count + " textures"); Console.WriteLine("Parsing ties..."); ties = engineParser.GetTies(tieModels); Console.WriteLine("Added " + ties.Count + " ties"); Console.WriteLine("Parsing Shrubs..."); shrubs = engineParser.GetShrubs(shrubModels); Console.WriteLine("Added " + shrubs.Count + " Shrubs"); Console.WriteLine("Parsing Lights..."); lights = engineParser.GetLights(); Console.WriteLine("Added " + lights.Count + " lights"); Console.WriteLine("Parsing terrain elements..."); terrains = engineParser.GetTerrainModels(); Console.WriteLine("Added " + terrains?.Count + " terrain elements"); Console.WriteLine("Parsing player animations..."); playerAnimations = engineParser.GetPlayerAnimations((MobyModel)mobyModels[0]); Console.WriteLine("Added " + playerAnimations?.Count + " player animations"); uiElements = engineParser.GetUiElements(); Console.WriteLine("Added " + uiElements?.Count + " ui elements"); lightConfig = engineParser.GetLightConfig(); textureConfigMenus = engineParser.GetTextureConfigMenu(); collisionModel = engineParser.GetCollisionModel(); } // Gameplay elements using (GameplayParser gameplayParser = new GameplayParser(game, path + @"/gameplay_ntsc")) { Console.WriteLine("Parsing Level variables..."); levelVariables = gameplayParser.GetLevelVariables(); Console.WriteLine("Parsing mobs..."); mobs = gameplayParser.GetMobies(game, mobyModels); Console.WriteLine("Added " + mobs?.Count + " mobs"); Console.WriteLine("Parsing splines..."); splines = gameplayParser.GetSplines(); //Console.WriteLine("Added " + splines.Count + " splines"); Console.WriteLine("Parsing languages..."); english = gameplayParser.GetEnglish(); lang2 = gameplayParser.GetLang2(); french = gameplayParser.GetFrench(); german = gameplayParser.GetGerman(); spanish = gameplayParser.GetSpanish(); italian = gameplayParser.GetItalian(); lang7 = gameplayParser.GetLang7(); lang8 = gameplayParser.GetLang8(); Console.WriteLine("Parsing other gameplay assets..."); unk6 = gameplayParser.GetUnk6(); unk7 = gameplayParser.GetUnk7(); unk13 = gameplayParser.GetUnk13(); unk17 = gameplayParser.GetUnk17(); unk14 = gameplayParser.GetUnk14(); tieData = gameplayParser.GetTieData(ties.Count); shrubData = gameplayParser.getShrubData(shrubs.Count); type04s = gameplayParser.GetType04s(); type0Cs = gameplayParser.GetType0Cs(); type64s = gameplayParser.GetType64s(); type68s = gameplayParser.GetType68s(); type7Cs = gameplayParser.GetType7Cs(); type80s = gameplayParser.GetType80(); type88s = gameplayParser.GetType88s(); type50s = gameplayParser.GetType50s(); type5Cs = gameplayParser.GetType5Cs(); pVars = gameplayParser.GetPvars(mobs); cuboids = gameplayParser.GetCuboids(); gameCameras = gameplayParser.GetGameCameras(); mobyIds = gameplayParser.GetMobyIds(); tieIds = gameplayParser.GetTieIds(); shrubIds = gameplayParser.GetShrubIds(); occlusionData = gameplayParser.GetOcclusionData(); } VramParser vramParser = new VramParser(path + @"/vram.ps3"); if (!vramParser.valid) { valid = false; return; } vramParser.GetTextures(textures); vramParser.Close(); Console.WriteLine("Level parsing done"); valid = true; }