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