6
2025-11-03 10:15:18 +03:00

65 lines
2.1 KiB
C#

using System.Numerics;
using Robust.Shared.GameStates;
using Robust.Shared.Physics.Components;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Content.Shared.Whitelist; // Frontier
namespace Content.Shared.Weapons.Melee.Components;
/// <summary>
/// This is used for a melee weapon that throws whatever gets hit by it in a line
/// until it hits a wall or a time limit is exhausted.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(MeleeThrowOnHitSystem))]
public sealed partial class MeleeThrowOnHitComponent : Component
{
/// <summary>
/// The speed at which hit entities should be thrown.
/// </summary>
[DataField, AutoNetworkedField]
public float Speed = 10f;
/// <summary>
/// The maximum distance the hit entity should be thrown.
/// </summary>
[DataField, AutoNetworkedField]
public float Distance = 20f;
/// <summary>
/// Whether or not anchorable entities should be unanchored when hit.
/// </summary>
[DataField, AutoNetworkedField]
public bool UnanchorOnHit;
/// <summary>
/// Frontier - If any entities on the whitelist then UnanchorOnHit won't work on anything else.
/// </summary>
[DataField]
public EntityWhitelist? Whitelist;
/// <summary>
/// How long should this stun the target, if applicable?
/// </summary>
[DataField, AutoNetworkedField]
public TimeSpan? StunTime;
/// <summary>
/// Should this also work on a throw-hit?
/// </summary>
[DataField, AutoNetworkedField]
public bool ActivateOnThrown;
}
/// <summary>
/// Raised a weapon entity with <see cref="MeleeThrowOnHitComponent"/> to see if a throw is allowed.
/// </summary>
[ByRefEvent]
public record struct AttemptMeleeThrowOnHitEvent(EntityUid Target, EntityUid? User, bool Cancelled = false, bool Handled = false);
/// <summary>
/// Raised a target entity before it is thrown by <see cref="MeleeThrowOnHitComponent"/>.
/// </summary>
[ByRefEvent]
public record struct MeleeThrowOnHitStartEvent(EntityUid Weapon, EntityUid? User);