using System.Numerics; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using JetBrains.Annotations; using Robust.Shared.Map; using Robust.Shared.Serialization; namespace Content.Shared.Hands { /// /// Raised directed on an entity when attempting to drop its hand items. /// public sealed class DropAttemptEvent : CancellableEntityEventArgs { public readonly EntityUid Uid; } /// /// Raised directed at an item that needs to update its in-hand sprites/layers. /// public sealed class GetInhandVisualsEvent : EntityEventArgs { /// /// Entity that owns the hand holding the item. /// public readonly EntityUid User; public readonly HandLocation Location; /// /// The layers that will be added to the entity that is holding this item. /// /// /// Note that the actual ordering of the layers depends on the order in which they are added to this list; /// public List<(string, PrototypeLayerData)> Layers = new(); public GetInhandVisualsEvent(EntityUid user, HandLocation location) { User = user; Location = location; } } /// /// Raised directed at an item after its visuals have been updated. /// /// /// Useful for systems/components that modify the visual layers that an item adds to a player. (e.g. RGB memes) /// public sealed class HeldVisualsUpdatedEvent : EntityEventArgs { /// /// Entity that is holding the item. /// public readonly EntityUid User; /// /// The layers that this item is now revealing. /// public HashSet RevealedLayers; public HeldVisualsUpdatedEvent(EntityUid user, HashSet revealedLayers) { User = user; RevealedLayers = revealedLayers; } } /// /// Raised when an entity item in a hand is deselected. /// [PublicAPI] public sealed class HandDeselectedEvent : HandledEntityEventArgs { /// /// Entity that owns the deselected hand. /// public EntityUid User { get; } public HandDeselectedEvent(EntityUid user) { User = user; } } /// /// Raised when an item entity held by a hand is selected. /// [PublicAPI] public sealed class HandSelectedEvent : HandledEntityEventArgs { /// /// Entity that owns the selected hand. /// public EntityUid User { get; } public HandSelectedEvent(EntityUid user) { User = user; } } [Serializable, NetSerializable] public sealed class RequestSetHandEvent : EntityEventArgs { /// /// The hand to be swapped to. /// public string HandName { get; } public RequestSetHandEvent(string handName) { HandName = handName; } } /// /// Plays a clientside pickup animation by copying the specified entity. /// [Serializable, NetSerializable] public sealed class PickupAnimationEvent : EntityEventArgs { /// /// Entity to be copied for the clientside animation. /// public readonly NetEntity ItemUid; public readonly NetCoordinates InitialPosition; public readonly NetCoordinates FinalPosition; public readonly Angle InitialAngle; public PickupAnimationEvent(NetEntity itemUid, NetCoordinates initialPosition, NetCoordinates finalPosition, Angle initialAngle) { ItemUid = itemUid; FinalPosition = finalPosition; InitialPosition = initialPosition; InitialAngle = initialAngle; } } /// /// Raised directed on both the blocking entity and user when /// a virtual hand item is deleted. /// public sealed class VirtualItemDeletedEvent : EntityEventArgs { public EntityUid BlockingEntity; public EntityUid User; public VirtualItemDeletedEvent(EntityUid blockingEntity, EntityUid user) { BlockingEntity = blockingEntity; User = user; } } /// /// Raised against an item being picked up before it is actually inserted /// into the pick-up-ers hand container. This can be handled with side /// effects, and may be canceled preventing the pickup in a way that /// and similar don't see. /// /// The user picking up the item. /// /// If true, the item will not be equipped into the user's hand. /// [ByRefEvent] public record struct BeforeGettingEquippedHandEvent(EntityUid User, bool Cancelled = false); /// /// Raised against a mob picking up and item before it is actually inserted /// into the pick-up-ers hand container. This can be handled with side /// effects, and may be canceled preventing the pickup in a way that /// and similar don't see. /// /// The item being picked up. /// /// If true, the item will not be equipped into the user's hand. /// [ByRefEvent] public record struct BeforeEquippingHandEvent(EntityUid Item, bool Cancelled = false); /// /// Raised when putting an entity into a hand slot /// [PublicAPI] public abstract class EquippedHandEvent : HandledEntityEventArgs { /// /// Entity that equipped the item. /// public EntityUid User { get; } /// /// Item that was equipped. /// public EntityUid Equipped { get; } /// /// Hand that the item was placed into. /// public Hand Hand { get; } public EquippedHandEvent(EntityUid user, EntityUid equipped, Hand hand) { User = user; Equipped = equipped; Hand = hand; } } /// /// Raised when removing an entity from an inventory slot. /// [PublicAPI] public abstract class UnequippedHandEvent : HandledEntityEventArgs { /// /// Entity that equipped the item. /// public EntityUid User { get; } /// /// Item that was unequipped. /// public EntityUid Unequipped { get; } /// /// Hand that the item is removed from. /// public Hand Hand { get; } public UnequippedHandEvent(EntityUid user, EntityUid unequipped, Hand hand) { User = user; Unequipped = unequipped; Hand = hand; } } /// /// Raised directed on an entity when it is equipped into hands. /// public sealed class GotEquippedHandEvent : EquippedHandEvent { public GotEquippedHandEvent(EntityUid user, EntityUid unequipped, Hand hand) : base(user, unequipped, hand) { } } /// /// Raised directed on an entity when it is unequipped from hands. /// public sealed class GotUnequippedHandEvent : UnequippedHandEvent { public GotUnequippedHandEvent(EntityUid user, EntityUid unequipped, Hand hand) : base(user, unequipped, hand) { } } /// /// Raised directed on a user when it picks something up. /// public sealed class DidEquipHandEvent : EquippedHandEvent { public DidEquipHandEvent(EntityUid user, EntityUid unequipped, Hand hand) : base(user, unequipped, hand) { } } /// /// Raised directed on a user when something leaves its hands. /// public sealed class DidUnequipHandEvent : UnequippedHandEvent { public DidUnequipHandEvent(EntityUid user, EntityUid unequipped, Hand hand) : base(user, unequipped, hand) { } } /// /// Event raised by a client when they want to use the item currently held in their hands. /// [Serializable, NetSerializable] public sealed class RequestUseInHandEvent : EntityEventArgs { } /// /// Event raised by a client when they want to activate the item currently in their hands. /// [Serializable, NetSerializable] public sealed class RequestActivateInHandEvent : EntityEventArgs { public string HandName { get; } public RequestActivateInHandEvent(string handName) { HandName = handName; } } /// /// Event raised by a client when they want to use the currently held item on some other held item /// [Serializable, NetSerializable] public sealed class RequestHandInteractUsingEvent : EntityEventArgs { public string HandName { get; } public RequestHandInteractUsingEvent(string handName) { HandName = handName; } } /// /// Event raised by a client when they want to move an item held in another hand to their currently active hand /// [Serializable, NetSerializable] public sealed class RequestMoveHandItemEvent : EntityEventArgs { public string HandName { get; } public RequestMoveHandItemEvent(string handName) { HandName = handName; } } /// /// Event raised by a client when they want to alt interact with the item currently in their hands. /// [Serializable, NetSerializable] public sealed class RequestHandAltInteractEvent : EntityEventArgs { public string HandName { get; } public RequestHandAltInteractEvent(string handName) { HandName = handName; } } public sealed class HandCountChangedEvent : EntityEventArgs { public HandCountChangedEvent(EntityUid sender) { Sender = sender; } public EntityUid Sender { get; } } [ByRefEvent] public sealed class HeldRelayedEvent : EntityEventArgs { public TEvent Args; public HeldRelayedEvent(TEvent args) { Args = args; } } }