34 lines
1 KiB
C#
34 lines
1 KiB
C#
using Content.Server.GameTicking;
|
|
using Content.Shared._Sunrise.SunriseCCVars;
|
|
using Content.Shared.Damage.Components;
|
|
using Robust.Server.Player;
|
|
using Robust.Shared.Configuration;
|
|
|
|
namespace Content.Server._Sunrise.GodModeRoundEnd;
|
|
|
|
public sealed class GodModeRoundEndSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
|
|
|
private bool _isEnabled = false;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
_cfg.OnValueChanged(SunriseCCVars.GodModeRoundEnd, v => _isEnabled = v, true);
|
|
SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEnded);
|
|
}
|
|
|
|
private void OnRoundEnded(RoundEndTextAppendEvent ev)
|
|
{
|
|
if (!_isEnabled)
|
|
return;
|
|
foreach (var session in _playerManager.Sessions)
|
|
{
|
|
if (!session.AttachedEntity.HasValue)
|
|
continue;
|
|
EnsureComp<GodmodeComponent>(session.AttachedEntity.Value);
|
|
}
|
|
}
|
|
}
|