diff --git a/Content.Shared/Interaction/Components/IgnoreContentsOnSmartEquipComponent.cs b/Content.Shared/Interaction/Components/IgnoreContentsOnSmartEquipComponent.cs new file mode 100644 index 0000000000000..3f5bc43d3837a --- /dev/null +++ b/Content.Shared/Interaction/Components/IgnoreContentsOnSmartEquipComponent.cs @@ -0,0 +1,10 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Interaction.Components; + +/// +/// Used for entities that we would rather not take the contents of when using smart equip +/// Like guns. +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class IgnoreContentsOnSmartEquipComponent : Component; diff --git a/Content.Shared/Interaction/SmartEquipSystem.cs b/Content.Shared/Interaction/SmartEquipSystem.cs index da79fc1e69167..2b53626ff96eb 100644 --- a/Content.Shared/Interaction/SmartEquipSystem.cs +++ b/Content.Shared/Interaction/SmartEquipSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Input; +using Content.Shared.Interaction.Components; using Content.Shared.Inventory; using Content.Shared.Popups; using Content.Shared.Stacks; @@ -102,9 +103,13 @@ private void HandleSmartEquip(ICommonSession? session, string equipmentSlot) // 4) has an item, with no special storage components // - with hand item: fail // - without hand item: try to put the item into your hand + // 5: has an item with something it but we don't want to take out its contents + // because we are fighting 3 nukeops and the item is a gun and the contents are its magazine + // - see case 4 _inventory.TryGetSlotEntity(uid, equipmentSlot, out var slotEntity); var emptyEquipmentSlotString = Loc.GetString("smart-equip-empty-equipment-slot", ("slotName", equipmentSlot)); + var ignoreContents = HasComp(slotEntity) && handItem is null; // case 1 (no slot item): if (slotEntity is not { } slotItem) @@ -127,7 +132,7 @@ private void HandleSmartEquip(ICommonSession? session, string equipmentSlot) } // case 2 (storage item): - if (TryComp(slotItem, out var storage)) + if (!ignoreContents && TryComp(slotItem, out var storage)) { switch (handItem) { @@ -164,7 +169,7 @@ private void HandleSmartEquip(ICommonSession? session, string equipmentSlot) } // case 3 (itemslot item): - if (TryComp(slotItem, out var slots)) + if (!ignoreContents && TryComp(slotItem, out var slots)) { if (handItem == null) { diff --git a/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml b/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml index e4afec873ccaa..e8d4cd81f3157 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml @@ -94,6 +94,7 @@ startValue: 0.1 endValue: 2.0 isLooped: true + - type: IgnoreContentsOnSmartEquip - type: PowerCellSlot cellSlotId: cell_slot - type: ItemSlots diff --git a/Resources/Prototypes/Entities/Clothing/Head/hardhats.yml b/Resources/Prototypes/Entities/Clothing/Head/hardhats.yml index ca8f7d4d061a1..1c54c4181725a 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/hardhats.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/hardhats.yml @@ -51,6 +51,7 @@ head: - state: on-equipped-HELMET - type: ItemTogglePointLight + - type: IgnoreContentsOnSmartEquip - type: PowerCellSlot cellSlotId: cell_slot - type: ItemSlots diff --git a/Resources/Prototypes/Entities/Clothing/Head/helmets.yml b/Resources/Prototypes/Entities/Clothing/Head/helmets.yml index f729ea1034c7d..323377632cbf7 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/helmets.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/helmets.yml @@ -524,6 +524,7 @@ mask: /Textures/Effects/LightMasks/double_cone.png - type: RotatingLight speed: 360 + - type: IgnoreContentsOnSmartEquip - type: PowerCellSlot cellSlotId: cell_slot - type: ContainerContainer diff --git a/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml b/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml index 8acac47133926..a723a82b0f6ca 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml @@ -11,6 +11,7 @@ - type: ContainerContainer containers: cell_slot: !type:ContainerSlot {} + - type: IgnoreContentsOnSmartEquip - type: PowerCellSlot cellSlotId: cell_slot - type: ItemSlots diff --git a/Resources/Prototypes/Entities/Objects/Misc/fluff_lights.yml b/Resources/Prototypes/Entities/Objects/Misc/fluff_lights.yml index db3fc4961ee8a..475e8ec04fc8e 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/fluff_lights.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/fluff_lights.yml @@ -24,6 +24,7 @@ startValue: 0.1 endValue: 2.0 isLooped: true + - type: IgnoreContentsOnSmartEquip - type: PowerCellSlot cellSlotId: cell_slot - type: ItemSlots diff --git a/Resources/Prototypes/Entities/Objects/Tools/flashlights.yml b/Resources/Prototypes/Entities/Objects/Tools/flashlights.yml index 6fd27c4302358..deee58e0061fe 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/flashlights.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/flashlights.yml @@ -37,6 +37,7 @@ - state: inhand-right-light shader: unshaded - type: ItemTogglePointLight + - type: IgnoreContentsOnSmartEquip - type: PowerCellSlot cellSlotId: cell_slot - type: ContainerContainer diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml index cdd3edd93f9e3..fef690e34d421 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml @@ -45,6 +45,7 @@ - type: HitscanBatteryAmmoProvider proto: RedLightLaser fireCost: 50 + - type: IgnoreContentsOnSmartEquip - type: ItemSlots slots: cell_slot: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml index 80d71669a7e8f..484892efad6a1 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml @@ -38,6 +38,7 @@ soundRack: path: /Audio/Weapons/Guns/Cock/lmg_cock.ogg - type: AmmoCounter + - type: IgnoreContentsOnSmartEquip - type: ItemSlots slots: gun_magazine: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml index 261cd87fd9480..6311a10966779 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml @@ -15,6 +15,7 @@ size: Huge - type: StaticPrice price: 500 + - type: IgnoreContentsOnSmartEquip - type: ContainerContainer containers: ballistic-ammo: !type:Container diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml index ed87a4edcb353..cd5cb73b84896 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml @@ -36,6 +36,7 @@ - type: ChamberMagazineAmmoProvider soundRack: path: /Audio/Weapons/Guns/Cock/pistol_cock.ogg + - type: IgnoreContentsOnSmartEquip - type: ItemSlots slots: gun_magazine: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml index 82955fdc9c3d2..b4fee2fa230f6 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml @@ -26,6 +26,7 @@ - type: ChamberMagazineAmmoProvider soundRack: path: /Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg + - type: IgnoreContentsOnSmartEquip - type: ItemSlots slots: gun_magazine: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml index 7c9332891bc41..84331ae023eb4 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml @@ -32,6 +32,7 @@ - type: ChamberMagazineAmmoProvider soundRack: path: /Audio/Weapons/Guns/Cock/smg_cock.ogg + - type: IgnoreContentsOnSmartEquip - type: ItemSlots slots: gun_magazine: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml index 8a770506fbc29..82803ff4205fb 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml @@ -36,6 +36,7 @@ proto: ShellShotgun soundInsert: path: /Audio/Weapons/Guns/MagIn/shotgun_insert.ogg + - type: IgnoreContentsOnSmartEquip - type: ContainerContainer containers: ballistic-ammo: !type:Container @@ -76,6 +77,7 @@ path: /Audio/Weapons/Guns/Gunshots/shotgun.ogg soundEmpty: path: /Audio/Weapons/Guns/Empty/empty.ogg + - type: IgnoreContentsOnSmartEquip - type: ItemSlots slots: gun_magazine: