ECSatize CameraRecoilSystem (#5448)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Camera;
|
||||
using Content.Shared.Camera;
|
||||
using Content.Shared.Gravity;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -20,6 +20,8 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
[Dependency] private readonly CameraRecoilSystem _cameraRecoil = default!;
|
||||
|
||||
private Dictionary<GridId, uint> _gridsToShake = new();
|
||||
|
||||
private const float GravityKick = 100.0f;
|
||||
@@ -81,12 +83,13 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
{
|
||||
if (player.AttachedEntity is not {Valid: true} attached
|
||||
|| EntityManager.GetComponent<TransformComponent>(attached).GridID != gridId
|
||||
|| !EntityManager.TryGetComponent(attached, out CameraRecoilComponent? recoil))
|
||||
|| !EntityManager.HasComponent<CameraRecoilComponent>(attached))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
recoil.Kick(new Vector2(_random.NextFloat(), _random.NextFloat()) * GravityKick);
|
||||
var kick = new Vector2(_random.NextFloat(), _random.NextFloat()) * GravityKick;
|
||||
_cameraRecoil.KickCamera(player.AttachedEntity.Value, kick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user