Files
OldThink/Content.Server/Shuttles/Systems/RadarConsoleSystem.cs
Ed 7a5f81ddb4 Handheld Mass Scanner (#25526)
* handheld

* Update meta.json

* Update meta.json

* Update cargo.yml

* research

* add to borg

* bruh

* borg to T2

* fix
2024-02-26 16:19:51 -07:00

50 lines
1.6 KiB
C#

using System.Numerics;
using Content.Server.UserInterface;
using Content.Shared.Shuttles.BUIStates;
using Content.Shared.Shuttles.Components;
using Content.Shared.Shuttles.Systems;
using Content.Shared.PowerCell;
using Content.Shared.Movement.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
namespace Content.Server.Shuttles.Systems;
public sealed class RadarConsoleSystem : SharedRadarConsoleSystem
{
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RadarConsoleComponent, ComponentStartup>(OnRadarStartup);
}
private void OnRadarStartup(EntityUid uid, RadarConsoleComponent component, ComponentStartup args)
{
UpdateState(uid, component);
}
protected override void UpdateState(EntityUid uid, RadarConsoleComponent component)
{
var xform = Transform(uid);
var onGrid = xform.ParentUid == xform.GridUid;
EntityCoordinates? coordinates = onGrid ? xform.Coordinates : null;
Angle? angle = onGrid ? xform.LocalRotation : null;
if (component.FollowEntity)
{
coordinates = new EntityCoordinates(uid, Vector2.Zero);
angle = Angle.Zero;
}
if (_uiSystem.TryGetUi(uid, RadarConsoleUiKey.Key, out var bui))
_uiSystem.SetUiState(bui, new RadarConsoleBoundInterfaceState(
component.MaxRange,
GetNetCoordinates(coordinates),
angle,
new List<DockingInterfaceState>()
));
}
}