mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Replace CVar OnValueChanged in systems with Subs.CVar
This commit is contained in:
@@ -106,8 +106,8 @@ public sealed partial class AudioSystem : SharedAudioSystem
|
||||
SubscribeNetworkEvent<PlayAudioEntityMessage>(OnEntityAudio);
|
||||
SubscribeNetworkEvent<PlayAudioPositionalMessage>(OnEntityCoordinates);
|
||||
|
||||
CfgManager.OnValueChanged(CVars.AudioAttenuation, OnAudioAttenuation, true);
|
||||
CfgManager.OnValueChanged(CVars.AudioRaycastLength, OnRaycastLengthChanged, true);
|
||||
Subs.CVar(CfgManager, CVars.AudioAttenuation, OnAudioAttenuation, true);
|
||||
Subs.CVar(CfgManager, CVars.AudioRaycastLength, OnRaycastLengthChanged, true);
|
||||
}
|
||||
|
||||
private void OnAudioState(EntityUid uid, AudioComponent component, ref AfterAutoHandleStateEvent args)
|
||||
@@ -133,13 +133,6 @@ public sealed partial class AudioSystem : SharedAudioSystem
|
||||
_audio.SetMasterGain(value);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
CfgManager.UnsubValueChanged(CVars.AudioAttenuation, OnAudioAttenuation);
|
||||
CfgManager.UnsubValueChanged(CVars.AudioRaycastLength, OnRaycastLengthChanged);
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
private void OnAudioPaused(EntityUid uid, AudioComponent component, ref EntityPausedEvent args)
|
||||
{
|
||||
component.Pause();
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Robust.Client.GameObjects
|
||||
SubscribeLocalEvent<SpriteComponent, SpriteUpdateInertEvent>(QueueUpdateInert);
|
||||
SubscribeLocalEvent<SpriteComponent, ComponentInit>(OnInit);
|
||||
|
||||
_cfg.OnValueChanged(CVars.RenderSpriteDirectionBias, OnBiasChanged, true);
|
||||
Subs.CVar(_cfg, CVars.RenderSpriteDirectionBias, OnBiasChanged, true);
|
||||
_sawmill = _logManager.GetSawmill("sprite");
|
||||
}
|
||||
|
||||
@@ -72,12 +72,6 @@ namespace Robust.Client.GameObjects
|
||||
QueueUpdateInert(uid, component);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
_cfg.UnsubValueChanged(CVars.RenderSpriteDirectionBias, OnBiasChanged);
|
||||
}
|
||||
|
||||
private void OnBiasChanged(double value)
|
||||
{
|
||||
SpriteComponent.DirectionBias = value;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Robust.Server.GameObjects
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<MapGridComponent, EmptyGridEvent>(HandleGridEmpty);
|
||||
|
||||
_cfg.OnValueChanged(CVars.GameDeleteEmptyGrids, SetGridDeletion, true);
|
||||
Subs.CVar(_cfg, CVars.GameDeleteEmptyGrids, SetGridDeletion, true);
|
||||
}
|
||||
|
||||
protected override void OnMapAdd(EntityUid uid, MapComponent component, ComponentAdd args)
|
||||
@@ -64,13 +64,6 @@ namespace Robust.Server.GameObjects
|
||||
return !(grid.GetAllTiles().Any());
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
_cfg.UnsubValueChanged(CVars.GameDeleteEmptyGrids, SetGridDeletion);
|
||||
}
|
||||
|
||||
private void HandleGridEmpty(EntityUid uid, MapGridComponent component, EmptyGridEvent args)
|
||||
{
|
||||
if (!_deleteEmptyGrids || TerminatingOrDeleted(uid) || HasComp<MapComponent>(uid))
|
||||
|
||||
@@ -20,7 +20,8 @@ namespace Robust.Server.GameObjects
|
||||
{
|
||||
base.Initialize();
|
||||
LoadMetricCVar();
|
||||
_configurationManager.OnValueChanged(CVars.MetricsEnabled, _ => LoadMetricCVar());
|
||||
|
||||
Subs.CVar(_configurationManager, CVars.MetricsEnabled, _ => LoadMetricCVar());
|
||||
}
|
||||
|
||||
private void LoadMetricCVar()
|
||||
|
||||
@@ -126,11 +126,12 @@ internal sealed partial class PvsSystem : EntitySystem
|
||||
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
|
||||
_transform.OnGlobalMoveEvent += OnEntityMove;
|
||||
|
||||
_configManager.OnValueChanged(CVars.NetPVS, SetPvs, true);
|
||||
_configManager.OnValueChanged(CVars.NetMaxUpdateRange, OnViewsizeChanged, true);
|
||||
_configManager.OnValueChanged(CVars.NetLowLodRange, OnLodChanged, true);
|
||||
_configManager.OnValueChanged(CVars.NetForceAckThreshold, OnForceAckChanged, true);
|
||||
_configManager.OnValueChanged(CVars.NetPvsAsync, OnAsyncChanged, true);
|
||||
Subs.CVar(_configManager, CVars.NetPVS, SetPvs, true);
|
||||
Subs.CVar(_configManager, CVars.NetMaxUpdateRange, OnViewsizeChanged, true);
|
||||
Subs.CVar(_configManager, CVars.NetLowLodRange, OnLodChanged, true);
|
||||
Subs.CVar(_configManager, CVars.NetForceAckThreshold, OnForceAckChanged, true);
|
||||
Subs.CVar(_configManager, CVars.NetPvsAsync, OnAsyncChanged, true);
|
||||
Subs.CVar(_configManager, CVars.NetPvsCompressLevel, ResetParallelism, true);
|
||||
|
||||
_serverGameStateManager.ClientAck += OnClientAck;
|
||||
_serverGameStateManager.ClientRequestFull += OnClientRequestFull;
|
||||
@@ -138,7 +139,6 @@ internal sealed partial class PvsSystem : EntitySystem
|
||||
InitializeDirty();
|
||||
|
||||
_parallelMgr.ParallelCountChanged += ResetParallelism;
|
||||
_configManager.OnValueChanged(CVars.NetPvsCompressLevel, ResetParallelism, true);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
@@ -148,10 +148,6 @@ internal sealed partial class PvsSystem : EntitySystem
|
||||
_playerManager.PlayerStatusChanged -= OnPlayerStatusChanged;
|
||||
_transform.OnGlobalMoveEvent -= OnEntityMove;
|
||||
|
||||
_configManager.UnsubValueChanged(CVars.NetPVS, SetPvs);
|
||||
_configManager.UnsubValueChanged(CVars.NetMaxUpdateRange, OnViewsizeChanged);
|
||||
_configManager.UnsubValueChanged(CVars.NetForceAckThreshold, OnForceAckChanged);
|
||||
_configManager.UnsubValueChanged(CVars.NetPvsCompressLevel, ResetParallelism);
|
||||
_parallelMgr.ParallelCountChanged -= ResetParallelism;
|
||||
|
||||
_serverGameStateManager.ClientAck -= OnClientAck;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Robust.Server.Physics
|
||||
SubscribeNetworkEvent<RequestGridNodesMessage>(OnDebugRequest);
|
||||
SubscribeNetworkEvent<StopGridNodesMessage>(OnDebugStopRequest);
|
||||
|
||||
_cfg.OnValueChanged(CVars.GridSplitting, SetSplitAllowed, true);
|
||||
Subs.CVar(_cfg, CVars.GridSplitting, SetSplitAllowed, true);
|
||||
}
|
||||
|
||||
private void SetSplitAllowed(bool value) => SplitAllowed = value;
|
||||
@@ -73,7 +73,6 @@ namespace Robust.Server.Physics
|
||||
{
|
||||
base.Shutdown();
|
||||
_subscribedSessions.Clear();
|
||||
_cfg.UnsubValueChanged(CVars.GridSplitting, SetSplitAllowed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -50,17 +50,11 @@ public abstract partial class SharedAudioSystem : EntitySystem
|
||||
base.Initialize();
|
||||
InitializeEffect();
|
||||
ZOffset = CfgManager.GetCVar(CVars.AudioZOffset);
|
||||
CfgManager.OnValueChanged(CVars.AudioZOffset, SetZOffset);
|
||||
Subs.CVar(CfgManager, CVars.AudioZOffset, SetZOffset);
|
||||
SubscribeLocalEvent<AudioComponent, ComponentGetStateAttemptEvent>(OnAudioGetStateAttempt);
|
||||
SubscribeLocalEvent<AudioComponent, EntityUnpausedEvent>(OnAudioUnpaused);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
CfgManager.UnsubValueChanged(CVars.AudioZOffset, SetZOffset);
|
||||
}
|
||||
|
||||
protected void SetZOffset(float value)
|
||||
{
|
||||
ZOffset = value;
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace Robust.Shared.GameObjects
|
||||
base.Initialize();
|
||||
UpdatesBefore.Add(typeof(SharedBroadphaseSystem));
|
||||
|
||||
_cfg.OnValueChanged(CVars.GenerateGridFixtures, SetEnabled, true);
|
||||
_cfg.OnValueChanged(CVars.GridFixtureEnlargement, SetEnlargement, true);
|
||||
Subs.CVar(_cfg, CVars.GenerateGridFixtures, SetEnabled, true);
|
||||
Subs.CVar(_cfg, CVars.GridFixtureEnlargement, SetEnlargement, true);
|
||||
|
||||
SubscribeLocalEvent<GridInitializeEvent>(OnGridInit);
|
||||
SubscribeLocalEvent<RegenerateGridBoundsEvent>(OnGridBoundsRegenerate);
|
||||
@@ -58,14 +58,6 @@ namespace Robust.Shared.GameObjects
|
||||
_map.RegenerateCollision(ev.EntityUid, grid, _map.GetMapChunks(ev.EntityUid, grid).Values.ToHashSet());
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
_cfg.UnsubValueChanged(CVars.GenerateGridFixtures, SetEnabled);
|
||||
_cfg.UnsubValueChanged(CVars.GridFixtureEnlargement, SetEnlargement);
|
||||
}
|
||||
|
||||
private void SetEnabled(bool value) => _enabled = value;
|
||||
|
||||
private void SetEnlargement(float value) => _fixtureEnlargement = value;
|
||||
|
||||
@@ -67,14 +67,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
UpdatesOutsidePrediction = true;
|
||||
UpdatesAfter.Add(typeof(SharedTransformSystem));
|
||||
|
||||
_cfg.OnValueChanged(CVars.BroadphaseExpand, SetBroadphaseExpand, true);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
_cfg.UnsubValueChanged(CVars.BroadphaseExpand, SetBroadphaseExpand);
|
||||
Subs.CVar(_cfg, CVars.BroadphaseExpand, SetBroadphaseExpand, true);
|
||||
}
|
||||
|
||||
private void SetBroadphaseExpand(float value) => _broadphaseExpand = value;
|
||||
|
||||
@@ -199,38 +199,20 @@ public abstract partial class SharedPhysicsSystem
|
||||
|
||||
private void InitializeIsland()
|
||||
{
|
||||
_configManager.OnValueChanged(CVars.NetTickrate, SetTickRate, true);
|
||||
_configManager.OnValueChanged(CVars.WarmStarting, SetWarmStarting, true);
|
||||
_configManager.OnValueChanged(CVars.MaxLinearCorrection, SetMaxLinearCorrection, true);
|
||||
_configManager.OnValueChanged(CVars.MaxAngularCorrection, SetMaxAngularCorrection, true);
|
||||
_configManager.OnValueChanged(CVars.VelocityIterations, SetVelocityIterations, true);
|
||||
_configManager.OnValueChanged(CVars.PositionIterations, SetPositionIterations, true);
|
||||
_configManager.OnValueChanged(CVars.MaxLinVelocity, SetMaxLinearVelocity, true);
|
||||
_configManager.OnValueChanged(CVars.MaxAngVelocity, SetMaxAngularVelocity, true);
|
||||
_configManager.OnValueChanged(CVars.SleepAllowed, SetSleepAllowed, true);
|
||||
_configManager.OnValueChanged(CVars.AngularSleepTolerance, SetAngularToleranceSqr, true);
|
||||
_configManager.OnValueChanged(CVars.LinearSleepTolerance, SetLinearToleranceSqr, true);
|
||||
_configManager.OnValueChanged(CVars.TimeToSleep, SetTimeToSleep, true);
|
||||
_configManager.OnValueChanged(CVars.VelocityThreshold, SetVelocityThreshold, true);
|
||||
_configManager.OnValueChanged(CVars.Baumgarte, SetBaumgarte, true);
|
||||
}
|
||||
|
||||
private void ShutdownIsland()
|
||||
{
|
||||
_configManager.UnsubValueChanged(CVars.NetTickrate, SetTickRate);
|
||||
_configManager.UnsubValueChanged(CVars.WarmStarting, SetWarmStarting);
|
||||
_configManager.UnsubValueChanged(CVars.MaxLinearCorrection, SetMaxLinearCorrection);
|
||||
_configManager.UnsubValueChanged(CVars.MaxAngularCorrection, SetMaxAngularCorrection);
|
||||
_configManager.UnsubValueChanged(CVars.VelocityIterations, SetVelocityIterations);
|
||||
_configManager.UnsubValueChanged(CVars.PositionIterations, SetPositionIterations);
|
||||
_configManager.UnsubValueChanged(CVars.MaxLinVelocity, SetMaxLinearVelocity);
|
||||
_configManager.UnsubValueChanged(CVars.MaxAngVelocity, SetMaxAngularVelocity);
|
||||
_configManager.UnsubValueChanged(CVars.SleepAllowed, SetSleepAllowed);
|
||||
_configManager.UnsubValueChanged(CVars.AngularSleepTolerance, SetAngularToleranceSqr);
|
||||
_configManager.UnsubValueChanged(CVars.LinearSleepTolerance, SetLinearToleranceSqr);
|
||||
_configManager.UnsubValueChanged(CVars.TimeToSleep, SetTimeToSleep);
|
||||
_configManager.UnsubValueChanged(CVars.VelocityThreshold, SetVelocityThreshold);
|
||||
_configManager.UnsubValueChanged(CVars.Baumgarte, SetBaumgarte);
|
||||
Subs.CVar(_configManager, CVars.NetTickrate, SetTickRate, true);
|
||||
Subs.CVar(_configManager, CVars.WarmStarting, SetWarmStarting, true);
|
||||
Subs.CVar(_configManager, CVars.MaxLinearCorrection, SetMaxLinearCorrection, true);
|
||||
Subs.CVar(_configManager, CVars.MaxAngularCorrection, SetMaxAngularCorrection, true);
|
||||
Subs.CVar(_configManager, CVars.VelocityIterations, SetVelocityIterations, true);
|
||||
Subs.CVar(_configManager, CVars.PositionIterations, SetPositionIterations, true);
|
||||
Subs.CVar(_configManager, CVars.MaxLinVelocity, SetMaxLinearVelocity, true);
|
||||
Subs.CVar(_configManager, CVars.MaxAngVelocity, SetMaxAngularVelocity, true);
|
||||
Subs.CVar(_configManager, CVars.SleepAllowed, SetSleepAllowed, true);
|
||||
Subs.CVar(_configManager, CVars.AngularSleepTolerance, SetAngularToleranceSqr, true);
|
||||
Subs.CVar(_configManager, CVars.LinearSleepTolerance, SetLinearToleranceSqr, true);
|
||||
Subs.CVar(_configManager, CVars.TimeToSleep, SetTimeToSleep, true);
|
||||
Subs.CVar(_configManager, CVars.VelocityThreshold, SetVelocityThreshold, true);
|
||||
Subs.CVar(_configManager, CVars.Baumgarte, SetBaumgarte, true);
|
||||
}
|
||||
|
||||
private void SetWarmStarting(bool value) => _warmStarting = value;
|
||||
|
||||
@@ -92,9 +92,9 @@ namespace Robust.Shared.Physics.Systems
|
||||
InitializeIsland();
|
||||
InitializeContacts();
|
||||
|
||||
_configManager.OnValueChanged(CVars.AutoClearForces, OnAutoClearChange);
|
||||
_configManager.OnValueChanged(CVars.NetTickrate, UpdateSubsteps, true);
|
||||
_configManager.OnValueChanged(CVars.TargetMinimumTickrate, UpdateSubsteps, true);
|
||||
Subs.CVar(_configManager, CVars.AutoClearForces, OnAutoClearChange);
|
||||
Subs.CVar(_configManager, CVars.NetTickrate, UpdateSubsteps, true);
|
||||
Subs.CVar(_configManager, CVars.TargetMinimumTickrate, UpdateSubsteps, true);
|
||||
}
|
||||
|
||||
private void OnPhysicsShutdown(EntityUid uid, PhysicsComponent component, ComponentShutdown args)
|
||||
@@ -250,8 +250,6 @@ namespace Robust.Shared.Physics.Systems
|
||||
base.Shutdown();
|
||||
|
||||
ShutdownContacts();
|
||||
ShutdownIsland();
|
||||
_configManager.UnsubValueChanged(CVars.AutoClearForces, OnAutoClearChange);
|
||||
}
|
||||
|
||||
private void UpdateMapAwakeState(EntityUid uid, PhysicsComponent body)
|
||||
|
||||
Reference in New Issue
Block a user