mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-14 19:30:01 +01:00
* Entity<T>, skipping Magazine and ChamberMagazine * missed some * AUGH!! * ballistic examine * dotnet hates me * WHY ARE YOU CALLED THAT!!!! * cheers aada
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using Content.Shared.Weapons.Ranged.Components;
|
|
using Content.Shared.Weapons.Ranged.Events;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.Client.Weapons.Ranged.Systems;
|
|
|
|
public sealed partial class GunSystem
|
|
{
|
|
protected override void InitializeBallistic()
|
|
{
|
|
base.InitializeBallistic();
|
|
SubscribeLocalEvent<BallisticAmmoProviderComponent, UpdateAmmoCounterEvent>(OnBallisticAmmoCount);
|
|
}
|
|
|
|
private void OnBallisticAmmoCount(Entity<BallisticAmmoProviderComponent> ent, ref UpdateAmmoCounterEvent args)
|
|
{
|
|
if (args.Control is DefaultStatusControl control)
|
|
{
|
|
control.Update(GetBallisticShots(ent.Comp), ent.Comp.Capacity);
|
|
}
|
|
}
|
|
|
|
protected override void Cycle(Entity<BallisticAmmoProviderComponent> ent, MapCoordinates coordinates)
|
|
{
|
|
if (!Timing.IsFirstTimePredicted)
|
|
return;
|
|
|
|
EntityUid? ammoEnt = null;
|
|
|
|
// TODO: Combine with TakeAmmo
|
|
if (ent.Comp.Entities.Count > 0)
|
|
{
|
|
var existing = ent.Comp.Entities[^1];
|
|
ent.Comp.Entities.RemoveAt(ent.Comp.Entities.Count - 1);
|
|
|
|
Containers.Remove(existing, ent.Comp.Container);
|
|
EnsureShootable(existing);
|
|
}
|
|
else if (ent.Comp.UnspawnedCount > 0)
|
|
{
|
|
ent.Comp.UnspawnedCount--;
|
|
ammoEnt = Spawn(ent.Comp.Proto, coordinates);
|
|
EnsureShootable(ammoEnt.Value);
|
|
}
|
|
|
|
if (ammoEnt != null && IsClientSide(ammoEnt.Value))
|
|
Del(ammoEnt.Value);
|
|
|
|
var cycledEvent = new GunCycledEvent();
|
|
RaiseLocalEvent(ent, ref cycledEvent);
|
|
}
|
|
}
|