diff --git a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs index a94ac2fd96..3aab81e2ec 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs @@ -11,6 +11,7 @@ using Content.Shared.Database; using Content.Shared.FixedPoint; using Content.Shared.Hands; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.MobState.Components; using Robust.Shared.GameStates; using Robust.Shared.Player; diff --git a/Content.Server/Clothing/Components/ClothingComponent.cs b/Content.Server/Clothing/Components/ClothingComponent.cs index 70568a95b4..93db5d6e58 100644 --- a/Content.Server/Clothing/Components/ClothingComponent.cs +++ b/Content.Server/Clothing/Components/ClothingComponent.cs @@ -1,14 +1,5 @@ -using Content.Server.Hands.Components; -using Content.Shared.Clothing; -using Content.Shared.Interaction; -using Content.Shared.Inventory; using Content.Shared.Item; -using Robust.Shared.GameObjects; using Robust.Shared.GameStates; -using Robust.Shared.IoC; -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.ViewVariables; namespace Content.Server.Clothing.Components { @@ -20,53 +11,12 @@ namespace Content.Server.Clothing.Components [RegisterComponent] [NetworkedComponent] [ComponentReference(typeof(SharedItemComponent))] - public sealed class ClothingComponent : ItemComponent, IUse + public sealed class ClothingComponent : ItemComponent { - [Dependency] private readonly IEntityManager _entities = default!; - [Dependency] private readonly IPrototypeManager _prototype = default!; - - [DataField("QuickEquip")] - private bool _quickEquipEnabled = true; - [DataField("HeatResistance")] private int _heatResistance = 323; [ViewVariables(VVAccess.ReadWrite)] public int HeatResistance => _heatResistance; - - bool IUse.UseEntity(UseEntityEventArgs eventArgs) - { - if (!_quickEquipEnabled) return false; - - var invSystem = EntitySystem.Get(); - if (!_entities.TryGetComponent(eventArgs.User, out InventoryComponent? inv) - || !_entities.TryGetComponent(eventArgs.User, out HandsComponent? hands) || !_prototype.TryIndex(inv.TemplateId, out var prototype)) return false; - - foreach (var slotDef in prototype.Slots) - { - if(!invSystem.CanEquip(eventArgs.User, Owner, slotDef.Name, out _, slotDef, inv)) - continue; - - if (invSystem.TryGetSlotEntity(eventArgs.User, slotDef.Name, out var slotEntity, inv)) - { - if(!invSystem.TryUnequip(eventArgs.User, slotDef.Name, true, inventory: inv)) - continue; - - if (!invSystem.TryEquip(eventArgs.User, Owner, slotDef.Name, true, inventory: inv)) - continue; - - hands.PutInHandOrDrop(slotEntity.Value); - } - else - { - if (!invSystem.TryEquip(eventArgs.User, Owner, slotDef.Name, true, inventory: inv)) - continue; - } - - return true; - } - - return false; - } } } diff --git a/Content.Server/Crayon/CrayonSystem.cs b/Content.Server/Crayon/CrayonSystem.cs index e4ebc0b8a4..0a9e2f2a12 100644 --- a/Content.Server/Crayon/CrayonSystem.cs +++ b/Content.Server/Crayon/CrayonSystem.cs @@ -7,6 +7,7 @@ using Content.Shared.Crayon; using Content.Shared.Database; using Content.Shared.Decals; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; using Robust.Server.GameObjects; using Robust.Shared.Audio; diff --git a/Content.Server/Dice/DiceSystem.cs b/Content.Server/Dice/DiceSystem.cs index cd8753210b..3780197b06 100644 --- a/Content.Server/Dice/DiceSystem.cs +++ b/Content.Server/Dice/DiceSystem.cs @@ -2,7 +2,7 @@ using System; using Content.Server.Popups; using Content.Shared.Audio; using Content.Shared.Examine; -using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Server.GameObjects; diff --git a/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs b/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs index 7edefb4b8c..377de6a7d3 100644 --- a/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs @@ -4,6 +4,7 @@ using Content.Server.Flash.Components; using Content.Server.Throwing; using Content.Shared.Explosion; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.IoC; diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs index b37868c1c8..3ea15d04a6 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs @@ -1,6 +1,6 @@ using System; using Content.Server.Explosion.Components; -using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Trigger; using Robust.Shared.GameObjects; diff --git a/Content.Server/Extinguisher/FireExtinguisherSystem.cs b/Content.Server/Extinguisher/FireExtinguisherSystem.cs index a40df29234..b06e28142f 100644 --- a/Content.Server/Extinguisher/FireExtinguisherSystem.cs +++ b/Content.Server/Extinguisher/FireExtinguisherSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.CharacterAppearance.Systems; using Content.Shared.Extinguisher; using Content.Shared.FixedPoint; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Verbs; using Robust.Shared.Audio; using Robust.Shared.GameObjects; diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index 869442d474..e57e1cd58a 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -4,6 +4,7 @@ using Content.Server.Weapon.Melee; using Content.Shared.Examine; using Content.Shared.Flash; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Inventory; using Content.Shared.Physics; using Content.Shared.Popups; diff --git a/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs b/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs index d3bb622ea0..b4d2c8475b 100644 --- a/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs +++ b/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs @@ -1,6 +1,6 @@ using Content.Server.Clothing.Components; using Content.Server.Light.Components; -using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Light.Component; using Content.Shared.Verbs; diff --git a/Content.Server/Medical/HealingSystem.cs b/Content.Server/Medical/HealingSystem.cs index 06af257f77..be6952e8da 100644 --- a/Content.Server/Medical/HealingSystem.cs +++ b/Content.Server/Medical/HealingSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.Audio; using Content.Shared.Damage; using Content.Shared.Database; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Stacks; using Robust.Shared.Audio; using Robust.Shared.Player; diff --git a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs index 13bfe95f6d..545a0be5e6 100644 --- a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs @@ -15,6 +15,7 @@ using Content.Shared.Database; using Content.Shared.Examine; using Content.Shared.FixedPoint; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; using Content.Shared.Nutrition.Components; using Content.Shared.Throwing; diff --git a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs index 07f0128060..bd4cfc56be 100644 --- a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs @@ -21,6 +21,7 @@ using Robust.Shared.Player; using Robust.Shared.Utility; using Content.Shared.Inventory; using Content.Shared.Item; +using Content.Shared.Interaction.Events; namespace Content.Server.Nutrition.EntitySystems { diff --git a/Content.Server/PAI/PAISystem.cs b/Content.Server/PAI/PAISystem.cs index 24462c89c0..eba8a44659 100644 --- a/Content.Server/PAI/PAISystem.cs +++ b/Content.Server/PAI/PAISystem.cs @@ -1,5 +1,4 @@ using Content.Shared.Examine; -using Content.Shared.Interaction; using Content.Shared.PAI; using Content.Shared.Verbs; using Content.Shared.Instruments; @@ -14,6 +13,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Player; using Content.Shared.Actions; +using Content.Shared.Interaction.Events; namespace Content.Server.PAI { diff --git a/Content.Server/PDA/PDASystem.cs b/Content.Server/PDA/PDASystem.cs index 86ab624fa3..c4af51f1c2 100644 --- a/Content.Server/PDA/PDASystem.cs +++ b/Content.Server/PDA/PDASystem.cs @@ -15,6 +15,7 @@ using Robust.Server.GameObjects; using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.IoC; +using Content.Shared.Interaction.Events; namespace Content.Server.PDA { diff --git a/Content.Server/RCD/Systems/RCDSystem.cs b/Content.Server/RCD/Systems/RCDSystem.cs index f6a44a98d0..d4e6dad4c0 100644 --- a/Content.Server/RCD/Systems/RCDSystem.cs +++ b/Content.Server/RCD/Systems/RCDSystem.cs @@ -5,6 +5,7 @@ using Content.Server.RCD.Components; using Content.Shared.Coordinates; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; using Content.Shared.Maps; using Content.Shared.Popups; diff --git a/Content.Server/Remotes/DoorRemoteSystem.cs b/Content.Server/Remotes/DoorRemoteSystem.cs index eda09bd27c..509238d213 100644 --- a/Content.Server/Remotes/DoorRemoteSystem.cs +++ b/Content.Server/Remotes/DoorRemoteSystem.cs @@ -11,6 +11,7 @@ using Content.Shared.Physics; using Content.Shared.Access.Components; using Content.Server.Doors.Systems; using Content.Server.Doors.Components; +using Content.Shared.Interaction.Events; namespace Content.Server.Remotes { diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index 0bab9c2326..11d6f37af7 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -3,6 +3,7 @@ using Content.Server.Sound.Components; using Content.Server.Throwing; using Content.Shared.Audio; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Shared.Audio; diff --git a/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs b/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs index 989db5cdac..a9402c4455 100644 --- a/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs +++ b/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Content.Server.Storage.Components; using Content.Shared.Hands.Components; -using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index df09fa6e8c..134201463a 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -8,7 +8,7 @@ using Content.Server.Weapon.Melee; using Content.Shared.ActionBlocker; using Content.Shared.Audio; using Content.Shared.Examine; -using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Jittering; using Content.Shared.Popups; diff --git a/Content.Server/UserInterface/ActivatableUISystem.cs b/Content.Server/UserInterface/ActivatableUISystem.cs index f88cb94bd9..c638e05ae1 100644 --- a/Content.Server/UserInterface/ActivatableUISystem.cs +++ b/Content.Server/UserInterface/ActivatableUISystem.cs @@ -4,6 +4,7 @@ using Content.Shared.Actions; using Content.Shared.Actions.ActionTypes; using Content.Shared.Hands; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; diff --git a/Content.Server/Weapon/Melee/EnergySword/EnergySwordSystem.cs b/Content.Server/Weapon/Melee/EnergySword/EnergySwordSystem.cs index d6caf5b57a..f4b5562cd3 100644 --- a/Content.Server/Weapon/Melee/EnergySword/EnergySwordSystem.cs +++ b/Content.Server/Weapon/Melee/EnergySword/EnergySwordSystem.cs @@ -1,6 +1,7 @@ using Content.Server.Tools.Components; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Weapons.Melee; using Robust.Shared.Audio; diff --git a/Content.Server/Weapon/Ranged/GunSystem.AmmoBox.cs b/Content.Server/Weapon/Ranged/GunSystem.AmmoBox.cs index 4ad3cdcc51..176fc913f3 100644 --- a/Content.Server/Weapon/Ranged/GunSystem.AmmoBox.cs +++ b/Content.Server/Weapon/Ranged/GunSystem.AmmoBox.cs @@ -6,6 +6,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components; using Content.Server.Weapon.Ranged.Barrels.Components; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Barrels.Components; using Robust.Shared.Containers; diff --git a/Content.Server/Weapon/Ranged/GunSystem.Bolt.cs b/Content.Server/Weapon/Ranged/GunSystem.Bolt.cs index 1d0af36019..9ffea29bea 100644 --- a/Content.Server/Weapon/Ranged/GunSystem.Bolt.cs +++ b/Content.Server/Weapon/Ranged/GunSystem.Bolt.cs @@ -3,6 +3,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components; using Content.Server.Weapon.Ranged.Barrels.Components; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Barrels.Components; using Robust.Shared.Audio; diff --git a/Content.Server/Weapon/Ranged/GunSystem.Magazine.cs b/Content.Server/Weapon/Ranged/GunSystem.Magazine.cs index 1871392ecf..c2c02245db 100644 --- a/Content.Server/Weapon/Ranged/GunSystem.Magazine.cs +++ b/Content.Server/Weapon/Ranged/GunSystem.Magazine.cs @@ -5,6 +5,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components; using Content.Server.Weapon.Ranged.Barrels.Components; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged; diff --git a/Content.Server/Weapon/Ranged/GunSystem.Pump.cs b/Content.Server/Weapon/Ranged/GunSystem.Pump.cs index a1917c3869..a8459131fd 100644 --- a/Content.Server/Weapon/Ranged/GunSystem.Pump.cs +++ b/Content.Server/Weapon/Ranged/GunSystem.Pump.cs @@ -2,6 +2,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components; using Content.Server.Weapon.Ranged.Barrels.Components; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Weapons.Ranged.Barrels.Components; using Content.Shared.Weapons.Ranged.Components; using Robust.Shared.Audio; diff --git a/Content.Server/Weapon/Ranged/GunSystem.RangedMagazine.cs b/Content.Server/Weapon/Ranged/GunSystem.RangedMagazine.cs index a0ae702a6e..a57be68810 100644 --- a/Content.Server/Weapon/Ranged/GunSystem.RangedMagazine.cs +++ b/Content.Server/Weapon/Ranged/GunSystem.RangedMagazine.cs @@ -4,6 +4,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components; using Content.Server.Weapon.Ranged.Barrels.Components; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Weapons.Ranged.Barrels.Components; using Robust.Shared.Containers; diff --git a/Content.Server/Weapon/Ranged/GunSystem.Revolvers.cs b/Content.Server/Weapon/Ranged/GunSystem.Revolvers.cs index 7afe7a13d4..343c545e18 100644 --- a/Content.Server/Weapon/Ranged/GunSystem.Revolvers.cs +++ b/Content.Server/Weapon/Ranged/GunSystem.Revolvers.cs @@ -2,6 +2,7 @@ using System; using Content.Server.Weapon.Ranged.Ammunition.Components; using Content.Server.Weapon.Ranged.Barrels.Components; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Popups; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Barrels.Components; diff --git a/Content.Server/Weapon/Ranged/GunSystem.SpeedLoader.cs b/Content.Server/Weapon/Ranged/GunSystem.SpeedLoader.cs index b71fefbf0b..0df95b9d44 100644 --- a/Content.Server/Weapon/Ranged/GunSystem.SpeedLoader.cs +++ b/Content.Server/Weapon/Ranged/GunSystem.SpeedLoader.cs @@ -2,6 +2,7 @@ using Content.Server.Hands.Components; using Content.Server.Weapon.Ranged.Ammunition.Components; using Content.Server.Weapon.Ranged.Barrels.Components; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Weapons.Ranged.Barrels.Components; using Robust.Shared.Containers; diff --git a/Content.Server/Weapon/Ranged/GunSystem.cs b/Content.Server/Weapon/Ranged/GunSystem.cs index 1391acdd8d..076ebe7cc2 100644 --- a/Content.Server/Weapon/Ranged/GunSystem.cs +++ b/Content.Server/Weapon/Ranged/GunSystem.cs @@ -12,6 +12,7 @@ using Content.Shared.Camera; using Content.Shared.Damage; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Popups; using Content.Shared.PowerCell.Components; using Content.Shared.Verbs; diff --git a/Content.Server/Wieldable/WieldableSystem.cs b/Content.Server/Wieldable/WieldableSystem.cs index 31ee3065dc..9f99aa2710 100644 --- a/Content.Server/Wieldable/WieldableSystem.cs +++ b/Content.Server/Wieldable/WieldableSystem.cs @@ -4,7 +4,7 @@ using Content.Server.Hands.Systems; using Content.Server.Weapon.Melee; using Content.Server.Wieldable.Components; using Content.Shared.Hands; -using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Popups; using Content.Shared.Verbs; diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index c1b22e0d82..0b987e575c 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -2,6 +2,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Acts; using Content.Shared.Hands.Components; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Popups; using Content.Shared.Sound; using Content.Shared.Verbs; diff --git a/Content.Shared/Interaction/Events/ChangeDirectionAttemptEvent.cs b/Content.Shared/Interaction/Events/ChangeDirectionAttemptEvent.cs index 895fa58abc..79ece52c0a 100644 --- a/Content.Shared/Interaction/Events/ChangeDirectionAttemptEvent.cs +++ b/Content.Shared/Interaction/Events/ChangeDirectionAttemptEvent.cs @@ -1,14 +1,13 @@ -using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects; -namespace Content.Shared.Interaction.Events +namespace Content.Shared.Interaction.Events; + +public sealed class ChangeDirectionAttemptEvent : CancellableEntityEventArgs { - public sealed class ChangeDirectionAttemptEvent : CancellableEntityEventArgs + public ChangeDirectionAttemptEvent(EntityUid uid) { - public ChangeDirectionAttemptEvent(EntityUid uid) - { - Uid = uid; - } - - public EntityUid Uid { get; } + Uid = uid; } + + public EntityUid Uid { get; } } diff --git a/Content.Shared/Interaction/Events/UseInHandEvent.cs b/Content.Shared/Interaction/Events/UseInHandEvent.cs new file mode 100644 index 0000000000..0a0b0406d5 --- /dev/null +++ b/Content.Shared/Interaction/Events/UseInHandEvent.cs @@ -0,0 +1,20 @@ +using JetBrains.Annotations; + +namespace Content.Shared.Interaction.Events; + +/// +/// Raised when using the entity in your hands. +/// +[PublicAPI] +public sealed class UseInHandEvent : HandledEntityEventArgs +{ + /// + /// Entity holding the item in their hand. + /// + public EntityUid User { get; } + + public UseInHandEvent(EntityUid user) + { + User = user; + } +} diff --git a/Content.Shared/Interaction/IUse.cs b/Content.Shared/Interaction/IUse.cs deleted file mode 100644 index 9d8f00934d..0000000000 --- a/Content.Shared/Interaction/IUse.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using JetBrains.Annotations; -using Robust.Shared.Analyzers; -using Robust.Shared.GameObjects; - -namespace Content.Shared.Interaction -{ - /// - /// This interface gives components behavior when using the entity in your active hand - /// (done by clicking the entity in the active hand or pressing the keybind that defaults to Z). - /// - [RequiresExplicitImplementation] - public interface IUse - { - /// - /// Called when we activate an object we are holding to use it - /// - /// - [Obsolete("Use UseInHandMessage instead")] - bool UseEntity(UseEntityEventArgs eventArgs); - } - - public sealed class UseEntityEventArgs : EventArgs - { - public UseEntityEventArgs(EntityUid user) - { - User = user; - } - - public EntityUid User { get; } - } - - /// - /// Raised when using the entity in your hands. - /// - [PublicAPI] - public sealed class UseInHandEvent : HandledEntityEventArgs - { - /// - /// Entity holding the item in their hand. - /// - public EntityUid User { get; } - - /// - /// Item that was used. - /// - public EntityUid Used { get; } - - public UseInHandEvent(EntityUid user, EntityUid used) - { - User = user; - Used = used; - } - } -} diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 891aa7f1fa..db4c8dd713 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -1,7 +1,5 @@ -using System; using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Threading.Tasks; using Content.Shared.ActionBlocker; using Content.Shared.Administration.Logs; using Content.Shared.CombatMode; @@ -26,6 +24,7 @@ using Content.Shared.Item; using Robust.Shared.Player; using Robust.Shared.Input; using Robust.Shared.Timing; +using Content.Shared.Interaction.Events; #pragma warning disable 618 @@ -786,7 +785,7 @@ namespace Content.Shared.Interaction if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user)) return false; - var useMsg = new UseInHandEvent(user, used); + var useMsg = new UseInHandEvent(user); RaiseLocalEvent(used, useMsg); if (useMsg.Handled) { @@ -794,19 +793,6 @@ namespace Content.Shared.Interaction return true; } - var uses = AllComps(used).ToList(); - - // Try to use item on any components which have the interface - foreach (var use in uses) - { - // If a Use returns a status completion we finish our interaction - if (use.UseEntity(new UseEntityEventArgs(user))) - { - _useDelay.BeginDelay(used, delayComponent); - return true; - } - } - // else, default to activating the item return InteractionActivate(user, used, false, false, false); } diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index 71ef00179d..8aeb082f15 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -1,8 +1,7 @@ -using System; using System.Diagnostics.CodeAnalysis; using Content.Shared.Hands.Components; using Content.Shared.Interaction; -using Content.Shared.Interaction.Helpers; +using Content.Shared.Interaction.Events; using Content.Shared.Inventory.Events; using Content.Shared.Item; using Content.Shared.Movement.EntitySystems; @@ -10,9 +9,6 @@ using Content.Shared.Popups; using Content.Shared.Strip.Components; using Robust.Shared.Audio; using Robust.Shared.Containers; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Shared.Timing; @@ -33,9 +29,47 @@ public abstract partial class InventorySystem SubscribeLocalEvent(OnEntInserted); SubscribeLocalEvent(OnEntRemoved); + SubscribeLocalEvent(OnUseInHand); + SubscribeAllEvent(OnUseSlot); } + private void OnUseInHand(EntityUid uid, SharedItemComponent component, UseInHandEvent args) + { + if (args.Handled || !component.QuickEquip) + return; + + if (!TryComp(args.User, out InventoryComponent? inv) + || !TryComp(args.User, out SharedHandsComponent? hands) + || !_prototypeManager.TryIndex(inv.TemplateId, out var prototype)) + return; + + foreach (var slotDef in prototype.Slots) + { + if (!CanEquip(args.User, uid, slotDef.Name, out _, slotDef, inv)) + continue; + + if (TryGetSlotEntity(args.User, slotDef.Name, out var slotEntity, inv)) + { + if (!TryUnequip(args.User, slotDef.Name, true, inventory: inv)) + continue; + + if (!TryEquip(args.User, uid, slotDef.Name, true, inventory: inv)) + continue; + + hands.PutInHandOrDrop(slotEntity.Value); + } + else + { + if (!TryEquip(args.User, uid, slotDef.Name, true, inventory: inv)) + continue; + } + + args.Handled = true; + break; + } + } + private void OnEntRemoved(EntityUid uid, InventoryComponent component, EntRemovedFromContainerMessage args) { if(!TryGetSlot(uid, args.Container.ID, out var slotDef, inventory: component)) diff --git a/Content.Shared/Item/SharedItemComponent.cs b/Content.Shared/Item/SharedItemComponent.cs index 83c3b63fc9..ba86a95f54 100644 --- a/Content.Shared/Item/SharedItemComponent.cs +++ b/Content.Shared/Item/SharedItemComponent.cs @@ -1,17 +1,8 @@ -using System; -using System.Collections.Generic; using Content.Shared.Hands.Components; -using Content.Shared.Interaction; -using Content.Shared.Interaction.Helpers; using Content.Shared.Inventory; using Content.Shared.Sound; -using Robust.Shared.GameObjects; using Robust.Shared.GameStates; -using Robust.Shared.IoC; -using Robust.Shared.Maths; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.ViewVariables; using static Robust.Shared.GameObjects.SharedSpriteComponent; namespace Content.Shared.Item @@ -24,6 +15,9 @@ namespace Content.Shared.Item { [Dependency] private readonly IEntityManager _entMan = default!; + [DataField("quickEquip")] + public bool QuickEquip = true; + /// /// How much big this item is. /// diff --git a/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml b/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml index fec974dc6a..bbeaaef27d 100644 --- a/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml +++ b/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml @@ -9,7 +9,7 @@ state: icon - type: Clothing size: 9999 - QuickEquip: false + quickEquip: false Slots: - back sprite: Clothing/Back/Backpacks/backpack.rsi diff --git a/Resources/Prototypes/Entities/Clothing/Back/duffel.yml b/Resources/Prototypes/Entities/Clothing/Back/duffel.yml index f11867c483..6b5516840c 100644 --- a/Resources/Prototypes/Entities/Clothing/Back/duffel.yml +++ b/Resources/Prototypes/Entities/Clothing/Back/duffel.yml @@ -10,7 +10,7 @@ - type: Clothing sprite: Clothing/Back/Duffels/duffel.rsi size: 9999 - QuickEquip: false + quickEquip: false Slots: - back - type: Storage diff --git a/Resources/Prototypes/Entities/Clothing/Back/satchel.yml b/Resources/Prototypes/Entities/Clothing/Back/satchel.yml index 73c04b2c56..1ce0d4dc0c 100644 --- a/Resources/Prototypes/Entities/Clothing/Back/satchel.yml +++ b/Resources/Prototypes/Entities/Clothing/Back/satchel.yml @@ -9,7 +9,7 @@ state: icon - type: Clothing size: 9999 - QuickEquip: false + quickEquip: false Slots: - back sprite: Clothing/Back/Satchels/satchel.rsi diff --git a/Resources/Prototypes/Entities/Clothing/Belt/base_clothingbelt.yml b/Resources/Prototypes/Entities/Clothing/Belt/base_clothingbelt.yml index 199a801e1a..176371a367 100644 --- a/Resources/Prototypes/Entities/Clothing/Belt/base_clothingbelt.yml +++ b/Resources/Prototypes/Entities/Clothing/Belt/base_clothingbelt.yml @@ -8,6 +8,6 @@ - type: Clothing Slots: [belt] size: 50 - QuickEquip: false + quickEquip: false EquipSound: path: /Audio/Items/belt_equip.ogg diff --git a/Resources/Prototypes/Entities/Clothing/Belt/belts.yml b/Resources/Prototypes/Entities/Clothing/Belt/belts.yml index f41ee76e5b..b53cde45e2 100644 --- a/Resources/Prototypes/Entities/Clothing/Belt/belts.yml +++ b/Resources/Prototypes/Entities/Clothing/Belt/belts.yml @@ -422,7 +422,7 @@ sprite: Clothing/Belt/champion.rsi - type: Clothing sprite: Clothing/Belt/champion.rsi - QuickEquip: true + quickEquip: true - type: entity parent: ClothingBeltBase @@ -474,4 +474,4 @@ state: icon - type: Clothing sprite: Clothing/Belt/suspenders.rsi - QuickEquip: true + quickEquip: true