mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add default star system override option
This commit is contained in:
parent
87c859728e
commit
d5ee5ff33a
@ -35,9 +35,10 @@ namespace NewHorizons
|
|||||||
public static Main Instance { get; private set; }
|
public static Main Instance { get; private set; }
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
public static bool Debug;
|
public static bool Debug { get; private set; }
|
||||||
private static bool _useCustomTitleScreen;
|
private static bool _useCustomTitleScreen;
|
||||||
private static bool _wasConfigured = false;
|
private static bool _wasConfigured = false;
|
||||||
|
private static string _defaultSystemOverride;
|
||||||
|
|
||||||
public static Dictionary<string, NewHorizonsSystem> SystemDict = new Dictionary<string, NewHorizonsSystem>();
|
public static Dictionary<string, NewHorizonsSystem> SystemDict = new Dictionary<string, NewHorizonsSystem>();
|
||||||
public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new Dictionary<string, List<NewHorizonsBody>>();
|
public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new Dictionary<string, List<NewHorizonsBody>>();
|
||||||
@ -84,6 +85,8 @@ namespace NewHorizons
|
|||||||
DebugReload.UpdateReloadButton();
|
DebugReload.UpdateReloadButton();
|
||||||
Logger.UpdateLogLevel(Debug ? Logger.LogType.Log : Logger.LogType.Error);
|
Logger.UpdateLogLevel(Debug ? Logger.LogType.Log : Logger.LogType.Error);
|
||||||
|
|
||||||
|
_defaultSystemOverride = config.GetSettingsValue<string>("Default System Override");
|
||||||
|
|
||||||
var wasUsingCustomTitleScreen = _useCustomTitleScreen;
|
var wasUsingCustomTitleScreen = _useCustomTitleScreen;
|
||||||
_useCustomTitleScreen = config.GetSettingsValue<bool>("Custom title screen");
|
_useCustomTitleScreen = config.GetSettingsValue<bool>("Custom title screen");
|
||||||
// Reload the title screen if this was updated on it
|
// Reload the title screen if this was updated on it
|
||||||
@ -111,11 +114,14 @@ namespace NewHorizons
|
|||||||
destroyStockPlanets = false
|
destroyStockPlanets = false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
foreach (AssetBundle bundle in AssetBundles.Values)
|
|
||||||
|
foreach (var pair in AssetBundles)
|
||||||
{
|
{
|
||||||
bundle.Unload(true);
|
if (pair.Value == null) Logger.LogError($"The asset bundle for {pair.Key} was null when trying to unload");
|
||||||
|
else pair.Value.Unload(true);
|
||||||
}
|
}
|
||||||
AssetBundles.Clear();
|
AssetBundles.Clear();
|
||||||
|
|
||||||
if (!resetTranslation) return;
|
if (!resetTranslation) return;
|
||||||
TranslationHandler.ClearTables();
|
TranslationHandler.ClearTables();
|
||||||
TextTranslation.Get().SetLanguage(TextTranslation.Get().GetLanguage());
|
TextTranslation.Get().SetLanguage(TextTranslation.Get().GetLanguage());
|
||||||
@ -274,9 +280,18 @@ namespace NewHorizons
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Reset back to original solar system after going to main menu.
|
// Reset back to original solar system after going to main menu.
|
||||||
|
// If the override is a valid system then we go there
|
||||||
|
if (SystemDict.Keys.Contains(_defaultSystemOverride))
|
||||||
|
{
|
||||||
|
_currentStarSystem = _defaultSystemOverride;
|
||||||
|
IsWarping = true; // always do this else sometimes the spawn gets messed up
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_currentStarSystem = _defaultStarSystem;
|
_currentStarSystem = _defaultStarSystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void EnableWarpDrive()
|
public void EnableWarpDrive()
|
||||||
{
|
{
|
||||||
@ -309,6 +324,12 @@ namespace NewHorizons
|
|||||||
var relativePath = file.Replace(folder, "");
|
var relativePath = file.Replace(folder, "");
|
||||||
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>(relativePath);
|
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>(relativePath);
|
||||||
|
|
||||||
|
if (starSystemConfig.startHere)
|
||||||
|
{
|
||||||
|
// We always want to allow mods to overwrite setting the main SolarSystem as default but not the other way around
|
||||||
|
if (name != "SolarSystem") SetDefaultSystem(name);
|
||||||
|
}
|
||||||
|
|
||||||
var system = new NewHorizonsSystem(name, starSystemConfig, mod);
|
var system = new NewHorizonsSystem(name, starSystemConfig, mod);
|
||||||
SystemDict[name] = system;
|
SystemDict[name] = system;
|
||||||
}
|
}
|
||||||
@ -380,15 +401,13 @@ namespace NewHorizons
|
|||||||
if (config.Base.CenterOfSolarSystem) config.Orbit.IsStatic = true;
|
if (config.Base.CenterOfSolarSystem) config.Orbit.IsStatic = true;
|
||||||
if (!SystemDict.ContainsKey(config.StarSystem))
|
if (!SystemDict.ContainsKey(config.StarSystem))
|
||||||
{
|
{
|
||||||
// See if theres a star system config
|
// Since we didn't load it earlier there shouldn't be a star system config
|
||||||
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>($"systems/{config.StarSystem}.json");
|
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>($"systems/{config.StarSystem}.json");
|
||||||
if (starSystemConfig == null) starSystemConfig = new StarSystemConfig(null);
|
if (starSystemConfig == null) starSystemConfig = new StarSystemConfig(null);
|
||||||
else Logger.Log($"Loaded system config for {config.StarSystem}");
|
else Logger.LogWarning($"Loaded system config for {config.StarSystem}. Why wasn't this loaded earlier?");
|
||||||
|
|
||||||
var system = new NewHorizonsSystem(config.StarSystem, starSystemConfig, mod);
|
var system = new NewHorizonsSystem(config.StarSystem, starSystemConfig, mod);
|
||||||
|
|
||||||
if (system.Config.startHere) SetDefaultSystem(system.Name);
|
|
||||||
|
|
||||||
SystemDict.Add(config.StarSystem, system);
|
SystemDict.Add(config.StarSystem, system);
|
||||||
|
|
||||||
BodyDict.Add(config.StarSystem, new List<NewHorizonsBody>());
|
BodyDict.Add(config.StarSystem, new List<NewHorizonsBody>());
|
||||||
@ -445,8 +464,18 @@ namespace NewHorizons
|
|||||||
{
|
{
|
||||||
// We reset the solar system on death (unless we just killed the player)
|
// We reset the solar system on death (unless we just killed the player)
|
||||||
if (!_isChangingStarSystem)
|
if (!_isChangingStarSystem)
|
||||||
|
{
|
||||||
|
// If the override is a valid system then we go there
|
||||||
|
if (SystemDict.Keys.Contains(_defaultSystemOverride))
|
||||||
|
{
|
||||||
|
_currentStarSystem = _defaultSystemOverride;
|
||||||
|
IsWarping = true; // always do this else sometimes the spawn gets messed up
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
_currentStarSystem = _defaultStarSystem;
|
_currentStarSystem = _defaultStarSystem;
|
||||||
|
}
|
||||||
|
|
||||||
IsWarping = false;
|
IsWarping = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user