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>
This commit is contained in:
Callmore
2025-10-12 19:34:20 +01:00
committed by GitHub
parent 11525673ba
commit 2696fd7cd5
3 changed files with 20 additions and 0 deletions

View 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>

View 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>

View File

@@ -89,3 +89,7 @@
- type: CartridgeAmmo
proto: BulletPistol
spent: true
- type: Tag
tags:
- CartridgePistol
- Trash # surely theres a way to automatically add this...