From eaeec645790de6214c8d3f6c48373bb5303673f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A5=D0=B8=D0=BB?= =?UTF-8?q?=D1=8E=D0=B2=D1=87=D0=B8=D1=86?= Date: Sat, 14 Sep 2024 19:41:23 +0300 Subject: [PATCH] Add station announcement --- .../SpiderQueen/SpiderQueenRuleSystem.cs | 2 +- .../SS220/SpiderQueen/SpiderQueenSystem.cs | 31 +++++++++++++++++++ .../Components/SpiderQueenComponent.cs | 9 ++++++ .../ru-RU/ss220/spider-queen/spider-queen.ftl | 3 +- .../SS220/Entities/Mobs/NPCs/spider_queen.yml | 1 + 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Content.Server/SS220/SpiderQueen/SpiderQueenRuleSystem.cs b/Content.Server/SS220/SpiderQueen/SpiderQueenRuleSystem.cs index 4f4654736d6f..9c4104f44cfb 100644 --- a/Content.Server/SS220/SpiderQueen/SpiderQueenRuleSystem.cs +++ b/Content.Server/SS220/SpiderQueen/SpiderQueenRuleSystem.cs @@ -102,7 +102,7 @@ private void OnGetBriefing(Entity ent, ref GetBriefing var max = spiderQueen.MaxMana; briefing = string.Format("{0}\n{1}", briefing, - Loc.GetString("spider-queen-mana-information", ("current", current), ("max", max))); + Loc.GetString("spider-queen-role-mana-information", ("current", current), ("max", max))); } args.Append(briefing); diff --git a/Content.Server/SS220/SpiderQueen/SpiderQueenSystem.cs b/Content.Server/SS220/SpiderQueen/SpiderQueenSystem.cs index 7a5d588b8cdb..e0923ff9dcfe 100644 --- a/Content.Server/SS220/SpiderQueen/SpiderQueenSystem.cs +++ b/Content.Server/SS220/SpiderQueen/SpiderQueenSystem.cs @@ -1,4 +1,6 @@ // © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +using Content.Server.Chat.Systems; +using Content.Server.Pinpointer; using Content.Server.Popups; using Content.Shared.Coordinates.Helpers; using Content.Shared.FixedPoint; @@ -8,10 +10,13 @@ using Content.Shared.SS220.SpiderQueen.Systems; using Content.Shared.Storage; using Robust.Server.GameObjects; +using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; using Robust.Shared.Map; +using Robust.Shared.Player; using Robust.Shared.Random; using Robust.Shared.Timing; +using Robust.Shared.Utility; namespace Content.Server.SS220.SpiderQueen; @@ -24,6 +29,9 @@ public sealed partial class SpiderQueenSystem : SharedSpiderQueenSystem [Dependency] private readonly MobStateSystem _mobState = default!; [Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly ChatSystem _chat = default!; + [Dependency] private readonly NavMapSystem _navMap = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; public override void Initialize() { @@ -114,6 +122,12 @@ private void OnAfterCocooning(Entity entity, ref AfterCoco spiderCocoon.CocoonOwner = entity.Owner; Dirty(cocoonUid, spiderCocoon); + if (entity.Comp.CocoonsCountToAnnouncement is { } value && + entity.Comp.CocoonsList.Count >= value) + { + DoStationAnnouncement(entity); + } + UpdateCocoonsBonus(entity.Owner); } @@ -152,4 +166,21 @@ private void UpdateCocoonsBonus(EntityUid spider, SpiderQueenComponent? componen component.CocoonsManaBonus = newBonus; Dirty(spider, component); } + + /// + /// Do a station announcement if all conditions are met + /// + private void DoStationAnnouncement(EntityUid uid, SpiderQueenComponent? component = null) + { + if (!Resolve(uid, ref component) || + component.IsAnnounced || + !TryComp(uid, out var xform)) + return; + + var msg = Loc.GetString("spider-queen-warning", + ("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString((uid, xform))))); + _chat.DispatchGlobalAnnouncement(msg, playSound: false, colorOverride: Color.Red); + _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true); + component.IsAnnounced = true; + } } diff --git a/Content.Shared/SS220/SpiderQueen/Components/SpiderQueenComponent.cs b/Content.Shared/SS220/SpiderQueen/Components/SpiderQueenComponent.cs index 2e1d7c9e18d7..3425bfdb98c9 100644 --- a/Content.Shared/SS220/SpiderQueen/Components/SpiderQueenComponent.cs +++ b/Content.Shared/SS220/SpiderQueen/Components/SpiderQueenComponent.cs @@ -8,6 +8,9 @@ namespace Content.Shared.SS220.SpiderQueen.Components; [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class SpiderQueenComponent : Component { + [ViewVariables] + public bool IsAnnounced = false; + /// /// Current amount of mana /// @@ -58,4 +61,10 @@ public sealed partial class SpiderQueenComponent : Component /// [DataField] public float CocoonsMinDistance = 0.5f; + + /// + /// How many cocoons need to station announcement + /// + [DataField] + public int? CocoonsCountToAnnouncement; } diff --git a/Resources/Locale/ru-RU/ss220/spider-queen/spider-queen.ftl b/Resources/Locale/ru-RU/ss220/spider-queen/spider-queen.ftl index b639d5a123c9..c6adc84f3e97 100644 --- a/Resources/Locale/ru-RU/ss220/spider-queen/spider-queen.ftl +++ b/Resources/Locale/ru-RU/ss220/spider-queen/spider-queen.ftl @@ -1,8 +1,9 @@ spider-queen-mana-amount = У вас [color=yellow]{ $current } маны[/color]. Ваш максимум — [color=yellow]{ $max } маны[/color]. spider-queen-not-enough-mana = Недостаточно маны +spider-queen-warning = Замечена аномальная биологическая активность в { $location }. Служба Безопасности должна ликвидировать угрозу до того как активу будет нанесен непоправимый ущерб! spider-queen-role-greeting = Королева пауков... -spider-queen-mana-information = У вас { $current } маны. Ваш максимум — { $max } маны. +spider-queen-role-mana-information = У вас { $current } маны. Ваш максимум — { $max } маны. cocooning-too-close = Слишком близко к другому кокону cocooning-target-not-dead = Цель должна быть мертва diff --git a/Resources/Prototypes/SS220/Entities/Mobs/NPCs/spider_queen.yml b/Resources/Prototypes/SS220/Entities/Mobs/NPCs/spider_queen.yml index 761959a6074b..09807798a8af 100644 --- a/Resources/Prototypes/SS220/Entities/Mobs/NPCs/spider_queen.yml +++ b/Resources/Prototypes/SS220/Entities/Mobs/NPCs/spider_queen.yml @@ -163,6 +163,7 @@ maxMana: 200 passiveGeneration: 0.5 cocoonsBonusCoefficient: 0.9 + cocoonsCountToAnnouncement: 2 cocoonPrototypes: - SpiderCocoonHorizontal - SpiderCocoonVertical