mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 15:47:26 +00:00
* cherry-pick: Screenshake (EphemeralSpace/ephemeral-space#627) * commit your shit at some point maybe * y * who knows * rename? * debugging + shit api * i hope no one fucks my ass * erm * p * replace with shit that makes way more sense * stuff * pretty sure this is just fine * actual fix noise shit * uhhh hmaybe if i feel like it wrong then later * explosion shake * grav shake * gun shake * idk * projectile melee Co-authored-by: DisposableCrewmember42 <disposablecrewmember42@proton.me> * tweak: tune recoil on weapons * docs: add _ES license info to LEGAL.md * fix: screenshake on spawn fix from ss14Starlight/space-station-14#3664 Co-authored-by: neomoth <69372252+neomoth@users.noreply.github.com> * feat: add client cvar to disable screenshake * feat: add screenshake toggle to accessibility settings * fix: upmerge compatibility * docs: properly document cvar * docs: add missing import comments --------- Co-authored-by: mirrorcult <mirrorcult@pm.me> Co-authored-by: neomoth <69372252+neomoth@users.noreply.github.com>
83 lines
2.7 KiB
C#
83 lines
2.7 KiB
C#
using System.Numerics;
|
|
using Content.Shared.Movement.Components;
|
|
using Content.Shared.Movement.Systems;
|
|
using Robust.Client.Player;
|
|
|
|
namespace Content.Client.Movement.Systems;
|
|
|
|
public sealed class ContentEyeSystem : SharedContentEyeSystem
|
|
{
|
|
[Dependency] private readonly IPlayerManager _player = default!;
|
|
|
|
public void RequestZoom(EntityUid uid, Vector2 zoom, bool ignoreLimit, bool scalePvs, ContentEyeComponent? content = null)
|
|
{
|
|
if (!Resolve(uid, ref content, false))
|
|
return;
|
|
|
|
RaisePredictiveEvent(new RequestTargetZoomEvent()
|
|
{
|
|
TargetZoom = zoom,
|
|
IgnoreLimit = ignoreLimit,
|
|
});
|
|
|
|
if (scalePvs)
|
|
RequestPvsScale(Math.Max(zoom.X, zoom.Y));
|
|
}
|
|
|
|
public void RequestPvsScale(float scale)
|
|
{
|
|
RaiseNetworkEvent(new RequestPvsScaleEvent(scale));
|
|
}
|
|
|
|
public void RequestToggleFov()
|
|
{
|
|
if (_player.LocalEntity is { } player)
|
|
RequestToggleFov(player);
|
|
}
|
|
|
|
public void RequestToggleFov(EntityUid uid, EyeComponent? eye = null)
|
|
{
|
|
if (Resolve(uid, ref eye, false))
|
|
RequestEye(!eye.DrawFov, eye.DrawLight);
|
|
}
|
|
|
|
public void RequestToggleLight(EntityUid uid, EyeComponent? eye = null)
|
|
{
|
|
if (Resolve(uid, ref eye, false))
|
|
RequestEye(eye.DrawFov, !eye.DrawLight);
|
|
}
|
|
|
|
|
|
public void RequestEye(bool drawFov, bool drawLight)
|
|
{
|
|
RaisePredictiveEvent(new RequestEyeEvent(drawFov, drawLight));
|
|
}
|
|
|
|
public override void FrameUpdate(float frameTime)
|
|
{
|
|
base.FrameUpdate(frameTime);
|
|
var eyeEntities = AllEntityQuery<ContentEyeComponent, EyeComponent>();
|
|
while (eyeEntities.MoveNext(out var entity, out ContentEyeComponent? contentComponent, out EyeComponent? eyeComponent))
|
|
{
|
|
UpdateEyeOffset((entity, eyeComponent));
|
|
// ES START
|
|
UpdateEyeRotation((entity, eyeComponent));
|
|
// ES END
|
|
}
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
// TODO: Ideally we wouldn't want this to run in both FrameUpdate and Update, but we kind of have to since the visual update happens in FrameUpdate, but interaction update happens in Update. It's a workaround and a better solution should be found.
|
|
var eyeEntities = AllEntityQuery<ContentEyeComponent, EyeComponent>();
|
|
while (eyeEntities.MoveNext(out var entity, out ContentEyeComponent? contentComponent, out EyeComponent? eyeComponent))
|
|
{
|
|
UpdateEyeOffset((entity, eyeComponent));
|
|
// ES START
|
|
UpdateEyeRotation((entity, eyeComponent));
|
|
// ES END
|
|
}
|
|
}
|
|
}
|