using System; using Content.Shared.Actions.Components; using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Shared.Actions.Behaviors.Item { /// /// Currently just a marker interface delineating the different possible /// types of item action behaviors. /// public interface IItemActionBehavior { } /// /// Base class for all item action event args /// public abstract class ItemActionEventArgs : EventArgs { /// /// Entity performing the action. /// public readonly EntityUid Performer; /// /// Item being used to perform the action /// public readonly EntityUid Item; /// /// Action being performed /// public readonly ItemActionType ActionType; /// /// Item actions component of the item. /// public readonly ItemActionsComponent? ItemActions; public ItemActionEventArgs(EntityUid performer, EntityUid item, ItemActionType actionType) { Performer = performer; ActionType = actionType; Item = item; var entMan = IoCManager.Resolve(); if (!entMan.TryGetComponent(Item, out ItemActions)) { throw new InvalidOperationException($"performer {entMan.GetComponent(performer).EntityName} tried to perform item action {actionType} " + $" for item {entMan.GetComponent(Item).EntityName} but the item had no ItemActionsComponent," + " which should never occur"); } } } }