62 lines
2.0 KiB
C#
Raw Normal View History

using HarmonyLib;
using QSB.Inputs;
2022-08-14 16:35:19 -07:00
using QSB.Messaging;
using QSB.Patches;
2022-08-14 16:35:19 -07:00
using QSB.TimeSync.Messages;
using QSB.Utility;
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;
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerCameraEffectController), nameof(PlayerCameraEffectController.WakeUp))]
public static void PlayerCameraEffectController_WakeUp(PlayerCameraEffectController __instance)
{
// prevent funny thing when you pause while waking up
Locator.GetPauseCommandListener().AddPauseCommandLock();
Delay.RunWhen(() => !__instance._isOpeningEyes, () => Locator.GetPauseCommandListener().RemovePauseCommandLock());
}
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))]
private static void SetSecondsRemaining(float secondsRemaining)
{
if (Remote)
{
return;
}
2022-08-14 16:35:19 -07:00
new SetSecondsRemainingMessage(secondsRemaining).Send();
}
2022-08-14 16:35:19 -07:00
}