* setup codebase * make auto-fire, but its broken * collider problem * fix rate, add toggle port * add laser * power cages * ginormous cells * fix inhand * add pirate cannon * salvage gun * functional Nuke cannon * rewrite to standart grenade * fix naming, add emp sprite * grenade cartridge * thruster fix * nuke cannon * audio + visual polish * balance tweak * tweaks * laser balance tweak: new Electronic damage modifier set, reduce structural cannon damage * resprite energy cages, start implementing in game * fix cage recharger craft * add small laser gun * fix colliders * add lasers and ptk to research and crafting * finish implementing weapon to rnd and sec * some fixes * splitted grenades and cannon balls * integrate new cannon balls * tweaks stick * move circuits to sectechfab, fix * fix? * add ability to E shoot, without signals * fix! * fix?!?! and naming tweak * go! * Lank fix * oh * mornings don't start with coffee. * the morning starts with bug fixes. * fucking bugs! * finally * it is now possible to craft projectiles separately from cartridges * +2 fix * refactor * piu * More weight * add AutoShootGunComponent * move autoshoot to partial * SetEnabled() * some fixes * remove CanShootWithoutUser field * remove null-checks ToCoordinates from AttemptShoot() * war without reason * return to home * ? * forgot remove it * review * Fix formatting and update path --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
47 lines
1.7 KiB
C#
47 lines
1.7 KiB
C#
using Content.Server.DeviceLinking.Components;
|
|
using Content.Server.DeviceLinking.Events;
|
|
using Content.Shared.Weapons.Ranged.Components;
|
|
using Content.Shared.Weapons.Ranged.Systems;
|
|
using Robust.Shared.Map;
|
|
using System.Numerics;
|
|
|
|
namespace Content.Server.DeviceLinking.Systems;
|
|
|
|
public sealed partial class GunSignalControlSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
|
[Dependency] private readonly SharedGunSystem _gun = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<GunSignalControlComponent, MapInitEvent>(OnInit);
|
|
SubscribeLocalEvent<GunSignalControlComponent, SignalReceivedEvent>(OnSignalReceived);
|
|
}
|
|
|
|
private void OnInit(Entity<GunSignalControlComponent> gunControl, ref MapInitEvent args)
|
|
{
|
|
_signalSystem.EnsureSinkPorts(gunControl, gunControl.Comp.TriggerPort, gunControl.Comp.TogglePort, gunControl.Comp.OnPort, gunControl.Comp.OffPort);
|
|
}
|
|
|
|
private void OnSignalReceived(Entity<GunSignalControlComponent> gunControl, ref SignalReceivedEvent args)
|
|
{
|
|
if (!TryComp<GunComponent>(gunControl, out var gun))
|
|
return;
|
|
|
|
if (args.Port == gunControl.Comp.TriggerPort)
|
|
_gun.AttemptShoot(gunControl, gun);
|
|
|
|
if (!TryComp<AutoShootGunComponent>(gunControl, out var autoShoot))
|
|
return;
|
|
|
|
if (args.Port == gunControl.Comp.TogglePort)
|
|
_gun.SetEnabled(gunControl, autoShoot, !autoShoot.Enabled);
|
|
|
|
if (args.Port == gunControl.Comp.OnPort)
|
|
_gun.SetEnabled(gunControl, autoShoot, true);
|
|
|
|
if (args.Port == gunControl.Comp.OffPort)
|
|
_gun.SetEnabled(gunControl, autoShoot, false);
|
|
}
|
|
}
|