using System.Numerics; using Robust.Shared.GameStates; using Robust.Shared.Physics.Components; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared.Weapons.Melee.Components; /// /// 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. /// [RegisterComponent, NetworkedComponent] [Access(typeof(MeleeThrowOnHitSystem))] [AutoGenerateComponentState] public sealed partial class MeleeThrowOnHitComponent : Component { /// /// The speed at which hit entities should be thrown. /// [DataField, ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] public float Speed = 10f; /// /// How long hit entities remain thrown, max. /// [DataField, ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] public float Lifetime = 3f; /// /// How long we wait to start accepting collision. /// [DataField, ViewVariables(VVAccess.ReadWrite)] public float MinLifetime = 0.05f; /// /// Whether or not anchorable entities should be unanchored when hit. /// [DataField, ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] public bool UnanchorOnHit; /// /// Whether or not the throwing behavior occurs by default. /// [DataField, ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] public bool Enabled = true; } /// /// Component used to track entities that have been yeeted by /// [RegisterComponent, NetworkedComponent] [AutoGenerateComponentState] [Access(typeof(MeleeThrowOnHitSystem))] public sealed partial class MeleeThrownComponent : Component { /// /// The velocity of the throw /// [DataField, ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] public Vector2 Velocity; /// /// How long the throw will last. /// [DataField, ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] public float Lifetime; /// /// How long we wait to start accepting collision. /// [DataField, ViewVariables(VVAccess.ReadWrite)] public float MinLifetime; /// /// At what point in time will the throw be complete? /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] [AutoNetworkedField] public TimeSpan ThrownEndTime; /// /// At what point in time will the be exhausted /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] [AutoNetworkedField] public TimeSpan MinLifetimeTime; /// /// the status to which the entity will return when the thrown ends /// [DataField] public BodyStatus PreviousStatus; } /// /// Event raised before an entity is thrown by to see if a throw is allowed. /// If not handled, the enabled field on the component will be used instead. /// [ByRefEvent] public record struct AttemptMeleeThrowOnHitEvent(EntityUid Hit, bool Cancelled = false, bool Handled = false); [ByRefEvent] public record struct MeleeThrowOnHitStartEvent(EntityUid User, EntityUid Used); [ByRefEvent] public record struct MeleeThrowOnHitEndEvent();