private void MouseLook() { //FIXME: use globals if (Cvar.Boolean("console_open") || Globals.menuopen.Boolean) { return; } if (smoothCamera.Boolean) { desiredCamX += Input.GetAxisRaw("Mouse Y") * mouseSensitivity.Value; desiredCamY += Input.GetAxisRaw("Mouse X") * mouseSensitivity.Value; camX = Mathf.Lerp(camX, desiredCamX, smoothCamera.Value); camY = Mathf.Lerp(camY, desiredCamY, smoothCamera.Value); } else { camX += Input.GetAxisRaw("Mouse Y") * mouseSensitivity.Value; camY += Input.GetAxisRaw("Mouse X") * mouseSensitivity.Value; } camX = Mathf.Clamp(camX, -90, 90); Camera.transform.rotation = Quaternion.Euler(-camX, camY, 0); }
public static void Noclip_c(string[] args) { //toggle noclip int val = Cvar.Boolean("noclip") ? 0 : 1; Cvar.Set("noclip", val); Console.LogInfo("Noclip set to " + (val != 0 ? "ON" : "OFF")); }
private void Update() { //use new input system for console toggle (fixes some keyboard layouts) if (Keyboard.current.backquoteKey.wasPressedThisFrame) { CommandManager.RunCommand("toggleconsole", null); return; } if (Keyboard.current.escapeKey.wasPressedThisFrame) { CommandManager.RunCommand("togglemenu", null); return; } InputContainer.ResetKeypressState(); RunBinds(Cvar.Boolean("console_open") || Globals.menuopen.Boolean); }
//private static GameState lastState = GameState.menu; public static void ChangeGameState(GameState state) { if (state == GameState.loading) { //begin loading Loader.Instance.ClearMap(); MenuManager.Instance.Deactivate(); LoadscreenManager.Instance.ActivateLoadScreen(); SetGameHudActive(false); } else { if (state != GameState.menu) { if (state == GameState.editor) { //editor SetGameHudActive(false); } else { //map SetGameHudActive(true); } MenuManager.Instance.Deactivate(); } else { //go to menu Loader.Instance.ClearMap(); MenuManager.Instance.Activate(); SetGameHudActive(false); } LoadscreenManager.Instance.DeactivateLoadScreen(); if (Cvar.Boolean("console_open")) { CommandManager.RunCommand("toggleconsole", null); } } }
private void Togglemenu_c(string[] args) { if (listenForKeyCancelled || !Cvar.Boolean("maploaded")) { listenForKeyCancelled = false; return; } gameObject.SetActive(!gameObject.activeSelf); mainParent.gameObject.SetActive(gameObject.activeSelf); Globals.menuopen.Value = gameObject.activeSelf ? 1 : 0; if (gameObject.activeSelf) { if (!Cvar.Boolean("console_open")) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } DisableAllPanels(); //lazy mainPanel.SetActive(true); if (Cvar.Boolean("maploaded")) { background.color = new Color(background.color.r, background.color.g, background.color.b, 0f); } else { background.color = new Color(background.color.r, background.color.g, background.color.b, 1f); } } else { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; listenForKey = false; pressKeyPanel.SetActive(false); keyPanelMask.SetActive(false); } }
private void Fire_c(string[] args) { if (!Cvar.Boolean("console_open")) { if (args.Length > 0) { return; } Weapon w = weaponSlots[currentWeapon]; if (!w) { return; } if (!w.IsCooldown) { float scale = Globals.scale.Value; Projectile p = Instantiate(w.WeaponTemplate.ProjectileModel); p.transform.position = w.transform.position + w.transform.forward * 0.2f; Vector3 far = (playerCamera.transform.position / scale) + playerCamera.transform.forward * 10000; TraceT farTrace = Trace.CL_Trace(playerCamera.transform.position / scale, Vector3.zero, Vector3.zero, far); if (farTrace.fraction < 1) { p.transform.LookAt(farTrace.endpos * scale); //this will always happen if map is sealed and the player is inside the map volume } else { p.transform.forward = w.transform.forward; } p.speed = w.WeaponTemplate.speed; p.damage = w.WeaponTemplate.damage; p.radiusDamage = w.WeaponTemplate.radiusDamage; p.damageRadius = w.WeaponTemplate.damageRadius; w.SetCooldown(w.WeaponTemplate.cooldown); } } }
private void ConsoleSet(bool active) { ConsolePanel.SetActive(active); consoleOpen.Integer = active ? 1 : 0; if (active) { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; InputField.text = ""; ResetScrollPosition(); } else if (Cvar.Boolean("menuopen")) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } //quickview QuickView.ToggleField(!active); }