diff --git a/Content.Client/Commands/DebugCommands.cs b/Content.Client/Commands/DebugCommands.cs index 715dd99549..30a844fdba 100644 --- a/Content.Client/Commands/DebugCommands.cs +++ b/Content.Client/Commands/DebugCommands.cs @@ -13,28 +13,14 @@ namespace Content.Client.Commands internal sealed class ShowMarkersCommand : IConsoleCommand { // ReSharper disable once StringLiteralTypo - public string Command => "togglemarkers"; + public string Command => "showmarkers"; public string Description => "Toggles visibility of markers such as spawn points."; public string Help => ""; public bool Execute(IDebugConsole console, params string[] args) { - bool? whichToSet = null; - foreach (var entity in IoCManager.Resolve() - .GetEntities(new TypeEntityQuery(typeof(SharedSpawnPointComponent)))) - { - if (!entity.TryGetComponent(out ISpriteComponent sprite)) - { - continue; - } - - if (!whichToSet.HasValue) - { - whichToSet = !sprite.Visible; - } - - sprite.Visible = whichToSet.Value; - } + EntitySystem.Get() + .MarkersVisible ^= true; return false; } diff --git a/Content.Client/GameObjects/Components/Markers/MarkerComponent.cs b/Content.Client/GameObjects/Components/Markers/MarkerComponent.cs new file mode 100644 index 0000000000..7b97d6f367 --- /dev/null +++ b/Content.Client/GameObjects/Components/Markers/MarkerComponent.cs @@ -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(); + + if (Owner.TryGetComponent(out ISpriteComponent sprite)) + { + sprite.Visible = system.MarkersVisible; + } + } + } +} diff --git a/Content.Client/GameObjects/EntitySystems/MarkerSystem.cs b/Content.Client/GameObjects/EntitySystems/MarkerSystem.cs new file mode 100644 index 0000000000..7573253fb6 --- /dev/null +++ b/Content.Client/GameObjects/EntitySystems/MarkerSystem.cs @@ -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(); + } + + public bool MarkersVisible + { + get => _markersVisible; + set + { + _markersVisible = value; + UpdateMarkers(); + } + } + + private void UpdateMarkers() + { + foreach (var entity in RelevantEntities) + { + entity.GetComponent().UpdateVisibility(); + } + } + } +} diff --git a/Resources/Prototypes/Entities/Markers/spawn_points.yml b/Resources/Prototypes/Entities/Markers/spawn_points.yml index 391d054c80..630061d3bd 100644 --- a/Resources/Prototypes/Entities/Markers/spawn_points.yml +++ b/Resources/Prototypes/Entities/Markers/spawn_points.yml @@ -7,14 +7,19 @@ netsync: false visible: false sprite: Objects/markers.rsi + state: cross_blue - type: Icon sprite: Objects/markers.rsi - type: SpawnPoint + - type: Marker + - type: Clickable + - type: InteractionOutline + - type: Collidable placement: - mode: SnapgridCenter + mode: AlignTileAny - type: entity name: LateJoin Spawn Point