ECSatize CameraRecoilSystem (#5448)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Acruid
2021-12-26 22:50:12 -08:00
committed by GitHub
parent e235002a54
commit b3b171da7f
11 changed files with 176 additions and 192 deletions

View File

@@ -1,7 +1,7 @@
using Content.Server.Administration.Logs;
using Content.Server.Camera;
using Content.Server.Projectiles.Components;
using Content.Shared.Body.Components;
using Content.Shared.Camera;
using Content.Shared.Damage;
using Content.Shared.Database;
using JetBrains.Annotations;
@@ -9,6 +9,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
@@ -19,6 +20,7 @@ namespace Content.Server.Projectiles
{
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly AdminLogSystem _adminLogSystem = default!;
[Dependency] private readonly CameraRecoilSystem _cameraRecoil = default!;
public override void Initialize()
{
@@ -65,10 +67,10 @@ namespace Content.Server.Projectiles
// Damaging it can delete it
if (!EntityManager.GetComponent<MetaDataComponent>(otherEntity).EntityDeleted &&
EntityManager.TryGetComponent(otherEntity, out CameraRecoilComponent? recoilComponent))
EntityManager.HasComponent<CameraRecoilComponent>(otherEntity))
{
var direction = args.OurFixture.Body.LinearVelocity.Normalized;
recoilComponent.Kick(direction);
_cameraRecoil.KickCamera(otherEntity, direction);
}
if (component.DeleteOnCollide)