mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add customizable loop duration
This commit is contained in:
parent
723f74f763
commit
b60b384a8a
@ -35,6 +35,11 @@ namespace NewHorizons.External.Configs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string factRequiredForWarp;
|
public string factRequiredForWarp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The duration of the time loop.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(22f)] public float loopDuration = 22f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should the player not be able to view the map in this system?
|
/// Should the player not be able to view the map in this system?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -209,6 +214,7 @@ namespace NewHorizons.External.Configs
|
|||||||
canEnterViaWarpDrive = canEnterViaWarpDrive && otherConfig.canEnterViaWarpDrive;
|
canEnterViaWarpDrive = canEnterViaWarpDrive && otherConfig.canEnterViaWarpDrive;
|
||||||
destroyStockPlanets = destroyStockPlanets && otherConfig.destroyStockPlanets;
|
destroyStockPlanets = destroyStockPlanets && otherConfig.destroyStockPlanets;
|
||||||
enableTimeLoop = enableTimeLoop && otherConfig.enableTimeLoop;
|
enableTimeLoop = enableTimeLoop && otherConfig.enableTimeLoop;
|
||||||
|
loopDuration = loopDuration == 22f ? otherConfig.loopDuration : loopDuration;
|
||||||
|
|
||||||
// If current one is null take the other
|
// If current one is null take the other
|
||||||
factRequiredForWarp = string.IsNullOrEmpty(factRequiredForWarp) ? otherConfig.factRequiredForWarp : factRequiredForWarp;
|
factRequiredForWarp = string.IsNullOrEmpty(factRequiredForWarp) ? otherConfig.factRequiredForWarp : factRequiredForWarp;
|
||||||
|
|||||||
@ -31,6 +31,11 @@ namespace NewHorizons.Handlers
|
|||||||
timeLoopController.AddComponent<TimeLoopController>();
|
timeLoopController.AddComponent<TimeLoopController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (system.Config.loopDuration != 22f)
|
||||||
|
{
|
||||||
|
TimeLoopUtilities.SetLoopDuration(system.Config.loopDuration);
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(system.Config.travelAudio))
|
if (!string.IsNullOrEmpty(system.Config.travelAudio))
|
||||||
{
|
{
|
||||||
Delay.FireOnNextUpdate(() => AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._travelSource, system.Config.travelAudio, system.Mod));
|
Delay.FireOnNextUpdate(() => AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._travelSource, system.Config.travelAudio, system.Mod));
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace NewHorizons
|
|||||||
public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new Dictionary<string, List<NewHorizonsBody>>();
|
public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new Dictionary<string, List<NewHorizonsBody>>();
|
||||||
public static List<IModBehaviour> MountedAddons = new List<IModBehaviour>();
|
public static List<IModBehaviour> MountedAddons = new List<IModBehaviour>();
|
||||||
|
|
||||||
public static float SecondsLeftInLoop = -1;
|
public static float SecondsElapsedInLoop = -1;
|
||||||
|
|
||||||
public static bool IsSystemReady { get; private set; }
|
public static bool IsSystemReady { get; private set; }
|
||||||
public static float FurthestOrbit { get; set; } = 50000f;
|
public static float FurthestOrbit { get; set; } = 50000f;
|
||||||
@ -239,9 +239,9 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set time loop stuff if its enabled and if we're warping to a new place
|
// Set time loop stuff if its enabled and if we're warping to a new place
|
||||||
if (IsChangingStarSystem && (SystemDict[_currentStarSystem].Config.enableTimeLoop || _currentStarSystem == "SolarSystem") && SecondsLeftInLoop > 0f)
|
if (IsChangingStarSystem && (SystemDict[_currentStarSystem].Config.enableTimeLoop || _currentStarSystem == "SolarSystem") && SecondsElapsedInLoop > 0f)
|
||||||
{
|
{
|
||||||
TimeLoop.SetSecondsRemaining(SecondsLeftInLoop);
|
TimeLoopUtilities.SetSecondsElapsed(SecondsElapsedInLoop);
|
||||||
// Prevent the OPC from firing
|
// Prevent the OPC from firing
|
||||||
var launchController = GameObject.FindObjectOfType<OrbitalProbeLaunchController>();
|
var launchController = GameObject.FindObjectOfType<OrbitalProbeLaunchController>();
|
||||||
if (launchController != null)
|
if (launchController != null)
|
||||||
@ -258,7 +258,7 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reset this
|
// Reset this
|
||||||
SecondsLeftInLoop = -1;
|
SecondsElapsedInLoop = -1;
|
||||||
|
|
||||||
IsChangingStarSystem = false;
|
IsChangingStarSystem = false;
|
||||||
|
|
||||||
@ -607,13 +607,13 @@ namespace NewHorizons
|
|||||||
|
|
||||||
if (newStarSystem == "EyeOfTheUniverse")
|
if (newStarSystem == "EyeOfTheUniverse")
|
||||||
{
|
{
|
||||||
PlayerData.SaveWarpedToTheEye(TimeLoop.GetSecondsRemaining());
|
PlayerData.SaveWarpedToTheEye(TimeLoopUtilities.GetVanillaSecondsRemaining());
|
||||||
sceneToLoad = OWScene.EyeOfTheUniverse;
|
sceneToLoad = OWScene.EyeOfTheUniverse;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SystemDict[_currentStarSystem].Config.enableTimeLoop) SecondsLeftInLoop = TimeLoop.GetSecondsRemaining();
|
if (SystemDict[_currentStarSystem].Config.enableTimeLoop) SecondsElapsedInLoop = TimeLoop.GetSecondsElapsed();
|
||||||
else SecondsLeftInLoop = -1;
|
else SecondsElapsedInLoop = -1;
|
||||||
|
|
||||||
sceneToLoad = OWScene.SolarSystem;
|
sceneToLoad = OWScene.SolarSystem;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ namespace NewHorizons.Patches
|
|||||||
VesselWarpController.s_playerWarpLocation = new RelativeLocationData(Locator.GetPlayerBody(), __instance.transform);
|
VesselWarpController.s_playerWarpLocation = new RelativeLocationData(Locator.GetPlayerBody(), __instance.transform);
|
||||||
VesselWarpController.s_relativeLocationSaved = !debugWarp;
|
VesselWarpController.s_relativeLocationSaved = !debugWarp;
|
||||||
if (!Main.Instance.IsWarpingFromVessel)
|
if (!Main.Instance.IsWarpingFromVessel)
|
||||||
PlayerData.SaveWarpedToTheEye(TimeLoop.GetSecondsRemaining());
|
PlayerData.SaveWarpedToTheEye(TimeLoopUtilities.GetVanillaSecondsRemaining());
|
||||||
LoadManager.EnableAsyncLoadTransition();
|
LoadManager.EnableAsyncLoadTransition();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ namespace NewHorizons.Utility.DebugUtilities
|
|||||||
|
|
||||||
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem);
|
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem);
|
||||||
|
|
||||||
Main.SecondsLeftInLoop = -1f;
|
Main.SecondsElapsedInLoop = -1f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
15
NewHorizons/Utility/TimeLoopUtilities.cs
Normal file
15
NewHorizons/Utility/TimeLoopUtilities.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NewHorizons.Utility
|
||||||
|
{
|
||||||
|
public static class TimeLoopUtilities
|
||||||
|
{
|
||||||
|
public const float LOOP_DURATION_IN_SECONDS = TimeLoop.LOOP_DURATION_IN_MINUTES * 60;
|
||||||
|
public static void SetLoopDuration(float minutes) => TimeLoop._loopDuration = minutes * 60f;
|
||||||
|
public static void SetSecondsElapsed(float secondsElapsed) => TimeLoop._timeOffset = secondsElapsed - Time.timeSinceLevelLoad;
|
||||||
|
public static float GetMinutesRemaining() => TimeLoop.GetSecondsRemaining() / 60f;
|
||||||
|
public static float GetVanillaSecondsRemaining() => LOOP_DURATION_IN_SECONDS - TimeLoop.GetSecondsElapsed();
|
||||||
|
public static float GetVanillaMinutesRemaining() => GetVanillaSecondsRemaining() / 60f;
|
||||||
|
public static float GetVanillaFractionElapsed() => TimeLoop.GetSecondsElapsed() / LOOP_DURATION_IN_SECONDS;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user