Co-authored-by: Kara <lunarautomaton6@gmail.com> Co-authored-by: T-Stalker <le0nel_1van@hotmail.com> Co-authored-by: T-Stalker <43253663+DogZeroX@users.noreply.github.com> Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
32 lines
917 B
C#
32 lines
917 B
C#
using Content.Shared.Weapons.Ranged.Components;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.Server.Weapon.Ranged.Systems;
|
|
|
|
public sealed partial class GunSystem
|
|
{
|
|
protected override void Cycle(BallisticAmmoProviderComponent component, MapCoordinates coordinates)
|
|
{
|
|
EntityUid? ent = null;
|
|
|
|
// TODO: Combine with TakeAmmo
|
|
if (component.Entities.Count > 0)
|
|
{
|
|
var existing = component.Entities[^1];
|
|
component.Entities.RemoveAt(component.Entities.Count - 1);
|
|
|
|
component.Container.Remove(existing);
|
|
EnsureComp<AmmoComponent>(existing);
|
|
}
|
|
else if (component.UnspawnedCount > 0)
|
|
{
|
|
component.UnspawnedCount--;
|
|
ent = Spawn(component.FillProto, coordinates);
|
|
EnsureComp<AmmoComponent>(ent.Value);
|
|
}
|
|
|
|
if (ent != null)
|
|
EjectCartridge(ent.Value);
|
|
}
|
|
}
|