mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-14 12:51:10 +03:00
* update math * target finder system * ports * guns with projectiles * make sure * custom sprites for the laser * add auto link * add module * sprite for the missile * update animation speed * ops * make it glow * overlay sprite * stuff that doesn't work * update launcher * fix it * make it see from far * make it work * sprite for the module * 30 seconds is too much * sprite for the range finder * why was that here? * update sprite of the missile * update module icon * ops * update missile and missile launcher * make it look like the launcher item * remove ammo counter from range finder * increase to 15 seconds * no longer show the battery percentage * use comp * change summary * ops * new line * make it last longer * commentary * acme moment * fix bug when shooter was also the target and the projectile wouldn't move * empty commit * fix test fail * replace with global behavior * forgot to remove from the yml * important * check to see if the target exists * fix autorefill bug * remove unused system * make it reload a tad slower --------- Co-authored-by: beck-thompson <beck314159@hotmail.com>
72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
using Content.Shared.DeviceLinking;
|
|
using Content.Shared.DeviceLinking.Events;
|
|
using Content.Shared.Weapons.Hitscan.Events;
|
|
using Content.Shared.Weapons.Ranged.Components;
|
|
|
|
namespace Content.Shared.Weapons.Ranged.Systems;
|
|
|
|
public partial class SharedGunSystem
|
|
{
|
|
[Dependency] private SharedDeviceLinkSystem _deviceLink = default!;
|
|
|
|
[SubscribeLocalEvent]
|
|
public void OnHitscanHit(Entity<TargetFinderHitscanComponent> entity, ref HitscanRaycastFiredEvent args)
|
|
{
|
|
if (!HasComp<TargetFinderComponent>(args.Data.Gun))
|
|
return;
|
|
|
|
UpdateTarget(args.Data.Gun, args.Data.HitEntity);
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnMapInit(Entity<TargetFinderComponent> ent, ref MapInitEvent args)
|
|
{
|
|
if (!TryComp<DeviceLinkSourceComponent>(ent, out var source))
|
|
return;
|
|
|
|
var linkedEntities = _deviceLink.GetLinkedSinks((ent.Owner, source), ent.Comp.LinkingPort);
|
|
|
|
foreach (var sink in linkedEntities)
|
|
{
|
|
if (!TryComp<TargetAssignComponent>(sink, out var targetAssigner))
|
|
continue;
|
|
|
|
ent.Comp.TargetAssigner = sink;
|
|
break;
|
|
}
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnNewLink(Entity<TargetFinderComponent> ent, ref NewLinkEvent args)
|
|
{
|
|
if (args.SourcePort != ent.Comp.LinkingPort || !HasComp<TargetAssignComponent>(args.Sink))
|
|
return;
|
|
|
|
ent.Comp.TargetAssigner = args.Sink;
|
|
Dirty(ent);
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnPortDisconnected(Entity<TargetFinderComponent> ent, ref PortDisconnectedEvent args)
|
|
{
|
|
if (args.Port != ent.Comp.LinkingPort || ent.Comp.TargetAssigner == null)
|
|
return;
|
|
|
|
ent.Comp.TargetAssigner = null;
|
|
Dirty(ent);
|
|
}
|
|
|
|
private void UpdateTarget(Entity<TargetFinderComponent?> ent, EntityUid? target)
|
|
{
|
|
if (!Resolve(ent, ref ent.Comp, false) || target is null)
|
|
return;
|
|
|
|
ent.Comp.Target = target;
|
|
|
|
if (ent.Comp.TargetAssigner is null ||
|
|
!TryComp<TargetAssignComponent>(ent.Comp.TargetAssigner, out var targetAssignComp))
|
|
return;
|
|
|
|
targetAssignComp.Target = target;
|
|
}
|
|
}
|