コード例 #1
0
        //Lock types
        //control-vessel-(vesselid) - Replaces the old "inUse" messages, the active pilot will have the control-vessel lock.
        //update-vessel-(vesselid) - Replaces the "only the closest player can update a vessel" code,
        //Now you acquire locks to update crafts around you.
        //asteroid - Held by the player that can spawn asteroids into the game.

        public static bool AcquireLock(LockDefinition lockDef, bool force)
        {
            if (force || !LockQuery.LockExists(lockDef))
            {
                LockStore.AddOrUpdateLock(lockDef);
                return(true);
            }
            return(false);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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))
            {
                LockStore.AddOrUpdateLock(lockDef);
                return(true);
            }
            return(false);
        }