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