public SimulatedEntity(NitroxId id, ushort playerId, bool changesPosition, SimulationLockType lockType) { Id = id; PlayerId = playerId; ChangesPosition = changesPosition; LockType = lockType; }
public SimulationOwnershipChange(NitroxId id, ushort owningPlayerId, SimulationLockType lockType) { Entities = new List <SimulatedEntity> { new(id, owningPlayerId, false, lockType) }; }
public void RequestSimulationLock(string guid, SimulationLockType lockType, LockRequestCompleted whenCompleted) { SimulationOwnershipRequest ownershipRequest = new SimulationOwnershipRequest(muliplayerSession.Reservation.PlayerId, guid, lockType); packetSender.Send(ownershipRequest); completeFunctionsByGuid[guid] = whenCompleted; }
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) }; }
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); } }
public bool PlayerHasMinLockType(NitroxId id, SimulationLockType lockType) { if (simulatedIdsByLockType.TryGetValue(id, out SimulationLockType playerLock)) { return(playerLock <= lockType); } return(false); }
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); } }
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?"); } }
public PlayerLock(Player player, SimulationLockType lockType) { Player = player; LockType = lockType; }
public SimulationOwnershipRequest(ulong playerId, string guid, SimulationLockType lockType) { PlayerId = playerId; Guid = guid; LockType = lockType; }
public void SimulateEntity(NitroxId id, SimulationLockType lockType) { simulatedIdsByLockType[id] = lockType; }
public void RequestSimulationLock(NitroxId id, SimulationLockType lockType) { SimulationOwnershipRequest ownershipRequest = new SimulationOwnershipRequest(muliplayerSession.Reservation.PlayerId, id, lockType); packetSender.Send(ownershipRequest); }
public SimulationOwnershipRequest(ushort playerId, NitroxId id, SimulationLockType lockType) { PlayerId = playerId; Id = id; LockType = lockType; }
public SimulationOwnershipResponse(string guid, bool lockAquired, SimulationLockType lockType) { Guid = guid; LockAquired = lockAquired; LockType = lockType; }
public void SimulateGuid(string guid, SimulationLockType lockType) { simulatedGuidsByLockType[guid] = lockType; }
public SimulationOwnershipResponse(NitroxId id, bool lockAquired, SimulationLockType lockType) { Id = id; LockAquired = lockAquired; LockType = lockType; }
public LockRequestBase(NitroxId Id, SimulationLockType LockType) : base() { this.Id = Id; this.LockType = LockType; }
public LockRequest(NitroxId id, SimulationLockType lockType, LockRequestCompleted onComplete, T context) : base(id, lockType) { this.onComplete = onComplete; this.context = context; }