From ff8ad629fa049694b1e3970d25592f0df943c2b8 Mon Sep 17 00:00:00 2001 From: Dvir <39403717+dvir001@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:34:32 +0300 Subject: [PATCH] CCVar Cleanup (#1900) * CleanUp * Update CCVars.cs * fixup * Small Change * Fix GhostUIController ref, CCVars.cs->NFCCVars.cs --------- Co-authored-by: Whatstone --- .../Systems/Ghost/GhostUIController.cs | 6 ++--- .../Systems/Ghost/Widgets/GhostGui.xaml.cs | 5 ++--- .../_NF/Commands/GhostRespawnCommand.cs | 6 ++--- .../CryoSleep/CryoSleepSystem.Returning.cs | 4 ++-- .../_NF/CryoSleep/CryoSleepSystem.cs | 4 ++-- .../_NF/GameRule/NfAdventureRuleSystem.cs | 14 ++++++------ .../_NF/PublicTransit/PublicTransitSystem.cs | 22 +++++++++---------- Content.Shared/DeltaV/CCVars/DCCVars.cs | 2 +- .../{CCVars/CCVars.cs => CCVar/NFCCVars.cs} | 4 ++-- 9 files changed, 33 insertions(+), 34 deletions(-) rename Content.Shared/_NF/{CCVars/CCVars.cs => CCVar/NFCCVars.cs} (98%) diff --git a/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs b/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs index c8d227eacee..218a996272b 100644 --- a/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs +++ b/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs @@ -3,7 +3,7 @@ using Content.Client.UserInterface.Systems.Gameplay; using Content.Client.UserInterface.Systems.Ghost.Widgets; using Content.Shared.CCVar; -using Content.Shared.NF14.CCVar; +using Content.Shared._NF.CCVar; // Frontier using Content.Shared.Ghost; using Robust.Client.Console; using Robust.Client.UserInterface; @@ -76,8 +76,8 @@ public void UpdateGui() Gui.Visible = _system?.IsGhost ?? false; Gui.Update(_system?.AvailableGhostRoleCount, _system?.Player?.CanReturnToBody, _system?.Player?.TimeOfDeath, - _cfg.GetCVar(NF14CVars.RespawnTime), - _canUncryo && _cfg.GetCVar(NF14CVars.CryoReturnEnabled)); + _cfg.GetCVar(NFCCVars.RespawnTime), // Frontier + _canUncryo && _cfg.GetCVar(NFCCVars.CryoReturnEnabled)); // Frontier } private void UpdateRespawn(TimeSpan? timeOfDeath) diff --git a/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs b/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs index 9b3dfebe745..d08d2d4ea9e 100644 --- a/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs +++ b/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs @@ -6,8 +6,7 @@ using Robust.Client.UserInterface.XAML; using Robust.Shared.Timing; using Robust.Shared.Configuration; -using Content.Shared.CCVar; -using Content.Shared.NF14.CCVar; +using Content.Shared._NF.CCVar; // Frontier namespace Content.Client.UserInterface.Systems.Ghost.Widgets; @@ -58,7 +57,7 @@ public void UpdateRespawn(TimeSpan? todd) if (todd != null) { _timeOfDeath = todd; - _minTimeToRespawn = _configurationManager.GetCVar(NF14CVars.RespawnTime); + _minTimeToRespawn = _configurationManager.GetCVar(NFCCVars.RespawnTime); // Frontier } } diff --git a/Content.Server/_NF/Commands/GhostRespawnCommand.cs b/Content.Server/_NF/Commands/GhostRespawnCommand.cs index b691187c45f..af88bfe7556 100644 --- a/Content.Server/_NF/Commands/GhostRespawnCommand.cs +++ b/Content.Server/_NF/Commands/GhostRespawnCommand.cs @@ -4,7 +4,7 @@ using Content.Shared.CCVar; using Content.Shared.Ghost; using Content.Shared.Mind; -using Content.Shared.NF14.CCVar; +using Content.Shared._NF.CCVar; using Content.Shared.Roles; using Robust.Server.Player; using Robust.Shared.Configuration; @@ -27,7 +27,7 @@ public sealed class GhostRespawnCommand : IConsoleCommand public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (!_configurationManager.GetCVar(NF14CVars.RespawnEnabled)) + if (!_configurationManager.GetCVar(NFCCVars.RespawnEnabled)) { shell.WriteLine("Respawning is disabled, ask an admin to respawn you."); return; @@ -58,7 +58,7 @@ public void Execute(IConsoleShell shell, string argStr, string[] args) return; } var time = (_gameTiming.CurTime - ghost.TimeOfDeath); - var respawnTime = _configurationManager.GetCVar(NF14CVars.RespawnTime); + var respawnTime = _configurationManager.GetCVar(NFCCVars.RespawnTime); if (respawnTime > time.TotalSeconds) { diff --git a/Content.Server/_NF/CryoSleep/CryoSleepSystem.Returning.cs b/Content.Server/_NF/CryoSleep/CryoSleepSystem.Returning.cs index 2cb51956dc2..cd316180a95 100644 --- a/Content.Server/_NF/CryoSleep/CryoSleepSystem.Returning.cs +++ b/Content.Server/_NF/CryoSleep/CryoSleepSystem.Returning.cs @@ -5,7 +5,7 @@ using Content.Shared.Database; using Content.Shared.Ghost; using Content.Shared.Mind; -using Content.Shared.NF14.CCVar; +using Content.Shared._NF.CCVar; using Content.Shared.Players; using Robust.Shared.Configuration; using Robust.Shared.Network; @@ -48,7 +48,7 @@ public void OnGetStatusMessage(GetStatusMessage message, EntitySessionEventArgs /// public ReturnToBodyStatus TryReturnToBody(MindComponent mind, bool force = false) { - if (!_configurationManager.GetCVar(NF14CVars.CryoReturnEnabled)) + if (!_configurationManager.GetCVar(NFCCVars.CryoReturnEnabled)) return ReturnToBodyStatus.Disabled; var id = mind.UserId; diff --git a/Content.Server/_NF/CryoSleep/CryoSleepSystem.cs b/Content.Server/_NF/CryoSleep/CryoSleepSystem.cs index 0e17d32b402..1a7f8bb00fc 100644 --- a/Content.Server/_NF/CryoSleep/CryoSleepSystem.cs +++ b/Content.Server/_NF/CryoSleep/CryoSleepSystem.cs @@ -20,7 +20,7 @@ using Content.Shared.Mind.Components; using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Systems; -using Content.Shared.NF14.CCVar; +using Content.Shared._NF.CCVar; using Content.Shared.Popups; using Content.Shared.Verbs; using Robust.Server.Containers; @@ -283,7 +283,7 @@ public void CryoStoreBody(EntityUid bodyId, EntityUid cryopod) _doAfter.Cancel(cryo.CryosleepDoAfter); // Start a timer. When it ends, the body needs to be deleted. - Timer.Spawn(TimeSpan.FromSeconds(_configurationManager.GetCVar(NF14CVars.CryoExpirationTime)), () => + Timer.Spawn(TimeSpan.FromSeconds(_configurationManager.GetCVar(NFCCVars.CryoExpirationTime)), () => { if (id != null) ResetCryosleepState(id.Value); diff --git a/Content.Server/_NF/GameRule/NfAdventureRuleSystem.cs b/Content.Server/_NF/GameRule/NfAdventureRuleSystem.cs index 5a563e92f5a..546400302f3 100644 --- a/Content.Server/_NF/GameRule/NfAdventureRuleSystem.cs +++ b/Content.Server/_NF/GameRule/NfAdventureRuleSystem.cs @@ -30,7 +30,7 @@ using Content.Server.Maps; using Content.Server.Station.Systems; using Content.Shared.CCVar; -using Content.Shared.NF14.CCVar; +using Content.Shared._NF.CCVar; // Frontier using Robust.Shared.Configuration; using Robust.Shared.Physics.Components; using Content.Server.Shuttles.Components; @@ -125,7 +125,7 @@ protected override void Started(EntityUid uid, AdventureRuleComponent component, { _mapId = GameTicker.DefaultMap; - _distanceOffset = _configurationManager.GetCVar(NF14CVars.POIDistanceModifier); + _distanceOffset = _configurationManager.GetCVar(NFCCVars.POIDistanceModifier); _stationCoords = new List(); //First, we need to grab the list and sort it into its respective spawning logics @@ -194,7 +194,7 @@ private void GenerateDepots(List depotPrototypes, out //by the number of depots set in our corresponding cvar depotStations = new List(); - var depotCount = _configurationManager.GetCVar(NF14CVars.CargoDepots); + var depotCount = _configurationManager.GetCVar(NFCCVars.CargoDepots); var rotation = 2 * Math.PI / depotCount; var rotationOffset = _random.NextAngle() / depotCount; @@ -226,7 +226,7 @@ private void GenerateMarkets(List marketPrototypes, ou //ideal world marketStations = new List(); - var marketCount = _configurationManager.GetCVar(NF14CVars.MarketStations); + var marketCount = _configurationManager.GetCVar(NFCCVars.MarketStations); _random.Shuffle(marketPrototypes); int marketsAdded = 0; foreach (var proto in marketPrototypes) @@ -252,7 +252,7 @@ private void GenerateOptionals(List optionalPrototypes //and most RP places. This will essentially put them all into a pool to pull from, and still does not use the RNG function. optionalStations = new List(); - var optionalCount = _configurationManager.GetCVar(NF14CVars.OptionalStations); + var optionalCount = _configurationManager.GetCVar(NFCCVars.OptionalStations); _random.Shuffle(optionalPrototypes); int optionalsAdded = 0; foreach (var proto in optionalPrototypes) @@ -372,8 +372,8 @@ private bool TrySpawnPoiGrid(PointOfInterestPrototype proto, Vector2 offset, out private Vector2 GetRandomPOICoord(float unscaledMinRange, float unscaledMaxRange, bool scaleRange) { - int numRetries = int.Max(_configurationManager.GetCVar(NF14CVars.POIPlacementRetries), 0); - float minDistance = float.Max(_configurationManager.GetCVar(NF14CVars.MinPOIDistance), 0); // Constant at the end to avoid NaN weirdness + int numRetries = int.Max(_configurationManager.GetCVar(NFCCVars.POIPlacementRetries), 0); + float minDistance = float.Max(_configurationManager.GetCVar(NFCCVars.MinPOIDistance), 0); // Constant at the end to avoid NaN weirdness Vector2 coords = _random.NextVector2(unscaledMinRange, unscaledMaxRange); if (scaleRange) diff --git a/Content.Server/_NF/PublicTransit/PublicTransitSystem.cs b/Content.Server/_NF/PublicTransit/PublicTransitSystem.cs index 54104cd8cda..bdf6e004b9e 100644 --- a/Content.Server/_NF/PublicTransit/PublicTransitSystem.cs +++ b/Content.Server/_NF/PublicTransit/PublicTransitSystem.cs @@ -5,7 +5,7 @@ using Content.Server.Shuttles.Events; using Content.Server.Shuttles.Systems; using Content.Shared.GameTicking; -using Content.Shared.NF14.CCVar; +using Content.Shared._NF.CCVar; using Content.Shared.Shuttles.Components; using Content.Shared.Tiles; using Robust.Server.GameObjects; @@ -49,12 +49,12 @@ public override void Initialize() SubscribeLocalEvent(OnShuttleTag); SubscribeLocalEvent(OnRoundStart); - Enabled = _cfgManager.GetCVar(NF14CVars.PublicTransit); - FlyTime = _cfgManager.GetCVar(NF14CVars.PublicTransitFlyTime); + Enabled = _cfgManager.GetCVar(NFCCVars.PublicTransit); + FlyTime = _cfgManager.GetCVar(NFCCVars.PublicTransitFlyTime); Counter = 0; StationList.Clear(); - _cfgManager.OnValueChanged(NF14CVars.PublicTransit, SetTransit); - _cfgManager.OnValueChanged(NF14CVars.PublicTransitFlyTime, SetFly); + _cfgManager.OnValueChanged(NFCCVars.PublicTransit, SetTransit); + _cfgManager.OnValueChanged(NFCCVars.PublicTransitFlyTime, SetFly); } public void OnRoundStart(RoundStartedEvent args) @@ -67,8 +67,8 @@ public void OnRoundStart(RoundStartedEvent args) public override void Shutdown() { base.Shutdown(); - _cfgManager.UnsubValueChanged(NF14CVars.PublicTransitFlyTime, SetFly); - _cfgManager.UnsubValueChanged(NF14CVars.PublicTransit, SetTransit); + _cfgManager.UnsubValueChanged(NFCCVars.PublicTransitFlyTime, SetFly); + _cfgManager.UnsubValueChanged(NFCCVars.PublicTransit, SetTransit); } @@ -136,7 +136,7 @@ private void OnShuttleArrival(EntityUid uid, TransitShuttleComponent comp, ref F var destinationString = metadata.EntityName; _chat.TrySendInGameICMessage(consoleUid, Loc.GetString("public-transit-arrival", - ("destination", destinationString), ("waittime", _cfgManager.GetCVar(NF14CVars.PublicTransitWaitTime))), + ("destination", destinationString), ("waittime", _cfgManager.GetCVar(NFCCVars.PublicTransitWaitTime))), InGameICChatType.Speak, ChatTransmitRange.HideChat, hideLog: true, checkRadioPrefix: false, ignoreActionBlocker: true); } @@ -206,7 +206,7 @@ public override void Update(float frameTime) if (TryGetNextStation(out var nextStation) && nextStation is { Valid: true } destination) comp.NextStation = destination; - comp.NextTransfer = curTime + TimeSpan.FromSeconds(FlyTime + _cfgManager.GetCVar(NF14CVars.PublicTransitWaitTime)); + comp.NextTransfer = curTime + TimeSpan.FromSeconds(FlyTime + _cfgManager.GetCVar(NFCCVars.PublicTransitWaitTime)); } } @@ -261,7 +261,7 @@ private void SetupPublicTransit() // Spawn the bus onto a dummy map var dummyMap = _mapManager.CreateMap(); - var busMap = _cfgManager.GetCVar(NF14CVars.PublicTransitBusMap); + var busMap = _cfgManager.GetCVar(NFCCVars.PublicTransitBusMap); if (_loader.TryLoad(dummyMap, busMap, out var shuttleUids)) { var shuttleComp = Comp(shuttleUids[0]); @@ -274,7 +274,7 @@ private void SetupPublicTransit() //we set up a default in case the second time we call it fails for some reason transitComp.NextStation = destination; _shuttles.FTLToDock(shuttleUids[0], shuttleComp, destination, hyperspaceTime: 5f); - transitComp.NextTransfer = _timing.CurTime + TimeSpan.FromSeconds(_cfgManager.GetCVar(NF14CVars.PublicTransitWaitTime)); + transitComp.NextTransfer = _timing.CurTime + TimeSpan.FromSeconds(_cfgManager.GetCVar(NFCCVars.PublicTransitWaitTime)); //since the initial cached value of the next station is actually the one we are 'starting' from, we need to run the //bus stop list code one more time so that our first trip isnt just Frontier - Frontier diff --git a/Content.Shared/DeltaV/CCVars/DCCVars.cs b/Content.Shared/DeltaV/CCVars/DCCVars.cs index bf1fe82adcc..d76fcd882ce 100644 --- a/Content.Shared/DeltaV/CCVars/DCCVars.cs +++ b/Content.Shared/DeltaV/CCVars/DCCVars.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Configuration; +using Robust.Shared.Configuration; namespace Content.Shared.DeltaV.CCVars; diff --git a/Content.Shared/_NF/CCVars/CCVars.cs b/Content.Shared/_NF/CCVar/NFCCVars.cs similarity index 98% rename from Content.Shared/_NF/CCVars/CCVars.cs rename to Content.Shared/_NF/CCVar/NFCCVars.cs index 655504762a0..2eeb13ee615 100644 --- a/Content.Shared/_NF/CCVars/CCVars.cs +++ b/Content.Shared/_NF/CCVar/NFCCVars.cs @@ -1,9 +1,9 @@ using Robust.Shared.Configuration; -namespace Content.Shared.NF14.CCVar; +namespace Content.Shared._NF.CCVar; [CVarDefs] -public sealed class NF14CVars +public sealed class NFCCVars { /// /// Whether or not respawning is enabled.