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 20:41:56 +00:00
|
|
|
|
public static class QSBSceneManager
|
|
|
|
|
{
|
|
|
|
|
public static OWScene CurrentScene => LoadManager.GetCurrentScene();
|
2020-08-16 20:39:21 +00:00
|
|
|
|
|
2020-12-14 20:41:56 +00:00
|
|
|
|
public static bool IsInUniverse => InUniverse(CurrentScene);
|
2020-08-16 20:39:21 +00:00
|
|
|
|
|
2020-12-14 20:41:56 +00:00
|
|
|
|
public static event Action<OWScene, bool> OnSceneLoaded;
|
2020-12-03 08:28:05 +00:00
|
|
|
|
|
2020-12-14 20:41:56 +00:00
|
|
|
|
public static event Action<OWScene> OnUniverseSceneLoaded;
|
2020-08-16 20:39:21 +00:00
|
|
|
|
|
2020-12-14 20:41:56 +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 20:41:56 +00:00
|
|
|
|
private static void OnCompleteSceneLoad(OWScene oldScene, OWScene newScene)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.DebugWrite($"COMPLETE SCENE LOAD ({oldScene} -> {newScene})", MessageType.Info);
|
|
|
|
|
var universe = InUniverse(newScene);
|
|
|
|
|
OnSceneLoaded?.Invoke(newScene, universe);
|
|
|
|
|
if (universe)
|
|
|
|
|
{
|
|
|
|
|
OnUniverseSceneLoaded?.Invoke(newScene);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-16 20:39:21 +00:00
|
|
|
|
|
2020-12-14 20:41:56 +00:00
|
|
|
|
private static bool InUniverse(OWScene scene) =>
|
|
|
|
|
scene == OWScene.SolarSystem || scene == OWScene.EyeOfTheUniverse;
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|