mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-02-15 00:54:51 +01:00
* Entity<T>, skipping Magazine and ChamberMagazine * missed some * AUGH!! * ballistic examine * dotnet hates me * WHY ARE YOU CALLED THAT!!!! * cheers aada
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using Content.Shared.Actions;
|
|
using Content.Shared.Weapons.Ranged.Components;
|
|
|
|
namespace Content.Shared.Weapons.Ranged.Systems;
|
|
|
|
public sealed class ActionGunSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
|
[Dependency] private readonly SharedGunSystem _gun = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ActionGunComponent, MapInitEvent>(OnMapInit);
|
|
SubscribeLocalEvent<ActionGunComponent, ComponentShutdown>(OnShutdown);
|
|
SubscribeLocalEvent<ActionGunComponent, ActionGunShootEvent>(OnShoot);
|
|
}
|
|
|
|
private void OnMapInit(Entity<ActionGunComponent> ent, ref MapInitEvent args)
|
|
{
|
|
if (string.IsNullOrEmpty(ent.Comp.Action))
|
|
return;
|
|
|
|
_actions.AddAction(ent, ref ent.Comp.ActionEntity, ent.Comp.Action);
|
|
ent.Comp.Gun = Spawn(ent.Comp.GunProto);
|
|
}
|
|
|
|
private void OnShutdown(Entity<ActionGunComponent> ent, ref ComponentShutdown args)
|
|
{
|
|
if (ent.Comp.Gun is { } gun)
|
|
QueueDel(gun);
|
|
}
|
|
|
|
private void OnShoot(Entity<ActionGunComponent> ent, ref ActionGunShootEvent args)
|
|
{
|
|
if (TryComp<GunComponent>(ent.Comp.Gun, out var gun))
|
|
_gun.AttemptShoot(ent, (ent.Comp.Gun.Value, gun), args.Target);
|
|
}
|
|
}
|
|
|