Ejemplo n.º 1
0
 public SimulatedEntity(NitroxId id, ushort playerId, bool changesPosition, SimulationLockType lockType)
 {
     Id              = id;
     PlayerId        = playerId;
     ChangesPosition = changesPosition;
     LockType        = lockType;
 }
Ejemplo n.º 2
0
 public SimulationOwnershipChange(NitroxId id, ushort owningPlayerId, SimulationLockType lockType)
 {
     Entities = new List <SimulatedEntity>
     {
         new(id, owningPlayerId, false, lockType)
     };
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 4
0
 public SimulatedEntity(string guid, ushort playerId, bool changesPosition, SimulationLockType lockType)
 {
     Guid            = guid;
     PlayerId        = playerId;
     ChangesPosition = changesPosition;
     LockType        = lockType;
 }
 public SimulationOwnershipChange(string guid, ulong owningPlayerId, SimulationLockType lockType)
 {
     Entities = new List <SimulatedEntity>
     {
         new SimulatedEntity(guid, owningPlayerId, false, lockType)
     };
 }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
 public bool PlayerHasMinLockType(NitroxId id, SimulationLockType lockType)
 {
     if (simulatedIdsByLockType.TryGetValue(id, out SimulationLockType playerLock))
     {
         return(playerLock <= lockType);
     }
     return(false);
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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?");
            }
        }
Ejemplo n.º 10
0
 public PlayerLock(Player player, SimulationLockType lockType)
 {
     Player   = player;
     LockType = lockType;
 }
 public SimulationOwnershipRequest(ulong playerId, string guid, SimulationLockType lockType)
 {
     PlayerId = playerId;
     Guid     = guid;
     LockType = lockType;
 }
Ejemplo n.º 12
0
 public void SimulateEntity(NitroxId id, SimulationLockType lockType)
 {
     simulatedIdsByLockType[id] = lockType;
 }
Ejemplo n.º 13
0
        public void RequestSimulationLock(NitroxId id, SimulationLockType lockType)
        {
            SimulationOwnershipRequest ownershipRequest = new SimulationOwnershipRequest(muliplayerSession.Reservation.PlayerId, id, lockType);

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