Skip to content

Commit b65f659

Browse files
committed
Update MAPI for Hollow Knight 1.5.12459 (Unity 6)
Hollow Knight received a major update on Feb 5, 2026 (build 12459) which upgraded the engine to Unity 6 (6000.0.61f1) and introduced significant changes to controller input handling, localization, and scene management. This commit updates the Modding API to compile against and work correctly with the new game binaries. Build system changes (Assembly-CSharp.csproj): - Use FrameworkPathOverride to resolve assemblies from Vanilla/ directory instead of individual HintPath references (required for Unity 6 which ships additional TeamCherry.* and System.* assemblies) - Add System.Memory NuGet package (Unity 6 uses ReadOnlySpan<byte> in Texture2D.LoadImage) - Remove Newtonsoft.Json from dependencies (now shipped with the game) - Remove mscorlib override (no longer needed with Unity 6 runtime) Localization system rewrite: - Delete Patches/Language.cs: The Language class moved from the global namespace to TeamCherry.Localization in HK 1.5. The old MonoMod patch targeting "global::Language.Language" no longer resolves. - Add Language/Language.cs: A backwards-compatible shim in the Language.Language namespace that delegates to TeamCherry.Localization via reflection, with MonoModLinkFrom to redirect existing mod references. This allows mods using Language.Language.Get() to continue working without recompilation. - Update ModHooks.cs LanguageGet to call Language.Language.GetInternal instead of the removed Patches.Language.GetInternal. Mod loading initialization (StartManager.cs): - Move mod loading bootstrap from OnScreenDebugInfo.Awake to StartManager.Awake. The OnScreenDebugInfo component was removed in HK 1.5, so it can no longer serve as the mod loading entry point. - Delete Patches/OnScreenDebugInfo.cs (component no longer exists in game). - Rewrite StartManager.Start to match the new HK 1.5 startup sequence: language verification, PlayerPrefs loading, and scene load state management. - Add deferred Menu_Title scene loading: when mod preloading is active, wait for mods to finish loading before transitioning to Menu_Title instead of using the allowSceneActivation pattern. HeroController patches updated for HK 1.5 game logic: - rb2d.velocity → rb2d.linearVelocity (Unity 6 Rigidbody2D API change) - wallSlideVibrationPlayer.Stop() → vibrationCtrl.StopWallSlide() (HK 1.5 replaced individual vibration players with HeroVibrationController) - Attack(): Add grubberfly beam (charm_35) support for wall slashes, change health check from == to >= for grubberfly beam activation on normal/up/down attacks (matches upstream game logic) - SoulGain(): String literals to nameof() for PlayerData fields - LookForQueueInput(): Remove duplicate CanDash() call - TakeDamage(): Rename flag → carefreeShouldStopDamage for clarity, string literals to nameof(), add explicit returns after death/hazard coroutine starts to match upstream flow control, fix ternary null check on damage angle - OrigDashVector(): Simplify ternary for bump velocity readability InputHandler.OnGUI rewrite: - Replace direct Cursor.visible/Cursor.lockState manipulation with calls to the game's SetCursorVisible() method. This preserves the OnCursorVisibilityChange event and proper cursor lock management through SetCursorEnabled(), fixing controller detection and connection mode switching that was broken by the old approach. GameManager patches: - Import TeamCherry.SharedUtils.Encryption (class moved in HK 1.5) - Add SetPausedState() MonoModIgnore declaration - Rewrite PauseToggleDynamicMenu to match HK 1.5 pause/unpause flow (SetPausedState calls, reordered input prevention, reduced wait times) - SceneManager.UnloadSceneAsync → SceneManager.UnloadScene (API change) SceneManager patches: - Replace DrawBlackBorders() full replacement with OnCameraAspectChanged() hook. HK 1.5 refactored border drawing into the camera aspect change handler with persistent border transforms (borderLeft/Right/Up/Down) instead of instantiating new GameObjects each time. - The ModHooks.OnDrawBlackBorders hook is preserved by collecting the border transforms after orig_OnCameraAspectChanged runs. Other patch updates: - MenuSetting.cs: Add new HK 1.5 settings enum values (SwitchFrameCap, Dithering, Noise, ControllerRumble, HudVisibility, CameraShake, NativeInput, XInput, MFi) - MenuButtonList.cs: Null-conditional on menuButtonLists to prevent NullReferenceException during early UIManager initialization - UIManager.cs: Add ADVANCED_GAMEPAD_MENU and ADVANCED_VIDEO_MENU to MainMenuState enum - TakeDamage.cs: Fix Multiplier ternary to match HK 1.5 operand order - PlayMakerUnity2DProxy.cs: Add explicit this. qualifier - ModHooks.cs: Add bounds checking on version string split to handle version formats with fewer than 4 segments Version: hollowknight.version updated to 1.5.12459 Tested on macOS (Apple M2 Pro) with Unity 6000.0.61f1: - Game launches and reaches title screen - Mod menu appears in Options with working mod list - CompassAlwaysOn and GatheringSwarmAlwaysOn load and function correctly - Controller support works (USB/Bluetooth, vibration, mode switching) - Scene transitions, pause menu, and settings menus all functional - No errors in Player.log or ModLog.txt Builds on work started in PR hk-modding#164 by SFGrenade. Closes hk-modding#169.
1 parent 4f4ff66 commit b65f659

16 files changed

Lines changed: 363 additions & 285 deletions

Assembly-CSharp/Assembly-CSharp.csproj

Lines changed: 16 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1111
<RestorePackagesPath>packages</RestorePackagesPath>
1212
<LangVersion>latest</LangVersion>
13+
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
14+
<NoStdLib>true</NoStdLib>
15+
<FrameworkPathOverride>$(MSBuildProjectDirectory)/../Vanilla</FrameworkPathOverride>
1316
</PropertyGroup>
1417

1518
<ItemGroup>
1619
<Files Include="../Vanilla/*" />
1720

1821
<BuildDir Include="$(TargetDir)" />
1922

20-
<Dependencies Include="$(TargetDir)Newtonsoft.Json.dll" />
2123
<Dependencies Include="$(TargetDir)MMHOOK_Assembly-CSharp.dll" />
2224
<Dependencies Include="$(TargetDir)MMHOOK_PlayMaker.dll" />
2325
<Dependencies Include="$(TargetDir)MonoMod.Utils.dll" />
@@ -72,10 +74,8 @@
7274
<!-- Make the output directory -->
7375
<MakeDir Directories="$(OutputDir)/" />
7476

75-
<!-- Copy the API, the documentation, the overridden mscorlib, and the README. -->
77+
<!-- Copy the API, the documentation, and the README. -->
7678
<Copy SourceFiles="../README.ModdingApi.md" DestinationFiles="$(OutputDir)/README.md" />
77-
<Copy SourceFiles="../override/mscorlib.dll" DestinationFiles="$(OutputDir)/mscorlib.dll" />
78-
<Copy SourceFiles="../override/mscorlib.xml" DestinationFiles="$(OutputDir)/mscorlib.xml" />
7979
<Copy SourceFiles="$(TargetDir)MONOMODDED_Assembly-CSharp.dll" DestinationFiles="$(OutputDir)/Assembly-CSharp.dll" />
8080
<Copy SourceFiles="$(TargetDir)Assembly-CSharp.mm.xml" DestinationFiles="$(OutputDir)/Assembly-CSharp.xml" />
8181

@@ -126,6 +126,7 @@
126126
</PackageReference>
127127

128128
<PackageReference Include="unityscenerepacker" Version="2.4.0" GeneratePathProperty="true" />
129+
<PackageReference Include="System.Memory" Version="4.6.3" />
129130
</ItemGroup>
130131

131132
<ItemGroup>
@@ -141,64 +142,16 @@
141142
</ItemGroup>
142143

143144
<ItemGroup>
144-
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
145-
<HintPath>../Vanilla/Assembly-CSharp.dll</HintPath>
146-
<SpecificVersion>False</SpecificVersion>
147-
</Reference>
148-
<Reference Include="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
149-
<HintPath>..\override\mscorlib.dll</HintPath>
150-
</Reference>
151-
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
152-
<HintPath>../Vanilla/netstandard.dll</HintPath>
153-
</Reference>
154-
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=null">
155-
<HintPath>../JsonNet/Newtonsoft.Json.dll</HintPath>
156-
</Reference>
157-
<Reference Include="PlayMaker, Version=1.6.0.0, Culture=neutral, processorArchitecture=MSIL">
158-
<HintPath>../Vanilla/PlayMaker.dll</HintPath>
159-
<SpecificVersion>False</SpecificVersion>
160-
</Reference>
161-
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
162-
<HintPath>../Vanilla/UnityEngine.dll</HintPath>
163-
</Reference>
164-
<Reference Include="UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
165-
<HintPath>../Vanilla/UnityEngine.AnimationModule.dll</HintPath>
166-
</Reference>
167-
<Reference Include="UnityEngine.AssetBundleModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
168-
<HintPath>../Vanilla/UnityEngine.AssetBundleModule.dll</HintPath>
169-
</Reference>
170-
<Reference Include="UnityEngine.AudioModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
171-
<HintPath>../Vanilla/UnityEngine.AudioModule.dll</HintPath>
172-
</Reference>
173-
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
174-
<HintPath>../Vanilla/UnityEngine.CoreModule.dll</HintPath>
175-
</Reference>
176-
<Reference Include="UnityEngine.ImageConversionModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
177-
<HintPath>../Vanilla/UnityEngine.ImageConversionModule.dll</HintPath>
178-
</Reference>
179-
<Reference Include="UnityEngine.IMGUIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
180-
<HintPath>../Vanilla/UnityEngine.IMGUIModule.dll</HintPath>
181-
</Reference>
182-
<Reference Include="UnityEngine.InputLegacyModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
183-
<HintPath>../Vanilla/UnityEngine.InputLegacyModule.dll</HintPath>
184-
</Reference>
185-
<Reference Include="UnityEngine.JSONSerializeModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
186-
<HintPath>../Vanilla/UnityEngine.JSONSerializeModule.dll</HintPath>
187-
</Reference>
188-
<Reference Include="UnityEngine.ParticleSystemModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
189-
<HintPath>../Vanilla/UnityEngine.ParticleSystemModule.dll</HintPath>
190-
</Reference>
191-
<Reference Include="UnityEngine.Physics2DModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
192-
<HintPath>../Vanilla/UnityEngine.Physics2DModule.dll</HintPath>
193-
</Reference>
194-
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
195-
<HintPath>../Vanilla/UnityEngine.TextRenderingModule.dll</HintPath>
196-
</Reference>
197-
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
198-
<HintPath>../Vanilla/UnityEngine.UI.dll</HintPath>
199-
</Reference>
200-
<Reference Include="UnityEngine.UIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
201-
<HintPath>../Vanilla/UnityEngine.UIModule.dll</HintPath>
202-
</Reference>
145+
<Reference Include="../Vanilla/Assembly-CSharp.dll"/>
146+
<Reference Include="../Vanilla/mscorlib.dll"/>
147+
<!--<Reference Include="../override/mscorlib.dll"/>-->
148+
<Reference Include="../Vanilla/netstandard.dll"/>
149+
<Reference Include="../Vanilla/Newtonsoft.Json.dll"/>
150+
<Reference Include="../Vanilla/PlayMaker.dll"/>
151+
<Reference Include="../Vanilla/UnityEngine.dll"/>
152+
<Reference Include="../Vanilla/UnityEngine.*.dll"/>
153+
<Reference Include="../Vanilla/TeamCherry.*.dll"/>
154+
<Reference Include="../Vanilla/System.dll"/>
155+
<Reference Include="../Vanilla/System.*.dll"/>
203156
</ItemGroup>
204157
</Project>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Reflection;
4+
using UObject = UnityEngine.Object;
5+
using USystemLanguage = UnityEngine.SystemLanguage;
6+
7+
namespace Language;
8+
9+
// for backwards compatibility
10+
[MonoMod.MonoModLinkFrom("TeamCherry.Localization.Language")]
11+
public static class Language
12+
{
13+
static Language()
14+
{
15+
TllType = Type.GetType("TeamCherry.Localization.Language, TeamCherry.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
16+
TllLoadLanguage = TllType.GetMethod("LoadLanguage", BindingFlags.Public | BindingFlags.Static, null, Array.Empty<Type>(), Array.Empty<ParameterModifier>());
17+
TllLoadAvailableLanguages = TllType.GetMethod("LoadAvailableLanguages", BindingFlags.Public | BindingFlags.Static, null, Array.Empty<Type>(), Array.Empty<ParameterModifier>());
18+
TllGetLanguages = TllType.GetMethod("GetLanguages", BindingFlags.Public | BindingFlags.Static, null, Array.Empty<Type>(), Array.Empty<ParameterModifier>());
19+
TllSwitchLanguageStr = TllType.GetMethod("SwitchLanguage", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
20+
TllSwitchLanguageLc = TllType.GetMethod("SwitchLanguage", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(TeamCherry.Localization.LanguageCode) }, Array.Empty<ParameterModifier>());
21+
TllGetAsset = TllType.GetMethod("GetAsset", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
22+
TllCurrentLanguage = TllType.GetMethod("CurrentLanguage", BindingFlags.Public | BindingFlags.Static, null, Array.Empty<Type>(), Array.Empty<ParameterModifier>());
23+
TllGet1 = TllType.GetMethod("Get", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
24+
TllGetSheets = TllType.GetMethod("GetSheets", BindingFlags.Public | BindingFlags.Static, null, Array.Empty<Type>(), Array.Empty<ParameterModifier>());
25+
TllGetKeys = TllType.GetMethod("GetKeys", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
26+
TllHas1 = TllType.GetMethod("Has", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
27+
TllHas2 = TllType.GetMethod("Has", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string), typeof(string) }, Array.Empty<ParameterModifier>());
28+
TllHasSheet = TllType.GetMethod("HasSheet", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
29+
TllLanguageNameToCode = TllType.GetMethod("LanguageNameToCode", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(USystemLanguage) }, Array.Empty<ParameterModifier>());
30+
TllGet2 = TllType.GetMethod("Get", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string), typeof(string) }, Array.Empty<ParameterModifier>());
31+
}
32+
private static readonly Type TllType;
33+
34+
private static readonly MethodInfo TllLoadLanguage;
35+
public static void LoadLanguage() => TllLoadLanguage.Invoke(null, Array.Empty<object>());
36+
37+
private static readonly MethodInfo TllLoadAvailableLanguages;
38+
public static void LoadAvailableLanguages() => TllLoadAvailableLanguages.Invoke(null, Array.Empty<object>());
39+
40+
private static readonly MethodInfo TllGetLanguages;
41+
public static string[] GetLanguages() => (string[])(TllGetLanguages.Invoke(null, Array.Empty<object>()));
42+
43+
private static readonly MethodInfo TllSwitchLanguageStr;
44+
public static bool SwitchLanguage(string langCode) => (bool)(TllSwitchLanguageStr.Invoke(null, new object[] { langCode }));
45+
46+
private static readonly MethodInfo TllSwitchLanguageLc;
47+
public static bool SwitchLanguage(TeamCherry.Localization.LanguageCode code) => (bool)(TllSwitchLanguageLc.Invoke(null, new object[] { code }));
48+
49+
private static readonly MethodInfo TllGetAsset;
50+
public static UObject GetAsset(string name) => (UObject)(TllGetAsset.Invoke(null, new object[] { name }));
51+
52+
private static readonly MethodInfo TllCurrentLanguage;
53+
public static TeamCherry.Localization.LanguageCode CurrentLanguage() => (TeamCherry.Localization.LanguageCode)(TllCurrentLanguage.Invoke(null, Array.Empty<object>()));
54+
55+
private static readonly MethodInfo TllGet1;
56+
public static string Get(string key) => (string)(TllGet1.Invoke(null, new object[] { key }));
57+
58+
private static readonly MethodInfo TllGetSheets;
59+
public static IEnumerable<string> GetSheets() => (IEnumerable<string>)(TllGetSheets.Invoke(null, Array.Empty<object>()));
60+
61+
private static readonly MethodInfo TllGetKeys;
62+
public static IEnumerable<string> GetKeys(string sheetTitle) => (IEnumerable<string>)(TllGetKeys.Invoke(null, new object[] { sheetTitle }));
63+
64+
private static readonly MethodInfo TllHas1;
65+
public static bool Has(string key) => (bool)(TllHas1.Invoke(null, new object[] { key }));
66+
67+
private static readonly MethodInfo TllHas2;
68+
public static bool Has(string key, string sheet) => (bool)(TllHas2.Invoke(null, new object[] { key, sheet }));
69+
70+
private static readonly MethodInfo TllHasSheet;
71+
public static bool HasSheet(string sheet) => (bool)(TllHasSheet.Invoke(null, new object[] { sheet }));
72+
73+
private static readonly MethodInfo TllLanguageNameToCode;
74+
public static TeamCherry.Localization.LanguageCode LanguageNameToCode(USystemLanguage name) => (TeamCherry.Localization.LanguageCode)(TllLanguageNameToCode.Invoke(null, new object[] { name }));
75+
76+
private static readonly MethodInfo TllGet2;
77+
public static string GetInternal(string key, string sheetTitle) => (string)(TllGet2.Invoke(null, new object[] { key, sheetTitle }));
78+
79+
public static string Get(string key, string sheetTitle) => Modding.ModHooks.LanguageGet(key, sheetTitle);
80+
}

Assembly-CSharp/ModHooks.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ static ModHooks()
6161
{
6262
string[] versionNums = Constants.GAME_VERSION.Split('.');
6363

64-
gameVersion.major = Convert.ToInt32(versionNums[0]);
65-
gameVersion.minor = Convert.ToInt32(versionNums[1]);
66-
gameVersion.revision = Convert.ToInt32(versionNums[2]);
67-
gameVersion.package = Convert.ToInt32(versionNums[3]);
64+
gameVersion.major = versionNums.Length > 0 ? Convert.ToInt32(versionNums[0]) : 0;
65+
gameVersion.minor = versionNums.Length > 1 ? Convert.ToInt32(versionNums[1]) : 0;
66+
gameVersion.revision = versionNums.Length > 2 ? Convert.ToInt32(versionNums[2]) : 0;
67+
gameVersion.package = versionNums.Length > 3 ? Convert.ToInt32(versionNums[3]) : 0;
6868
}
6969
catch (Exception e)
7070
{
@@ -225,7 +225,7 @@ internal static void LogConsole(string message, LogLevel level)
225225
/// <remarks>N/A</remarks>
226226
internal static string LanguageGet(string key, string sheet)
227227
{
228-
string res = Patches.Language.GetInternal(key, sheet);
228+
string res = Language.Language.GetInternal(key, sheet);
229229

230230
if (LanguageGetHook == null)
231231
return res;

Assembly-CSharp/Patches/GameManager.cs

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Newtonsoft.Json;
99
using UnityEngine;
1010
using UnityEngine.SceneManagement;
11+
using Encryption = TeamCherry.SharedUtils.Encryption;
1112

1213
// ReSharper disable all
1314
#pragma warning disable 1591, 649, 414, 169, CS0108, CS0626
@@ -196,9 +197,7 @@ public void SaveGame(int saveSlot, Action<bool> callback)
196197
text = JsonUtility.ToJson(obj);
197198
}
198199

199-
bool flag = this.gameConfig.useSaveEncryption && !Platform.Current.IsFileSystemProtected;
200-
201-
if (flag)
200+
if (this.gameConfig.useSaveEncryption && !Platform.Current.IsFileSystemProtected)
202201
{
203202
string graph = Encryption.Encrypt(text);
204203
BinaryFormatter binaryFormatter = new BinaryFormatter();
@@ -578,12 +577,12 @@ public IEnumerator LoadSceneAdditive(string destScene)
578577
AsyncOperation loadop = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(destScene, LoadSceneMode.Additive);
579578
loadop.allowSceneActivation = true;
580579
yield return loadop;
581-
yield return UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(exitingScene);
580+
UnityEngine.SceneManagement.SceneManager.UnloadScene(exitingScene);
582581
ModHooks.OnSceneChanged(destScene);
583582
this.RefreshTilemapInfo(destScene);
584583
if (this.IsUnloadAssetsRequired(exitingScene, destScene))
585584
{
586-
Debug.LogFormat(this, "Unloading assets due to zone transition", new object[0]);
585+
Debug.LogFormat(this, "Unloading assets due to zone transition", Array.Empty<object>());
587586
yield return Resources.UnloadUnusedAssets();
588587
}
589588

@@ -628,48 +627,46 @@ public void OnWillActivateFirstLevel()
628627
[MonoModIgnore]
629628
public extern void SetTimeScale(float timescale);
630629

630+
[MonoModIgnore]
631+
private extern void SetPausedState(bool value);
632+
631633
// code has been copied from PauseGameToggle
632634
public IEnumerator PauseToggleDynamicMenu(MenuScreen screen, bool allowUnpause = false)
633635
{
634-
if (!this.TimeSlowed)
636+
if (this.TimeSlowed)
637+
{
638+
yield break;
639+
}
640+
if (!this.playerData.GetBool(nameof(PlayerData.disablePause)) && this.gameState == GlobalEnums.GameState.PLAYING)
635641
{
636-
if (!this.playerData.GetBool(nameof(PlayerData.disablePause)) && this.gameState == GlobalEnums.GameState.PLAYING)
642+
this.isPaused = true;
643+
this.ui.SetState(GlobalEnums.UIState.PAUSED);
644+
this.SetPausedState(true);
645+
this.SetState(GlobalEnums.GameState.PAUSED);
646+
if (HeroController.instance != null)
637647
{
638-
this.gameCams.StopCameraShake();
639-
this.inputHandler.PreventPause();
640-
this.inputHandler.StopUIInput();
641-
this.actorSnapshotPaused.TransitionTo(0f);
642-
this.isPaused = true;
643-
this.SetState(GlobalEnums.GameState.PAUSED);
644-
this.ui.AudioGoToPauseMenu(0.2f);
645-
this.ui.UIPauseToDynamicMenu(screen);
646-
if (HeroController.instance != null)
647-
{
648-
HeroController.instance.Pause();
649-
}
650-
this.gameCams.MoveMenuToHUDCamera();
651-
this.SetTimeScale(0f);
652-
yield return new WaitForSecondsRealtime(0.8f);
653-
this.inputHandler.AllowPause();
648+
HeroController.instance.Pause();
654649
}
655-
else if (allowUnpause && this.gameState == GlobalEnums.GameState.PAUSED)
650+
this.gameCams.MoveMenuToHUDCamera();
651+
this.inputHandler.PreventPause();
652+
this.inputHandler.StopUIInput();
653+
yield return new WaitForSecondsRealtime(0.3f);
654+
this.inputHandler.AllowPause();
655+
}
656+
else if (allowUnpause && this.gameState == GlobalEnums.GameState.PAUSED)
657+
{
658+
this.isPaused = false;
659+
this.inputHandler.PreventPause();
660+
this.ui.SetState(GlobalEnums.UIState.PLAYING);
661+
this.SetPausedState(false);
662+
this.SetState(GlobalEnums.GameState.PLAYING);
663+
if (HeroController.instance != null)
656664
{
657-
this.gameCams.ResumeCameraShake();
658-
this.inputHandler.PreventPause();
659-
this.actorSnapshotUnpaused.TransitionTo(0f);
660-
this.isPaused = false;
661-
this.ui.AudioGoToGameplay(0.2f);
662-
this.ui.SetState( GlobalEnums.UIState.PLAYING);
663-
this.SetState( GlobalEnums.GameState.PLAYING);
664-
if (HeroController.instance != null)
665-
{
666-
HeroController.instance.UnPause();
667-
}
668-
MenuButtonList.ClearAllLastSelected();
669-
this.SetTimeScale(1f);
670-
yield return new WaitForSecondsRealtime(0.8f);
671-
this.inputHandler.AllowPause();
665+
HeroController.instance.UnPause();
672666
}
667+
MenuButtonList.ClearAllLastSelected();
668+
yield return new WaitForSecondsRealtime(0.3f);
669+
this.inputHandler.AllowPause();
673670
}
674671
yield break;
675672
}

0 commit comments

Comments
 (0)