2023-05-07 11:20:43 +03:00
|
|
|
namespace Content.Shared.Pinpointer;
|
2021-11-04 00:35:34 +03:00
|
|
|
|
2023-05-07 11:20:43 +03:00
|
|
|
public abstract class SharedPinpointerSystem : EntitySystem
|
2021-11-04 00:35:34 +03:00
|
|
|
{
|
2023-05-07 11:20:43 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// Manually set distance from pinpointer to target
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void SetDistance(EntityUid uid, Distance distance, PinpointerComponent? pinpointer = null)
|
2021-11-04 00:35:34 +03:00
|
|
|
{
|
2023-05-07 11:20:43 +03:00
|
|
|
if (!Resolve(uid, ref pinpointer))
|
|
|
|
|
return;
|
2021-11-04 00:35:34 +03:00
|
|
|
|
2023-05-07 11:20:43 +03:00
|
|
|
if (distance == pinpointer.DistanceToTarget)
|
|
|
|
|
return;
|
2021-11-04 00:35:34 +03:00
|
|
|
|
2023-05-07 11:20:43 +03:00
|
|
|
pinpointer.DistanceToTarget = distance;
|
|
|
|
|
Dirty(pinpointer);
|
|
|
|
|
}
|
2021-11-04 00:35:34 +03:00
|
|
|
|
2023-05-07 11:20:43 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// Try to manually set pinpointer arrow direction.
|
|
|
|
|
/// If difference between current angle and new angle is smaller than
|
|
|
|
|
/// pinpointer precision, new value will be ignored and it will return false.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool TrySetArrowAngle(EntityUid uid, Angle arrowAngle, PinpointerComponent? pinpointer = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref pinpointer))
|
|
|
|
|
return false;
|
2022-11-04 05:15:23 +01:00
|
|
|
|
2023-05-07 11:20:43 +03:00
|
|
|
if (pinpointer.ArrowAngle.EqualsApprox(arrowAngle, pinpointer.Precision))
|
|
|
|
|
return false;
|
2021-11-04 00:35:34 +03:00
|
|
|
|
2023-05-07 11:20:43 +03:00
|
|
|
pinpointer.ArrowAngle = arrowAngle;
|
|
|
|
|
Dirty(pinpointer);
|
2021-11-04 00:35:34 +03:00
|
|
|
|
2023-05-07 11:20:43 +03:00
|
|
|
return true;
|
|
|
|
|
}
|
2021-11-04 00:35:34 +03:00
|
|
|
|
2023-05-07 11:20:43 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// Activate/deactivate pinpointer screen. If it has target it will start tracking it.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void SetActive(EntityUid uid, bool isActive, PinpointerComponent? pinpointer = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref pinpointer))
|
|
|
|
|
return;
|
|
|
|
|
if (isActive == pinpointer.IsActive)
|
|
|
|
|
return;
|
2021-11-04 00:35:34 +03:00
|
|
|
|
2023-05-07 11:20:43 +03:00
|
|
|
pinpointer.IsActive = isActive;
|
|
|
|
|
Dirty(pinpointer);
|
2021-11-04 00:35:34 +03:00
|
|
|
}
|
|
|
|
|
}
|