Salvage magnet revamp (#23119)
* Generic offering window * More work * weh * Parity * Progression meter * magnet * rona * PG asteroid work * code red * Asteroid spawnings * clams * a * Marker fixes * More fixes * Workings of biome asteroids * A * Fix this loading code * a * Fix masking * weh * Fixes * Magnet claiming * toe * petogue * magnet * Bunch of fixes * Fix default * Fixes * asteroids * Fix offerings * Localisation and a bunch of fixes * a * Fixes * Preliminary draft * Announcement fixes * Fixes and bump spawn rate * Fix asteroid spawns and UI * More fixes * Expeditions fix * fix * Gravity * Fix announcement rounding * a * Offset tweak * sus * jankass * Fix merge
This commit is contained in:
69
Content.Shared/Salvage/SharedSalvageSystem.Magnet.cs
Normal file
69
Content.Shared/Salvage/SharedSalvageSystem.Magnet.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using Content.Shared.Procedural;
|
||||
using Content.Shared.Procedural.PostGeneration;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Salvage.Magnet;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Salvage;
|
||||
|
||||
public abstract partial class SharedSalvageSystem
|
||||
{
|
||||
private readonly List<SalvageMapPrototype> _salvageMaps = new();
|
||||
|
||||
private readonly List<ProtoId<DungeonConfigPrototype>> _asteroidConfigs = new()
|
||||
{
|
||||
"BlobAsteroid",
|
||||
"ClusterAsteroid",
|
||||
"SpindlyAsteroid",
|
||||
"SwissCheeseAsteroid"
|
||||
};
|
||||
|
||||
public ISalvageMagnetOffering GetSalvageOffering(int seed)
|
||||
{
|
||||
var rand = new System.Random(seed);
|
||||
|
||||
// Asteroid seed
|
||||
if (seed % 2 == 0)
|
||||
{
|
||||
var config = _asteroidConfigs[rand.Next(_asteroidConfigs.Count)];
|
||||
var layerRand = new System.Random(seed);
|
||||
var configProto = _proto.Index(config);
|
||||
var layers = new Dictionary<string, int>();
|
||||
|
||||
// If we ever add more random layers will need to Next on these.
|
||||
foreach (var layer in configProto.PostGeneration)
|
||||
{
|
||||
switch (layer)
|
||||
{
|
||||
case BiomeMarkerLayerPostGen marker:
|
||||
for (var i = 0; i < marker.Count; i++)
|
||||
{
|
||||
var proto = _proto.Index(marker.MarkerTemplate).Pick(layerRand);
|
||||
var layerCount = layers.GetOrNew(proto);
|
||||
layerCount++;
|
||||
layers[proto] = layerCount;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new AsteroidOffering
|
||||
{
|
||||
DungeonConfig = configProto,
|
||||
MarkerLayers = layers,
|
||||
};
|
||||
}
|
||||
|
||||
// Salvage map seed
|
||||
_salvageMaps.Clear();
|
||||
_salvageMaps.AddRange(_proto.EnumeratePrototypes<SalvageMapPrototype>());
|
||||
var mapIndex = rand.Next(_salvageMaps.Count);
|
||||
var map = _salvageMaps[mapIndex];
|
||||
|
||||
return new SalvageOffering()
|
||||
{
|
||||
SalvageMap = map,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user