From cdf977d652c4b5fc69c1fede89cb69829d0c04b5 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sat, 15 Feb 2025 02:10:57 -0500 Subject: [PATCH] keepLoaded and sectorOccupantsUpdated --- .../External/Modules/Props/DetailInfo.cs | 1 + NewHorizons/Handlers/TitleSceneHandler.cs | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/NewHorizons/External/Modules/Props/DetailInfo.cs b/NewHorizons/External/Modules/Props/DetailInfo.cs index 4c4ca70c..6662586d 100644 --- a/NewHorizons/External/Modules/Props/DetailInfo.cs +++ b/NewHorizons/External/Modules/Props/DetailInfo.cs @@ -61,6 +61,7 @@ namespace NewHorizons.External.Modules.Props public DetailInfo(SimplifiedDetailInfo info) { + keepLoaded = true; JsonConvert.PopulateObject(JsonConvert.SerializeObject(info), this); } diff --git a/NewHorizons/Handlers/TitleSceneHandler.cs b/NewHorizons/Handlers/TitleSceneHandler.cs index db3ffd4e..29309224 100644 --- a/NewHorizons/Handlers/TitleSceneHandler.cs +++ b/NewHorizons/Handlers/TitleSceneHandler.cs @@ -27,7 +27,11 @@ namespace NewHorizons.Handlers public static void Init() { var scene = SearchUtilities.Find("Scene"); + var background = SearchUtilities.Find("Scene/Background"); + var planetPivot = SearchUtilities.Find("Scene/Background/PlanetPivot"); scene.AddComponent(); + background.AddComponent(); + planetPivot.AddComponent(); var planetRoot = SearchUtilities.Find("Scene/Background/PlanetPivot/PlanetRoot"); var campfire = SearchUtilities.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire"); @@ -132,7 +136,6 @@ namespace NewHorizons.Handlers var background = SearchUtilities.Find("Scene/Background"); var menuPlanet = SearchUtilities.Find("Scene/Background/PlanetPivot"); - var sector = background.GetComponentInParent(); if (config.Background != null) { @@ -145,7 +148,7 @@ namespace NewHorizons.Handlers { foreach (var simplifiedDetail in config.Background.details) { - DetailBuilder.Make(background, sector, mod, new DetailInfo(simplifiedDetail)); + DetailBuilder.Make(background, background.GetComponentInParent(), mod, new DetailInfo(simplifiedDetail)); } } @@ -164,7 +167,7 @@ namespace NewHorizons.Handlers { foreach (var simplifiedDetail in config.MenuPlanet.details) { - DetailBuilder.Make(menuPlanet, sector, mod, new DetailInfo(simplifiedDetail)); + DetailBuilder.Make(menuPlanet, menuPlanet.GetComponentInParent(), mod, new DetailInfo(simplifiedDetail)); } } @@ -509,8 +512,16 @@ namespace NewHorizons.Handlers { public override void Awake() { + _subsectors = new List(); _occupantMask = DynamicOccupant.Player; SectorManager.RegisterSector(this); + _parentSector = GetComponentInParent(); + if (_parentSector != null && _parentSector != this) _parentSector.AddSubsector(this); + } + + public void Start() + { + OnSectorOccupantsUpdated.Invoke(); } } }