2021-10-15 21:06:51 +01:00
|
|
|
|
using HarmonyLib;
|
2022-06-07 17:16:16 -07:00
|
|
|
|
using QSB.Inputs;
|
2022-08-14 16:35:19 -07:00
|
|
|
|
using QSB.Messaging;
|
2021-10-15 21:06:51 +01:00
|
|
|
|
using QSB.Patches;
|
2022-08-14 16:35:19 -07:00
|
|
|
|
using QSB.TimeSync.Messages;
|
2021-11-20 11:48:46 +00:00
|
|
|
|
using QSB.Utility;
|
2022-11-21 21:30:43 +00:00
|
|
|
|
using UnityEngine;
|
2021-06-12 15:58:34 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.TimeSync.Patches;
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch]
|
2023-07-28 19:30:57 +01:00
|
|
|
|
public class TimePatches : QSBPatch
|
2021-06-12 15:58:34 +01:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
2022-02-05 10:14:27 +00:00
|
|
|
|
|
2022-08-15 15:05:11 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// prevents wakeup prompt since we automatically wake you up.
|
2022-08-15 15:06:19 -07:00
|
|
|
|
/// (doesn't happen for host because we don't patch until TimeLoop._initialized i.e. after Start)
|
2022-08-15 15:05:11 -07:00
|
|
|
|
/// </summary>
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
[HarmonyPatch(typeof(PlayerCameraEffectController), nameof(PlayerCameraEffectController.OnStartOfTimeLoop))]
|
|
|
|
|
public static bool PlayerCameraEffectController_OnStartOfTimeLoop() => false;
|
|
|
|
|
|
2022-06-07 17:16:16 -07:00
|
|
|
|
[HarmonyPostfix]
|
|
|
|
|
[HarmonyPatch(typeof(PlayerCameraEffectController), nameof(PlayerCameraEffectController.WakeUp))]
|
|
|
|
|
public static void PlayerCameraEffectController_WakeUp(PlayerCameraEffectController __instance)
|
|
|
|
|
{
|
|
|
|
|
// prevent funny thing when you pause while waking up
|
2022-11-06 16:40:31 -08:00
|
|
|
|
Locator.GetPauseCommandListener().AddPauseCommandLock();
|
|
|
|
|
Delay.RunWhen(() => !__instance._isOpeningEyes, () => Locator.GetPauseCommandListener().RemovePauseCommandLock());
|
2022-06-07 17:16:16 -07:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
[HarmonyPatch(typeof(OWTime), nameof(OWTime.Pause))]
|
|
|
|
|
public static bool StopPausing(OWTime.PauseType pauseType)
|
|
|
|
|
=> pauseType
|
|
|
|
|
is OWTime.PauseType.Initializing
|
|
|
|
|
or OWTime.PauseType.Streaming
|
|
|
|
|
or OWTime.PauseType.Loading;
|
2022-10-06 17:52:22 -07:00
|
|
|
|
|
|
|
|
|
[HarmonyPostfix]
|
|
|
|
|
[HarmonyPatch(typeof(SubmitActionSkipToNextLoop), nameof(SubmitActionSkipToNextLoop.AdvanceToNewTimeLoop))]
|
|
|
|
|
public static void PreventMeditationSoftlock()
|
|
|
|
|
=> OWInput.ChangeInputMode(InputMode.Character);
|
2022-08-14 16:11:28 -07:00
|
|
|
|
}
|
2022-08-14 16:35:19 -07:00
|
|
|
|
|
2023-07-28 19:30:57 +01:00
|
|
|
|
public class ClientTimePatches : QSBPatch
|
2022-08-14 16:35:19 -07:00
|
|
|
|
{
|
|
|
|
|
public override QSBPatchTypes Type => QSBPatchTypes.OnNonServerClientConnect;
|
|
|
|
|
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
[HarmonyPatch(typeof(TimeLoop), nameof(TimeLoop.SetSecondsRemaining))]
|
2022-08-14 17:09:41 -07:00
|
|
|
|
private static void SetSecondsRemaining(float secondsRemaining)
|
|
|
|
|
{
|
|
|
|
|
if (Remote)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-08-14 16:35:19 -07:00
|
|
|
|
new SetSecondsRemainingMessage(secondsRemaining).Send();
|
2022-08-14 17:09:41 -07:00
|
|
|
|
}
|
2022-08-14 16:35:19 -07:00
|
|
|
|
}
|