Add cvar for events (#2478)

There's also the existing events command as well that's separate. I think there's value in having both? (Where mods can turn it on and off but not change the default?)

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2020-11-06 04:04:07 +11:00
committed by GitHub
parent 14568bc10c
commit e62df15ef9
2 changed files with 9 additions and 0 deletions

View File

@@ -4,11 +4,13 @@ using System.Text;
using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking;
using Content.Server.StationEvents;
using Content.Shared;
using Content.Shared.GameTicking;
using JetBrains.Annotations;
using Robust.Server.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.Interfaces.Reflection;
@@ -23,6 +25,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
// Somewhat based off of TG's implementation of events
public sealed class StationEventSystem : EntitySystem, IResettingEntitySystem
{
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IServerNetManager _netManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTicker _gameTicker = default!;
@@ -164,6 +167,9 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
_stationEvents.Add(stationEvent);
}
// Can't just check debug / release for a default given mappers need to use release mode
// As such we'll always pause it by default.
_configurationManager.OnValueChanged(CCVars.EventsEnabled, value => Enabled = value, true);
_netManager.RegisterNetMessage<MsgGetStationEvents>(nameof(MsgGetStationEvents), GetEventReceived);
}

View File

@@ -7,6 +7,9 @@ namespace Content.Shared
[CVarDefs]
public sealed class CCVars : CVars
{
public static readonly CVarDef<bool>
EventsEnabled = CVarDef.Create("events.enabled", false, CVar.ARCHIVE | CVar.SERVERONLY);
public static readonly CVarDef<bool>
GameLobbyEnabled = CVarDef.Create("game.lobbyenabled", false, CVar.ARCHIVE);