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)
|
||||
{
|
||||
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);
|
||||
|
||||
12
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
12
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
@ -33,7 +33,7 @@ namespace NewHorizons.External.Configs
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
[DefaultValue(true)] public bool canEnterViaWarpDrive = true;
|
||||
|
||||
@ -44,16 +44,16 @@ namespace NewHorizons.External.Configs
|
||||
public string factRequiredForWarp;
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
[DefaultValue(true)] public bool canWarpHome = true;
|
||||
[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 factRequiredForWarpHome;
|
||||
public string factRequiredToExitViaWarpDrive;
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
}
|
||||
}
|
||||
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
|
||||
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> _factIDToStarSystem;
|
||||
|
||||
private static bool _canExitViaWarpDrive;
|
||||
private static string _factRequiredToExitViaWarpDrive;
|
||||
|
||||
private static NewHorizonsSystem[] _systems;
|
||||
|
||||
public static void Init(NewHorizonsSystem[] systems)
|
||||
@ -63,9 +66,10 @@ namespace NewHorizons.Handlers
|
||||
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>
|
||||
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;
|
||||
|
||||
@ -104,6 +112,9 @@ namespace NewHorizons.Handlers
|
||||
return ShipLogHandler.KnowsFact(factID);
|
||||
}
|
||||
|
||||
public static bool CanExitViaWarpDrive() => _canExitViaWarpDrive
|
||||
&& (string.IsNullOrEmpty(_factRequiredToExitViaWarpDrive) || ShipLogHandler.KnowsFact(_factRequiredToExitViaWarpDrive));
|
||||
|
||||
/// <summary>
|
||||
/// Is it actually a valid warp target
|
||||
/// </summary>
|
||||
@ -118,29 +129,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;
|
||||
var canEnterViaWarpDrive = Main.SystemDict[system].Config.canEnterViaWarpDrive || system == "SolarSystem";
|
||||
|
||||
// For the base solar system, use canWarpHome instead for better mod compat
|
||||
if (system.Equals("SolarSystem"))
|
||||
{
|
||||
canEnterViaWarpDrive = Main.SystemDict[Main.Instance.CurrentStarSystem].Config.canWarpHome;
|
||||
}
|
||||
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
|
||||
&& 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user