quantum-space-buddies/QSB/QSBSceneManager.cs
Mister_Nebula 6cfb546933 stuff
2020-11-25 09:54:52 +00:00

38 lines
1.1 KiB
C#

using OWML.Common;
using QSB.Utility;
using System;
namespace QSB
{
public static class QSBSceneManager
{
public static OWScene CurrentScene => LoadManager.GetCurrentScene();
public static bool IsInUniverse => InUniverse(CurrentScene);
public static event Action<OWScene, bool> OnSceneLoaded;
public static event Action<OWScene> OnUniverseSceneLoaded;
static QSBSceneManager()
{
LoadManager.OnCompleteSceneLoad += OnCompleteSceneLoad;
DebugLog.DebugWrite("Scene Manager ready.", MessageType.Success);
}
private static void OnCompleteSceneLoad(OWScene oldScene, OWScene newScene)
{
var universe = InUniverse(newScene);
OnSceneLoaded?.Invoke(newScene, universe);
if (universe)
{
OnUniverseSceneLoaded?.Invoke(newScene);
}
}
private static bool InUniverse(OWScene scene)
{
return scene == OWScene.SolarSystem || scene == OWScene.EyeOfTheUniverse;
}
}
}