mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-19 06:28:40 +03:00
* add: crossbar * add: crossbar * add: crossbow * clean up * AI rewie * fix * fix * fix :( * Update tags.yml * fix
47 lines
1.4 KiB
C#
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
|
|
}
|