Skip to content
Open
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>
/// Marks entity for <see cref="SmartEquipSystem"/> <br/>
/// Trying to smart equip this item will result in picking it up instead of taking something from <see cref="StorageComponent"/>
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class SmartEquipPickupStorageComponent : Component;
14 changes: 13 additions & 1 deletion 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 @@ -32,6 +33,7 @@ public sealed class SmartEquipSystem : EntitySystem
/// <inheritdoc/>
public override void Initialize()
{

CommandBinds.Builder
.Bind(ContentKeyFunctions.SmartEquipBackpack, InputCmdHandler.FromDelegate(HandleSmartEquipBackpack, handle: false, outsidePrediction: false))
.Bind(ContentKeyFunctions.SmartEquipBelt, InputCmdHandler.FromDelegate(HandleSmartEquipBelt, handle: false, outsidePrediction: false))
Expand Down Expand Up @@ -113,7 +115,9 @@ private void HandleSmartEquip(ICommonSession? session, string equipmentSlot)
// - without hand item: fail
// 2) has an item, and that item is a storage item
// - with hand item: try to put it in storage
// - without hand item: try to take the last stored item and put it in our hands
// - without hand item:
// - if item has SmartEquipPickupStorageComponent - try to pick up it
// - try to take the last stored item and put it in our hands
// 3) has an item, and that item is an item slots holder
// - with hand item: get the highest priority item slot with a valid whitelist and try to insert it
// - without hand item: get the highest priority item slot with an item and try to eject it
Expand Down Expand Up @@ -145,6 +149,14 @@ private void HandleSmartEquip(ICommonSession? session, string equipmentSlot)
}

// case 2 (storage item):
if (HasComp<SmartEquipPickupStorageComponent>(slotItem) && handItem == null
&& _inventory.CanUnequip(uid, equipmentSlot, out var _))
{
if (_inventory.TryUnequip(uid, equipmentSlot, inventory: inventory, predicted: true, checkDoafter: true)
&& _hands.TryPickup(uid, slotItem, handsComp: hands))
return;
}

if (TryComp<StorageComponent>(slotItem, out var storage))
{
switch (handItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
soundGunshot:
collection: BulletMiss
soundEmpty: null
- type: SmartEquipPickupStorage
- type: ItemSlots
slots:
projectiles:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
path: /Audio/Weapons/Guns/Empty/lmg_empty.ogg
- type: StaticPrice
price: 500
- type: SmartEquipPickupStorage
# No chamber because HMG may want its own

- type: entity
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: SmartEquipPickupStorage
- type: ItemSlots
slots:
gun_magazine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
size: Ginormous
- type: StaticPrice
price: 500
- type: SmartEquipPickupStorage
- type: ContainerContainer
containers:
ballistic-ammo: !type:Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- type: ChamberMagazineAmmoProvider
soundRack:
path: /Audio/Weapons/Guns/Cock/pistol_cock.ogg
- type: SmartEquipPickupStorage
- type: ItemSlots
slots:
gun_magazine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
path: /Audio/Weapons/Guns/Gunshots/revolver.ogg
- type: UseDelay
delay: 0.66
- type: SmartEquipPickupStorage
- type: ContainerContainer
containers:
revolver-ammo: !type:Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- type: ChamberMagazineAmmoProvider
soundRack:
path: /Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg
- type: SmartEquipPickupStorage
- type: ItemSlots
slots:
gun_magazine:
Expand Down Expand Up @@ -199,7 +200,7 @@
name: XL8
description: |-
The Experimental Lecter 8
An unreasonably expensive military grade assault rifle with integrated optic.
An unreasonably expensive military grade assault rifle with integrated optic.
Uses .20 rifle ammo.
components:
- type: Sprite
Expand All @@ -219,7 +220,7 @@
- Burst
- SemiAuto
- FullAuto

- type: entity
name: Estoc DMR
parent: [BaseWeaponRifle, BaseSyndicateContraband]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- type: ChamberMagazineAmmoProvider
soundRack:
path: /Audio/Weapons/Guns/Cock/smg_cock.ogg
- type: SmartEquipPickupStorage
- type: ItemSlots
slots:
gun_magazine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
proto: ShellShotgun
soundInsert:
path: /Audio/Weapons/Guns/MagIn/shotgun_insert.ogg
- type: SmartEquipPickupStorage
- type: ContainerContainer
containers:
ballistic-ammo: !type:Container
Expand Down
Loading