2022-05-12 06:11:50 -05:00
|
|
|
using Robust.Client.GameObjects;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-05-24 01:47:14 +02:00
|
|
|
|
2023-05-14 13:15:18 +10:00
|
|
|
namespace Content.Client.Markers;
|
|
|
|
|
|
|
|
|
|
public sealed class MarkerSystem : EntitySystem
|
2020-05-24 01:47:14 +02:00
|
|
|
{
|
2023-05-14 13:15:18 +10:00
|
|
|
private bool _markersVisible;
|
2020-05-24 01:47:14 +02:00
|
|
|
|
2023-05-14 13:15:18 +10:00
|
|
|
public bool MarkersVisible
|
|
|
|
|
{
|
|
|
|
|
get => _markersVisible;
|
|
|
|
|
set
|
2020-05-24 01:47:14 +02:00
|
|
|
{
|
2023-05-14 13:15:18 +10:00
|
|
|
_markersVisible = value;
|
|
|
|
|
UpdateMarkers();
|
2020-05-24 01:47:14 +02:00
|
|
|
}
|
2023-05-14 13:15:18 +10:00
|
|
|
}
|
2020-05-24 01:47:14 +02:00
|
|
|
|
2023-05-14 13:15:18 +10:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2022-05-12 06:11:50 -05:00
|
|
|
|
2023-05-14 13:15:18 +10:00
|
|
|
SubscribeLocalEvent<MarkerComponent, ComponentStartup>(OnStartup);
|
|
|
|
|
}
|
2022-05-12 06:11:50 -05:00
|
|
|
|
2023-05-14 13:15:18 +10:00
|
|
|
private void OnStartup(EntityUid uid, MarkerComponent marker, ComponentStartup args)
|
|
|
|
|
{
|
|
|
|
|
UpdateVisibility(uid);
|
|
|
|
|
}
|
2022-05-12 06:11:50 -05:00
|
|
|
|
2023-05-14 13:15:18 +10:00
|
|
|
private void UpdateVisibility(EntityUid uid)
|
|
|
|
|
{
|
|
|
|
|
if (EntityManager.TryGetComponent(uid, out SpriteComponent? sprite))
|
2022-05-12 06:11:50 -05:00
|
|
|
{
|
2023-05-14 13:15:18 +10:00
|
|
|
sprite.Visible = MarkersVisible;
|
2022-05-12 06:11:50 -05:00
|
|
|
}
|
2023-05-14 13:15:18 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateMarkers()
|
|
|
|
|
{
|
|
|
|
|
var query = AllEntityQuery<MarkerComponent>();
|
2022-05-12 06:11:50 -05:00
|
|
|
|
2023-05-14 13:15:18 +10:00
|
|
|
while (query.MoveNext(out var uid, out var comp))
|
2020-05-24 01:47:14 +02:00
|
|
|
{
|
2023-05-14 13:15:18 +10:00
|
|
|
UpdateVisibility(uid);
|
2020-05-24 01:47:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|