Files
tbd-station-14/Content.Shared/Ensnaring/Components/EnsnaringComponent.cs
Vordenburg 7ebe16dd3d Fix snares (#16699)
The alert for snares will appear again. Previously it was being updated
on the snare itself and not the player.

It is no longer possible to infinitely ensnare someone; the maximum
number is dependent on the target's legs.

Only one snare at a time will be removed now.

Clarified the wording and logic around CanMoveBreakout. It was
inconsistent.

Made multiple snares impose cumulative speed penalties.

It is no longer possible to remove bolas while moving.
2023-05-22 15:49:37 -06:00

117 lines
3.2 KiB
C#

using System.Threading;
using Robust.Shared.GameStates;
namespace Content.Shared.Ensnaring.Components;
/// <summary>
/// Use this on something you want to use to ensnare an entity with
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed class EnsnaringComponent : Component
{
/// <summary>
/// How long it should take to free someone else.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("freeTime")]
public float FreeTime = 3.5f;
/// <summary>
/// How long it should take for an entity to free themselves.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("breakoutTime")]
public float BreakoutTime = 30.0f;
/// <summary>
/// How much should this slow down the entities walk?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("walkSpeed")]
public float WalkSpeed = 0.9f;
/// <summary>
/// How much should this slow down the entities sprint?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("sprintSpeed")]
public float SprintSpeed = 0.9f;
/// <summary>
/// Should this ensnare someone when thrown?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("canThrowTrigger")]
public bool CanThrowTrigger;
/// <summary>
/// What is ensnared?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("ensnared")]
public EntityUid? Ensnared;
/// <summary>
/// Should breaking out be possible when moving?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("canMoveBreakout")]
public bool CanMoveBreakout;
}
/// <summary>
/// Used whenever you want to do something when someone becomes ensnared by the <see cref="EnsnaringComponent"/>
/// </summary>
public sealed class EnsnareEvent : EntityEventArgs
{
public readonly float WalkSpeed;
public readonly float SprintSpeed;
public EnsnareEvent(float walkSpeed, float sprintSpeed)
{
WalkSpeed = walkSpeed;
SprintSpeed = sprintSpeed;
}
}
/// <summary>
/// Used whenever you want to do something when someone is freed by the <see cref="EnsnaringComponent"/>
/// </summary>
public sealed class EnsnareRemoveEvent : CancellableEntityEventArgs
{
public readonly float WalkSpeed;
public readonly float SprintSpeed;
public EnsnareRemoveEvent(float walkSpeed, float sprintSpeed)
{
WalkSpeed = walkSpeed;
SprintSpeed = sprintSpeed;
}
}
/// <summary>
/// Used for the do after event to free the entity that owns the <see cref="EnsnareableComponent"/>
/// </summary>
public sealed class FreeEnsnareDoAfterComplete : EntityEventArgs
{
public readonly EntityUid EnsnaringEntity;
public FreeEnsnareDoAfterComplete(EntityUid ensnaringEntity)
{
EnsnaringEntity = ensnaringEntity;
}
}
/// <summary>
/// Used for the do after event when it fails to free the entity that owns the <see cref="EnsnareableComponent"/>
/// </summary>
public sealed class FreeEnsnareDoAfterCancel : EntityEventArgs
{
public readonly EntityUid EnsnaringEntity;
public FreeEnsnareDoAfterCancel(EntityUid ensnaringEntity)
{
EnsnaringEntity = ensnaringEntity;
}
}