diff --git a/Content.Server/Dragon/DragonRiftSystem.cs b/Content.Server/Dragon/DragonRiftSystem.cs index 776aa841d85..ae358f33e5b 100644 --- a/Content.Server/Dragon/DragonRiftSystem.cs +++ b/Content.Server/Dragon/DragonRiftSystem.cs @@ -72,9 +72,8 @@ public override void Update(float frameTime) comp.State = DragonRiftState.AlmostFinished; Dirty(comp); - var location = xform.LocalPosition; _announcer.SendAnnouncement(_announcer.GetAnnouncementId("CarpRift"), Filter.Broadcast(), - "carp-rift-warning", colorOverride: Color.Red, localeArgs: ("location", location)); + "carp-rift-warning", colorOverride: Color.Red, localeArgs: ("location", FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((uid, xform))))); _navMap.SetBeaconEnabled(uid, true); } diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs index 2f62f9d6743..5b62a84a076 100644 --- a/Content.Server/Nuke/NukeSystem.cs +++ b/Content.Server/Nuke/NukeSystem.cs @@ -452,11 +452,6 @@ public void ArmBomb(EntityUid uid, NukeComponent? component = null) if (stationUid != null) _alertLevel.SetLevel(stationUid.Value, component.AlertLevelOnActivate, true, true, true, true); - var pos = nukeXform.MapPosition; - var x = (int) pos.X; - var y = (int) pos.Y; - var posText = $"({x}, {y})"; - // We are collapsing the randomness here, otherwise we would get separate random song picks for checking duration and when actually playing the song afterwards _selectedNukeSong = _audio.GetSound(component.ArmMusic); @@ -467,7 +462,7 @@ public void ArmBomb(EntityUid uid, NukeComponent? component = null) Color.Red, stationUid ?? uid, null, - ("time", (int) component.RemainingTime), ("position", posText) + ("time", (int) component.RemainingTime), ("position", FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((uid, nukeXform)))) ); _sound.PlayGlobalOnStation(uid, _audio.GetSound(component.ArmSound)); diff --git a/Content.Server/Pinpointer/NavMapSystem.cs b/Content.Server/Pinpointer/NavMapSystem.cs index 5881daa0689..c47af94efeb 100644 --- a/Content.Server/Pinpointer/NavMapSystem.cs +++ b/Content.Server/Pinpointer/NavMapSystem.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using Content.Server.Administration.Logs; using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; @@ -7,8 +8,12 @@ using Content.Shared.Examine; using Content.Shared.Localizations; using Content.Shared.Maps; +using Content.Shared.Localizations; using Content.Shared.Pinpointer; +using Content.Shared.Tag; using JetBrains.Annotations; +using Robust.Server.GameObjects; +using Robust.Shared.GameStates; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Timing; @@ -23,19 +28,17 @@ public sealed partial class NavMapSystem : SharedNavMapSystem { [Dependency] private readonly IAdminLogManager _adminLog = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; - [Dependency] private readonly SharedMapSystem _mapSystem = default!; - [Dependency] private readonly SharedTransformSystem _transformSystem = default!; + [Dependency] private readonly TagSystem _tags = default!; + [Dependency] private readonly MapSystem _map = default!; [Dependency] private readonly IMapManager _mapManager = default!; - [Dependency] private readonly IGameTiming _gameTiming = default!; - [Dependency] private readonly ITileDefinitionManager _tileDefManager = default!; + [Dependency] private readonly TransformSystem _transform = default!; + + private EntityQuery _physicsQuery; + private EntityQuery _tagQuery; public const float CloseDistance = 15f; public const float FarDistance = 30f; - private EntityQuery _airtightQuery; - private EntityQuery _gridQuery; - private EntityQuery _navQuery; - public override void Initialize() { base.Initialize(); @@ -57,8 +60,8 @@ public override void Initialize() SubscribeLocalEvent(OnAirtightChange); - // Beacon events SubscribeLocalEvent(OnNavMapBeaconMapInit); + SubscribeLocalEvent(OnNavMapBeaconStartup); SubscribeLocalEvent(OnNavMapBeaconAnchor); SubscribeLocalEvent(OnConfigureMessage); SubscribeLocalEvent(OnConfigurableMapInit); @@ -87,6 +90,17 @@ private void OnNavMapSplit(ref GridSplitEvent args) RefreshGrid(comp, _gridQuery.GetComponent(args.Grid)); } + private void OnNavMapBeaconStartup(EntityUid uid, NavMapBeaconComponent component, ComponentStartup args) + { + if (component.DefaultText == null || component.Text != null) + return; + + component.Text = Loc.GetString(component.DefaultText); + Dirty(uid, component); + + UpdateNavMapBeaconData(uid, component); + } + private NavMapChunk EnsureChunk(NavMapComponent component, Vector2i origin) { if (!component.Chunks.TryGetValue(origin, out var chunk)) @@ -377,7 +391,7 @@ public bool TryGetNearestBeacon(Entity ent, if (!Resolve(ent, ref ent.Comp)) return false; - return TryGetNearestBeacon(_transformSystem.GetMapCoordinates(ent, ent.Comp), out beacon, out beaconCoords); + return TryGetNearestBeacon(_transform.GetMapCoordinates(ent, ent.Comp), out beacon, out beaconCoords); } /// @@ -404,7 +418,7 @@ public bool TryGetNearestBeacon(MapCoordinates coordinates, if (coordinates.MapId != xform.MapID) continue; - var coords = _transformSystem.GetWorldPosition(xform); + var coords = _transform.GetWorldPosition(xform); var distanceSquared = (coordinates.Position - coords).LengthSquared(); if (!float.IsInfinity(minDistance) && distanceSquared >= minDistance) continue; @@ -423,7 +437,7 @@ public string GetNearestBeaconString(Entity ent) if (!Resolve(ent, ref ent.Comp)) return Loc.GetString("nav-beacon-pos-no-beacons"); - return GetNearestBeaconString(_transformSystem.GetMapCoordinates(ent, ent.Comp)); + return GetNearestBeaconString(_transform.GetMapCoordinates(ent, ent.Comp)); } public string GetNearestBeaconString(MapCoordinates coordinates) @@ -452,13 +466,13 @@ public string GetNearestBeaconString(MapCoordinates coordinates) ? Loc.GetString("nav-beacon-pos-format-direction-mod-far") : string.Empty; - // we can null suppress the text being null because TryGetNearestVisibleStationBeacon always gives us a beacon with not-null text. + // we can null suppress the text being null because TRyGetNearestVisibleStationBeacon always gives us a beacon with not-null text. return Loc.GetString("nav-beacon-pos-format-direction", ("modifier", modifier), ("direction", ContentLocalizationManager.FormatDirection(adjustedDir).ToLowerInvariant()), ("color", beacon.Value.Comp.Color), ("marker", beacon.Value.Comp.Text!)); } - - #endregion } + +#endregion \ No newline at end of file diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index 90be263ae2e..e7bff4fda7a 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -320,12 +320,7 @@ public void CallEmergencyShuttle(EntityUid stationUid, StationEmergencyShuttleCo else { var location = FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((stationShuttle.EmergencyShuttle.Value, xform))); - _announcer.SendAnnouncementMessage( - _announcer.GetAnnouncementId("ShuttleNearby"), - "emergency-shuttle-nearby", - null, null, null, null, - ("direction", location) - ); + _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-nearby", ("direction", location)), playDefaultSound: false); _logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid)} unable to find a valid docking port for {ToPrettyString(stationUid)}"); _announcer.SendAnnouncementAudio(_announcer.GetAnnouncementId("ShuttleNearby"), Filter.Broadcast()); diff --git a/Resources/Prototypes/Entities/Objects/Devices/station_beacon.yml b/Resources/Prototypes/Entities/Objects/Devices/station_beacon.yml index 28d6ddea691..f302d23a754 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/station_beacon.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/station_beacon.yml @@ -630,4 +630,4 @@ suffix: Escape Pod components: - type: NavMapBeacon - defaultText: station-beacon-escape-pod + defaultText: station-beacon-escape-pod \ No newline at end of file