mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
index
This commit is contained in:
parent
2869544b92
commit
d9441f5140
@ -453,6 +453,7 @@ namespace NewHorizons.Handlers
|
||||
public void Add(ITitleScreenBuilder builder)
|
||||
{
|
||||
list.Add(builder);
|
||||
builder.Index = list.IndexOf(builder);
|
||||
}
|
||||
|
||||
public bool IsValid => GetRelevantBuilder() != null;
|
||||
@ -484,23 +485,23 @@ namespace NewHorizons.Handlers
|
||||
|
||||
public void Build()
|
||||
{
|
||||
NHLogger.LogVerbose("Building handler: " + mod.ModHelper.Manifest.UniqueName);
|
||||
NHLogger.LogVerbose($"Building handler {mod.ModHelper.Manifest.UniqueName} #{index}");
|
||||
try
|
||||
{
|
||||
builder.Invoke(SearchUtilities.Find("Scene"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
NHLogger.LogError(e);
|
||||
NHLogger.LogError($"Error while building title screen handler {mod.ModHelper.Manifest.UniqueName} #{index}: {e}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Main.Instance.OnTitleScreenLoaded?.Invoke(mod.ModHelper.Manifest.UniqueName);
|
||||
Main.Instance.OnTitleScreenLoaded?.Invoke(mod.ModHelper.Manifest.UniqueName, index);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
NHLogger.LogError($"Error in event handler for OnTitleScreenLoaded on title screen {mod.ModHelper.Manifest.UniqueName}: {e}");
|
||||
NHLogger.LogError($"Error in event handler for OnTitleScreenLoaded on title screen {mod.ModHelper.Manifest.UniqueName} #{index}: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,6 +514,9 @@ namespace NewHorizons.Handlers
|
||||
public bool KnowsFact() => string.IsNullOrEmpty(factRequired) || StandaloneProfileManager.SharedInstance.currentProfile != null && ShipLogHandler.KnowsFact(factRequired);
|
||||
|
||||
public bool HasCondition() => string.IsNullOrEmpty(persistentConditionRequired) || StandaloneProfileManager.SharedInstance.currentProfile != null && PlayerData.GetPersistentCondition(persistentConditionRequired);
|
||||
|
||||
private int index = -1;
|
||||
public int Index { get => index; set => index = value; }
|
||||
}
|
||||
|
||||
internal class TitleScreenConfigBuilder : ITitleScreenBuilder
|
||||
@ -528,23 +532,23 @@ namespace NewHorizons.Handlers
|
||||
|
||||
public void Build()
|
||||
{
|
||||
NHLogger.LogVerbose("Building config: " + mod.ModHelper.Manifest.UniqueName);
|
||||
NHLogger.LogVerbose($"Building config {mod.ModHelper.Manifest.UniqueName} #{index}");
|
||||
try
|
||||
{
|
||||
BuildConfig(mod, config);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
NHLogger.LogError(e);
|
||||
NHLogger.LogError($"Error while building title screen config {mod.ModHelper.Manifest.UniqueName} #{index}: {e}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Main.Instance.OnTitleScreenLoaded?.Invoke(mod.ModHelper.Manifest.UniqueName);
|
||||
Main.Instance.OnTitleScreenLoaded?.Invoke(mod.ModHelper.Manifest.UniqueName, index);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
NHLogger.LogError($"Error in event handler for OnTitleScreenLoaded on title screen {mod.ModHelper.Manifest.UniqueName}: {e}");
|
||||
NHLogger.LogError($"Error in event handler for OnTitleScreenLoaded on title screen {mod.ModHelper.Manifest.UniqueName} #{index}: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -557,6 +561,9 @@ namespace NewHorizons.Handlers
|
||||
public bool KnowsFact() => string.IsNullOrEmpty(config.factRequiredForTitle) || StandaloneProfileManager.SharedInstance.currentProfile != null && ShipLogHandler.KnowsFact(config.factRequiredForTitle);
|
||||
|
||||
public bool HasCondition() => string.IsNullOrEmpty(config.persistentConditionRequiredForTitle) || StandaloneProfileManager.SharedInstance.currentProfile != null && PlayerData.GetPersistentCondition(config.persistentConditionRequiredForTitle);
|
||||
|
||||
private int index = -1;
|
||||
public int Index { get => index; set => index = value; }
|
||||
}
|
||||
|
||||
internal interface ITitleScreenBuilder
|
||||
@ -570,6 +577,8 @@ namespace NewHorizons.Handlers
|
||||
void Build();
|
||||
bool KnowsFact();
|
||||
bool HasCondition();
|
||||
|
||||
int Index { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -76,9 +76,9 @@ namespace NewHorizons
|
||||
|
||||
/// <summary>
|
||||
/// An event invoked when NH has finished building a title screen.
|
||||
/// Gives the unique name of the mod the title screen builder was from.
|
||||
/// Gives the unique name of the mod the title screen builder was from and the index for when you have multiple title screens.
|
||||
/// </summary>
|
||||
UnityEvent<string> GetTitleScreenLoadedEvent();
|
||||
UnityEvent<string, int> GetTitleScreenLoadedEvent();
|
||||
|
||||
/// <summary>
|
||||
/// An event invoked when NH has finished building the title screen.
|
||||
|
||||
@ -112,7 +112,8 @@ namespace NewHorizons
|
||||
public StringEvent OnChangeStarSystem = new();
|
||||
public StringEvent OnStarSystemLoaded = new();
|
||||
public StringEvent OnPlanetLoaded = new();
|
||||
public StringEvent OnTitleScreenLoaded = new();
|
||||
public class StringIndexEvent : UnityEvent<string, int> { }
|
||||
public StringIndexEvent OnTitleScreenLoaded = new();
|
||||
public UnityEvent OnAllTitleScreensLoaded = new();
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -90,7 +90,7 @@ namespace NewHorizons
|
||||
public UnityEvent<string> GetChangeStarSystemEvent() => Main.Instance.OnChangeStarSystem;
|
||||
public UnityEvent<string> GetStarSystemLoadedEvent() => Main.Instance.OnStarSystemLoaded;
|
||||
public UnityEvent<string> GetBodyLoadedEvent() => Main.Instance.OnPlanetLoaded;
|
||||
public UnityEvent<string> GetTitleScreenLoadedEvent() => Main.Instance.OnTitleScreenLoaded;
|
||||
public UnityEvent<string, int> GetTitleScreenLoadedEvent() => Main.Instance.OnTitleScreenLoaded;
|
||||
public UnityEvent GetAllTitleScreensLoadedEvent() => Main.Instance.OnAllTitleScreensLoaded;
|
||||
|
||||
public bool SetDefaultSystem(string name)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user