diff --git a/Content.Server/Parallax/BiomeSystem.cs b/Content.Server/Parallax/BiomeSystem.cs index 9f8c9c1c4c..01e818b9c7 100644 --- a/Content.Server/Parallax/BiomeSystem.cs +++ b/Content.Server/Parallax/BiomeSystem.cs @@ -2,26 +2,28 @@ using Content.Server.Decals; using Content.Shared.Decals; using Content.Shared.Parallax.Biomes; using Robust.Server.Player; +using Robust.Shared; +using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Noise; using Robust.Shared.Player; -using Robust.Shared.Prototypes; using Robust.Shared.Random; -using Robust.Shared.Serialization.Manager; namespace Content.Server.Parallax; public sealed class BiomeSystem : SharedBiomeSystem { + [Dependency] private readonly IConfigurationManager _configManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly DecalSystem _decals = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; private readonly HashSet _handledEntities = new(); - private const float LoadRange = ChunkSize * 2f; - private readonly Box2 _loadArea = new(-LoadRange, -LoadRange, LoadRange, LoadRange); + private const float DefaultLoadRange = 16f; + private float _loadRange = DefaultLoadRange; + private Box2 _loadArea = new(-DefaultLoadRange, -DefaultLoadRange, DefaultLoadRange, DefaultLoadRange); private readonly Dictionary> _activeChunks = new(); @@ -29,6 +31,20 @@ public sealed class BiomeSystem : SharedBiomeSystem { base.Initialize(); SubscribeLocalEvent(OnBiomeMapInit); + _configManager.OnValueChanged(CVars.NetMaxUpdateRange, SetLoadRange, true); + } + + public override void Shutdown() + { + base.Shutdown(); + _configManager.UnsubValueChanged(CVars.NetMaxUpdateRange, SetLoadRange); + } + + private void SetLoadRange(float obj) + { + // Round it up + _loadRange = MathF.Ceiling(obj / ChunkSize) * ChunkSize; + _loadArea = new Box2(-_loadRange, -_loadRange, _loadRange, _loadRange); } private void OnBiomeMapInit(EntityUid uid, BiomeComponent component, MapInitEvent args) diff --git a/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs b/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs index eefc772c17..5cdba8f5ec 100644 --- a/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs +++ b/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs @@ -18,7 +18,7 @@ public abstract class SharedBiomeSystem : EntitySystem [Dependency] protected readonly IPrototypeManager ProtoManager = default!; [Dependency] protected readonly ITileDefinitionManager TileDefManager = default!; - protected const byte ChunkSize = 4; + protected const byte ChunkSize = 8; // TODO: After I wrote all of this FastNoiseLite got ported so this needs updating for that don't @ me