Dynamic space world generation and debris. (#15120)

* World generation (squash)

* Test fixes.

* command

* o

* Access cleanup.

* Documentation touchups.

* Use a prototype serializer for BiomeSelectionComponent

* Struct enumerator in SimpleFloorPlanPopulatorSystem

* Safety margins around PoissonDiskSampler, cookie acquisition methodologies

* Struct enumerating PoissonDiskSampler; internal side

* Struct enumerating PoissonDiskSampler: Finish it

* Update WorldgenConfigSystem.cs

awa

---------

Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
Co-authored-by: 20kdc <asdd2808@gmail.com>
This commit is contained in:
Moony
2023-05-16 06:36:45 -05:00
committed by GitHub
parent cdb46778dc
commit e91fc652a3
54 changed files with 2748 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
using Content.Server.Worldgen.Components;
using Content.Server.Worldgen.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.Worldgen.Systems;
/// <summary>
/// This handles the noise index.
/// </summary>
public sealed class NoiseIndexSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IRobustRandom _random = default!;
/// <summary>
/// Gets a particular noise channel from the index on the given entity.
/// </summary>
/// <param name="holder">The holder of the index</param>
/// <param name="protoId">The channel prototype ID</param>
/// <returns>An initialized noise generator</returns>
public NoiseGenerator Get(EntityUid holder, string protoId)
{
var idx = EnsureComp<NoiseIndexComponent>(holder);
if (idx.Generators.TryGetValue(protoId, out var generator))
return generator;
var proto = _prototype.Index<NoiseChannelPrototype>(protoId);
var gen = new NoiseGenerator(proto, _random.Next());
idx.Generators[protoId] = gen;
return gen;
}
/// <summary>
/// Attempts to evaluate the given noise channel using the generator on the given entity.
/// </summary>
/// <param name="holder">The holder of the index</param>
/// <param name="protoId">The channel prototype ID</param>
/// <param name="coords">The coordinates to evaluate at</param>
/// <returns>The result of evaluation</returns>
public float Evaluate(EntityUid holder, string protoId, Vector2 coords)
{
var gen = Get(holder, protoId);
return gen.Evaluate(coords);
}
}