From 2696fd7cd50cb1ed097875c4edff00a8f2f61f48 Mon Sep 17 00:00:00 2001 From: Callmore <22885888+Callmore@users.noreply.github.com> Date: Sun, 12 Oct 2025 19:34:20 +0100 Subject: [PATCH] Automatically add trash tag to spent bullet casings (#40829) * Automatically add trash tag to spent bullet casings * Resolving comments * 2 * Update Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/pistol.yml --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- .../Weapons/Ranged/Components/AmmoComponent.cs | 6 ++++++ .../Weapons/Ranged/Systems/SharedGunSystem.cs | 10 ++++++++++ .../Weapons/Guns/Ammunition/Cartridges/pistol.yml | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/Content.Shared/Weapons/Ranged/Components/AmmoComponent.cs b/Content.Shared/Weapons/Ranged/Components/AmmoComponent.cs index 0ba8a5faee..0fedf95146 100644 --- a/Content.Shared/Weapons/Ranged/Components/AmmoComponent.cs +++ b/Content.Shared/Weapons/Ranged/Components/AmmoComponent.cs @@ -34,6 +34,12 @@ public sealed partial class CartridgeAmmoComponent : AmmoComponent [DataField, AutoNetworkedField] public bool Spent; + /// + /// Is this cartridge automatically marked as trash once spent? + /// + [DataField, AutoNetworkedField] + public bool MarkSpentAsTrash = true; + /// /// Caseless ammunition. /// diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index e3fbec0d5d..952b53acf2 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -65,6 +65,8 @@ public abstract partial class SharedGunSystem : EntitySystem [Dependency] private readonly UseDelaySystem _useDelay = default!; [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; + private static readonly ProtoId TrashTag = "Trash"; + private const float InteractNextFire = 0.3f; private const double SafetyNextFire = 0.5; private const float EjectOffset = 0.4f; @@ -452,6 +454,14 @@ public abstract partial class SharedGunSystem : EntitySystem cartridge.Spent = spent; Appearance.SetData(uid, AmmoVisuals.Spent, spent); + + if (!cartridge.MarkSpentAsTrash) + return; + + if (spent) + TagSystem.AddTag(uid, TrashTag); + else + TagSystem.RemoveTag(uid, TrashTag); } /// diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/pistol.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/pistol.yml index ba2b856778..3862918e38 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/pistol.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/pistol.yml @@ -89,3 +89,7 @@ - type: CartridgeAmmo proto: BulletPistol spent: true + - type: Tag + tags: + - CartridgePistol + - Trash # surely theres a way to automatically add this... -- 2.51.2