Files
Delta-v/Content.Server/_DV/StationEvents/GameRules/EpsilonEventRule.cs
T
652e52dbca Nuke/CosCult Global Music and SFX (#5918)
* Extended ServerGlobalSoundSystem and exposed its lies. Now its actually global.

* Fixed Epsilon event rule namespacing and formatting.

* Cosmic Cult Music Updates

* Few more CosCult changes.

* Nuke and Alert Changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update Content.Server/_DV/CosmicCult/EntitySystems/CosmicChantrySystem.cs

Co-authored-by: Sir Warock <67167466+SirWarock@users.noreply.github.com>
Signed-off-by: Vanessa <908648+ShepardToTheStars@users.noreply.github.com>

* Update Content.Server/_DV/Audio/ServerGlobalSoundSystem.cs

Signed-off-by: Vanessa <908648+ShepardToTheStars@users.noreply.github.com>

---------

Signed-off-by: Vanessa <908648+ShepardToTheStars@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sir Warock <67167466+SirWarock@users.noreply.github.com>
2026-06-23 12:40:17 +02:00

74 lines
2.7 KiB
C#

using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.StationEvents.Events;
using Content.Shared.GameTicking.Components;
using Content.Shared.Station.Components;
using Content.Server.AlertLevel;
using Content.Server.Audio;
using Content.Server._DV.StationEvents.Components;
using Robust.Shared.Audio.Systems;
namespace Content.Server._DV.StationEvents.Events;
public sealed class EpsilonEventRule : StationEventSystem<EpsilonEventRuleComponent>
{
[Dependency] private readonly ApcSystem _apcSystem = default!;
[Dependency] private readonly AlertLevelSystem _alertLevelSystem = default!;
[Dependency] private readonly ServerGlobalSoundSystem _sound = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
protected override void Started(EntityUid uid, EpsilonEventRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
// This should be checked before playing the sound
if (!TryGetRandomStation(out var chosenStation))
return;
component.AffectedStation = chosenStation.Value;
// Plays the power off sound for those who are on the station.
_sound.PlayGlobalOnStation(component.AffectedStation, _audio.ResolveSound(component.PowerOffSound));
var query = AllEntityQuery<ApcComponent, TransformComponent>();
while (query.MoveNext(out var apcUid, out var apc, out var transform))
{
if (CompOrNull<StationMemberComponent>(transform.GridUid)?.Station != chosenStation)
continue;
// Turns off APCs during the event. Basic power-outage event.
if (apc.MainBreakerEnabled)
{
_apcSystem.ApcToggleBreaker(apcUid, apc);
component.ToggledAPCs.Add((apcUid, apc));
}
}
}
protected override void Ended(EntityUid uid, EpsilonEventRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
{
base.Ended(uid, component, gameRule, args);
// Checks if station exists.
if (!Exists(component.AffectedStation))
return;
// Restores the power to the station.
foreach (var apc in component.ToggledAPCs)
{
if (Deleted(apc))
continue;
if (!apc.Comp.MainBreakerEnabled)
_apcSystem.ApcToggleBreaker(apc, apc);
}
component.ToggledAPCs.Clear();
// Final effect, sets the code to Epsilon
if (!HasComp<AlertLevelComponent>(component.AffectedStation))
return;
_alertLevelSystem.SetLevel(component.AffectedStation, "epsilon", true, true, true);
}
}