From e37f95c24c447e568e3d6a6c33f1ba587c4a9495 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Wed, 15 May 2024 03:27:25 +0000 Subject: [PATCH] biome flexibility changes (#28017) make biome apply template on mapinit, add api for setting Enabled Co-authored-by: deltanedas <@deltanedas:kde.org> --- Content.Server/Parallax/BiomeSystem.cs | 13 +++++++++++++ Content.Shared/Parallax/Biomes/BiomeComponent.cs | 13 ++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Content.Server/Parallax/BiomeSystem.cs b/Content.Server/Parallax/BiomeSystem.cs index 0543518dcc..ec780d1f99 100644 --- a/Content.Server/Parallax/BiomeSystem.cs +++ b/Content.Server/Parallax/BiomeSystem.cs @@ -39,6 +39,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem [Dependency] private readonly IConsoleHost _console = default!; [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IParallelManager _parallel = default!; + [Dependency] private readonly IPrototypeManager _proto = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly AtmosphereSystem _atmos = default!; @@ -119,6 +120,9 @@ public sealed partial class BiomeSystem : SharedBiomeSystem SetSeed(uid, component, _random.Next()); } + if (_proto.TryIndex(component.Template, out var biome)) + SetTemplate(uid, component, biome); + var xform = Transform(uid); var mapId = xform.MapID; @@ -151,6 +155,15 @@ public sealed partial class BiomeSystem : SharedBiomeSystem } } + public void SetEnabled(Entity ent, bool enabled = true) + { + if (!Resolve(ent, ref ent.Comp) || ent.Comp.Enabled == enabled) + return; + + ent.Comp.Enabled = enabled; + Dirty(ent, ent.Comp); + } + public void SetSeed(EntityUid uid, BiomeComponent component, int seed, bool dirty = true) { component.Seed = seed; diff --git a/Content.Shared/Parallax/Biomes/BiomeComponent.cs b/Content.Shared/Parallax/Biomes/BiomeComponent.cs index 8446febfb2..af8eb88683 100644 --- a/Content.Shared/Parallax/Biomes/BiomeComponent.cs +++ b/Content.Shared/Parallax/Biomes/BiomeComponent.cs @@ -30,14 +30,13 @@ public sealed partial class BiomeComponent : Component public List Layers = new(); /// - /// Templates to use for . Optional as this can be set elsewhere. + /// Templates to use for . + /// If this is set on mapinit, it will fill out layers automatically. + /// If not set, use BiomeSystem to do it. + /// Prototype reloading will also use this. /// - /// - /// This is really just here for prototype reload support. - /// - [ViewVariables(VVAccess.ReadWrite), - DataField("template", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string? Template; + [DataField] + public ProtoId? Template; /// /// If we've already generated a tile and couldn't deload it then we won't ever reload it in future.