private System.Collections.IEnumerator CheckLockCR() { while (HighLogic.LoadedSceneIsFlight) { yield return(new WaitForSeconds(updateFrequency)); cachedLockResult = CheatOptions.InfiniteElectricity ? ControlLockerUtils.LockLevel.UNLOCKED : ControlLockerUtils.ShouldLock(vessel.Parts, true, out maxMass, out vesselMass); } }
public void Update() { if (!HighLogic.LoadedSceneIsFlight || !FlightGlobals.ready) { InputLockManager.RemoveControlLock(LockID); return; } if (Vessel != FlightGlobals.ActiveVessel) { Vessel = FlightGlobals.ActiveVessel; _masterMechJeb = null; } ControlLockerUtils.LockLevel lockLevel = ShouldLock(); if (_isLimitedByNonInterplanetary) { GameplayTips.Instance.ShowInterplanetaryAvionicsReminder(); } if (lockLevel != _oldLockLevel) { if (_oldLockLevel != ControlLockerUtils.LockLevel.Unlocked) { InputLockManager.RemoveControlLock(LockID); _message.message = "Avionics: Unlocking Controls"; } else { InputLockManager.SetControlLock(Lockmask, LockID); if (!_onRails) { DisableAutopilot(); } _message.message = $"Insufficient Avionics, Locking Controls (supports {_maxMass:N3}t, vessel {_vesselMass:N3}t)"; } ScreenMessages.PostScreenMessage(_message); FlightLogger.fetch.LogEvent(_message.message); _oldLockLevel = lockLevel; } if (_masterMechJeb == null && _getMasterMechJeb != null) { _masterMechJeb = _getMasterMechJeb.Invoke(null, new object[] { FlightGlobals.ActiveVessel }); } if (_masterMechJeb != null && _mjDeactivateControl != null) { // Update MJ every tick, to make sure it gets correct state after separation / docking. _mjDeactivateControl.SetValue(_masterMechJeb, lockLevel != ControlLockerUtils.LockLevel.Unlocked, index: null); } }
public ControlLockerUtils.LockLevel ShouldLock() { // if we have no active vessel, undo locks if (vessel is null) { return(cachedLockResult = ControlLockerUtils.LockLevel.UNLOCKED); } if (requested) { cachedLockResult = CheatOptions.InfiniteElectricity ? ControlLockerUtils.LockLevel.UNLOCKED : ControlLockerUtils.ShouldLock(vessel.Parts, true, out maxMass, out vesselMass); } requested = false; return(cachedLockResult); }
public ControlLockerUtils.LockLevel ShouldLock() { // if we have no active vessel, undo locks if (Vessel is null) { return(_cachedLockResult = ControlLockerUtils.LockLevel.Unlocked); } if (_requested) { _cachedLockResult = CheatOptions.InfiniteElectricity ? ControlLockerUtils.LockLevel.Unlocked : ControlLockerUtils.ShouldLock(Vessel.Parts, true, out _maxMass, out _vesselMass, out _isLimitedByNonInterplanetary); } _requested = false; return(_cachedLockResult); }
public void Update() { _deltaTime += Time.deltaTime; if (_deltaTime > UpdateInterval) { _deltaTime = 0; _haveParts = false; _lockLevel = ControlLockerUtils.LockLevel.Unlocked; if (EditorLogic.fetch.ship?.Parts is List <Part> parts && parts.Count > 0) { _lockLevel = ControlLockerUtils.ShouldLock(parts, false, out _maxMass, out _vesselMass, out _); _haveParts = true; } } }
private IEnumerator CheckLockCR() { const int maxFramesWaited = 250; int i = 0; do { yield return(new WaitForFixedUpdate()); } while ((FlightGlobals.ActiveVessel == null || FlightGlobals.ActiveVessel.packed) && i++ < maxFramesWaited); while (HighLogic.LoadedSceneIsFlight) { yield return(new WaitForSeconds(UpdateFrequency)); _cachedLockResult = CheatOptions.InfiniteElectricity ? ControlLockerUtils.LockLevel.Unlocked : ControlLockerUtils.ShouldLock(Vessel.Parts, true, out _maxMass, out _vesselMass, out _isLimitedByNonInterplanetary); } }
public void Update() { if (!HighLogic.LoadedSceneIsFlight || !FlightGlobals.ready) { InputLockManager.RemoveControlLock(lockID); return; } if (vessel != FlightGlobals.ActiveVessel) { vessel = FlightGlobals.ActiveVessel; masterMechJeb = null; } ControlLockerUtils.LockLevel lockLevel = ShouldLock(); if (lockLevel != oldLockLevel) { if (oldLockLevel != ControlLockerUtils.LockLevel.UNLOCKED) { InputLockManager.RemoveControlLock(lockID); message.message = "Avionics: Unlocking Controls"; } else { InputLockManager.SetControlLock(lockmask, lockID); if (!onRails) { DisableAutopilot(); } message.message = $"Insufficient Avionics, Locking Controls (supports {maxMass:N3}t, vessel {vesselMass:N3}t)"; } ScreenMessages.PostScreenMessage(message); FlightLogger.fetch.LogEvent(message.message); oldLockLevel = lockLevel; } if (masterMechJeb == null && getMasterMechJeb != null) { masterMechJeb = getMasterMechJeb.Invoke(null, new object[] { FlightGlobals.ActiveVessel }); } if (masterMechJeb != null && mjDeactivateControl != null) { // Update MJ every tick, to make sure it gets correct state after separation / docking. mjDeactivateControl.SetValue(masterMechJeb, lockLevel != ControlLockerUtils.LockLevel.UNLOCKED, index: null); } }