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); }; }