diff --git a/Content.Server/Pinpointer/NavMapSystem.cs b/Content.Server/Pinpointer/NavMapSystem.cs index dcedeb15cc..8221cdb05d 100644 --- a/Content.Server/Pinpointer/NavMapSystem.cs +++ b/Content.Server/Pinpointer/NavMapSystem.cs @@ -441,7 +441,7 @@ public sealed partial class NavMapSystem : SharedNavMapSystem // get the angle between the two positions, adjusted for the grid rotation so that // we properly preserve north in relation to the grid. - var dir = (pos.Value.Position - coordinates.Position).ToWorldAngle(); + var dir = (coordinates.Position - pos.Value.Position).ToWorldAngle(); // White Dream fix var adjustedDir = (dir - gridOffset).GetDir(); var length = (pos.Value.Position - coordinates.Position).Length(); diff --git a/Content.Server/StationEvents/Components/RandomSpawnRuleComponent.cs b/Content.Server/StationEvents/Components/RandomSpawnRuleComponent.cs index ddc811f4da..5d5dd965e2 100644 --- a/Content.Server/StationEvents/Components/RandomSpawnRuleComponent.cs +++ b/Content.Server/StationEvents/Components/RandomSpawnRuleComponent.cs @@ -27,4 +27,16 @@ public sealed partial class RandomSpawnRuleComponent : Component /// [DataField("maxCount")] public int MaxCount = 1; + + /// + /// Should the station receive an announcement with the approximate spawn location? | WWDP + /// + [DataField] + public bool Announce; + + /// + /// Locale to use for the announcement | WWDP + /// + [DataField] + public string? LocId; } diff --git a/Content.Server/StationEvents/Events/RandomSpawnRule.cs b/Content.Server/StationEvents/Events/RandomSpawnRule.cs index 7b3e252086..701cc58d03 100644 --- a/Content.Server/StationEvents/Events/RandomSpawnRule.cs +++ b/Content.Server/StationEvents/Events/RandomSpawnRule.cs @@ -1,15 +1,28 @@ using System; +using Content.Server.Announcements.Systems; using Content.Server.GameTicking.Rules.Components; +using Content.Server.Pinpointer; using Content.Server.StationEvents.Components; using Content.Shared.GameTicking.Components; +using Content.Shared.Localizations; using Robust.Shared.Random; using Robust.Shared.GameObjects; +using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; +using Robust.Shared.Utility; namespace Content.Server.StationEvents.Events; public sealed class RandomSpawnRule : StationEventSystem { - [Dependency] private readonly IRobustRandom _random = default!; // WWDP + // WD EDIT START + [Dependency] private readonly IRobustRandom _random = default!; + + [Dependency] private readonly AnnouncerSystem _announcer = default!; + [Dependency] private readonly NavMapSystem _navMap = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; + // WD EDIT END + protected override void Started(EntityUid uid, RandomSpawnRuleComponent comp, GameRuleComponent gameRule, GameRuleStartedEvent args) { base.Started(uid, comp, gameRule, args); @@ -19,11 +32,47 @@ public sealed class RandomSpawnRule : StationEventSystem(); + + var entityCOM = entityPos; + var gridCOM = Robust.Shared.Physics.Transform.Mul(new Transform(gridPos, gridRot), + physicsQuery.GetComponent(grid.Value).LocalCenter); + + var mapDiff = entityCOM - gridCOM; + var angle = mapDiff.ToWorldAngle(); + angle -= gridRot; + + var direction = ContentLocalizationManager.FormatDirection(angle.GetDir()); + var location = FormattedMessage.RemoveMarkupPermissive( + _navMap.GetNearestBeaconString((entity, Transform(entity)))); + + _announcer.SendAnnouncement( + _announcer.GetAnnouncementId("Attention"), + comp.LocId, + localeArgs: + [ + ("direction", direction), + ("location", location) + ] + ); + // WWDP-EDIT-END } } diff --git a/Resources/Locale/ru-RU/_white/station-events/events/events.ftl b/Resources/Locale/ru-RU/_white/station-events/events/events.ftl index 5424e0c09a..25903f8ed5 100644 --- a/Resources/Locale/ru-RU/_white/station-events/events/events.ftl +++ b/Resources/Locale/ru-RU/_white/station-events/events/events.ftl @@ -1,2 +1 @@ station-event-stray-supply-pod-announcement = На сканерах дальнего действия обнаружена бродячая капсула с товарами. Примерное место приземления неизвестно. -station-event-stray-supply-pod-syndicate-announcement = На сканерах дальнего действия обнаружена бродячая капсула с товарами. Примерное место приземления неизвестно. diff --git a/Resources/Prototypes/_White/GameRules/events.yml b/Resources/Prototypes/_White/GameRules/events.yml index 35eb4cec2f..e60bef64ff 100644 --- a/Resources/Prototypes/_White/GameRules/events.yml +++ b/Resources/Prototypes/_White/GameRules/events.yml @@ -19,7 +19,6 @@ id: StraySupplyPod components: - type: StationEvent - startAnnouncement: true weight: 8 duration: 1 minimumPlayers: 5 @@ -27,13 +26,14 @@ reoccurrenceDelay: 15 - type: RandomSpawnRule prototype: SpawnStraySupplyPod + announce: true + locId: station-event-stray-supply-pod-announcement - type: entity parent: BaseGameRule id: StraySupplyPodSyndicate components: - type: StationEvent - startAnnouncement: true weight: 6 duration: 1 minimumPlayers: 10 @@ -41,6 +41,8 @@ reoccurrenceDelay: 40 - type: RandomSpawnRule prototype: SpawnStraySupplyPodSyndicate + announce: true + locId: station-event-stray-supply-pod-announcement - type: entity parent: BaseGameRule