2024-06-20 03:14:18 +12:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2024-08-07 01:15:35 -04:00
|
|
|
using Content.Shared.Alert;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Interaction;
|
2021-07-12 01:32:10 -07:00
|
|
|
using Robust.Shared.GameStates;
|
2020-06-25 15:52:24 +02:00
|
|
|
using Robust.Shared.Serialization;
|
2024-06-20 03:14:18 +12:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
2020-06-25 15:52:24 +02:00
|
|
|
|
2022-11-14 20:30:30 +01:00
|
|
|
namespace Content.Shared.Buckle.Components;
|
2020-10-14 15:24:07 +02:00
|
|
|
|
2024-06-20 03:14:18 +12:00
|
|
|
/// <summary>
|
|
|
|
|
/// This component allows an entity to be buckled to an entity with a <see cref="StrapComponent"/>.
|
|
|
|
|
/// </summary>
|
2024-09-22 18:21:40 +10:00
|
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
|
2023-05-01 03:04:23 -04:00
|
|
|
[Access(typeof(SharedBuckleSystem))]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class BuckleComponent : Component
|
2022-11-14 20:30:30 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2023-05-01 03:04:23 -04:00
|
|
|
/// 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.
|
2022-11-14 20:30:30 +01:00
|
|
|
/// </summary>
|
2023-09-28 16:20:29 -07:00
|
|
|
[DataField]
|
2024-09-22 18:21:40 +10:00
|
|
|
public float Range = SharedInteractionSystem.InteractionRange;
|
2022-10-16 17:38:04 +11:00
|
|
|
|
2022-11-14 20:30:30 +01:00
|
|
|
/// <summary>
|
2023-05-01 03:04:23 -04:00
|
|
|
/// True if the entity is buckled, false otherwise.
|
2022-11-14 20:30:30 +01:00
|
|
|
/// </summary>
|
2024-06-20 03:14:18 +12:00
|
|
|
[MemberNotNullWhen(true, nameof(BuckledTo))]
|
|
|
|
|
public bool Buckled => BuckledTo != null;
|
2022-07-16 13:51:52 +10:00
|
|
|
|
2023-05-01 03:04:23 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Whether or not collisions should be possible with the entity we are strapped to
|
|
|
|
|
/// </summary>
|
2024-09-22 18:21:40 +10:00
|
|
|
[DataField, AutoNetworkedField]
|
2023-05-01 03:04:23 -04:00
|
|
|
public bool DontCollide;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether or not we should be allowed to pull the entity we are strapped to
|
|
|
|
|
/// </summary>
|
2023-09-28 16:20:29 -07:00
|
|
|
[DataField]
|
2023-05-01 03:04:23 -04:00
|
|
|
public bool PullStrap;
|
2022-12-23 23:55:31 -05:00
|
|
|
|
|
|
|
|
/// <summary>
|
2023-05-01 03:04:23 -04:00
|
|
|
/// The amount of time that must pass for this entity to
|
|
|
|
|
/// be able to unbuckle after recently buckling.
|
2022-12-23 23:55:31 -05:00
|
|
|
/// </summary>
|
2023-09-28 16:20:29 -07:00
|
|
|
[DataField]
|
|
|
|
|
public TimeSpan Delay = TimeSpan.FromSeconds(0.25f);
|
2022-12-23 23:55:31 -05:00
|
|
|
|
|
|
|
|
/// <summary>
|
2023-05-01 03:04:23 -04:00
|
|
|
/// The time that this entity buckled at.
|
2022-12-23 23:55:31 -05:00
|
|
|
/// </summary>
|
2024-09-22 18:21:40 +10:00
|
|
|
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField, AutoNetworkedField]
|
2024-06-20 03:14:18 +12:00
|
|
|
public TimeSpan? BuckleTime;
|
2022-12-23 23:55:31 -05:00
|
|
|
|
|
|
|
|
/// <summary>
|
2023-05-01 03:04:23 -04:00
|
|
|
/// The strap that this component is buckled to.
|
2022-12-23 23:55:31 -05:00
|
|
|
/// </summary>
|
2024-09-22 18:21:40 +10:00
|
|
|
[DataField, AutoNetworkedField]
|
2023-05-01 03:04:23 -04:00
|
|
|
public EntityUid? BuckledTo;
|
2022-12-23 23:55:31 -05:00
|
|
|
|
|
|
|
|
/// <summary>
|
2023-05-01 03:04:23 -04:00
|
|
|
/// The amount of space that this entity occupies in a
|
|
|
|
|
/// <see cref="StrapComponent"/>.
|
2022-12-23 23:55:31 -05:00
|
|
|
/// </summary>
|
2023-09-28 16:20:29 -07:00
|
|
|
[DataField]
|
2022-12-23 23:55:31 -05:00
|
|
|
public int Size = 100;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used for client rendering
|
|
|
|
|
/// </summary>
|
2023-09-28 16:20:29 -07:00
|
|
|
[ViewVariables] public int? OriginalDrawDepth;
|
2022-11-14 20:30:30 +01:00
|
|
|
}
|
2022-04-15 18:53:52 -04:00
|
|
|
|
2024-08-07 01:15:35 -04:00
|
|
|
public sealed partial class UnbuckleAlertEvent : BaseAlertEvent;
|
2024-06-20 03:14:18 +12:00
|
|
|
|
|
|
|
|
/// <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>
|
2023-05-01 03:04:23 -04:00
|
|
|
[ByRefEvent]
|
2024-06-20 03:14:18 +12:00
|
|
|
public readonly record struct UnstrappedEvent(Entity<StrapComponent> Strap, Entity<BuckleComponent> Buckle);
|
2020-07-26 12:12:53 +02:00
|
|
|
|
2024-06-20 03:14:18 +12:00
|
|
|
/// <summary>
|
|
|
|
|
/// Event raised directed at a buckle entity after it has been unbuckled from some strap entity.
|
|
|
|
|
/// </summary>
|
2023-05-01 03:04:23 -04:00
|
|
|
[ByRefEvent]
|
2024-06-20 03:14:18 +12:00
|
|
|
public readonly record struct UnbuckledEvent(Entity<StrapComponent> Strap, Entity<BuckleComponent> Buckle);
|
2022-11-14 20:30:30 +01:00
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public enum BuckleVisuals
|
|
|
|
|
{
|
|
|
|
|
Buckled
|
2020-06-25 15:52:24 +02:00
|
|
|
}
|