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 IEntity Performer; /// /// Item being used to perform the action /// public readonly IEntity Item; /// /// Action being performed /// public readonly ItemActionType ActionType; /// /// Item actions component of the item. /// public readonly ItemActionsComponent? ItemActions; public ItemActionEventArgs(IEntity performer, IEntity item, ItemActionType actionType) { Performer = performer; ActionType = actionType; Item = item; if (!IoCManager.Resolve().TryGetComponent(Item.Uid, out ItemActions)) { throw new InvalidOperationException($"performer {IoCManager.Resolve().GetComponent(performer.Uid).EntityName} tried to perform item action {actionType} " + $" for item {IoCManager.Resolve().GetComponent(Item.Uid).EntityName} but the item had no ItemActionsComponent," + " which should never occur"); } } } }