]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Trigger on round end (#39545)
authorāda <ss.adasts@gmail.com>
Mon, 11 Aug 2025 07:44:36 +0000 (02:44 -0500)
committerGitHub <noreply@github.com>
Mon, 11 Aug 2025 07:44:36 +0000 (09:44 +0200)
* works if it works

* small rewording

---------

Co-authored-by: iaada <iaada@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Shared/Trigger/Components/Triggers/TriggerOnRoundEndComponent.cs [new file with mode: 0644]
Content.Shared/Trigger/Systems/TriggerOnRoundEndSystem.cs [new file with mode: 0644]

diff --git a/Content.Shared/Trigger/Components/Triggers/TriggerOnRoundEndComponent.cs b/Content.Shared/Trigger/Components/Triggers/TriggerOnRoundEndComponent.cs
new file mode 100644 (file)
index 0000000..29a9643
--- /dev/null
@@ -0,0 +1,9 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Trigger.Components.Triggers;
+
+/// <summary>
+/// Triggers the entity when the round ends, i.e. the scoreboard appears and post-round begins.
+/// </summary>
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class TriggerOnRoundEndComponent : BaseTriggerOnXComponent;
diff --git a/Content.Shared/Trigger/Systems/TriggerOnRoundEndSystem.cs b/Content.Shared/Trigger/Systems/TriggerOnRoundEndSystem.cs
new file mode 100644 (file)
index 0000000..c18fb08
--- /dev/null
@@ -0,0 +1,31 @@
+using Content.Shared.GameTicking;
+using Content.Shared.Trigger.Components.Triggers;
+
+namespace Content.Shared.Trigger.Systems;
+
+/// <summary>
+/// System for creating a trigger when the round ends.
+/// </summary>
+public sealed class TriggerOnRoundEndSystem : EntitySystem
+{
+    [Dependency] private readonly TriggerSystem _trigger = default!;
+
+    /// <inheritdoc/>
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<RoundEndMessageEvent>(OnRoundEnd);
+    }
+
+    private void OnRoundEnd(RoundEndMessageEvent args)
+    {
+        var triggerQuery = EntityQueryEnumerator<TriggerOnRoundEndComponent>();
+
+        // trigger everything with the component
+        while (triggerQuery.MoveNext(out var uid, out var comp))
+        {
+            _trigger.Trigger(uid, null, comp.KeyOut);
+        }
+    }
+}