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:
@@ -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;
|
||||||
31
Content.Shared/Trigger/Systems/TriggerOnRoundEndSystem.cs
Normal file
31
Content.Shared/Trigger/Systems/TriggerOnRoundEndSystem.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user