From 9146c59ecf94448c8d6fde740cd176a8493324e1 Mon Sep 17 00:00:00 2001 From: DisposableCrewmember42 Date: Fri, 15 May 2026 21:32:40 +0000 Subject: [PATCH] feat: Fancy Screenshake from Ephemeral Space (#5503) * 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 * 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 Co-authored-by: neomoth <69372252+neomoth@users.noreply.github.com> --- Content.Client/Eye/EyeLerpingSystem.cs | 41 +++++- .../Movement/Systems/ContentEyeSystem.cs | 6 + .../Options/UI/Tabs/AccessibilityTab.xaml | 1 + .../Options/UI/Tabs/AccessibilityTab.xaml.cs | 2 + .../Weapons/Ranged/Systems/GunSystem.cs | 5 +- Content.Client/_ES/ESScreenshakeSystem.cs | 99 +++++++++++++ .../Damage/Systems/DamageOtherOnHitSystem.cs | 11 +- .../EntitySystems/ExplosionSystem.cs | 16 +- .../Projectiles/ProjectileSystem.cs | 11 +- .../Gravity/SharedGravitySystem.Shake.cs | 24 +++ .../Components/ContentEyeComponent.cs | 14 +- .../Systems/SharedContentEyeSystem.cs | 15 ++ .../Weapons/Melee/SharedMeleeWeaponSystem.cs | 28 ++++ .../Weapons/Ranged/Systems/SharedGunSystem.cs | 10 ++ Content.Shared/_DV/CCVars/DCCVars.cs | 7 + .../_ES/Camera/ESGetEyeRotationEvent.cs | 15 ++ .../_ES/Camera/ESScreenshakeComponent.cs | 63 ++++++++ .../_ES/Camera/SharedESScreenshakeSystem.cs | 138 ++++++++++++++++++ .../ESScreenshakeUserOnTriggerComponent.cs | 17 +++ .../ESScreenshakeUserOnTriggerSystem.cs | 17 +++ LEGAL.md | 2 + .../en-US/_DV/escape-menu/options-menu.ftl | 4 + .../en-US/escape-menu/ui/options-menu.ftl | 3 +- .../Weapons/Guns/Battery/battery_guns.yml | 9 ++ .../Objects/Weapons/Guns/Snipers/snipers.yml | 1 + .../Objects/Weapons/Guns/pneumatic_cannon.yml | 1 + .../_ES/Entities/Debugging/screenshake.yml | 20 +++ 27 files changed, 569 insertions(+), 11 deletions(-) create mode 100644 Content.Client/_ES/ESScreenshakeSystem.cs create mode 100644 Content.Shared/_ES/Camera/ESGetEyeRotationEvent.cs create mode 100644 Content.Shared/_ES/Camera/ESScreenshakeComponent.cs create mode 100644 Content.Shared/_ES/Camera/SharedESScreenshakeSystem.cs create mode 100644 Content.Shared/_ES/Camera/Trigger/ESScreenshakeUserOnTriggerComponent.cs create mode 100644 Content.Shared/_ES/Camera/Trigger/ESScreenshakeUserOnTriggerSystem.cs create mode 100644 Resources/Prototypes/_ES/Entities/Debugging/screenshake.yml diff --git a/Content.Client/Eye/EyeLerpingSystem.cs b/Content.Client/Eye/EyeLerpingSystem.cs index c0a7c016966..89719653d34 100644 --- a/Content.Client/Eye/EyeLerpingSystem.cs +++ b/Content.Client/Eye/EyeLerpingSystem.cs @@ -36,6 +36,9 @@ public sealed class EyeLerpingSystem : EntitySystem UpdatesAfter.Add(typeof(TransformSystem)); UpdatesAfter.Add(typeof(Robust.Client.Physics.PhysicsSystem)); UpdatesBefore.Add(typeof(SharedEyeSystem)); + // ES START + UpdatesBefore.Add(typeof(EyeSystem)); + // ES END UpdatesOutsidePrediction = true; } @@ -68,6 +71,11 @@ public sealed class EyeLerpingSystem : EntitySystem { _eye.SetRotation(uid, lerpInfo.TargetRotation, component); _eye.SetZoom(uid, lerpInfo.TargetZoom, component); + + // Starlight begin - fix ES Screenshake triggering on spawn + if (TryComp(uid, out var contentEye)) + contentEye.BaseRotation = lerpInfo.TargetRotation; + // Starlight end } } @@ -175,9 +183,15 @@ public sealed class EyeLerpingSystem : EntitySystem { var tickFraction = (float) _gameTiming.TickFraction / ushort.MaxValue; const double lerpMinimum = 0.00001; - var query = AllEntityQuery(); + // ES START + // add contenteye bc we only want to modify the fuckin base rotation + var query = AllEntityQuery(); + // ES END - while (query.MoveNext(out var entity, out var lerpInfo, out var eye, out var xform)) + // ES START + // contenteye + while (query.MoveNext(out var entity, out var lerpInfo, out var eye, out var contentEye, out var xform)) + // ES END { // Handle zoom var zoomDiff = Vector2.Lerp(lerpInfo.LastZoom, lerpInfo.TargetZoom, tickFraction); @@ -191,6 +205,14 @@ public sealed class EyeLerpingSystem : EntitySystem _eye.SetZoom(entity, zoomDiff, eye); } + // ES START + // UHHHHHHHHHHHh + // shit is fucked idk + // we need to alter baserotation not regular eye rotation and also i added baserotation because uhh + // there was no good way to separate 'how the eye should be oriented because of the grid/turning/etc' and 'the eye rotating on top of that' + // had to add it + // ES END + // Handle Rotation TryComp(entity, out var mover); @@ -199,7 +221,10 @@ public sealed class EyeLerpingSystem : EntitySystem if (!NeedsLerp(mover)) { - _eye.SetRotation(entity, lerpInfo.TargetRotation, eye); + // ES START + // contenteye + contentEye.BaseRotation = lerpInfo.TargetRotation; + // ES END continue; } @@ -207,11 +232,17 @@ public sealed class EyeLerpingSystem : EntitySystem if (Math.Abs(shortest.Theta) < lerpMinimum) { - _eye.SetRotation(entity, lerpInfo.TargetRotation, eye); + // ES START + // contenteye + contentEye.BaseRotation = lerpInfo.TargetRotation; + // ES END continue; } - _eye.SetRotation(entity, shortest * tickFraction + lerpInfo.LastRotation, eye); + // ES START + // contenteye + contentEye.BaseRotation = shortest * tickFraction + lerpInfo.LastRotation; + // ES END } } } diff --git a/Content.Client/Movement/Systems/ContentEyeSystem.cs b/Content.Client/Movement/Systems/ContentEyeSystem.cs index a332d25f9a1..b03fe537e1e 100644 --- a/Content.Client/Movement/Systems/ContentEyeSystem.cs +++ b/Content.Client/Movement/Systems/ContentEyeSystem.cs @@ -60,6 +60,9 @@ public sealed class ContentEyeSystem : SharedContentEyeSystem while (eyeEntities.MoveNext(out var entity, out ContentEyeComponent? contentComponent, out EyeComponent? eyeComponent)) { UpdateEyeOffset((entity, eyeComponent)); + // ES START + UpdateEyeRotation((entity, eyeComponent)); + // ES END } } @@ -71,6 +74,9 @@ public sealed class ContentEyeSystem : SharedContentEyeSystem while (eyeEntities.MoveNext(out var entity, out ContentEyeComponent? contentComponent, out EyeComponent? eyeComponent)) { UpdateEyeOffset((entity, eyeComponent)); + // ES START + UpdateEyeRotation((entity, eyeComponent)); + // ES END } } } diff --git a/Content.Client/Options/UI/Tabs/AccessibilityTab.xaml b/Content.Client/Options/UI/Tabs/AccessibilityTab.xaml index 41fac83c598..b617ba03491 100644 --- a/Content.Client/Options/UI/Tabs/AccessibilityTab.xaml +++ b/Content.Client/Options/UI/Tabs/AccessibilityTab.xaml @@ -7,6 +7,7 @@