Files
Delta-v/Content.Shared/_ES/Camera/ESScreenshakeComponent.cs
T
9146c59ecf 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 <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>
2026-05-15 23:32:40 +02:00

64 lines
2.6 KiB
C#

using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared._ES.Camera;
/// <summary>
/// Marks an entity which is actively screenshaking because of a screenshake command being given.
/// </summary>
/// <remarks>
/// This doesn't mark an entity which *can* screenshake--all entities can, by default, as long as a client is controlling them.
/// </remarks>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class ESScreenshakeComponent : Component
{
/// <summary>
/// A set of screenshake commands which this entity is currently processing.
/// Trauma is 0..1, with 0 being no shake and 1 being maximum shake.
/// </summary>
/// <remarks>
/// This is a set, because order doesn't matter, and we don't want to accidentally readd the same command twice.
/// </remarks>
[DataField, AutoNetworkedField]
public HashSet<ESScreenshakeCommand> Commands = new();
public override bool SendOnlyToOwner => true;
}
/// <summary>
/// Represents a single screenshake command. These are stored and networked on <see cref="ESScreenshakeComponent"/>,
/// and the client that controls that entity will use the trauma values in each command, and their start time,
/// to calculate multipliers on the current eye offset & rotation modifiers.
/// </summary>
/// <param name="Translational">Parameters of translational screenshake (offset-based)</param>
/// <param name="Rotational">Parameters of rotational screenshake (rotation-based)</param>
/// <param name="Start">Time this screenshake command was added.</param>
/// <param name="CalculatedEnd">The end time for this command, calculated from trauma, decay rate, and start time.</param>
[DataRecord, Serializable, NetSerializable]
public partial record ESScreenshakeCommand(ESScreenshakeParameters? Translational, ESScreenshakeParameters? Rotational, TimeSpan Start, TimeSpan CalculatedEnd);
/// <summary>
/// Represents the parameters of a single instance of screenshake, which may apply to translational or rotational shake.
/// </summary>
[DataDefinition, Serializable, NetSerializable]
public partial record ESScreenshakeParameters()
{
/// <summary>
/// Strength of the shake.
/// </summary>
[DataField(required: true)]
public float Trauma = 0f;
/// <summary>
/// How fast the shake decays.
/// </summary>
[DataField]
public float DecayRate = 1.2f;
/// <summary>
/// How frantically the shake oscillates.
/// </summary>
[DataField]
public float Frequency = 0.01f;
};