Handle potentially missing ship log canvas

This commit is contained in:
Joshua Thome 2022-07-29 14:22:20 -05:00
parent 5d1a16f572
commit e74dbfb863

View File

@ -20,6 +20,8 @@ namespace NewHorizons.Handlers
var shipLogRoot = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas");
if (shipLogRoot != null)
{
var starChartLog = new GameObject("StarChartMode");
starChartLog.SetActive(false);
starChartLog.transform.parent = shipLogRoot.transform;
@ -47,6 +49,12 @@ namespace NewHorizons.Handlers
var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.GetComponent<ScreenPromptList>();
var oneShotSource = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent<OWAudioSource>();
ShipLogStarChartMode.Initialize(
centerPromptList,
upperRightPromptList,
oneShotSource);
}
_starSystemToFactID = new Dictionary<string, string>();
_factIDToStarSystem = new Dictionary<string, string>();
@ -57,11 +65,6 @@ namespace NewHorizons.Handlers
RegisterFactForSystem(system.Config.factRequiredForWarp, system.UniqueID);
}
}
ShipLogStarChartMode.Initialize(
centerPromptList,
upperRightPromptList,
oneShotSource);
}
public static bool CanWarp()
@ -98,7 +101,9 @@ namespace NewHorizons.Handlers
if (_factIDToStarSystem.TryGetValue(factID, out var systemUnlocked))
{
Logger.Log($"Just learned [{factID}] and unlocked [{systemUnlocked}]");
if (!Main.HasWarpDrive) Main.Instance.EnableWarpDrive();
if (!Main.HasWarpDrive)
Main.Instance.EnableWarpDrive();
if (ShipLogStarChartMode != null)
ShipLogStarChartMode.AddSystemCard(systemUnlocked);
}
}