Files
tbd-station-14/Content.Server/Procedural/BiomeSystem.Planet.cs
metalgearsloth fe7b96147c Biome rework (#37735)
* DungeonData rework

Back to fields, serializes better, just make new layers dumby.

* wawawewa

* Fix this

* Fixes

* Port the work over

* wawawewa

* zoom

* Kinda workin

* Adjust wawa

* Unloading work

* Ore + entitytable fixes

Iterate every dungeon not just last.

* Big shot

* wawawewa

* Fixes

* true

* Fixes

# Conflicts:
#	Content.Server/Procedural/DungeonJob/DungeonJob.cs

* wawawewa

* Fixes

* Fix

* Lot of work

* wawawewa

* Fixing

* eh?

* a

* Fix a heap of stuff

* Better ignored check

* Reserve tile changes

* biome

* changes

* wawawewa

* Fixes & snow

* Shadow fixes

* wawawewa

* smol

* Add layer API

* More work

* wawawewa

* Preloads and running again

* wawawewa

* Modified

* Replacements and command

* Runtime support

* werk

* Fix expeds + dungeon alltiles

* reh

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
2025-07-03 00:36:06 -04:00

66 lines
2.2 KiB
C#

using Content.Shared.Atmos;
using Content.Shared.Gravity;
using Content.Shared.Light.Components;
using Content.Shared.Procedural.Components;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
namespace Content.Server.Procedural;
public sealed partial class BiomeSystem
{
/// <summary>
/// Copies the biomecomponent to the specified map.
/// </summary>
public BiomeComponent? AddBiome(Entity<BiomeComponent?> mapUid, EntProtoId biomeTemplate, int? seed = null)
{
if (!_protomanager.Index(biomeTemplate).Components.TryGetComponent(Factory.GetComponentName<BiomeComponent>(), out var template))
{
return null;
}
var biome = Factory.GetComponent<BiomeComponent>();
var biomeObj = (object)biome;
_serManager.CopyTo(template, ref biomeObj, notNullableOverride: true);
seed ??= _random.Next();
biome.Seed = seed.Value;
AddComp(mapUid, biome, true);
return biome;
}
/// <summary>
/// Creates a simple planet setup for a map.
/// </summary>
public void EnsurePlanet(EntityUid mapUid, EntProtoId biomeTemplate, int? seed = null, MetaDataComponent? metadata = null, Color? mapLight = null)
{
if (!Resolve(mapUid, ref metadata))
return;
EnsureComp<MapGridComponent>(mapUid);
AddBiome(mapUid, biomeTemplate, seed);
var gravity = EnsureComp<GravityComponent>(mapUid);
gravity.Enabled = true;
gravity.Inherent = true;
Dirty(mapUid, gravity, metadata);
var light = EnsureComp<MapLightComponent>(mapUid);
light.AmbientLightColor = mapLight ?? Color.FromHex("#D8B059");
Dirty(mapUid, light, metadata);
EnsureComp<RoofComponent>(mapUid);
EnsureComp<LightCycleComponent>(mapUid);
EnsureComp<SunShadowComponent>(mapUid);
EnsureComp<SunShadowCycleComponent>(mapUid);
var moles = new float[Atmospherics.AdjustedNumberOfGases];
moles[(int)Gas.Oxygen] = 21.824779f;
moles[(int)Gas.Nitrogen] = 82.10312f;
var mixture = new GasMixture(moles, Atmospherics.T20C);
_atmos.SetMapAtmosphere(mapUid, false, mixture);
}
}