Add settings for being able to warp home

This commit is contained in:
xen-42 2024-09-27 13:31:59 -04:00
parent a3d16fa20d
commit 4bf12e5fbe
4 changed files with 48 additions and 10 deletions

View File

@ -2,6 +2,7 @@ using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Xml;
using NewHorizons.External.Modules;
using NewHorizons.External.SerializableData;
using Newtonsoft.Json;
@ -31,10 +32,29 @@ namespace NewHorizons.External.Configs
public float farClipPlaneOverride;
/// <summary>
/// Whether this system can be warped to via the warp drive. If you set factRequiredForWarp, this will be true.
/// Whether this system can be warped to via the warp drive. If you set `factRequiredForWarp`, this will be true.
/// Does NOT effect the base SolarSystem. For that, see `canWarpHome` and `factRequiredForWarpHome`
/// </summary>
[DefaultValue(true)] public bool canEnterViaWarpDrive = true;
/// <summary>
/// The FactID that must be revealed before it can be warped to. Don't set `canEnterViaWarpDrive` to `false` if
/// you're using this, because it will be overwritten.
/// </summary>
public string factRequiredForWarp;
/// <summary>
/// Can you use the warp drive to return home to the Outer Wilds from this system? If you set `factRequiredForWarpHome`
/// this will be true.
/// </summary>
[DefaultValue(true)] public bool canWarpHome = true;
/// <summary>
/// The FactID that must be revealed for you to warp back to the main solar system from here. Don't set `canWarpHome`
/// to `false` if you're using this, because it will be overwritten.
/// </summary>
public string factRequiredForWarpHome;
/// <summary>
/// Do you want a clean slate for this star system? Or will it be a modified version of the original.
/// </summary>
@ -45,12 +65,6 @@ namespace NewHorizons.External.Configs
/// </summary>
[DefaultValue(true)] public bool enableTimeLoop = true;
/// <summary>
/// The FactID that must be revealed before it can be warped to. Don't set `canEnterViaWarpDrive` to `false` if
/// you're using this, because it will be overwritten.
/// </summary>
public string factRequiredForWarp;
/// <summary>
/// The duration of the time loop in minutes. This is the time the sun explodes. End Times plays 85 seconds before this time, and your memories get sent back about 40 seconds after this time.
/// </summary>
@ -414,6 +428,10 @@ namespace NewHorizons.External.Configs
Vessel.warpExit.attachToVessel = true;
}
}
if (!string.IsNullOrEmpty(factRequiredForWarpHome))
{
canWarpHome = true;
}
}
}
}

View File

@ -1,6 +1,7 @@
using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using OWML.Common;
using System.Linq;
namespace NewHorizons.External
{
@ -19,6 +20,12 @@ namespace NewHorizons.External
Config = config;
RelativePath = relativePath;
Mod = mod;
// Backwards compat
if (new string[] { "2walker2.OogaBooga", "2walker2.EndingIfYouWarpHereYouAreMean", "FeldsparSystem" }.Contains(uniqueID))
{
config.canWarpHome = false;
}
}
}
}

View File

@ -58,10 +58,15 @@ namespace NewHorizons.Handlers
foreach (NewHorizonsSystem system in _systems)
{
if (system.Config.factRequiredForWarp != default)
if (system.Config.factRequiredForWarp != default && system.UniqueID != "SolarSystem")
{
RegisterFactForSystem(system.Config.factRequiredForWarp, system.UniqueID);
}
if (system.UniqueID == Main.Instance.CurrentStarSystem && !string.IsNullOrEmpty(system.Config.factRequiredForWarpHome))
{
RegisterFactForSystem(system.Config.factRequiredForWarpHome, "SolarSystem");
}
}
}
@ -113,8 +118,16 @@ namespace NewHorizons.Handlers
else if (system.Equals("EyeOfTheUniverse")) canWarpTo = false;
else if (config.Spawn?.shipSpawn != null) canWarpTo = true;
var canEnterViaWarpDrive = Main.SystemDict[system].Config.canEnterViaWarpDrive;
// For the base solar system, use canWarpHome instead for better mod compat
if (system.Equals("SolarSystem"))
{
canEnterViaWarpDrive = Main.SystemDict[Main.Instance.CurrentStarSystem].Config.canWarpHome;
}
return canWarpTo
&& Main.SystemDict[system].Config.canEnterViaWarpDrive
&& canEnterViaWarpDrive
&& system != Main.Instance.CurrentStarSystem
&& HasUnlockedSystem(system);
}

View File

@ -4,7 +4,7 @@
"author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends",
"name": "New Horizons",
"uniqueName": "xen.NewHorizons",
"version": "1.22.5",
"version": "1.22.6",
"owmlVersion": "2.12.1",
"dependencies": [ "JohnCorby.VanillaFix", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
"conflicts": [ "PacificEngine.OW_CommonResources" ],