Remove gun .Owners (#14585)

This commit is contained in:
metalgearsloth
2023-03-11 20:08:22 +11:00
committed by GitHub
parent 19f5c403b5
commit 330bb7bb14
18 changed files with 333 additions and 280 deletions

View File

@@ -29,7 +29,8 @@ public abstract partial class SharedGunSystem
private void OnBatteryHandleState(EntityUid uid, BatteryAmmoProviderComponent component, ref ComponentHandleState args)
{
if (args.Current is not BatteryAmmoProviderComponentState state) return;
if (args.Current is not BatteryAmmoProviderComponentState state)
return;
component.Shots = state.Shots;
component.Capacity = state.MaxShots;
@@ -56,7 +57,8 @@ public abstract partial class SharedGunSystem
var shots = Math.Min(args.Shots, component.Shots);
// Don't dirty if it's an empty fire.
if (shots == 0) return;
if (shots == 0)
return;
for (var i = 0; i < shots; i++)
{
@@ -90,15 +92,15 @@ public abstract partial class SharedGunSystem
Appearance.SetData(uid, AmmoVisuals.AmmoMax, component.Capacity, appearance);
}
private IShootable GetShootable(BatteryAmmoProviderComponent component, EntityCoordinates coordinates)
private (EntityUid? Entity, IShootable) GetShootable(BatteryAmmoProviderComponent component, EntityCoordinates coordinates)
{
switch (component)
{
case ProjectileBatteryAmmoProviderComponent proj:
var ent = Spawn(proj.Prototype, coordinates);
return EnsureComp<AmmoComponent>(ent);
return (ent, EnsureComp<AmmoComponent>(ent));
case HitscanBatteryAmmoProviderComponent hitscan:
return ProtoManager.Index<HitscanPrototype>(hitscan.Prototype);
return (null, ProtoManager.Index<HitscanPrototype>(hitscan.Prototype));
default:
throw new ArgumentOutOfRangeException();
}