private void UpdateLocal() { _serverTime += Time.unscaledDeltaTime; if (_state == State.NotLoaded) { return; } if (_state == State.FastForwarding) { var diff = _serverTime - Time.timeSinceLevelLoad; Time.timeScale = Mathf.Lerp(MinFastForwardSpeed, MaxFastForwardSpeed, Mathf.Abs(diff) / MaxFastForwardDiff); } else { Time.timeScale = _timeScale; } bool isDoneFastForwarding = _state == State.FastForwarding && Time.timeSinceLevelLoad >= _serverTime; bool isDonePausing = _state == State.Pausing && Time.timeSinceLevelLoad < _serverTime; if (isDoneFastForwarding || isDonePausing) { ResetTimeScale(); } if (!_isInputEnabled && OWInput.GetInputMode() != InputMode.None) { DisableInput(); } }
public void SwitchTo3rdPerson() { if (!IsSetUp) { DebugLog.ToConsole("Warning - Camera not set up!", MessageType.Warning); OWInput.ChangeInputMode(InputMode.None); Mode = CameraMode.ThirdPerson; return; } if (Mode == CameraMode.ThirdPerson) { DebugLog.ToConsole("Warning - Already in 3rd person!", MessageType.Warning); return; } if (OWInput.GetInputMode() != InputMode.Character) { DebugLog.ToConsole("Warning - Cannot change to 3rd person while not in Character inputmode!", MessageType.Warning); return; } OWInput.ChangeInputMode(InputMode.None); QSBEventManager.FireEvent("SwitchActiveCamera", _owCamera); Locator.GetPlayerCamera().mainCamera.enabled = false; if (_cameraObj.GetComponent <PostProcessingBehaviour>() == null) { var postProcessing = _cameraObj.AddComponent <PostProcessingBehaviour>(); postProcessing.profile = Locator.GetPlayerCamera().gameObject.GetComponent <PostProcessingBehaviour>().profile; } _camera.enabled = true; Mode = CameraMode.ThirdPerson; }
static void PatchTurning(PlayerCharacterController __instance) { if (OWInput.GetInputMode() != InputMode.Character) { return; } var playerCam = __instance.GetValue <OWCamera>("_playerCam"); var transform = __instance.GetValue <Transform>("_transform"); Quaternion fromTo = Quaternion.FromToRotation(transform.forward, Vector3.ProjectOnPlane(playerCam.transform.forward, transform.up)); var magnitudeUp = 1 - Vector3.ProjectOnPlane(playerCam.transform.up, transform.up).magnitude; var magnitudeForward = 1 - Vector3.ProjectOnPlane(playerCam.transform.up, transform.right).magnitude; var magnitude = magnitudeUp + magnitudeForward; if (magnitude < 0.3f) { return; } var targetRotation = fromTo * transform.rotation; var inverseRotation = Quaternion.Inverse(fromTo) * _playArea.rotation; var maxDegreesDelta = magnitude * 3f; _playArea.rotation = Quaternion.RotateTowards(_playArea.rotation, inverseRotation, maxDegreesDelta); transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, maxDegreesDelta); }
public void UpdateStateObjects() { if (OWInput.GetInputMode() == InputMode.None) { return; } FlashLight?.UpdateState(FlagsHelper.IsSet(State, State.Flashlight)); Translator?.ChangeEquipState(FlagsHelper.IsSet(State, State.Translator)); ProbeLauncher?.ChangeEquipState(FlagsHelper.IsSet(State, State.ProbeLauncher)); Signalscope?.ChangeEquipState(FlagsHelper.IsSet(State, State.Signalscope)); PlayerRegistry.GetSyncObject <AnimationSync>(NetId)?.SetSuitState(FlagsHelper.IsSet(State, State.Suit)); }
public void UpdateStateObjects() { if (OWInput.GetInputMode() == InputMode.None) { return; } FlashLight?.UpdateState(FlagsHelper.IsSet(State, State.Flashlight)); Translator?.ChangeEquipState(FlagsHelper.IsSet(State, State.Translator)); ProbeLauncher?.ChangeEquipState(FlagsHelper.IsSet(State, State.ProbeLauncher)); Signalscope?.ChangeEquipState(FlagsHelper.IsSet(State, State.Signalscope)); QSBCore.UnityEvents.RunWhen(() => QSBPlayerManager.GetSyncObject <AnimationSync>(PlayerId) != null, () => QSBPlayerManager.GetSyncObject <AnimationSync>(PlayerId).SetSuitState(FlagsHelper.IsSet(State, State.Suit))); }
private static void PatchTurning(OWCamera ____playerCam, Transform ____transform) { var runSpeedX = _playerAnimator.GetFloat("RunSpeedX"); var runSpeedY = _playerAnimator.GetFloat("RunSpeedY"); var isStopped = runSpeedX + runSpeedY == 0; var isControllerOriented = !isStopped && NomaiVR.Config.controllerOrientedMovement; if ((OWInput.GetInputMode() != InputMode.Character)) { return; } var rotationSource = isControllerOriented ? LaserPointer.Behaviour.LeftHandLaser : ____playerCam.transform; var fromTo = Quaternion.FromToRotation(____transform.forward, Vector3.ProjectOnPlane(rotationSource.transform.forward, ____transform.up)); var magnitude = 0f; if (!isControllerOriented) { var magnitudeUp = 1 - Vector3.ProjectOnPlane(rotationSource.transform.up, ____transform.up).magnitude; var magnitudeForward = 1 - Vector3.ProjectOnPlane(rotationSource.transform.up, ____transform.right).magnitude; magnitude = magnitudeUp + magnitudeForward; if (magnitude < 0.3f) { return; } } var targetRotation = fromTo * ____transform.rotation; var inverseRotation = Quaternion.Inverse(fromTo) * _playArea.rotation; if (isControllerOriented) { _playArea.rotation = inverseRotation; ____transform.rotation = targetRotation; } else { var maxDegreesDelta = magnitude * 3f; _playArea.rotation = Quaternion.RotateTowards(_playArea.rotation, inverseRotation, maxDegreesDelta); ____transform.rotation = Quaternion.RotateTowards(____transform.rotation, targetRotation, maxDegreesDelta); } }
public void UpdateObjectsFromStates() { if (OWInput.GetInputMode() == InputMode.None) { // ? why is this here lmao return; } if (CameraBody == null) { return; } FlashLight?.UpdateState(FlashlightActive); Translator?.ChangeEquipState(TranslatorEquipped); ProbeLauncher?.ChangeEquipState(ProbeLauncherEquipped); Signalscope?.ChangeEquipState(SignalscopeEquipped); AnimationSync.SetSuitState(SuitedUp); }
private void UpdateLocal() { _serverTime += Time.unscaledDeltaTime; if (_state == State.NotLoaded) { return; } if (_state == State.FastForwarding) { var diff = _serverTime - Time.timeSinceLevelLoad; Time.timeScale = Mathf.Lerp(MinFastForwardSpeed, MaxFastForwardSpeed, Mathf.Abs(diff) / MaxFastForwardDiff); if (QSBSceneManager.CurrentScene == OWScene.SolarSystem && _isFirstFastForward) { var spawnPoint = Locator.GetPlayerBody().GetComponent <PlayerSpawner>().GetInitialSpawnPoint().transform; Locator.GetPlayerTransform().position = spawnPoint.position; Locator.GetPlayerTransform().rotation = spawnPoint.rotation; Physics.SyncTransforms(); } } else { Time.timeScale = _timeScale; } var isDoneFastForwarding = _state == State.FastForwarding && Time.timeSinceLevelLoad >= _serverTime; var isDonePausing = _state == State.Pausing && Time.timeSinceLevelLoad < _serverTime; if (isDoneFastForwarding || isDonePausing) { ResetTimeScale(); } if (!_isInputEnabled && OWInput.GetInputMode() != InputMode.None) { DisableInput(); } }
private void Update() { if (_currentDialogueBox != null && OWInput.GetInputMode() == InputMode.Dialogue) { if (OWInput.IsNewlyPressed(InputLibrary.interact) || OWInput.IsNewlyPressed(InputLibrary.cancel) || OWInput.IsNewlyPressed(InputLibrary.enter) || OWInput.IsNewlyPressed(InputLibrary.enter2)) { if (!_currentDialogueBox.AreTextEffectsComplete()) { _currentDialogueBox.FinishAllTextEffects(); return; } if (_currentDialogueBox.TimeCompletelyRevealed() < 0.1f) { return; } var selectedOption = _currentDialogueBox.GetSelectedOption(); if (!InputDialogueOption(selectedOption)) { EndConversation(); return; } } else { if (OWInput.IsNewlyPressed(InputLibrary.down) || OWInput.IsNewlyPressed(InputLibrary.down2)) { _currentDialogueBox.OnDownPressed(); return; } if (OWInput.IsNewlyPressed(InputLibrary.up) || OWInput.IsNewlyPressed(InputLibrary.up2)) { _currentDialogueBox.OnUpPressed(); } } } }
void Update() { if (OWInput.GetInputMode() == InputMode.None) { this._degreesY = OWInput.GetValue(InputLibrary.look, InputMode.All).y * 2f; this._degreesX = OWInput.GetValue(InputLibrary.look, InputMode.All).x * 2f; MainClass._camera.transform.Rotate(Vector3.up, _degreesX); MainClass._camera.transform.Rotate(Vector3.right, -_degreesY); if (Input.GetKey(KeyCode.LeftShift)) { if (MainClass._moveSpeed == 7f) { MainClass._moveSpeed = 14f; } if (MainClass._moveSpeed == 1000f) { MainClass._moveSpeed = 2000; } } else { if (MainClass._moveSpeed == 14f) { MainClass._moveSpeed = 7f; } if (MainClass._moveSpeed == 2000f) { MainClass._moveSpeed = 1000; } } if (Input.GetKey(KeyCode.W)) { MainClass._freeCam.transform.position += MainClass._freeCam.transform.forward * 0.02f * MainClass._moveSpeed; } if (Input.GetKey(KeyCode.S)) { MainClass._freeCam.transform.position -= MainClass._freeCam.transform.forward * 0.02f * MainClass._moveSpeed; } if (Input.GetKey(KeyCode.A)) { MainClass._freeCam.transform.position -= MainClass._freeCam.transform.right * 0.02f * MainClass._moveSpeed; } if (Input.GetKey(KeyCode.D)) { MainClass._freeCam.transform.position += MainClass._freeCam.transform.right * 0.02f * MainClass._moveSpeed; } if (Input.GetKey(KeyCode.Q)) { MainClass._freeCam.transform.Rotate(Vector3.forward, 1); } if (Input.GetKey(KeyCode.E)) { MainClass._freeCam.transform.Rotate(Vector3.forward, -1); } } }
private void OnGUI() { if (_playerController == null || _playerForceDetector == null) { this._playerForceDetector = Locator.GetPlayerForceDetector(); this._playerController = Locator.GetPlayerController(); if (_playerController == null || _playerForceDetector == null) { return; } } float num = 400f; if (GUIMode.IsHiddenMode() || PlayerState.UsingShipComputer()) { return; } if (inputHUD == 1) { GUI.Label(new Rect(10f + num, 10f, 200f, 20f), "Time Scale: " + Mathf.Round(Time.timeScale * 100f) / 100f); GUI.Label(new Rect(10f + num, 25f, 200f, 20f), string.Concat(new object[] { "Time Remaining: ", Mathf.Floor(TimeLoop.GetSecondsRemaining() / 60f), ":", Mathf.Round(TimeLoop.GetSecondsRemaining() % 60f * 100f / 100f) })); GUI.Label(new Rect(10f + num, 40f, 200f, 20f), "Loop Count: " + TimeLoop.GetLoopCount()); GUI.Label(new Rect(10f + num, 55f, 90f, 40f), "PauseFlags: "); GUI.Label(new Rect(100f + num, 55f, 50f, 40f), "MENU\n" + ((!OWTime.IsPaused(OWTime.PauseType.Menu)) ? "FALSE" : "TRUE ")); GUI.Label(new Rect(150f + num, 55f, 50f, 40f), "LOAD\n" + ((!OWTime.IsPaused(OWTime.PauseType.Loading)) ? "FALSE" : "TRUE ")); GUI.Label(new Rect(200f + num, 55f, 50f, 40f), "READ\n" + ((!OWTime.IsPaused(OWTime.PauseType.Reading)) ? "FALSE" : "TRUE ")); GUI.Label(new Rect(250f + num, 55f, 50f, 40f), "SLP\n" + ((!OWTime.IsPaused(OWTime.PauseType.Sleeping)) ? "FALSE" : "TRUE ")); GUI.Label(new Rect(300f + num, 55f, 50f, 40f), "INIT\n" + ((!OWTime.IsPaused(OWTime.PauseType.Initializing)) ? "FALSE" : "TRUE ")); GUI.Label(new Rect(350f + num, 55f, 50f, 40f), "STRM\n" + ((!OWTime.IsPaused(OWTime.PauseType.Streaming)) ? "FALSE" : "TRUE ")); GUI.Label(new Rect(400f + num, 55f, 50f, 40f), "SYS\n" + ((!OWTime.IsPaused(OWTime.PauseType.System)) ? "FALSE" : "TRUE ")); GUI.Label(new Rect(10f + num, 85f, 200f, 20f), "Input Mode: " + OWInput.GetInputMode().ToString()); this._inputModeArray = OWInput.GetInputModeStack(); GUI.Label(new Rect(10f + num, 100f, 200f, 20f), "Input Mode Stack: "); int num2 = 150; int num3 = 0; while (num3 < this._inputModeArray.Length && this._inputModeArray[num3] != InputMode.None) { GUI.Label(new Rect((float)num2 + num, 100f, 200f, 20f), this._inputModeArray[num3].ToString()); num2 += 75; num3++; } GUI.Label(new Rect(10f + num, 115f, 300f, 20f), "Net Force Accel: " + Mathf.Round(this._playerForceDetector.GetForceAcceleration().magnitude * 100f) / 100f); GUI.Label(new Rect(210f + num, 115f, 300f, 20f), "G-Force: " + Mathf.Round(this._gForce * 100f) / 100f); GUI.Label(new Rect(10f + num, 130f, 200f, 20f), "Load Time: " + LoadTimeTracker.GetLatestLoadTime()); if (DynamicResolutionManager.isEnabled) { GUI.Label(new Rect(10f + num, 145f, 200f, 20f), "Resolution Scale: " + DynamicResolutionManager.currentResolutionScale); } GUI.Label(new Rect(10f + num, 160f, 200f, 20f), "Player Speed: " + (Locator.GetCenterOfTheUniverse().GetOffsetVelocity() + Locator.GetPlayerBody().GetVelocity()).magnitude.ToString()); GUI.Label(new Rect(210f + num, 160f, 200f, 20f), "Player Accel: " + Locator.GetPlayerBody().GetAcceleration().magnitude.ToString()); if (Locator.GetPlayerSuit().GetComponent <JetpackThrusterModel>()) { GUI.Label(new Rect(10f + num, 175f, 200f, 20f), string.Concat(new object[] { "Jetpack Max Accel: ", Locator.GetPlayerSuit().GetComponent <JetpackThrusterModel>().GetMaxTranslationalThrust().ToString(), "/", Locator.GetPlayerSuit().GetComponent <JetpackThrusterModel>().GetBoostMaxThrust().ToString() })); } if (Locator.GetShipBody().GetComponent <ShipThrusterModel>()) { GUI.Label(new Rect(210f + num, 175f, 200f, 20f), "Ship Max Accel: " + Locator.GetShipBody().GetComponent <ShipThrusterModel>().GetMaxTranslationalThrust().ToString()); } GUI.Label(new Rect(10f + num, 190f, 400f, 20f), string.Concat(new object[] { "Inspector layer: ", rayMask, " ", LayerMask.LayerToName(rayMask) })); if (GetWarpOWRigidbody()) { GUI.Label(new Rect(10f + num, 205f, 400f, 20f), string.Concat(new string[] { "Warp Body: ", GetWarpOWRigidbody().gameObject.name, " layer: ", GetWarpOWRigidbody().gameObject.layer.ToString(), " ", LayerMask.LayerToName(GetWarpOWRigidbody().gameObject.layer) })); } if (hit.collider) { GUI.Label(new Rect(10f + num, 220f, 400f, 20f), string.Concat(new string[] { "Latest hit layer: ", hit.collider.gameObject.layer.ToString(), " ", LayerMask.LayerToName(hit.collider.gameObject.layer) })); GUI.Label(new Rect(10f + num, 235f, 600f, 20f), "Name: " + hit.collider.gameObject.name + " Distance: " + (hit.point - Locator.GetPlayerBody().transform.position).magnitude.ToString()); } /*if (PadEZ.PadManager.GetActiveController()!=null) * { * GUI.Label(new Rect(10f + num, 250f, 600f, 20f), PadEZ.PadManager.GetActiveController().GetIndex().ToString() + " " + PadEZ.PadManager.GetActiveController().GetPadType().ToString() +" "+ UnityEngine.Input.GetJoystickNames()[PadEZ.PadManager.GetActiveController().GetIndex()]); * }*/ } if (inputHUD == 2) { GUI.Label(new Rect(10f, 10f, 300f, 2500f), ReadInputManager.ReadCommandInputs(false)); } if (inputHUD == 3) { GUI.Label(new Rect(0f, 0f, 300f, 2500f), ReadInputManager.ReadCommandInputs(false)); GUI.Label(new Rect(300f, 0f, 300f, 2500f), ReadInputManager.ReadCommandInputs(true)); } if (inputHUD == 4) { GUI.Label(new Rect(0f, 0f, 500f, 2500f), ReadInputManager.ReadInputAxes()); GUI.Label(new Rect(500f, 0f, 500f, 2500f), ReadInputManager.ReadRawInputManagerButtons()); } }
void Update() { if (inputEnabled) { if (Input.GetKeyDown(KeyCode.UpArrow)) { SetupCamera(); } if (Input.GetKeyDown(KeyCode.LeftArrow)) { if (Locator.GetPlayerSuit().IsWearingHelmet()) { Locator.GetPlayerSuit().RemoveHelmet(); } else { Locator.GetPlayerSuit().PutOnHelmet(); } } if (Input.GetKeyDown(KeyCode.KeypadDivide)) { Time.timeScale = 0f; } if (Input.GetKeyDown(KeyCode.KeypadMultiply)) { Time.timeScale = 0.5f; } if (Input.GetKeyDown(KeyCode.KeypadMinus)) { Time.timeScale = 1f; } if (Input.GetKeyDown(KeyCode.Keypad0)) { _freeCam.transform.parent = Locator.GetPlayerTransform(); } if (Input.GetKeyDown(KeyCode.Keypad1)) { _freeCam.transform.parent = Locator.GetSunTransform(); } if (Input.GetKeyDown(KeyCode.Keypad2)) { _freeCam.transform.parent = Locator.GetAstroObject(AstroObject.Name.Comet).gameObject.transform; } if (Input.GetKeyDown(KeyCode.Keypad3)) { _freeCam.transform.parent = Locator.GetAstroObject(AstroObject.Name.CaveTwin).gameObject.transform; } if (Input.GetKeyDown(KeyCode.Keypad4)) { _freeCam.transform.parent = Locator.GetAstroObject(AstroObject.Name.TowerTwin).gameObject.transform; } if (Input.GetKeyDown(KeyCode.Keypad5)) { _freeCam.transform.parent = Locator.GetAstroObject(AstroObject.Name.TimberHearth).gameObject.transform; } if (Input.GetKeyDown(KeyCode.Keypad6)) { _freeCam.transform.parent = Locator.GetAstroObject(AstroObject.Name.BrittleHollow).gameObject.transform; } if (Input.GetKeyDown(KeyCode.Keypad7)) { _freeCam.transform.parent = Locator.GetAstroObject(AstroObject.Name.GiantsDeep).gameObject.transform; } if (Input.GetKeyDown(KeyCode.Keypad8)) { _freeCam.transform.parent = Locator.GetAstroObject(AstroObject.Name.DarkBramble).gameObject.transform; } if (Input.GetKeyDown(KeyCode.Keypad9)) { _freeCam.transform.position = Locator.GetPlayerTransform().position; } if (Input.GetKeyDown(KeyCode.KeypadPlus)) { _moveSpeed = 7f; } if (Input.GetKeyDown(KeyCode.KeypadEnter)) { _moveSpeed = 1000f; } if (Input.GetKeyDown(KeyCode.KeypadPeriod)) { if (mode) { mode = false; if (_storedMode == InputMode.None) { _storedMode = InputMode.Character; } OWInput.ChangeInputMode(_storedMode); GlobalMessenger <OWCamera> .FireEvent("SwitchActiveCamera", Locator.GetPlayerCamera()); _camera.enabled = false; Locator.GetActiveCamera().mainCamera.enabled = true; } else { mode = true; _storedMode = OWInput.GetInputMode(); OWInput.ChangeInputMode(InputMode.None); GlobalMessenger <OWCamera> .FireEvent("SwitchActiveCamera", _OWCamera); Locator.GetActiveCamera().mainCamera.enabled = false; _camera.enabled = true; } } } }