mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Change to can exit
This commit is contained in:
parent
4bf12e5fbe
commit
c7402bf60f
@ -96,7 +96,7 @@ namespace NewHorizons.Components.ShipLog
|
|||||||
if (_cardTemplate == null)
|
if (_cardTemplate == null)
|
||||||
{
|
{
|
||||||
var panRoot = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot");
|
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);
|
_cardTemplate.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +209,12 @@ namespace NewHorizons.Components.ShipLog
|
|||||||
|
|
||||||
private void UpdateMapCamera()
|
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;
|
Vector2 b = -_starSystemCards[_cardIndex].transform.localPosition;
|
||||||
float num = Mathf.InverseLerp(_startPanTime, _startPanTime + _panDuration, Time.unscaledTime);
|
float num = Mathf.InverseLerp(_startPanTime, _startPanTime + _panDuration, Time.unscaledTime);
|
||||||
num = 1f - (num - 1f) * (num - 1f);
|
num = 1f - (num - 1f) * (num - 1f);
|
||||||
|
|||||||
12
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
12
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
@ -33,7 +33,7 @@ namespace NewHorizons.External.Configs
|
|||||||
|
|
||||||
/// <summary>
|
/// <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`
|
/// Does NOT effect the base SolarSystem. For that, see `canExitViaWarpDrive` and `factRequiredToExitViaWarpDrive`
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(true)] public bool canEnterViaWarpDrive = true;
|
[DefaultValue(true)] public bool canEnterViaWarpDrive = true;
|
||||||
|
|
||||||
@ -44,16 +44,16 @@ namespace NewHorizons.External.Configs
|
|||||||
public string factRequiredForWarp;
|
public string factRequiredForWarp;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Can you use the warp drive to return home to the Outer Wilds from this system? If you set `factRequiredForWarpHome`
|
/// Can you use the warp drive to leave this system? If you set `factRequiredToExitViaWarpDrive`
|
||||||
/// this will be true.
|
/// this will be true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(true)] public bool canWarpHome = true;
|
[DefaultValue(true)] public bool canExitViaWarpDrive = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The FactID that must be revealed for you to warp back to the main solar system from here. Don't set `canWarpHome`
|
/// 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.
|
/// to `false` if you're using this, because it will be overwritten.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string factRequiredForWarpHome;
|
public string factRequiredToExitViaWarpDrive;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Do you want a clean slate for this star system? Or will it be a modified version of the original.
|
/// Do you want a clean slate for this star system? Or will it be a modified version of the original.
|
||||||
@ -428,9 +428,9 @@ namespace NewHorizons.External.Configs
|
|||||||
Vessel.warpExit.attachToVessel = true;
|
Vessel.warpExit.attachToVessel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(factRequiredForWarpHome))
|
if (!string.IsNullOrEmpty(factRequiredToExitViaWarpDrive))
|
||||||
{
|
{
|
||||||
canWarpHome = true;
|
canExitViaWarpDrive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
NewHorizons/External/NewHorizonsSystem.cs
vendored
2
NewHorizons/External/NewHorizonsSystem.cs
vendored
@ -24,7 +24,7 @@ namespace NewHorizons.External
|
|||||||
// Backwards compat
|
// Backwards compat
|
||||||
if (new string[] { "2walker2.OogaBooga", "2walker2.EndingIfYouWarpHereYouAreMean", "FeldsparSystem" }.Contains(uniqueID))
|
if (new string[] { "2walker2.OogaBooga", "2walker2.EndingIfYouWarpHereYouAreMean", "FeldsparSystem" }.Contains(uniqueID))
|
||||||
{
|
{
|
||||||
config.canWarpHome = false;
|
config.canExitViaWarpDrive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,9 @@ namespace NewHorizons.Handlers
|
|||||||
private static Dictionary<string, string> _starSystemToFactID;
|
private static Dictionary<string, string> _starSystemToFactID;
|
||||||
private static Dictionary<string, string> _factIDToStarSystem;
|
private static Dictionary<string, string> _factIDToStarSystem;
|
||||||
|
|
||||||
|
private static bool _canExitViaWarpDrive;
|
||||||
|
private static string _factRequiredToExitViaWarpDrive;
|
||||||
|
|
||||||
private static NewHorizonsSystem[] _systems;
|
private static NewHorizonsSystem[] _systems;
|
||||||
|
|
||||||
public static void Init(NewHorizonsSystem[] systems)
|
public static void Init(NewHorizonsSystem[] systems)
|
||||||
@ -63,9 +66,10 @@ namespace NewHorizons.Handlers
|
|||||||
RegisterFactForSystem(system.Config.factRequiredForWarp, system.UniqueID);
|
RegisterFactForSystem(system.Config.factRequiredForWarp, system.UniqueID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (system.UniqueID == Main.Instance.CurrentStarSystem && !string.IsNullOrEmpty(system.Config.factRequiredForWarpHome))
|
if (system.UniqueID == Main.Instance.CurrentStarSystem && !string.IsNullOrEmpty(system.Config.factRequiredToExitViaWarpDrive))
|
||||||
{
|
{
|
||||||
RegisterFactForSystem(system.Config.factRequiredForWarpHome, "SolarSystem");
|
_factRequiredToExitViaWarpDrive = system.Config.factRequiredToExitViaWarpDrive;
|
||||||
|
_canExitViaWarpDrive = system.Config.canExitViaWarpDrive || !string.IsNullOrEmpty(_factRequiredToExitViaWarpDrive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,6 +97,10 @@ namespace NewHorizons.Handlers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool HasUnlockedSystem(string system)
|
public static bool HasUnlockedSystem(string system)
|
||||||
{
|
{
|
||||||
|
// If warp drive is entirely disabled, then no
|
||||||
|
if (!CanExitViaWarpDrive())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (_starSystemToFactID == null || _starSystemToFactID.Count == 0)
|
if (_starSystemToFactID == null || _starSystemToFactID.Count == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -104,6 +112,9 @@ namespace NewHorizons.Handlers
|
|||||||
return ShipLogHandler.KnowsFact(factID);
|
return ShipLogHandler.KnowsFact(factID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool CanExitViaWarpDrive() => _canExitViaWarpDrive
|
||||||
|
&& (string.IsNullOrEmpty(_factRequiredToExitViaWarpDrive) || ShipLogHandler.KnowsFact(_factRequiredToExitViaWarpDrive));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is it actually a valid warp target
|
/// Is it actually a valid warp target
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -118,29 +129,55 @@ namespace NewHorizons.Handlers
|
|||||||
else if (system.Equals("EyeOfTheUniverse")) canWarpTo = false;
|
else if (system.Equals("EyeOfTheUniverse")) canWarpTo = false;
|
||||||
else if (config.Spawn?.shipSpawn != null) canWarpTo = true;
|
else if (config.Spawn?.shipSpawn != null) canWarpTo = true;
|
||||||
|
|
||||||
var canEnterViaWarpDrive = Main.SystemDict[system].Config.canEnterViaWarpDrive;
|
var canEnterViaWarpDrive = Main.SystemDict[system].Config.canEnterViaWarpDrive || system == "SolarSystem";
|
||||||
|
|
||||||
// For the base solar system, use canWarpHome instead for better mod compat
|
var canExitViaWarpDrive = CanExitViaWarpDrive();
|
||||||
if (system.Equals("SolarSystem"))
|
|
||||||
{
|
// Make base system always ignore canExitViaWarpDrive
|
||||||
canEnterViaWarpDrive = Main.SystemDict[Main.Instance.CurrentStarSystem].Config.canWarpHome;
|
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
||||||
}
|
canExitViaWarpDrive = true;
|
||||||
|
|
||||||
|
NHLogger.Log(canEnterViaWarpDrive, canExitViaWarpDrive, system, HasUnlockedSystem(system));
|
||||||
|
|
||||||
return canWarpTo
|
return canWarpTo
|
||||||
&& canEnterViaWarpDrive
|
&& canEnterViaWarpDrive
|
||||||
|
&& canExitViaWarpDrive
|
||||||
&& system != Main.Instance.CurrentStarSystem
|
&& system != Main.Instance.CurrentStarSystem
|
||||||
&& HasUnlockedSystem(system);
|
&& HasUnlockedSystem(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnRevealFact(string factID)
|
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))
|
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}]");
|
NHLogger.Log($"Just learned [{factID}] and unlocked [{systemUnlocked}]");
|
||||||
if (!Main.HasWarpDrive)
|
if (!Main.HasWarpDrive && knowsWarpFact)
|
||||||
|
{
|
||||||
Main.Instance.EnableWarpDrive();
|
Main.Instance.EnableWarpDrive();
|
||||||
if (ShipLogStarChartMode != null)
|
}
|
||||||
ShipLogStarChartMode.AddSystemCard(systemUnlocked);
|
ShipLogStarChartMode?.AddSystemCard(systemUnlocked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user