2023-07-08 14:08:32 +10:00
|
|
|
using System.Numerics;
|
2022-07-06 14:33:54 +10:00
|
|
|
using Content.Server.UserInterface;
|
2022-06-16 15:28:16 +10:00
|
|
|
using Content.Shared.Shuttles.BUIStates;
|
|
|
|
|
using Content.Shared.Shuttles.Components;
|
|
|
|
|
using Content.Shared.Shuttles.Systems;
|
2024-02-27 02:19:51 +03:00
|
|
|
using Content.Shared.PowerCell;
|
|
|
|
|
using Content.Shared.Movement.Components;
|
2022-06-16 15:28:16 +10:00
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Shuttles.Systems;
|
|
|
|
|
|
|
|
|
|
public sealed class RadarConsoleSystem : SharedRadarConsoleSystem
|
|
|
|
|
{
|
2024-03-03 18:39:19 +11:00
|
|
|
[Dependency] private readonly ShuttleConsoleSystem _console = default!;
|
2022-06-16 15:28:16 +10:00
|
|
|
[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)
|
|
|
|
|
{
|
2023-07-08 09:02:17 -07:00
|
|
|
UpdateState(uid, component);
|
2022-06-16 15:28:16 +10:00
|
|
|
}
|
|
|
|
|
|
2023-07-08 09:02:17 -07:00
|
|
|
protected override void UpdateState(EntityUid uid, RadarConsoleComponent component)
|
2022-06-16 15:28:16 +10:00
|
|
|
{
|
2023-07-08 09:02:17 -07:00
|
|
|
var xform = Transform(uid);
|
2022-06-23 14:36:47 +10:00
|
|
|
var onGrid = xform.ParentUid == xform.GridUid;
|
2022-07-06 14:33:54 +10:00
|
|
|
EntityCoordinates? coordinates = onGrid ? xform.Coordinates : null;
|
|
|
|
|
Angle? angle = onGrid ? xform.LocalRotation : null;
|
|
|
|
|
|
2024-02-27 02:19:51 +03:00
|
|
|
if (component.FollowEntity)
|
2022-07-06 14:33:54 +10:00
|
|
|
{
|
2024-02-27 02:19:51 +03:00
|
|
|
coordinates = new EntityCoordinates(uid, Vector2.Zero);
|
|
|
|
|
angle = Angle.Zero;
|
2022-07-06 14:33:54 +10:00
|
|
|
}
|
2022-06-23 14:36:47 +10:00
|
|
|
|
2023-07-08 09:02:17 -07:00
|
|
|
if (_uiSystem.TryGetUi(uid, RadarConsoleUiKey.Key, out var bui))
|
2024-03-03 18:39:19 +11:00
|
|
|
{
|
|
|
|
|
NavInterfaceState state;
|
|
|
|
|
var docks = _console.GetAllDocks();
|
|
|
|
|
|
|
|
|
|
if (coordinates != null && angle != null)
|
|
|
|
|
{
|
|
|
|
|
state = _console.GetNavState(uid, docks, coordinates.Value, angle.Value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
state = _console.GetNavState(uid, docks);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_uiSystem.SetUiState(bui, new NavBoundUserInterfaceState(state));
|
|
|
|
|
}
|
2022-06-16 15:28:16 +10:00
|
|
|
}
|
|
|
|
|
}
|