Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinary1 committed Nov 21, 2024
1 parent c77121d commit 6dbf768
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Content.Server.GameTicking;
using Content.Shared.Starlight.CCVar;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Mindshield.Components;
using Robust.Server.Player;
using Robust.Shared.Configuration;

namespace Content.Server.Starlight.GameTicking;

public sealed class PeacefulRoundEndSystem : 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(StarlightCCVars.PeacefulRoundEnd, 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;

var entityId = session.AttachedEntity.Value;

EnsureComp<PacifiedComponent>(entityId);
}
}
}
6 changes: 6 additions & 0 deletions Content.Shared/_Starlight/CCVar/StarlightCCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ public sealed partial class StarlightCCVars

public static readonly CVarDef<string> ServerName =
CVarDef.Create("lobby.server_name", "☆ Starlight ☆", CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Making everyone a pacifist at the end of a round.
/// </summary>
public static readonly CVarDef<bool> PeacefulRoundEnd =
CVarDef.Create("game.peaceful_end", true, CVar.SERVERONLY);
}

0 comments on commit 6dbf768

Please sign in to comment.