mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-06 17:58:05 +02:00
Don't run client physics in frameupdate (#2953)
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameStates;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
@@ -12,31 +10,12 @@ namespace Robust.Client.Physics
|
||||
public sealed class PhysicsSystem : SharedPhysicsSystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IClientGameStateManager _gameState = default!;
|
||||
|
||||
private TimeSpan _lastRem;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
_lastRem = _gameTiming.CurTime;
|
||||
SimulateWorld(frameTime, _gameTiming.InPrediction);
|
||||
}
|
||||
|
||||
public override void FrameUpdate(float frameTime)
|
||||
{
|
||||
if (!_gameState.IsPredictionEnabled)
|
||||
return;
|
||||
|
||||
if (_lastRem > _gameTiming.TickRemainder)
|
||||
{
|
||||
_lastRem = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
var diff = _gameTiming.TickRemainder - _lastRem;
|
||||
_lastRem = _gameTiming.TickRemainder;
|
||||
SimulateWorld((float) diff.TotalSeconds, true);
|
||||
}
|
||||
|
||||
protected override void HandleMapCreated(MapChangedEvent eventArgs)
|
||||
{
|
||||
if (eventArgs.Map == MapId.Nullspace) return;
|
||||
|
||||
Reference in New Issue
Block a user