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:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -89,3 +89,7 @@
|
||||
- type: CartridgeAmmo
|
||||
proto: BulletPistol
|
||||
spent: true
|
||||
- type: Tag
|
||||
tags:
|
||||
- CartridgePistol
|
||||
- Trash # surely theres a way to automatically add this...
|
||||
|
||||
Reference in New Issue
Block a user