Improve marker visualization for mapping.
Command renamed to showmarkers. Actually permanent (so if you place markers with it active, you immediately see them).
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using Content.Client.GameObjects.EntitySystems;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Markers
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class MarkerComponent : Component
|
||||
{
|
||||
public override string Name => "Marker";
|
||||
|
||||
protected override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
UpdateVisibility();
|
||||
}
|
||||
|
||||
public void UpdateVisibility()
|
||||
{
|
||||
var system = EntitySystem.Get<MarkerSystem>();
|
||||
|
||||
if (Owner.TryGetComponent(out ISpriteComponent sprite))
|
||||
{
|
||||
sprite.Visible = system.MarkersVisible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Content.Client/GameObjects/EntitySystems/MarkerSystem.cs
Normal file
36
Content.Client/GameObjects/EntitySystems/MarkerSystem.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Content.Client.GameObjects.Components.Markers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
|
||||
namespace Content.Client.GameObjects.EntitySystems
|
||||
{
|
||||
public sealed class MarkerSystem : EntitySystem
|
||||
{
|
||||
private bool _markersVisible;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
EntityQuery = new TypeEntityQuery<MarkerComponent>();
|
||||
}
|
||||
|
||||
public bool MarkersVisible
|
||||
{
|
||||
get => _markersVisible;
|
||||
set
|
||||
{
|
||||
_markersVisible = value;
|
||||
UpdateMarkers();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateMarkers()
|
||||
{
|
||||
foreach (var entity in RelevantEntities)
|
||||
{
|
||||
entity.GetComponent<MarkerComponent>().UpdateVisibility();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user