public static bool AcquireLock(LockDefinition lockDef, bool force, out bool repeatedAcquire) { repeatedAcquire = false; //Player tried to acquire a lock that they already own if (LockQuery.LockBelongsToPlayer(lockDef.Type, lockDef.VesselId, lockDef.KerbalName, lockDef.PlayerName)) { repeatedAcquire = true; return(true); } if (force || !LockQuery.LockExists(lockDef)) { if (lockDef.Type == LockType.Control) { //If they acquired a control lock they probably switched vessels or something like that and they can only have one control lock. //So remove the other control locks just for safety... var controlLocks = LockQuery.GetAllPlayerLocks(lockDef.PlayerName).Where(l => l.Type == LockType.Control); foreach (var control in controlLocks) { ReleaseLock(control); } } LockStore.AddOrUpdateLock(lockDef); return(true); } return(false); }
public static bool AcquireLock(LockDefinition lockDef, bool force, out bool repeatedAcquire) { repeatedAcquire = false; //Player tried to acquire a lock that he already owns if (LockQuery.LockBelongsToPlayer(lockDef.Type, lockDef.VesselId, lockDef.PlayerName)) { repeatedAcquire = true; return(true); } if (force || !LockQuery.LockExists(lockDef)) { if (GeneralSettings.SettingsStore.DropControlOnVesselSwitching && lockDef.Type == LockType.Control) { //If he acquired a control lock he probably switched vessels or smth like that and he can only have 1 control lock. //So remove the other control locks just for safety... var controlLocks = LockQuery.GetAllPlayerLocks(lockDef.PlayerName).Where(l => l.Type == LockType.Control); foreach (var control in controlLocks) { ReleaseLock(control); } } LockStore.AddOrUpdateLock(lockDef); return(true); } return(false); }
/// <summary> /// Releases all the player locks /// </summary> public void ReleaseAllPlayerLocks() { foreach (var lockToRelease in LockQuery.GetAllPlayerLocks(SettingsSystem.CurrentSettings.PlayerName)) { ReleaseLock(lockToRelease); } }
/// <summary> /// Releases all the player locks /// </summary> public void ReleaseAllPlayerSpecifiedLocks(params LockType[] lockTypes) { foreach (var lockToRelease in LockQuery.GetAllPlayerLocks(SettingsSystem.CurrentSettings.PlayerName)) { if (lockTypes.Contains(lockToRelease.Type)) { ReleaseLock(lockToRelease); } } }
public static void ReleasePlayerLocks(string playerName) { var removeList = LockQuery.GetAllPlayerLocks(playerName); foreach (var lockToRemove in removeList) { if (lockToRemove.Type == LockType.Control && !GeneralSettings.SettingsStore.DropControlOnExit) { continue; } LockSystemSender.ReleaseAndSendLockReleaseMessage(lockToRemove); } }