/////////////////////////////////////////////////////////// // this method schedules a check in 'seconds' to reenable // any active states on the controller that may have been // temporarily disabled on the current weapon /////////////////////////////////////////////////////////// public void ReenableWeaponStatesIn(float seconds) { // cancel the timer if it's currently running, to prevent // problems with button spamming if (m_ReenableWeaponStatesTimer != null) { m_ReenableWeaponStatesTimer.Cancel(); } m_ReenableWeaponStatesTimer = vp_Timer.In(seconds, delegate() { if (Controller.StateEnabled("Zoom")) { if (CurrentWeapon != null) { CurrentWeapon.SetState("Zoom", true); } if (CurrentShooter != null) { CurrentShooter.SetState("Zoom", true); } return; // don't reenable 'Crouch' or 'Run' on the weapon while zooming } if (Controller.StateEnabled("Crouch")) { if (CurrentWeapon != null) { CurrentWeapon.SetState("Crouch", true); } if (CurrentShooter != null) { CurrentShooter.SetState("Crouch", true); } } if (Controller.StateEnabled("Run")) { if (CurrentWeapon != null) { CurrentWeapon.SetState("Run", true); } if (CurrentShooter != null) { CurrentShooter.SetState("Run", true); } } }); }
/////////////////////////////////////////////////////////// // sets a state on the controller, camera, current weapon // and current shooter. NOTE: SetState does not update // currently disabled weapons or shooters /////////////////////////////////////////////////////////// public void SetState(string state, bool isEnabled) { if (Controller != null) { Controller.SetState(state, isEnabled); } if (Camera != null) { Camera.SetState(state, isEnabled); if (CurrentWeapon != null) { CurrentWeapon.SetState(state, isEnabled); } if (CurrentShooter != null) { CurrentShooter.SetState(state, isEnabled); } } }