Skip to content

Commit

Permalink
update pinpointer (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
778b authored Mar 13, 2024
1 parent a4103f5 commit df26bba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Content.Server/Pinpointer/PinpointerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
using Robust.Shared.Utility;
using Content.Server.Shuttles.Events;
using Content.Shared.IdentityManagement;
using Content.Shared.Mobs.Systems;

namespace Content.Server.Pinpointer;

public sealed class PinpointerSystem : SharedPinpointerSystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;

private EntityQuery<TransformComponent> _xformQuery;

Expand Down Expand Up @@ -80,7 +82,7 @@ private void LocateTarget(EntityUid uid, PinpointerComponent component)
return;
}

var target = FindTargetFromComponent(uid, reg.Type);
var target = FindTargetFromComponent(uid, reg.Type, component);
SetTarget(uid, target, component);
}
}
Expand All @@ -102,7 +104,7 @@ public override void Update(float frameTime)
/// Try to find the closest entity from whitelist on a current map
/// Will return null if can't find anything
/// </summary>
private EntityUid? FindTargetFromComponent(EntityUid uid, Type whitelist, TransformComponent? transform = null)
private EntityUid? FindTargetFromComponent(EntityUid uid, Type whitelist, PinpointerComponent? pinpointer = null, TransformComponent? transform = null)
{
_xformQuery.Resolve(uid, ref transform, false);

Expand All @@ -119,6 +121,11 @@ public override void Update(float frameTime)
if (!_xformQuery.TryGetComponent(otherUid, out var compXform) || compXform.MapID != mapId)
continue;

if (pinpointer != null)
{
if (pinpointer.MustBeAlive && !_mobStateSystem.IsAlive(otherUid))
continue;
}
var dist = (_transform.GetWorldPosition(compXform) - worldPos).LengthSquared();
l.TryAdd(dist, otherUid);
}
Expand Down
4 changes: 4 additions & 0 deletions Content.Shared/Pinpointer/PinpointerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public sealed partial class PinpointerComponent : Component
[DataField("canRetarget"), ViewVariables(VVAccess.ReadWrite)]
public bool CanRetarget;


[DataField]
public bool MustBeAlive = false;

[ViewVariables]
public EntityUid? Target = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
- type: Icon
state: pinpointer-station
- type: Pinpointer
mustBeAlive: true
component: MissionAntag
targetName: Unknown magnite signature

0 comments on commit df26bba

Please sign in to comment.