/// <summary> /// Freeze the UFPS player (i.e., gameplay) and show the cursor. /// </summary> public void Freeze() { if (fpPlayerEventHandler != null) { fpPlayerEventHandler.Attack.Stop(); } if (fpController != null) { fpController.SetState("Freeze", true); fpController.Stop(); } wasCrosshairVisible = (fpCrosshair != null) && fpCrosshair.enabled; if (fpCrosshair != null) { fpCrosshair.enabled = false; } if (fpCamera != null) { fpCamera.SetState("Freeze", true); } if (fpInput != null) { fpInput.enabled = false; } if (hideHUD && (fpHUD != null)) { fpHUD.enabled = false; } StartCoroutine(ShowCursorAfterOneFrame()); }
private void SetMovementState(bool state) { if (fpController) { if (state == false) { fpController.Stop(); } } }
/// <summary> /// moves the controller to a coordinate in one frame and /// freezes movement and optionally camera input /// </summary> public void FreezePlayer(Vector3 pos, Vector2 startAngle, bool freezeCamera) { m_UnFreezePosition = Controller.transform.position; Teleport(pos, startAngle); Controller.SetState("Freeze", true); Controller.Stop(); if (freezeCamera) { Camera.SetState("Freeze", true); } }
/// <summary>Handles debugging features</summary> private void Update() { // the debug menu shouldn't function if the game is frozen if (Time.timeScale <= 0f) { return; } // toggle the debug menu if (Input.GetKeyDown(KeyCode.F9)) { _debug = !_debug; // if the debug menu was on previously, // turn off any cheats that may be on. if (!_debug) { _noclip = false; _infiniteEnergy = false; _infiniteHealth = false; // make hud visible _hudUi.SetActive(true); } } // debug mode is off, nothing more to do here if (!_debug) { return; } // retrieve object and component references if (_player == null) { _player = GameObject.Find("SimplePlayer"); } if (_fpController == null) { _fpController = _player?.GetComponent <vp_FPController>(); } if (_camera == null) { _camera = GameObject.Find("FPSCamera"); } if (_hudUi == null) { _hudUi = GameObject.Find("HudUI"); } // decrement time of day if (Input.GetKeyDown(KeyCode.LeftBracket)) { _timeDir.AdjustTimeOfDay(-0.0416666679f); // check for negative time if (_timeDir.WorldTime() <= 0f) { _timeDir.SetWorldTime(0f); } } // increment time of day else if (Input.GetKeyDown(KeyCode.RightBracket)) { _timeDir.AdjustTimeOfDay(0.0416666679f); } // toggle help menu if (Input.GetKeyDown(KeyCode.F10)) { _showHelp = !_showHelp; } // add 1000 credits if (Input.GetKeyDown(KeyCode.Equals) || Input.GetKeyDown(KeyCode.KeypadPlus)) { _playerState.AddCurrency(1000); } // subtract 1000 credits else if (Input.GetKeyDown(KeyCode.Minus) || Input.GetKeyDown(KeyCode.KeypadMinus)) { _playerState.AddCurrency(-1000); } // toggle heads-up display if (Input.GetKeyDown(KeyCode.F6)) { _hudUi.SetActive(!_hudUi.activeSelf); } // reset player progress if (Input.GetKeyDown(KeyCode.F12)) { Console.WriteLine("DEBUG: Tutorials/Pedia/Achievements/Progress Reset"); _pediaDir.DebugClearUnlocked(); _tutorialDir.DebugClearCompleted(); _achieveDir.DebugClearAwarded(); _progressDir.DebugClearProgress(); } // unlock all progress else if (Input.GetKeyDown(KeyCode.F11)) { Console.WriteLine("DEBUG: Tutorials/Pedia/Achievements/Progress Unlocked"); _pediaDir.DebugAllUnlocked(); _tutorialDir.DebugAllCompleted(); _achieveDir.DebugAllAwarded(); _progressDir.DebugUnlockProgress(); } // unlock all upgrades if (Input.GetKeyDown(KeyCode.Alpha0)) { Console.WriteLine("DEBUG: All Personal Upgrades"); _playerState.DebugGiveAllUpgrades(); _playerState.SetHealth(_playerState.GetMaxHealth()); _playerState.SetEnergy(_playerState.GetMaxEnergy()); // add 5 keys for (var i = 0; i < 5; i++) { _playerState.AddKey(); } } // fill inventory with random items and ammo if (Input.GetKeyDown(KeyCode.Alpha9)) { Console.WriteLine("DEBUG: Fill Ammo"); _playerState.Ammo.DebugFillRandomAmmo(_playerState.GetMaxAmmo()); } // toggle infinite energy if (Input.GetKeyDown(KeyCode.Alpha6)) { _infiniteEnergy = !_infiniteEnergy; } // toggle infinite health if (Input.GetKeyDown(KeyCode.Alpha7)) { _infiniteHealth = !_infiniteHealth; } // clear inventory if (Input.GetKeyDown(KeyCode.M)) { _playerState.Ammo.Clear(); } // toggle noclip if (Input.GetKeyDown(KeyCode.N) && _player) { _noclip = !_noclip; _noclipPos = _player.transform.position; } // force the game to save if (Input.GetKeyDown(KeyCode.Alpha8)) { Console.WriteLine("DEBUG: Forcing save now"); _autoSave.SaveAllNow(); } // handle noclip, if it's enabled if (_noclip && _camera && _fpController) { // calculate speed, will be multiplied by two if run is held var speed = 20f * (SRInput.Actions.run.State ? 2f : 1f); // add movement _noclipPos += _camera.transform.forward * SRInput.Actions.vertical.RawValue * speed * Time.deltaTime; _noclipPos += _camera.transform.right * SRInput.Actions.horizontal.RawValue * speed * Time.deltaTime; // stop all movement on the controller and reposition it _fpController.Stop(); _fpController.SetPosition(_noclipPos); } if (_infiniteEnergy) // infinite energy's on, set our energy to max { _playerState.SetEnergy(_playerState.GetMaxEnergy()); } if (_infiniteHealth) // god mode's on, set our health to max { _playerState.SetHealth(_playerState.GetMaxHealth()); } }
public void Reset() { player.Stop(); ClearHistory(); }
/// <summary>Handles debugging features</summary> private void Update() { // retrieve the directors { if (_inputDir) // prevent user from submitting bug reports. { var bugReportUI = _inputDir.bugReportPrefab.GetComponentInChildren<BugReportUI>(); bugReportUI.submitButton.interactable = false; bugReportUI.summaryField.interactable = false; bugReportUI.descField.interactable = false; bugReportUI.summaryField.text = "Debug Menu Mod installed - Reporting Issues is deactivated"; bugReportUI.descField.text = "Notice: While this debug menu mod is active, you will not be able to report bugs. " + "This mod is not supported by Monomi Park and never will be."; } } // retrieve object and component references if (!_player) _player = GameObject.Find("SimplePlayer"); if (!_fpController) { _fpController = _player?.GetComponent<vp_FPController>(); if (_noclip) StartNoclip(); } if (!_camera) _camera = GameObject.Find("FPSCamera"); if (!_hudUi) _hudUi = GameObject.Find("HudUI"); // the debug menu shouldn't function if the game is frozen if (Time.timeScale <= 0f) return; // toggle the debug menu if (Input.GetKeyDown(KeyCode.F9)) { _debug = !_debug; // if the debug menu was on previously, // turn off any cheats that may be on. if (!_debug) { _noclip = false; _infiniteEnergy = false; _infiniteHealth = false; // make hud visible _hudUi?.SetActive(true); } } // debug mode is off, nothing more to do here if (!_debug) return; // decrement time of day if (Input.GetKeyDown(KeyCode.LeftBracket)) { _timeDir?.AdjustTimeOfDay(-0.0416666679f); // check for negative time if (_timeDir?.WorldTime() <= 0f) _timeDir?.SetWorldTime(0f); } // increment time of day else if (Input.GetKeyDown(KeyCode.RightBracket)) _timeDir?.AdjustTimeOfDay(0.0416666679f); // toggle help menu if (Input.GetKeyDown(KeyCode.F10)) _showHelp = !_showHelp; // add 1000 credits if (Input.GetKeyDown(KeyCode.Equals) || Input.GetKeyDown(KeyCode.KeypadPlus)) _playerState?.AddCurrency(1000); // subtract 1000 credits else if (Input.GetKeyDown(KeyCode.Minus) || Input.GetKeyDown(KeyCode.KeypadMinus)) _playerState?.AddCurrency(-1000); // toggle heads-up display if (Input.GetKeyDown(KeyCode.F6)) _hudUi?.SetActive(!_hudUi.activeSelf); // reset player progress if (Input.GetKeyDown(KeyCode.F12)) { Console.WriteLine("DEBUG: Tutorials/Pedia/Achievements/Progress Reset"); _pediaDir?.DebugClearUnlocked(); _tutorialDir?.DebugClearCompleted(); _achieveDir?.DebugClearAwarded(); _progressDir?.DebugClearProgress(); } // unlock all progress else if (Input.GetKeyDown(KeyCode.F11)) { Console.WriteLine("DEBUG: Tutorials/Pedia/Achievements/Progress Unlocked"); _pediaDir?.DebugAllUnlocked(); _tutorialDir?.DebugAllCompleted(); _progressDir?.DebugUnlockProgress(); } // unlock all upgrades if (Input.GetKeyDown(KeyCode.Alpha0)) { Console.WriteLine("DEBUG: All Personal Upgrades"); _playerState?.DebugGiveAllUpgrades(); _playerState?.SetHealth(_playerState.GetMaxHealth()); _playerState?.SetEnergy(_playerState.GetMaxEnergy()); // add 5 keys for (var i = 0; i < 5; i++) _playerState?.AddKey(); } // fill inventory with random items and ammo if (Input.GetKeyDown(KeyCode.Alpha9) && _playerState) { Console.WriteLine("DEBUG: Fill Ammo"); _playerState?.Ammo?.DebugFillRandomAmmo(); } // toggle infinite energy if (Input.GetKeyDown(KeyCode.Alpha6)) _infiniteEnergy = !_infiniteEnergy; // toggle infinite health if (Input.GetKeyDown(KeyCode.Alpha7)) _infiniteHealth = !_infiniteHealth; // clear inventory if (Input.GetKeyDown(KeyCode.K)) _playerState?.Ammo?.Clear(); // refill inventory if (Input.GetKeyDown(KeyCode.L) && _playerState) _playerState?.Ammo?.DebugRefillAmmo(); // toggle noclip if (Input.GetKeyDown(KeyCode.N) && _player) { if (!_noclip) StartNoclip(); else StopNoclip(); } // force the game to save if (Input.GetKeyDown(KeyCode.Alpha8)) { Console.WriteLine("DEBUG: Forcing save now"); _autoSave?.SaveAllNow(); } // handle noclip, if it's enabled if (_noclip && _camera && _fpController) { // calculate speed, will be multiplied by two if run is held var speed = 20f * (SRInput.Actions.run.State ? 2f : 1f); // add movement _noclipPos += _camera.transform.forward * SRInput.Actions.vertical.RawValue * speed * Time.deltaTime; _noclipPos += _camera.transform.right * SRInput.Actions.horizontal.RawValue * speed * Time.deltaTime; // stop all movement on the controller and reposition it _fpController?.Stop(); _fpController?.SetPosition(_noclipPos); } if (_infiniteEnergy && _playerState) // infinite energy's on, set our energy to max _playerState.SetEnergy(_playerState.GetMaxEnergy()); if (_infiniteHealth && _playerState) // god mode's on, set our health to max _playerState.SetHealth(_playerState.GetMaxHealth()); }