Files
crystall-punk-14/Content.Server/Weapons/Ranged/Systems/GunSystem.Ballistic.cs

36 lines
1.0 KiB
C#
Raw Permalink Normal View History

using Content.Shared.Weapons.Ranged.Components;
2023-05-27 14:15:15 +10:00
using Content.Shared.Weapons.Ranged.Events;
using Robust.Shared.Map;
namespace Content.Server.Weapons.Ranged.Systems;
public sealed partial class GunSystem
{
2023-05-27 14:15:15 +10:00
protected override void Cycle(EntityUid uid, 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);
2023-12-27 21:30:03 -08:00
Containers.Remove(existing, component.Container);
EnsureShootable(existing);
}
else if (component.UnspawnedCount > 0)
{
component.UnspawnedCount--;
ent = Spawn(component.Proto, coordinates);
EnsureShootable(ent.Value);
}
if (ent != null)
EjectCartridge(ent.Value);
2023-05-27 14:15:15 +10:00
var cycledEvent = new GunCycledEvent();
RaiseLocalEvent(uid, ref cycledEvent);
}
}