]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix biome seed gen (#15352)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Wed, 12 Apr 2023 14:38:14 +0000 (00:38 +1000)
committerGitHub <noreply@github.com>
Wed, 12 Apr 2023 14:38:14 +0000 (09:38 -0500)
Well the command itself didn't set the seed properly so.

Content.Server/Maps/PlanetCommand.cs
Content.Server/Parallax/BiomeSystem.cs
Content.Shared/Parallax/Biomes/BiomeComponent.cs

index 117d1da431e2f1fe501a05cfe285d5abe9c37ccf..5f1a9a5c12acf557c3bd5132c37346010e2c6977 100644 (file)
@@ -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<BiomeComponent>(mapUid);
-        biome.BiomePrototype = args[1];
-        biome.Seed = _random.Next();
+        _entManager.System<BiomeSystem>().SetPrototype(biome, args[1]);
+        _entManager.System<BiomeSystem>().SetSeed(biome, _random.Next());
         _entManager.Dirty(biome);
 
         var gravity = _entManager.EnsureComponent<GravityComponent>(mapUid);
index 22048066390bebbd7841daf858e77c539a10f9d2..5733d7327744d10c5cbbdadec52592c79d1a223d 100644 (file)
@@ -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);
     }
 
index ac960f5ce7a41723ab4a610bbd14b3222660c169..9b8d8ca430ba67f8f52e5cf7ffadca77e5de3f7a 100644 (file)
@@ -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();