]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Automatically add trash tag to spent bullet casings (#40829)
authorCallmore <22885888+Callmore@users.noreply.github.com>
Sun, 12 Oct 2025 18:34:20 +0000 (19:34 +0100)
committerGitHub <noreply@github.com>
Sun, 12 Oct 2025 18:34:20 +0000 (18:34 +0000)
* 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>
Content.Shared/Weapons/Ranged/Components/AmmoComponent.cs
Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/pistol.yml

index 0ba8a5faee0f632ef96ea8913030e8f9c64405ce..0fedf951461b6e4dd4d8cf400bf4e1725a22756a 100644 (file)
@@ -34,6 +34,12 @@ public sealed partial class CartridgeAmmoComponent : AmmoComponent
     [DataField, AutoNetworkedField]
     public bool Spent;
 
+    /// <summary>
+    /// Is this cartridge automatically marked as trash once spent?
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public bool MarkSpentAsTrash = true;
+
     /// <summary>
     /// Caseless ammunition.
     /// </summary>
index e3fbec0d5dd7f0d0935bec225b1ca5d3a4d61980..952b53acf251d1f0012a9e5e2725031ad19f7dea 100644 (file)
@@ -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<TagPrototype> 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);
     }
 
     /// <summary>
index ba2b8567784aac3af6d7e02a9c1220478ed6fbfa..3862918e38a522d0870b80a310c57c113e34deab 100644 (file)
@@ -89,3 +89,7 @@
   - type: CartridgeAmmo
     proto: BulletPistol
     spent: true
+  - type: Tag
+    tags:
+    - CartridgePistol
+    - Trash # surely theres a way to automatically add this...