using OWML.Common; using QSB.Utility; using QSB.WorldSync; using System; namespace QSB { public static class QSBSceneManager { public static OWScene CurrentScene => LoadManager.GetCurrentScene(); public static bool IsInUniverse => InUniverse(CurrentScene); public static event Action OnSceneLoaded; public static event Action OnUniverseSceneLoaded; static QSBSceneManager() { LoadManager.OnCompleteSceneLoad += OnCompleteSceneLoad; DebugLog.DebugWrite("Scene Manager ready.", MessageType.Success); } private static void OnCompleteSceneLoad(OWScene oldScene, OWScene newScene) { DebugLog.DebugWrite($"COMPLETE SCENE LOAD ({oldScene} -> {newScene})", MessageType.Info); if (QSBCore.IsInMultiplayer) { WorldObjectManager.Rebuild(newScene); } var universe = InUniverse(newScene); OnSceneLoaded?.SafeInvoke(newScene, universe); if (universe) { OnUniverseSceneLoaded?.SafeInvoke(newScene); } } private static bool InUniverse(OWScene scene) => scene == OWScene.SolarSystem || scene == OWScene.EyeOfTheUniverse; } }