Files
wwdpublic/Content.Server/Weapons/Ranged/Systems/GunSystem.Ballistic.cs
Spatison 266ae606de [Port] Crossbow / Арбалет (#76)
* add: crossbar

* add: crossbar

* add: crossbow

* clean up

* AI rewie

* fix

* fix

* fix :(

* Update tags.yml

* fix
2024-10-26 16:41:08 +07:00

47 lines
1.4 KiB
C#

using Content.Server.Stack;
using Content.Shared.Stacks;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
using Robust.Shared.Map;
namespace Content.Server.Weapons.Ranged.Systems;
public sealed partial class GunSystem
{
[Dependency] private readonly StackSystem _stack = default!; // WD EDIT
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);
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);
var cycledEvent = new GunCycledEvent();
RaiseLocalEvent(uid, ref cycledEvent);
}
// WD EDIT START
protected override EntityUid GetStackEntity(EntityUid uid, StackComponent stack)
{
return _stack.Split(uid, 1, Transform(uid).Coordinates, stack) ?? uid;
}
// WD EDIT END
}