Null check for profile

This commit is contained in:
Noah Pilarski 2025-01-29 00:10:21 -05:00
parent 64b0816d62
commit fcd4ab4fe6
2 changed files with 8 additions and 6 deletions

View File

@ -88,8 +88,8 @@ namespace NewHorizons.External.Configs
/// </summary>
public object extras;
public bool KnowsFact() => string.IsNullOrEmpty(factRequiredForTitle) || ShipLogHandler.KnowsFact(factRequiredForTitle);
public bool KnowsFact() => string.IsNullOrEmpty(factRequiredForTitle) || StandaloneProfileManager.SharedInstance.currentProfile != null && ShipLogHandler.KnowsFact(factRequiredForTitle);
public bool HasCondition() => string.IsNullOrEmpty(conditionRequiredForTitle) || PlayerData.GetPersistentCondition(conditionRequiredForTitle);
public bool HasCondition() => string.IsNullOrEmpty(conditionRequiredForTitle) || StandaloneProfileManager.SharedInstance.currentProfile != null && PlayerData.GetPersistentCondition(conditionRequiredForTitle);
}
}

View File

@ -34,11 +34,13 @@ namespace NewHorizons.Handlers
var profileManager = StandaloneProfileManager.SharedInstance;
profileManager.PreInitialize();
profileManager.Initialize();
if (profileManager.currentProfile != null)
PlayerData.Init(profileManager.currentProfileGameSave,
profileManager.currentProfileGameSettings,
profileManager.currentProfileGraphicsSettings,
profileManager.currentProfileInputJSON);
// TODO: Select one title screen and if it has shareTitleScreen set to true do all the other ones that have it true too.
var (mod, config) = Main.TitleScreenConfigs.FirstOrDefault(kvp => kvp.Value.KnowsFact() && kvp.Value.HasCondition());
if (config != null)