Disposable turret explodes when empty (#18175)

* turret go boom

* fix ammo

* universal function name

* Also explodes when destroyed

* comment added

* Triggerwhenemptycomponent added

* comment adjusted

* Updated uplink description

* Moved to own event file

* file namespace

* rerun tests

---------

Co-authored-by: Slava0135 <super.novalskiy_0135@inbox.ru>
This commit is contained in:
Arendian
2023-08-01 21:38:22 +02:00
committed by GitHub
parent 78c66cca75
commit 4cd70b241c
8 changed files with 47 additions and 20 deletions

View File

@@ -130,15 +130,14 @@ public abstract partial class SharedGunSystem
private void OnBallisticVerb(EntityUid uid, BallisticAmmoProviderComponent component, GetVerbsEvent<Verb> args)
{
if (!args.CanAccess || !args.CanInteract || args.Hands == null)
if (!args.CanAccess || !args.CanInteract || args.Hands == null || !component.Cycleable)
return;
if (component.Cycleable == true)
args.Verbs.Add(new Verb()
{
Text = Loc.GetString("gun-ballistic-cycle"),
Disabled = GetBallisticShots(component) == 0,
Act = () => ManualCycle(uid, component, Transform(uid).MapPosition, args.User),
});
args.Verbs.Add(new Verb()
{
Text = Loc.GetString("gun-ballistic-cycle"),
Disabled = GetBallisticShots(component) == 0,
Act = () => ManualCycle(uid, component, Transform(uid).MapPosition, args.User),
});
}
private void OnBallisticExamine(EntityUid uid, BallisticAmmoProviderComponent component, ExaminedEvent args)
@@ -151,6 +150,9 @@ public abstract partial class SharedGunSystem
private void ManualCycle(EntityUid uid, BallisticAmmoProviderComponent component, MapCoordinates coordinates, EntityUid? user = null, GunComponent? gunComp = null)
{
if (!component.Cycleable)
return;
// Reset shotting for cycling
if (Resolve(uid, ref gunComp, false) &&
gunComp is { FireRate: > 0f } &&