コード例 #1
0
        /// <summary>
        /// Removes given lock from storage
        /// </summary>
        public void RemoveLock(LockDefinition lockDefinition)
        {
            switch (lockDefinition.Type)
            {
            case LockType.Asteroid:
                lock (_asteroidSyncLock)
                {
                    AsteroidLock = null;
                }
                break;

            case LockType.UnloadedUpdate:
                UnloadedUpdateLocks.TryRemove(lockDefinition.VesselId, out _);
                break;

            case LockType.Update:
                UpdateLocks.TryRemove(lockDefinition.VesselId, out _);
                break;

            case LockType.Control:
                ControlLocks.TryRemove(lockDefinition.VesselId, out _);
                break;

            case LockType.Spectator:
                SpectatorLocks.TryRemove(lockDefinition.PlayerName, out _);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #2
0
ファイル: LockStore.cs プロジェクト: rosokan/LunaMultiplayer
        /// <summary>
        /// Adds or replace the given lock to the storage
        /// </summary>
        public void AddOrUpdateLock(LockDefinition lockDefinition)
        {
            switch (lockDefinition.Type)
            {
            case LockType.Asteroid:
                lock (_asteroidSyncLock)
                {
                    if (AsteroidLock == null)
                    {
                        AsteroidLock = new LockDefinition(LockType.Asteroid, lockDefinition.PlayerName);
                    }
                    else
                    {
                        AsteroidLock.PlayerName = lockDefinition.PlayerName;
                    }
                }
                break;

            case LockType.Kerbal:
                KerbalLocks.AddOrUpdate(lockDefinition.KerbalName, lockDefinition, (key, existingVal) => lockDefinition);
                break;

            case LockType.Update:
                UpdateLocks.AddOrUpdate(lockDefinition.VesselId, lockDefinition, (key, existingVal) => lockDefinition);
                break;

            case LockType.UnloadedUpdate:
                UnloadedUpdateLocks.AddOrUpdate(lockDefinition.VesselId, lockDefinition, (key, existingVal) => lockDefinition);
                break;

            case LockType.Control:
                ControlLocks.AddOrUpdate(lockDefinition.VesselId, lockDefinition, (key, existingVal) => lockDefinition);
                break;

            case LockType.Spectator:
                SpectatorLocks.AddOrUpdate(lockDefinition.PlayerName, lockDefinition, (key, existingVal) => lockDefinition);
                break;

            case LockType.Contract:
                lock (_contractSyncLock)
                {
                    if (ContractLock == null)
                    {
                        ContractLock = new LockDefinition(LockType.Contract, lockDefinition.PlayerName);
                    }
                    else
                    {
                        ContractLock.PlayerName = lockDefinition.PlayerName;
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #3
0
ファイル: LockQuery.cs プロジェクト: meyer9/LunaMultiPlayer
        /// <summary>
        /// Checks if the given lock exists
        /// </summary>
        public bool LockExists(LockDefinition lockDefinition)
        {
            switch (lockDefinition.Type)
            {
            case LockType.Asteroid:
                return(LockStore.AsteroidLock != null);

            case LockType.Update:
                return(LockStore.UpdateLocks.ContainsKey(lockDefinition.VesselId));

            case LockType.Control:
                return(LockStore.ControlLocks.ContainsKey(lockDefinition.VesselId));

            case LockType.Spectator:
                return(LockStore.SpectatorLocks.ContainsKey(lockDefinition.PlayerName));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #4
0
ファイル: LockStore.cs プロジェクト: meyer9/LunaMultiPlayer
        /// <summary>
        /// Adds or replace the given lock to the storage
        /// </summary>
        public void AddOrUpdateLock(LockDefinition lockDefinition)
        {
            switch (lockDefinition.Type)
            {
            case LockType.Asteroid:
                AsteroidLock = lockDefinition;
                break;

            case LockType.Update:
                UpdateLocks.AddOrUpdate(lockDefinition.VesselId, lockDefinition, (key, existingVal) => lockDefinition);
                break;

            case LockType.Control:
                ControlLocks.AddOrUpdate(lockDefinition.VesselId, lockDefinition, (key, existingVal) => lockDefinition);
                break;

            case LockType.Spectator:
                SpectatorLocks.AddOrUpdate(lockDefinition.PlayerName, lockDefinition, (key, existingVal) => lockDefinition);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #5
0
 public void CopyFrom(LockDefinition lockDefinition)
 {
     PlayerName = lockDefinition.PlayerName.Clone() as string;
     Type       = lockDefinition.Type;
     VesselId   = lockDefinition.VesselId;
 }