Files
tbd-station-14/Content.Server/StationEvents/Events/FalseAlarmRule.cs
deltanedas a3a1538d32 move gamerule components to shared (#28572)
* move MinMax to shared

* cleanup MinMax

* move other ticking components to shared just because

* remove unused prototype file

* update everything to use shared components

* test

* test 2

* test 3

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
2024-06-04 21:53:24 +10:00

29 lines
1011 B
C#

using System.Linq;
using Content.Server.StationEvents.Components;
using Content.Shared.GameTicking.Components;
using JetBrains.Annotations;
using Robust.Shared.Random;
namespace Content.Server.StationEvents.Events;
[UsedImplicitly]
public sealed class FalseAlarmRule : StationEventSystem<FalseAlarmRuleComponent>
{
[Dependency] private readonly EventManagerSystem _event = default!;
protected override void Started(EntityUid uid, FalseAlarmRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
if (!TryComp<StationEventComponent>(uid, out var stationEvent))
return;
var allEv = _event.AllEvents().Select(p => p.Value).ToList();
var picked = RobustRandom.Pick(allEv);
stationEvent.StartAnnouncement = picked.StartAnnouncement;
stationEvent.StartAudio = picked.StartAudio;
stationEvent.StartAnnouncementColor = picked.StartAnnouncementColor;
base.Started(uid, component, gameRule, args);
}
}