using System.Diagnostics.CodeAnalysis; using Content.Shared.Alert; using Content.Shared.Interaction; using Robust.Shared.GameStates; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared.Buckle.Components; /// /// This component allows an entity to be buckled to an entity with a . /// [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause] [Access(typeof(SharedBuckleSystem))] public sealed partial class BuckleComponent : Component { /// /// The range from which this entity can buckle to a . /// Separated from normal interaction range to fix the "someone buckled to a strap /// across a table two tiles away" problem. /// [DataField] public float Range = SharedInteractionSystem.InteractionRange; /// /// True if the entity is buckled, false otherwise. /// [MemberNotNullWhen(true, nameof(BuckledTo))] public bool Buckled => BuckledTo != null; /// /// Whether or not collisions should be possible with the entity we are strapped to /// [DataField, AutoNetworkedField] public bool DontCollide; /// /// Whether or not we should be allowed to pull the entity we are strapped to /// [DataField] public bool PullStrap; /// /// The amount of time that must pass for this entity to /// be able to unbuckle after recently buckling. /// [DataField] public TimeSpan Delay = TimeSpan.FromSeconds(0.25f); /// /// The time that this entity buckled at. /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField, AutoNetworkedField] public TimeSpan? BuckleTime; /// /// The strap that this component is buckled to. /// [DataField, AutoNetworkedField] public EntityUid? BuckledTo; /// /// The amount of space that this entity occupies in a /// . /// [DataField] public int Size = 100; /// /// Used for client rendering /// [ViewVariables] public int? OriginalDrawDepth; } public sealed partial class UnbuckleAlertEvent : BaseAlertEvent; /// /// Event raised directed at a strap entity before some entity gets buckled to it. /// [ByRefEvent] public record struct StrapAttemptEvent( Entity Strap, Entity Buckle, EntityUid? User, bool Popup) { public bool Cancelled; } /// /// Event raised directed at a buckle entity before it gets buckled to some strap entity. /// [ByRefEvent] public record struct BuckleAttemptEvent( Entity Strap, Entity Buckle, EntityUid? User, bool Popup) { public bool Cancelled; } /// /// Event raised directed at a strap entity before some entity gets unbuckled from it. /// [ByRefEvent] public record struct UnstrapAttemptEvent( Entity Strap, Entity Buckle, EntityUid? User, bool Popup) { public bool Cancelled; } /// /// Event raised directed at a buckle entity before it gets unbuckled. /// [ByRefEvent] public record struct UnbuckleAttemptEvent( Entity Strap, Entity Buckle, EntityUid? User, bool Popup) { public bool Cancelled; } /// /// Event raised directed at a strap entity after something has been buckled to it. /// [ByRefEvent] public readonly record struct StrappedEvent(Entity Strap, Entity Buckle); /// /// Event raised directed at a buckle entity after it has been buckled. /// [ByRefEvent] public readonly record struct BuckledEvent(Entity Strap, Entity Buckle); /// /// Event raised directed at a strap entity after something has been unbuckled from it. /// [ByRefEvent] public readonly record struct UnstrappedEvent(Entity Strap, Entity Buckle); /// /// Event raised directed at a buckle entity after it has been unbuckled from some strap entity. /// [ByRefEvent] public readonly record struct UnbuckledEvent(Entity Strap, Entity Buckle); [Serializable, NetSerializable] public enum BuckleVisuals { Buckled }