Fix admin verb to set unspawned ballisic ammo count (#26411)
Don't crash if an invalid value is given.
This commit is contained in:
@@ -718,9 +718,21 @@ public sealed partial class AdminVerbSystem
|
|||||||
Icon = new SpriteSpecifier.Rsi(new("/Textures/Objects/Fun/caps.rsi"), "mag-6"),
|
Icon = new SpriteSpecifier.Rsi(new("/Textures/Objects/Fun/caps.rsi"), "mag-6"),
|
||||||
Act = () =>
|
Act = () =>
|
||||||
{
|
{
|
||||||
_quickDialog.OpenDialog(player, "Set Bullet Amount", $"Amount (max {ballisticAmmo.Capacity}):", (int amount) =>
|
_quickDialog.OpenDialog(player, "Set Bullet Amount", $"Amount (standard {ballisticAmmo.Capacity}):", (string amount) =>
|
||||||
{
|
{
|
||||||
ballisticAmmo.UnspawnedCount = amount;
|
if (!int.TryParse(amount, out var result))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (result > 0)
|
||||||
|
{
|
||||||
|
ballisticAmmo.UnspawnedCount = result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ballisticAmmo.UnspawnedCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gun.UpdateBallisticAppearance(args.Target, ballisticAmmo);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
Impact = LogImpact.Medium,
|
Impact = LogImpact.Medium,
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ public abstract partial class SharedGunSystem
|
|||||||
args.Capacity = component.Capacity;
|
args.Capacity = component.Capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateBallisticAppearance(EntityUid uid, BallisticAmmoProviderComponent component)
|
public void UpdateBallisticAppearance(EntityUid uid, BallisticAmmoProviderComponent component)
|
||||||
{
|
{
|
||||||
if (!Timing.IsFirstTimePredicted || !TryComp<AppearanceComponent>(uid, out var appearance))
|
if (!Timing.IsFirstTimePredicted || !TryComp<AppearanceComponent>(uid, out var appearance))
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user