diff --git a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs index a0acf783ec..ad49c13d6e 100644 --- a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using Content.Server.Atmos.Components; @@ -15,6 +13,7 @@ using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Map; using Robust.Shared.Timing; + // ReSharper disable once RedundantUsingDirective namespace Content.Server.Atmos.EntitySystems @@ -44,7 +43,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// How far away do we update gas overlays (minimum; due to chunking further away tiles may also be updated). /// - private Vector2 _updateRange; + private float _updateRange; // Because the gas overlay updates aren't run every tick we need to avoid the pop-in that might occur with // the regular PVS range. @@ -67,7 +66,7 @@ namespace Content.Server.Atmos.EntitySystems _playerManager.PlayerStatusChanged += OnPlayerStatusChanged; var configManager = IoCManager.Resolve(); configManager.OnValueChanged(CCVars.NetGasOverlayTickRate, value => _updateCooldown = value > 0.0f ? 1 / value : float.MaxValue, true); - configManager.OnValueChanged(CVars.NetDefaultUpdateRange, value => _updateRange = value + RangeOffset, true); + configManager.OnValueChanged(CVars.NetMaxUpdateRange, value => _updateRange = value + RangeOffset, true); configManager.OnValueChanged(CCVars.GasOverlayThresholds, value => _thresholds = value, true); } @@ -188,21 +187,20 @@ namespace Content.Server.Atmos.EntitySystems private List GetChunksInRange(EntityUid entity) { // This is the max in any direction that we can get a chunk (e.g. max 2 chunks away of data). - var (maxXDiff, maxYDiff) = ((int) (_updateRange.X / ChunkSize) + 1, (int) (_updateRange.Y / ChunkSize) + 1); + var (maxXDiff, maxYDiff) = ((int) (_updateRange / ChunkSize) + 1, (int) (_updateRange / ChunkSize) + 1); // Setting initial list size based on the theoretical max number of chunks from a single grid. For default // parameters, this is currently 6^2 = 36. Unless a player is near more than one grid, this is will // generally slightly over-estimate the actual list size, which will be either 25, 30, or 36 (assuming the // player is not near the edge of a grid). - var initialListSize = (1 + (int) MathF.Ceiling(2 * _updateRange.X / ChunkSize)) * (1 + (int) MathF.Ceiling(2 * _updateRange.Y / ChunkSize)); + var initialListSize = (1 + (int) MathF.Ceiling(2 * _updateRange / ChunkSize)) * (1 + (int) MathF.Ceiling(2 * _updateRange / ChunkSize)); var inRange = new List(initialListSize); var xform = Transform(entity); var worldPos = xform.MapPosition; - var worldBounds = Box2.CenteredAround(worldPos.Position, - _updateRange); + var worldBounds = Box2.CenteredAround(worldPos.Position, new Vector2(_updateRange, _updateRange)); foreach (var grid in _mapManager.FindGridsIntersecting(xform.MapID, worldBounds)) { @@ -225,10 +223,10 @@ namespace Content.Server.Atmos.EntitySystems // (e.g. if we're on the very edge of a chunk we may need more chunks). var (xDiff, yDiff) = (chunkIndices.X - entityTile.X, chunkIndices.Y - entityTile.Y); - if (xDiff > _updateRange.X || - yDiff > _updateRange.Y || - xDiff < 0 && Math.Abs(xDiff + ChunkSize) > _updateRange.X || - yDiff < 0 && Math.Abs(yDiff + ChunkSize) > _updateRange.Y) continue; + if (xDiff > _updateRange || + yDiff > _updateRange || + xDiff < 0 && Math.Abs(xDiff + ChunkSize) > _updateRange || + yDiff < 0 && Math.Abs(yDiff + ChunkSize) > _updateRange) continue; inRange.Add(chunk); } diff --git a/Content.Shared/Decals/SharedDecalSystem.cs b/Content.Shared/Decals/SharedDecalSystem.cs index c6bf05aa54..4d8b805686 100644 --- a/Content.Shared/Decals/SharedDecalSystem.cs +++ b/Content.Shared/Decals/SharedDecalSystem.cs @@ -18,23 +18,23 @@ namespace Content.Shared.Decals public const int ChunkSize = 32; public static Vector2i GetChunkIndices(Vector2 coordinates) => new ((int) Math.Floor(coordinates.X / ChunkSize), (int) Math.Floor(coordinates.Y / ChunkSize)); - private Vector2 _viewSize; + private float _viewSize; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnGridInitialize); - _configurationManager.OnValueChanged(CVars.NetDefaultUpdateRange, OnPvsRangeChanged, true); + _configurationManager.OnValueChanged(CVars.NetMaxUpdateRange, OnPvsRangeChanged, true); } public override void Shutdown() { base.Shutdown(); - _configurationManager.UnsubValueChanged(CVars.NetDefaultUpdateRange, OnPvsRangeChanged); + _configurationManager.UnsubValueChanged(CVars.NetMaxUpdateRange, OnPvsRangeChanged); } - private void OnPvsRangeChanged(Vector2 obj) + private void OnPvsRangeChanged(float obj) { _viewSize = obj * 2f; } diff --git a/RobustToolbox b/RobustToolbox index 4cf88507c2..1eb7393a60 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 4cf88507c2096c7bb625342c8a5309bef00a4058 +Subproject commit 1eb7393a60db8b61e790092dd04c24d6b4f2e694