mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using System;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.GameStates;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Robust.Client.Physics
|
|
{
|
|
[UsedImplicitly]
|
|
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(object? sender, MapEventArgs eventArgs)
|
|
{
|
|
if (eventArgs.Map == MapId.Nullspace) return;
|
|
var mapUid = MapManager.GetMapEntityId(eventArgs.Map);
|
|
EntityManager.AddComponent<PhysicsMapComponent>(mapUid);
|
|
}
|
|
}
|
|
}
|