mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Can warp home (#936)
## Minor features - Added `canExitViaWarpDrive` and `factRequiredToExitViaWarpDrive` to enable/disable warping out of your own system. Replaces setting `canEnterViaWarpDrive = false` on the base solar system (which now does nothing). Fixes compatibility between Astral Codec and anything that uses the warp drive.
This commit is contained in:
commit
3624408e63
@ -96,7 +96,7 @@ namespace NewHorizons.Components.ShipLog
|
||||
if (_cardTemplate == null)
|
||||
{
|
||||
var panRoot = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot");
|
||||
_cardTemplate = Instantiate(panRoot.GetComponentInChildren<ShipLogEntryCard>().gameObject);
|
||||
_cardTemplate = Instantiate(panRoot.GetComponentInChildren<ShipLogEntryCard>(true).gameObject);
|
||||
_cardTemplate.SetActive(false);
|
||||
}
|
||||
|
||||
@ -209,6 +209,12 @@ namespace NewHorizons.Components.ShipLog
|
||||
|
||||
private void UpdateMapCamera()
|
||||
{
|
||||
if (_starSystemCards.Count == 0)
|
||||
{
|
||||
NHLogger.LogWarning("Showing star chart mode when there are no avaialble systems");
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 b = -_starSystemCards[_cardIndex].transform.localPosition;
|
||||
float num = Mathf.InverseLerp(_startPanTime, _startPanTime + _panDuration, Time.unscaledTime);
|
||||
num = 1f - (num - 1f) * (num - 1f);
|
||||
|
||||
32
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
32
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
@ -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 `canExitViaWarpDrive` and `factRequiredToExitViaWarpDrive`
|
||||
/// </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 leave this system? If you set `factRequiredToExitViaWarpDrive`
|
||||
/// this will be true.
|
||||
/// </summary>
|
||||
[DefaultValue(true)] public bool canExitViaWarpDrive = 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 factRequiredToExitViaWarpDrive;
|
||||
|
||||
/// <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(factRequiredToExitViaWarpDrive))
|
||||
{
|
||||
canExitViaWarpDrive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
NewHorizons/External/NewHorizonsSystem.cs
vendored
7
NewHorizons/External/NewHorizonsSystem.cs
vendored
@ -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.canExitViaWarpDrive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,9 @@ namespace NewHorizons.Handlers
|
||||
private static Dictionary<string, string> _starSystemToFactID;
|
||||
private static Dictionary<string, string> _factIDToStarSystem;
|
||||
|
||||
private static bool _canExitViaWarpDrive;
|
||||
private static string _factRequiredToExitViaWarpDrive;
|
||||
|
||||
private static NewHorizonsSystem[] _systems;
|
||||
|
||||
public static void Init(NewHorizonsSystem[] systems)
|
||||
@ -56,12 +59,20 @@ namespace NewHorizons.Handlers
|
||||
_starSystemToFactID = new Dictionary<string, string>();
|
||||
_factIDToStarSystem = new Dictionary<string, string>();
|
||||
|
||||
_factRequiredToExitViaWarpDrive = string.Empty;
|
||||
|
||||
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.factRequiredToExitViaWarpDrive))
|
||||
{
|
||||
_factRequiredToExitViaWarpDrive = system.Config.factRequiredToExitViaWarpDrive;
|
||||
_canExitViaWarpDrive = system.Config.canExitViaWarpDrive || !string.IsNullOrEmpty(_factRequiredToExitViaWarpDrive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,6 +99,10 @@ namespace NewHorizons.Handlers
|
||||
/// <returns></returns>
|
||||
public static bool HasUnlockedSystem(string system)
|
||||
{
|
||||
// If warp drive is entirely disabled, then no
|
||||
if (!CanExitViaWarpDrive())
|
||||
return false;
|
||||
|
||||
if (_starSystemToFactID == null || _starSystemToFactID.Count == 0)
|
||||
return true;
|
||||
|
||||
@ -99,6 +114,9 @@ namespace NewHorizons.Handlers
|
||||
return ShipLogHandler.KnowsFact(factID);
|
||||
}
|
||||
|
||||
public static bool CanExitViaWarpDrive() => Main.Instance.CurrentStarSystem == "SolarSystem" || (_canExitViaWarpDrive
|
||||
&& (string.IsNullOrEmpty(_factRequiredToExitViaWarpDrive) || ShipLogHandler.KnowsFact(_factRequiredToExitViaWarpDrive)));
|
||||
|
||||
/// <summary>
|
||||
/// Is it actually a valid warp target
|
||||
/// </summary>
|
||||
@ -113,21 +131,55 @@ 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 || system == "SolarSystem";
|
||||
|
||||
var canExitViaWarpDrive = CanExitViaWarpDrive();
|
||||
|
||||
// Make base system always ignore canExitViaWarpDrive
|
||||
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
||||
canExitViaWarpDrive = true;
|
||||
|
||||
NHLogger.Log(canEnterViaWarpDrive, canExitViaWarpDrive, system, HasUnlockedSystem(system));
|
||||
|
||||
return canWarpTo
|
||||
&& Main.SystemDict[system].Config.canEnterViaWarpDrive
|
||||
&& canEnterViaWarpDrive
|
||||
&& canExitViaWarpDrive
|
||||
&& system != Main.Instance.CurrentStarSystem
|
||||
&& HasUnlockedSystem(system);
|
||||
}
|
||||
|
||||
public static void OnRevealFact(string factID)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_factRequiredToExitViaWarpDrive) && factID == _factRequiredToExitViaWarpDrive)
|
||||
{
|
||||
if (!Main.HasWarpDrive)
|
||||
{
|
||||
Main.Instance.EnableWarpDrive();
|
||||
// Add all cards that now work
|
||||
foreach (var starSystem in Main.SystemDict.Keys)
|
||||
{
|
||||
if (CanWarpToSystem(starSystem))
|
||||
{
|
||||
ShipLogStarChartMode.AddSystemCard(starSystem);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NHLogger.LogWarning("Warp drive was enabled before learning fact?");
|
||||
}
|
||||
}
|
||||
|
||||
if (_factIDToStarSystem != null && _factIDToStarSystem.TryGetValue(factID, out var systemUnlocked))
|
||||
{
|
||||
var knowsWarpFact = string.IsNullOrEmpty(_factRequiredToExitViaWarpDrive) || ShipLogHandler.KnowsFact(_factRequiredToExitViaWarpDrive);
|
||||
|
||||
NHLogger.Log($"Just learned [{factID}] and unlocked [{systemUnlocked}]");
|
||||
if (!Main.HasWarpDrive)
|
||||
if (!Main.HasWarpDrive && knowsWarpFact)
|
||||
{
|
||||
Main.Instance.EnableWarpDrive();
|
||||
if (ShipLogStarChartMode != null)
|
||||
ShipLogStarChartMode.AddSystemCard(systemUnlocked);
|
||||
}
|
||||
ShipLogStarChartMode?.AddSystemCard(systemUnlocked);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,9 +20,22 @@
|
||||
},
|
||||
"canEnterViaWarpDrive": {
|
||||
"type": "boolean",
|
||||
"description": "Whether this system can be warped to via the warp drive. If you set factRequiredForWarp, this will be true.",
|
||||
"description": "Whether this system can be warped to via the warp drive. If you set `factRequiredForWarp`, this will be true.\nDoes NOT effect the base SolarSystem. For that, see `canExitViaWarpDrive` and `factRequiredToExitViaWarpDrive`",
|
||||
"default": true
|
||||
},
|
||||
"factRequiredForWarp": {
|
||||
"type": "string",
|
||||
"description": "The FactID that must be revealed before it can be warped to. Don't set `canEnterViaWarpDrive` to `false` if\nyou're using this, because it will be overwritten."
|
||||
},
|
||||
"canExitViaWarpDrive": {
|
||||
"type": "boolean",
|
||||
"description": "Can you use the warp drive to leave this system? If you set `factRequiredToExitViaWarpDrive`\nthis will be true.",
|
||||
"default": true
|
||||
},
|
||||
"factRequiredToExitViaWarpDrive": {
|
||||
"type": "string",
|
||||
"description": "The FactID that must be revealed for you to warp back to the main solar system from here. Don't set `canWarpHome`\nto `false` if you're using this, because it will be overwritten."
|
||||
},
|
||||
"destroyStockPlanets": {
|
||||
"type": "boolean",
|
||||
"description": "Do you want a clean slate for this star system? Or will it be a modified version of the original.",
|
||||
@ -33,10 +46,6 @@
|
||||
"description": "Should the time loop be enabled in this system?",
|
||||
"default": true
|
||||
},
|
||||
"factRequiredForWarp": {
|
||||
"type": "string",
|
||||
"description": "The FactID that must be revealed before it can be warped to. Don't set `canEnterViaWarpDrive` to `false` if\nyou're using this, because it will be overwritten."
|
||||
},
|
||||
"loopDuration": {
|
||||
"type": "number",
|
||||
"description": "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.",
|
||||
|
||||
@ -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" ],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user