Skip to content

Commit

Permalink
clears snapback when you leave the game
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Nov 8, 2022
1 parent bb6a15f commit 0f0fdb0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Binary file modified 1.4/Assemblies/CameraPlus.dll
Binary file not shown.
10 changes: 10 additions & 0 deletions Source/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,16 @@ public static void Postfix(TickManager __instance)
}
}

[HarmonyPatch(typeof(MainTabWindow_Menu))]
[HarmonyPatch(nameof(MainTabWindow_Menu.PreOpen))]
static class MainTabWindow_Menu_PreOpen_Patch
{
public static void Postfix()
{
Tools.ResetSnapback();
}
}

[HarmonyPatch(typeof(UIRoot_Play))]
[HarmonyPatch(nameof(UIRoot_Play.UIRootOnGUI))]
static class UIRoot_Play_UIRootOnGUI_Patch
Expand Down
9 changes: 7 additions & 2 deletions Source/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ public static void CreateSnapback()

public static bool HasSnapback => snapbackRootSize != 0;

public static void ResetSnapback()
{
snapbackRootPos = default;
snapbackRootSize = default;
}

public static void RestoreSnapback()
{
var tm = Find.TickManager;
Expand All @@ -392,8 +398,7 @@ IEnumerator ApplyRootPosAndSize()
{
yield return new WaitForSeconds(0.35f);
Find.CameraDriver.SetRootPosAndSize(snapbackRootPos, snapbackRootSize);
snapbackRootPos = default;
snapbackRootSize = default;
ResetSnapback();
tm.curTimeSpeed = savedSpeed;
}

Expand Down

0 comments on commit 0f0fdb0

Please # to comment.