public override void Process(SimulationOwnershipChange simulationOwnershipChange) { foreach (SimulatedEntity simulatedEntity in simulationOwnershipChange.Entities) { if (multiplayerSession.Reservation.PlayerId == simulatedEntity.PlayerId) { if (simulatedEntity.ChangesPosition) { StartBroadcastingEntityPosition(simulatedEntity.Id); } simulationOwnershipManager.SimulateEntity(simulatedEntity.Id, SimulationLockType.TRANSIENT); } else if (simulationOwnershipManager.HasAnyLockType(simulatedEntity.Id)) { // The server has forcibly removed this lock from the client. This is generally fine for // transient locks because it is only broadcasting position. However, exclusive locks may // need additional cleanup (such as a person piloting a vehicle - they need to be kicked out) // We can later add a forcibly removed callback but as of right now we have no use-cases for // forcibly removing an exclusive lock. Just log it if it happens.... if (simulationOwnershipManager.HasExclusiveLock(simulatedEntity.Id)) { Log.Warn("The server has forcibly revoked an exlusive lock - this may cause undefined behaviour. GUID: " + simulatedEntity.Id); } simulationOwnershipManager.StopSimulatingEntity(simulatedEntity.Id); EntityPositionBroadcaster.StopWatchingEntity(simulatedEntity.Id); } } }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { int idsSynced = 0; foreach (NitroxId entityId in packet.InitialSimulationOwnerships) { waitScreenItem.SetProgress(idsSynced++, packet.InitialSimulationOwnerships.Count); // Initial locks are transient simulationOwnership.SimulateEntity(entityId, SimulationLockType.TRANSIENT); Log.Debug($"Transient simulation ownership for {entityId} from initial sync"); } yield return(null); }