Remove SharedEye (but content) (#19481)

This commit is contained in:
metalgearsloth
2023-09-11 16:15:23 +10:00
committed by GitHub
parent c477e5b0c2
commit 28bf3a6240
29 changed files with 86 additions and 75 deletions

View File

@@ -28,19 +28,13 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
/// </summary>
protected const float KickMagnitudeMax = 1f;
private ISawmill _log = default!;
public override void Initialize()
{
base.Initialize();
_log = Logger.GetSawmill($"ecs.systems.{nameof(SharedCameraRecoilSystem)}");
}
[Dependency] private readonly SharedEyeSystem _eye = default!;
/// <summary>
/// Applies explosion/recoil/etc kickback to the view of the entity.
/// </summary>
/// <remarks>
/// If the entity is missing <see cref="CameraRecoilComponent" /> and/or <see cref="SharedEyeComponent" />,
/// If the entity is missing <see cref="CameraRecoilComponent" /> and/or <see cref="EyeComponent" />,
/// this call will have no effect. It is safe to call this function on any entity.
/// </remarks>
public abstract void KickCamera(EntityUid euid, Vector2 kickback, CameraRecoilComponent? component = null);
@@ -49,15 +43,15 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
{
base.FrameUpdate(frameTime);
foreach (var entity in EntityManager.EntityQuery<SharedEyeComponent, CameraRecoilComponent>(true))
var query = AllEntityQuery<EyeComponent, CameraRecoilComponent>();
while (query.MoveNext(out var uid, out var eye, out var recoil))
{
var recoil = entity.Item2;
var eye = entity.Item1;
var magnitude = recoil.CurrentKick.Length();
if (magnitude <= 0.005f)
{
recoil.CurrentKick = Vector2.Zero;
eye.Offset = recoil.BaseOffset + recoil.CurrentKick;
_eye.SetOffset(uid, recoil.BaseOffset + recoil.CurrentKick, eye);
}
else // Continually restore camera to 0.
{
@@ -72,7 +66,7 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
recoil.CurrentKick = new Vector2(x, y);
eye.Offset = recoil.BaseOffset + recoil.CurrentKick;
_eye.SetOffset(uid, recoil.BaseOffset + recoil.CurrentKick, eye);
}
}
}