From 94ea61defa2f178503d39fe22d0075232e9f84c6 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 13 Apr 2023 00:38:14 +1000 Subject: [PATCH] Fix biome seed gen (#15352) Well the command itself didn't set the seed properly so. --- Content.Server/Maps/PlanetCommand.cs | 5 +++-- Content.Server/Parallax/BiomeSystem.cs | 18 ++++++++++++++++-- .../Parallax/Biomes/BiomeComponent.cs | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Content.Server/Maps/PlanetCommand.cs b/Content.Server/Maps/PlanetCommand.cs index 117d1da431..5f1a9a5c12 100644 --- a/Content.Server/Maps/PlanetCommand.cs +++ b/Content.Server/Maps/PlanetCommand.cs @@ -2,6 +2,7 @@ using System.Linq; using Content.Server.Administration; using Content.Server.Atmos; using Content.Server.Atmos.Components; +using Content.Server.Parallax; using Content.Shared.Administration; using Content.Shared.Atmos; using Content.Shared.Gravity; @@ -62,8 +63,8 @@ public sealed class PlanetCommand : IConsoleCommand MetaDataComponent? metadata = null; var biome = _entManager.EnsureComponent(mapUid); - biome.BiomePrototype = args[1]; - biome.Seed = _random.Next(); + _entManager.System().SetPrototype(biome, args[1]); + _entManager.System().SetSeed(biome, _random.Next()); _entManager.Dirty(biome); var gravity = _entManager.EnsureComponent(mapUid); diff --git a/Content.Server/Parallax/BiomeSystem.cs b/Content.Server/Parallax/BiomeSystem.cs index 2204806639..5733d73277 100644 --- a/Content.Server/Parallax/BiomeSystem.cs +++ b/Content.Server/Parallax/BiomeSystem.cs @@ -58,8 +58,22 @@ public sealed class BiomeSystem : SharedBiomeSystem private void OnBiomeMapInit(EntityUid uid, BiomeComponent component, MapInitEvent args) { - component.Seed = _random.Next(); - component.Noise.SetSeed(component.Seed); + SetSeed(component, _random.Next()); + } + + public void SetPrototype(BiomeComponent component, string proto) + { + if (component.BiomePrototype == proto) + return; + + component.BiomePrototype = proto; + Dirty(component); + } + + public void SetSeed(BiomeComponent component, int seed) + { + component.Seed = seed; + component.Noise.SetSeed(seed); Dirty(component); } diff --git a/Content.Shared/Parallax/Biomes/BiomeComponent.cs b/Content.Shared/Parallax/Biomes/BiomeComponent.cs index ac960f5ce7..9b8d8ca430 100644 --- a/Content.Shared/Parallax/Biomes/BiomeComponent.cs +++ b/Content.Shared/Parallax/Biomes/BiomeComponent.cs @@ -4,7 +4,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy namespace Content.Shared.Parallax.Biomes; -[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true), Access(typeof(SharedBiomeSystem))] public sealed partial class BiomeComponent : Component { public FastNoiseLite Noise = new(); -- 2.51.2