using System.Collections; using System.Collections.Generic; using UnityEngine; using NeoFPS; using NeoCC; using NeoFPS.SinglePlayer; using NeoFPS.Samples; namespace SimpleInventorySystem { public class NeoFPSPause : MonoBehaviour { NeoCharacterController ncc; MouseAndGamepadAimController inputAim; InputCharacterMotion inputMotion; InputInventory inputInventory; FpsInventoryQuickSwitch fpsIQS; Rigidbody rb; bool usingState; FpsSoloCharacter fpsSoloCharacter; Player_IS player; InputFirearm[] inputFirearms; NeoFPSAnimationController nfpsAC; public InGameMenu pauseMenu; bool paused; public bool IsPaused() { return paused; } // Update is called once per frame void Update() { paused = pauseMenu.IsPaused(); if (!InventorySystem.instance.IsUsingInventoryMenuUI()) { pauseMenu.gameObject.SetActive(true); pauseMenu.enabled = true; } else { pauseMenu.gameObject.SetActive(false); pauseMenu.enabled = false; } if (player == null && InventorySystem.instance.player != null) { player = InventorySystem.instance.player; inputMotion = player.GetComponent(); inputAim = player.GetComponent(); ncc = player.GetComponent(); inputInventory = player.GetComponent(); fpsIQS = player.GetComponent(); rb = player.GetComponent(); fpsSoloCharacter = player.GetComponent(); inputFirearms = player.GetComponentsInChildren(); nfpsAC = player.GetComponent(); } else if (usingState != InventorySystem.instance.IsUsingInventoryMenuUI()) { switch (InventorySystem.instance.IsUsingInventoryMenuUI()) { case true: fpsSoloCharacter.motionController.inputMoveDirection = Vector2.zero; rb.velocity = new Vector3(0, rb.velocity.y, 0); //ncc.ResetVelocity(); // TODO: optimize this in case player is falling //ncc.SetVelocity(new Vector3(0, ncc.velocity.y, 0)); SetEnabledComponents(false); usingState = true; break; case false: SetEnabledComponents(true); usingState = false; break; } } } void SetEnabledComponents(bool value) { inputMotion.enabled = value; inputAim.enabled = value; inputInventory.enabled = value; fpsIQS.enabled = value; ncc.enabled = value; fpsSoloCharacter.enabled = value; nfpsAC.enabled = value; foreach (InputFirearm inputFirearm in inputFirearms) { inputFirearm.enabled = value; } } } }