2020-11-04 09:34:01 +00:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using System;
|
2020-08-16 20:39:21 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB
|
|
|
|
|
{
|
2020-12-14 21:20:53 +00:00
|
|
|
|
public static class QSBSceneManager
|
|
|
|
|
{
|
|
|
|
|
public static OWScene CurrentScene => LoadManager.GetCurrentScene();
|
2020-08-16 20:39:21 +00:00
|
|
|
|
|
2020-12-14 21:20:53 +00:00
|
|
|
|
public static bool IsInUniverse => InUniverse(CurrentScene);
|
2020-08-16 20:39:21 +00:00
|
|
|
|
|
2020-12-14 21:20:53 +00:00
|
|
|
|
public static event Action<OWScene, bool> OnSceneLoaded;
|
|
|
|
|
public static event Action<OWScene> OnUniverseSceneLoaded;
|
2020-08-16 20:39:21 +00:00
|
|
|
|
|
2020-12-14 21:20:53 +00:00
|
|
|
|
static QSBSceneManager()
|
|
|
|
|
{
|
|
|
|
|
LoadManager.OnCompleteSceneLoad += OnCompleteSceneLoad;
|
|
|
|
|
DebugLog.DebugWrite("Scene Manager ready.", MessageType.Success);
|
|
|
|
|
}
|
2020-08-16 20:39:21 +00:00
|
|
|
|
|
2020-12-14 21:20:53 +00:00
|
|
|
|
private static void OnCompleteSceneLoad(OWScene oldScene, OWScene newScene)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.DebugWrite($"COMPLETE SCENE LOAD ({oldScene} -> {newScene})", MessageType.Info);
|
|
|
|
|
var universe = InUniverse(newScene);
|
2021-02-06 22:03:10 +00:00
|
|
|
|
OnSceneLoaded?.SafeInvoke(newScene, universe);
|
2020-12-14 21:20:53 +00:00
|
|
|
|
if (universe)
|
|
|
|
|
{
|
2021-02-06 22:14:29 +00:00
|
|
|
|
OnUniverseSceneLoaded?.SafeInvoke(newScene);
|
2020-12-14 21:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-16 20:39:21 +00:00
|
|
|
|
|
2020-12-14 21:20:53 +00:00
|
|
|
|
private static bool InUniverse(OWScene scene) =>
|
|
|
|
|
scene == OWScene.SolarSystem || scene == OWScene.EyeOfTheUniverse;
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|