public static PhxRuntimeEnvironment Create(PhxPath envPath, PhxPath fallbackPath = null, bool initMatch = true) { if (!envPath.Exists()) { Debug.LogErrorFormat("Given environment path '{0}' doesn't exist!", envPath); return(null); } if (fallbackPath == null) { fallbackPath = envPath; } Debug.Assert(fallbackPath.Exists()); PhxAnimationLoader.ClearDB(); GameLuaEvents.Clear(); PhxRuntimeEnvironment rt = new PhxRuntimeEnvironment(envPath, fallbackPath); rt.ScheduleLVLRel("core.lvl"); rt.ScheduleLVLRel("shell.lvl"); rt.ScheduleLVLRel("common.lvl"); rt.ScheduleLVLRel("mission.lvl"); rt.ScheduleSoundBankRel("sound/common.bnk"); rt.RTScene = new PhxRuntimeScene(rt, rt.EnvCon); rt.Match = initMatch ? new PhxRuntimeMatch() : null; rt.Timers = new PhxTimerDB(); PhxAnimationLoader.Con = rt.EnvCon; return(rt); }
public void EnterSWBF2Map(string mapScript) { Debug.Assert(Env == null || Env.IsLoaded); ShowLoadscreen(); RemoveMenu(false); PhxPath envPath = StdLVLPC; if (RegisteredAddons.TryGetValue(mapScript, out string addonName)) { envPath = AddonPath / addonName / "data/_lvl_pc"; } if (UnitySceneName != null) { SceneManager.UnloadSceneAsync(UnitySceneName); UnitySceneName = null; } Env?.Delete(); Env = PhxRuntimeEnvironment.Create(envPath, StdLVLPC); Env.ScheduleLVLRel("load/common.lvl"); Env.OnLoadscreenLoaded += OnLoadscreenTextureLoaded; Env.OnLoaded += OnEnvLoaded; Env.OnExecuteMain += OnEnvExecutionMain; Env.Run(mapScript, "ScriptInit", "ScriptPostLoad"); }
public void EnterMainMenu(bool bInit = false) { Debug.Assert(Env == null || Env.IsLoaded); MapRotation.Clear(); MapRotationIdx = -1; bInitMainMenu = bInit; ShowLoadscreen(bInit); RemoveMenu(false); if (UnitySceneName != null) { SceneManager.UnloadSceneAsync(UnitySceneName); UnitySceneName = null; } Env?.Delete(); Env = PhxRuntimeEnvironment.Create(StdLVLPC); if (!bInit) { Env.ScheduleLVLRel("load/gal_con.lvl"); } RegisteredAddons.Clear(); ExploreAddons(); Env.OnExecuteMain += OnMainMenuExecution; Env.OnLoaded += OnMainMenuLoaded; Env.Run("missionlist"); }
public void EnterUnityScene(string sceneName) { Debug.Assert(Env == null || Env.IsLoaded); ShowLoadscreen(); RemoveMenu(false); if (UnitySceneName != null) { SceneManager.UnloadSceneAsync(UnitySceneName); UnitySceneName = null; } SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); UnitySceneName = sceneName; SceneManager.sceneLoaded += (Scene scene, LoadSceneMode mode) => { PhxUnityScene sceneInit = FindObjectOfType <PhxUnityScene>(); // for some reason, this event fires twice... // and only the second time, the script is found if (sceneInit == null) { return; } Env?.Delete(); Env = PhxRuntimeEnvironment.Create(StdLVLPC); Env.ScheduleLVLRel("load/common.lvl"); Env.ScheduleLVLRel("ingame.lvl"); if (sceneInit.ScheduleLVLs != null) { for (int i = 0; i < sceneInit.ScheduleLVLs.Length; ++i) { Env.ScheduleLVLRel(sceneInit.ScheduleLVLs[i]); } } Env.OnLoadscreenLoaded += OnLoadscreenTextureLoaded; Env.OnLoaded += OnEnvLoaded; Env.OnExecuteMain += OnEnvExecutionMain; Env.Run(null); }; }