/// <summary> /// Callback method for the InputHandler#Update method. /// </summary> /// <param name="orig">The original method.</param> /// <param name="self">The InputHandler instance.</param> private void InputHandlerOnUpdate(On.InputHandler.orig_Update orig, InputHandler self) { if (!_netClient.IsConnected) { orig(self); return; } // First evaluate whether the original method would have started the coroutine: // GameManager#PauseGameToggleByMenu var setTimeScale = false; if (self.acceptingInput && self.inputActions.pause.WasPressed && self.pauseAllowed && !PlayerData.instance.GetBool(nameof(PlayerData.disablePause))) { var state = global::GameManager.instance.gameState; if (state == GameState.PLAYING || state == GameState.PAUSED) { setTimeScale = true; } } // Now we execute the original method, which will potentially set the timescale to 0f orig(self); // If we evaluated that the coroutine was started, we can now reset the timescale back to 1 again if (setTimeScale) { SetTimeScale(1f); } }
private static void EnableSuperslides(On.InputHandler.orig_Update orig, InputHandler self) { if (Superslides && GameManager.instance.TimeSlowed) { // Ensure the slide has the correct speed ReflectionHelper.SetAttr(HeroController.instance, "recoilSteps", 0); // Kill the thing that kills superslides ref int timeSlowedCount = ref Mirror.GetFieldRef <GameManager, int>(GameManager.instance, "timeSlowedCount"); int origCount = timeSlowedCount; timeSlowedCount = 0; orig(self); // Restore to old value timeSlowedCount = origCount; }
private static void EnableSuperslides(On.InputHandler.orig_Update orig, InputHandler self) { if (Superslides && GameManager.instance.TimeSlowed) { // Ensure the slide has the correct speed ReflectionHelper.SetAttr(HeroController.instance, "recoilSteps", 0); // Kill the thing that kills superslides int timeSlowedCount = ReflectionHelper.GetAttr <GameManager, int>(GameManager.instance, "timeSlowedCount"); ReflectionHelper.SetAttr(GameManager.instance, "timeSlowedCount", 0); orig(self); // Restore to old value ReflectionHelper.SetAttr(GameManager.instance, "timeSlowedCount", timeSlowedCount); } else { orig(self); } }