From a8b66575ef2d3b38639dd94fa95d6b1df1c5c1b5 Mon Sep 17 00:00:00 2001 From: sleepyyapril Date: Sat, 11 Jan 2025 07:08:06 -0400 Subject: [PATCH] fix sentienceRule --- .../Events/RandomSentienceRule.cs | 39 +++++-------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/Content.Server/StationEvents/Events/RandomSentienceRule.cs b/Content.Server/StationEvents/Events/RandomSentienceRule.cs index 308f37fdeb..b4b5a61d31 100644 --- a/Content.Server/StationEvents/Events/RandomSentienceRule.cs +++ b/Content.Server/StationEvents/Events/RandomSentienceRule.cs @@ -1,8 +1,6 @@ -using Content.Server.Announcements.Systems; using System.Linq; using Content.Shared.Dataset; using Content.Server.Ghost.Roles.Components; -using Content.Server.Station.Components; using Content.Server.StationEvents.Components; using Content.Shared.GameTicking.Components; using Content.Shared.Random.Helpers; @@ -13,27 +11,25 @@ namespace Content.Server.StationEvents.Events; public sealed class RandomSentienceRule : StationEventSystem { - [Dependency] private readonly AnnouncerSystem _announcer = default!; - [Dependency] private readonly IPrototypeManager _prototype = default!; [Dependency] private readonly IRobustRandom _random = default!; protected override void Started(EntityUid uid, RandomSentienceRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) { - if (!TryGetRandomStation(out var randomStation)) + if (!TryGetRandomStation(out var station)) return; var targetList = new List>(); var query = EntityQueryEnumerator(); while (query.MoveNext(out var targetUid, out var target, out var xform)) { - if (StationSystem.GetOwningStation(targetUid, xform) != randomStation) + if (StationSystem.GetOwningStation(targetUid, xform) != station) continue; targetList.Add((targetUid, target)); } var toMakeSentient = _random.Next(component.MinSentiences, component.MaxSentiences); - var stationsToNotify = new List(); + var groups = new HashSet(); for (var i = 0; i < toMakeSentient && targetList.Count > 0; i++) @@ -72,27 +68,12 @@ protected override void Started(EntityUid uid, RandomSentienceRuleComponent comp var kind2 = groupList.Count > 1 ? groupList[1] : "???"; var kind3 = groupList.Count > 2 ? groupList[2] : "???"; - foreach (var target in targetList) - { - var targetStation = StationSystem.GetOwningStation(target); - if(targetStation == null) - continue; - stationsToNotify.Add((EntityUid) targetStation); - } - foreach (var station in stationsToNotify) - { - _announcer.SendAnnouncement( - _announcer.GetAnnouncementId(args.RuleId), - StationSystem.GetInStation(EntityManager.GetComponent(station)), - "station-event-random-sentience-announcement", - null, - Color.Gold, - null, - null, + ChatSystem.DispatchStationAnnouncement( + station.Value, + _announcer.GetAnnouncementId(args.RuleId), ("kind1", kind1), ("kind2", kind2), ("kind3", kind3), ("amount", groupList.Count), - ("data", _random.Pick(_prototype.Index("RandomSentienceEventData"))), - ("strength", _random.Pick(_prototype.Index("RandomSentienceEventStrength"))) - ); - } + ("data", _random.Pick(_prototype.Index("RandomSentienceEventData"))), + ("strength", _random.Pick(_prototype.Index("RandomSentienceEventStrength"))) + ); } -} +} \ No newline at end of file