Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Interaction.Components;

/// <summary>
/// Used for entities that we would rather not take the contents of when using smart equip
/// Like guns.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class IgnoreContentsOnSmartEquipComponent : Component;
9 changes: 7 additions & 2 deletions Content.Shared/Interaction/SmartEquipSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<IgnoreContentsOnSmartEquipComponent>(slotEntity) && handItem is null;

// case 1 (no slot item):
if (slotEntity is not { } slotItem)
Expand All @@ -127,7 +132,7 @@ private void HandleSmartEquip(ICommonSession? session, string equipmentSlot)
}

// case 2 (storage item):
if (TryComp<StorageComponent>(slotItem, out var storage))
if (!ignoreContents && TryComp<StorageComponent>(slotItem, out var storage))
{
switch (handItem)
{
Expand Down Expand Up @@ -164,7 +169,7 @@ private void HandleSmartEquip(ICommonSession? session, string equipmentSlot)
}

// case 3 (itemslot item):
if (TryComp<ItemSlotsComponent>(slotItem, out var slots))
if (!ignoreContents && TryComp<ItemSlotsComponent>(slotItem, out var slots))
{
if (handItem == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
startValue: 0.1
endValue: 2.0
isLooped: true
- type: IgnoreContentsOnSmartEquip
- type: PowerCellSlot
cellSlotId: cell_slot
- type: ItemSlots
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Clothing/Head/hardhats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
head:
- state: on-equipped-HELMET
- type: ItemTogglePointLight
- type: IgnoreContentsOnSmartEquip
- type: PowerCellSlot
cellSlotId: cell_slot
- type: ItemSlots
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Clothing/Head/helmets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@
mask: /Textures/Effects/LightMasks/double_cone.png
- type: RotatingLight
speed: 360
- type: IgnoreContentsOnSmartEquip
- type: PowerCellSlot
cellSlotId: cell_slot
- type: ContainerContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- type: ContainerContainer
containers:
cell_slot: !type:ContainerSlot {}
- type: IgnoreContentsOnSmartEquip
- type: PowerCellSlot
cellSlotId: cell_slot
- type: ItemSlots
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
startValue: 0.1
endValue: 2.0
isLooped: true
- type: IgnoreContentsOnSmartEquip
- type: PowerCellSlot
cellSlotId: cell_slot
- type: ItemSlots
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- state: inhand-right-light
shader: unshaded
- type: ItemTogglePointLight
- type: IgnoreContentsOnSmartEquip
- type: PowerCellSlot
cellSlotId: cell_slot
- type: ContainerContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- type: HitscanBatteryAmmoProvider
proto: RedLightLaser
fireCost: 50
- type: IgnoreContentsOnSmartEquip
- type: ItemSlots
slots:
cell_slot:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
soundRack:
path: /Audio/Weapons/Guns/Cock/lmg_cock.ogg
- type: AmmoCounter
- type: IgnoreContentsOnSmartEquip
- type: ItemSlots
slots:
gun_magazine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
size: Huge
- type: StaticPrice
price: 500
- type: IgnoreContentsOnSmartEquip
- type: ContainerContainer
containers:
ballistic-ammo: !type:Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- type: ChamberMagazineAmmoProvider
soundRack:
path: /Audio/Weapons/Guns/Cock/pistol_cock.ogg
- type: IgnoreContentsOnSmartEquip
- type: ItemSlots
slots:
gun_magazine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- type: ChamberMagazineAmmoProvider
soundRack:
path: /Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg
- type: IgnoreContentsOnSmartEquip
- type: ItemSlots
slots:
gun_magazine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- type: ChamberMagazineAmmoProvider
soundRack:
path: /Audio/Weapons/Guns/Cock/smg_cock.ogg
- type: IgnoreContentsOnSmartEquip
- type: ItemSlots
slots:
gun_magazine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
proto: ShellShotgun
soundInsert:
path: /Audio/Weapons/Guns/MagIn/shotgun_insert.ogg
- type: IgnoreContentsOnSmartEquip
- type: ContainerContainer
containers:
ballistic-ammo: !type:Container
Expand Down Expand Up @@ -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:
Expand Down
Loading