From cfaa0dc55adb6288decab0cd00e8581fc2223edc Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sat, 15 Feb 2025 03:31:14 -0500 Subject: [PATCH] add an event --- NewHorizons/Handlers/TitleSceneHandler.cs | 9 +++++++++ NewHorizons/INewHorizons.cs | 5 +++++ NewHorizons/Main.cs | 1 + NewHorizons/NewHorizonsApi.cs | 1 + 4 files changed, 16 insertions(+) diff --git a/NewHorizons/Handlers/TitleSceneHandler.cs b/NewHorizons/Handlers/TitleSceneHandler.cs index 9daf2645..4be176c8 100644 --- a/NewHorizons/Handlers/TitleSceneHandler.cs +++ b/NewHorizons/Handlers/TitleSceneHandler.cs @@ -91,6 +91,15 @@ namespace NewHorizons.Handlers // default to displaying nh planets if no title screen builders else DisplayBodiesOnTitleScreen(); + + try + { + Main.Instance.OnTitleScreenLoaded?.Invoke(); + } + catch (Exception e) + { + NHLogger.LogError($"Error in event handler for OnTitleScreenLoaded: {e}"); + } } public static void InitSubtitles() diff --git a/NewHorizons/INewHorizons.cs b/NewHorizons/INewHorizons.cs index 5a1a9b09..82f7509c 100644 --- a/NewHorizons/INewHorizons.cs +++ b/NewHorizons/INewHorizons.cs @@ -73,6 +73,11 @@ namespace NewHorizons /// Gives the name of the planet that was just loaded. /// UnityEvent GetBodyLoadedEvent(); + + /// + /// An event invoked when NH has finished building the title screen. + /// + UnityEvent GetTitleScreenLoadedEvent(); #endregion #region Querying configs diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index d471f1d4..25e2303d 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -111,6 +111,7 @@ namespace NewHorizons public StarSystemEvent OnChangeStarSystem = new(); public StarSystemEvent OnStarSystemLoaded = new(); public StarSystemEvent OnPlanetLoaded = new(); + public UnityEvent OnTitleScreenLoaded = new(); /// /// Depending on platform, the AsyncOwnershipStatus might not be ready by the time we go to check it. diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index e2407347..ee3da69f 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -90,6 +90,7 @@ namespace NewHorizons public UnityEvent GetChangeStarSystemEvent() => Main.Instance.OnChangeStarSystem; public UnityEvent GetStarSystemLoadedEvent() => Main.Instance.OnStarSystemLoaded; public UnityEvent GetBodyLoadedEvent() => Main.Instance.OnPlanetLoaded; + public UnityEvent GetTitleScreenLoadedEvent() => Main.Instance.OnTitleScreenLoaded; public bool SetDefaultSystem(string name) {