Trigger on round end (#39545)

* 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>
This commit is contained in:
āda
2025-08-11 02:44:36 -05:00
committed by GitHub
parent 936831bfe0
commit ad5fe5678c
2 changed files with 40 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);
}
}
}