using Content.Shared.Hands.Components; using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.Serialization; using System; using Robust.Shared.IoC; namespace Content.Shared.Hands { public abstract class SharedHandsSystem : EntitySystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(HandleContainerModified); SubscribeLocalEvent(HandleContainerModified); SubscribeAllEvent(HandleSetHand); } private void HandleSetHand(RequestSetHandEvent msg, EntitySessionEventArgs eventArgs) { var entity = eventArgs.SenderSession.AttachedEntityUid; if (entity == null || !EntityManager.TryGetComponent(entity.Value, out SharedHandsComponent? hands)) return; hands.ActiveHand = msg.HandName; } protected virtual void HandleContainerModified( EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args) { component.Dirty(); } } [Serializable, NetSerializable] public class RequestSetHandEvent : EntityEventArgs { /// /// The hand to be swapped to. /// public string HandName { get; } public RequestSetHandEvent(string handName) { HandName = handName; } } /// /// Raised directed on both the blocking entity and user when /// a virtual hand item is deleted. /// public class VirtualItemDeletedEvent : EntityEventArgs { public EntityUid BlockingEntity; public EntityUid User; public VirtualItemDeletedEvent(EntityUid blockingEntity, EntityUid user) { BlockingEntity = blockingEntity; User = user; } } }