コード例 #1
0
ファイル: SimulatedEntity.cs プロジェクト: Shirkie01/Nitrox
 public SimulatedEntity(NitroxId id, ushort playerId, bool changesPosition, SimulationLockType lockType)
 {
     Id              = id;
     PlayerId        = playerId;
     ChangesPosition = changesPosition;
     LockType        = lockType;
 }
コード例 #2
0
 public SimulationOwnershipChange(NitroxId id, ushort owningPlayerId, SimulationLockType lockType)
 {
     Entities = new List <SimulatedEntity>
     {
         new(id, owningPlayerId, false, lockType)
     };
 }
コード例 #3
0
        public void RequestSimulationLock(string guid, SimulationLockType lockType, LockRequestCompleted whenCompleted)
        {
            SimulationOwnershipRequest ownershipRequest = new SimulationOwnershipRequest(muliplayerSession.Reservation.PlayerId, guid, lockType);

            packetSender.Send(ownershipRequest);
            completeFunctionsByGuid[guid] = whenCompleted;
        }
コード例 #4
0
ファイル: SimulatedEntity.cs プロジェクト: yawaraka/Nitrox
 public SimulatedEntity(string guid, ushort playerId, bool changesPosition, SimulationLockType lockType)
 {
     Guid            = guid;
     PlayerId        = playerId;
     ChangesPosition = changesPosition;
     LockType        = lockType;
 }
コード例 #5
0
 public SimulationOwnershipChange(string guid, ulong owningPlayerId, SimulationLockType lockType)
 {
     Entities = new List <SimulatedEntity>
     {
         new SimulatedEntity(guid, owningPlayerId, false, lockType)
     };
 }
コード例 #6
0
ファイル: SimulationOwnership.cs プロジェクト: x0n1c/Nitrox
        public bool TryToAcquire(string guid, Player player, SimulationLockType requestedLock)
        {
            lock (playerLocksByGuid)
            {
                PlayerLock playerLock;

                // If no one is simulating then aquire a lock for this player
                if (!playerLocksByGuid.TryGetValue(guid, out playerLock))
                {
                    playerLocksByGuid[guid] = new PlayerLock(player, requestedLock);
                    return(true);
                }

                // If this player owns the lock then they are already simulating
                if (playerLock.Player == player)
                {
                    // update the lock type in case they are attempting to downgrade
                    playerLocksByGuid[guid] = new PlayerLock(player, requestedLock);
                    return(true);
                }

                // If the current lock owner has a transient lock then only override if we are requesting exclusive access
                if (playerLock.LockType == SimulationLockType.TRANSIENT && requestedLock == SimulationLockType.EXCLUSIVE)
                {
                    playerLocksByGuid[guid] = new PlayerLock(player, requestedLock);
                    return(true);
                }

                // We must be requesting a transient lock and the owner already has a lock (either transient or exclusive).
                // there is no way to break it so we will return false.
                return(false);
            }
        }
コード例 #7
0
 public bool PlayerHasMinLockType(NitroxId id, SimulationLockType lockType)
 {
     if (simulatedIdsByLockType.TryGetValue(id, out SimulationLockType playerLock))
     {
         return(playerLock <= lockType);
     }
     return(false);
 }
コード例 #8
0
        public void ReceivedSimulationLockResponse(NitroxId id, bool lockAquired, SimulationLockType lockType)
        {
            Log.Info("Received lock response, id: " + id + " " + lockAquired + " " + lockType);

            if (lockAquired)
            {
                SimulateEntity(id, lockType);
            }

            if (lockRequestsById.TryGetValue(id, out LockRequestBase lockRequest))
            {
                lockRequest.LockRequestComplete(id, lockAquired);
                lockRequestsById.Remove(id);
            }
        }
コード例 #9
0
        public void ReceivedSimulationLockResponse(string guid, bool lockAquired, SimulationLockType lockType)
        {
            Log.Info("Received lock response, guid: " + guid + " " + lockAquired + " " + lockType);

            if (lockAquired)
            {
                SimulateGuid(guid, lockType);
            }

            LockRequestCompleted requestCompleted = null;

            if (completeFunctionsByGuid.TryGetValue(guid, out requestCompleted) && requestCompleted != null)
            {
                completeFunctionsByGuid.Remove(guid);
                requestCompleted(guid, lockAquired);
            }
            else
            {
                Log.Warn("Did not have an outstanding simulation request for " + guid + " maybe there were multiple outstanding requests?");
            }
        }
コード例 #10
0
ファイル: SimulationOwnership.cs プロジェクト: x0n1c/Nitrox
 public PlayerLock(Player player, SimulationLockType lockType)
 {
     Player   = player;
     LockType = lockType;
 }
コード例 #11
0
 public SimulationOwnershipRequest(ulong playerId, string guid, SimulationLockType lockType)
 {
     PlayerId = playerId;
     Guid     = guid;
     LockType = lockType;
 }
コード例 #12
0
 public void SimulateEntity(NitroxId id, SimulationLockType lockType)
 {
     simulatedIdsByLockType[id] = lockType;
 }
コード例 #13
0
        public void RequestSimulationLock(NitroxId id, SimulationLockType lockType)
        {
            SimulationOwnershipRequest ownershipRequest = new SimulationOwnershipRequest(muliplayerSession.Reservation.PlayerId, id, lockType);

            packetSender.Send(ownershipRequest);
        }
コード例 #14
0
 public SimulationOwnershipRequest(ushort playerId, NitroxId id, SimulationLockType lockType)
 {
     PlayerId = playerId;
     Id       = id;
     LockType = lockType;
 }
コード例 #15
0
 public SimulationOwnershipResponse(string guid, bool lockAquired, SimulationLockType lockType)
 {
     Guid        = guid;
     LockAquired = lockAquired;
     LockType    = lockType;
 }
コード例 #16
0
 public void SimulateGuid(string guid, SimulationLockType lockType)
 {
     simulatedGuidsByLockType[guid] = lockType;
 }
コード例 #17
0
 public SimulationOwnershipResponse(NitroxId id, bool lockAquired, SimulationLockType lockType)
 {
     Id          = id;
     LockAquired = lockAquired;
     LockType    = lockType;
 }
コード例 #18
0
 public LockRequestBase(NitroxId Id, SimulationLockType LockType) : base()
 {
     this.Id       = Id;
     this.LockType = LockType;
 }
コード例 #19
0
 public LockRequest(NitroxId id, SimulationLockType lockType, LockRequestCompleted onComplete, T context) : base(id, lockType)
 {
     this.onComplete = onComplete;
     this.context    = context;
 }