public override void ProcessPacket(Guid sourcePlayerId, Packet packet, IProcessorContext context) { TimeScaleUpdatePacket timeScaleUpdatedPacket = (TimeScaleUpdatePacket)packet; ClientProcessorContext processorContext = (ClientProcessorContext)context; processorContext.Client.TimeManager.OnTimeScaleUpdated(timeScaleUpdatedPacket.TimeScale, timeScaleUpdatedPacket.IsPaused); }
public void FreezeTime() { if (timeLocked) { return; } TimeScaleUpdatePacket timeScaleUpdatedPacket = new TimeScaleUpdatePacket(timeScale, true); server.SendPacketToAll(timeScaleUpdatedPacket); timeLocked = true; }
public void SetTimescale(float speed, bool paused) { Player?simulationOwner = client.SimulationManager.GetSimulationOwner(); if (simulationOwner == null || simulationOwner.Value != client.LocalPlayer) { return; // Don't send the packet if we aren't the simulation owner } TimeScaleUpdatePacket timeScaleUpdatePacket = new TimeScaleUpdatePacket(speed, paused); client.SendPacket(timeScaleUpdatePacket); }
public void SetTimescale(float speed, bool paused) { if (timeLocked) { return; } timeScale = speed; isPaused = paused; TimeScaleUpdatePacket timeScaleUpdatedPacket = new TimeScaleUpdatePacket(timeScale, isPaused); server.SendPacketToAll(timeScaleUpdatedPacket); }
public override void ProcessPacket(Guid sourcePlayerId, Packet packet, IProcessorContext context) { TimeScaleUpdatePacket timeScaleUpdatePacket = (TimeScaleUpdatePacket)packet; ServerProcessorContext processorContext = (ServerProcessorContext)context; SimulationManager simulationManager = processorContext.Server.SimulationManager; TimeManager timeManager = processorContext.Server.TimeManager; Player?simulationOwner = simulationManager.GetSimulationOwner(); if (simulationOwner == null || sourcePlayerId != simulationOwner.Value.Id) { //Deny request if client isn't the simulation owner return; } if (timeManager.IsTimeLocked()) { // The server is holding onto the current timescale // Inform the client, maybe? return; } timeManager.SetTimescale(timeScaleUpdatePacket.TimeScale, timeScaleUpdatePacket.IsPaused); }