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;
|
|
|
|
|
|
2022-11-14 20:30:30 +01:00
|
|
|
namespace Content.Shared.Buckle.Components;
|
2020-10-14 15:24:07 +02:00
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
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]
|
2023-05-01 03:04:23 -04:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2022-12-23 23:55:31 -05:00
|
|
|
public float Range = SharedInteractionSystem.InteractionRange / 1.4f;
|
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>
|
2023-05-01 03:04:23 -04:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2023-09-28 16:20:29 -07:00
|
|
|
[AutoNetworkedField]
|
2023-05-01 03:04:23 -04:00
|
|
|
public bool Buckled;
|
2022-10-16 17:38:04 +11:00
|
|
|
|
2023-05-01 03:04:23 -04:00
|
|
|
[ViewVariables]
|
2023-09-28 16:20:29 -07:00
|
|
|
[AutoNetworkedField]
|
2023-05-01 03:04:23 -04:00
|
|
|
public EntityUid? LastEntityBuckledTo;
|
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>
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2023-09-28 16:20:29 -07: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>
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
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]
|
2023-05-01 03:04:23 -04:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2023-09-28 16:20:29 -07:00
|
|
|
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>
|
2023-05-01 03:04:23 -04:00
|
|
|
[ViewVariables]
|
|
|
|
|
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>
|
|
|
|
|
[ViewVariables]
|
2023-09-28 16:20:29 -07:00
|
|
|
[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]
|
2023-05-01 03:04:23 -04:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
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
|
|
|
|
2023-05-01 03:04:23 -04:00
|
|
|
[ByRefEvent]
|
2023-06-28 23:19:56 -04:00
|
|
|
public record struct BuckleAttemptEvent(EntityUid StrapEntity, EntityUid BuckledEntity, EntityUid UserEntity, bool Buckling, bool Cancelled = false);
|
2020-07-26 12:12:53 +02:00
|
|
|
|
2023-05-01 03:04:23 -04:00
|
|
|
[ByRefEvent]
|
|
|
|
|
public readonly record struct BuckleChangeEvent(EntityUid StrapEntity, EntityUid BuckledEntity, bool Buckling);
|
2022-11-14 20:30:30 +01:00
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public enum BuckleVisuals
|
|
|
|
|
{
|
|
|
|
|
Buckled
|
2020-06-25 15:52:24 +02:00
|
|
|
}
|