Add space debris to salvage magnet (#31113)

* add space debris to salvage magnet

* multiplication

* necessary mercy for NPCs

* back and forth on mercy
This commit is contained in:
Nemanja
2024-08-23 22:09:36 -04:00
committed by GitHub
parent 907411d0d1
commit b52686ea38
9 changed files with 251 additions and 53 deletions

View File

@@ -53,9 +53,9 @@ public sealed class SalvageMagnetBoundUserInterface : BoundUserInterface
option.Claimed = current.ActiveSeed == seed; option.Claimed = current.ActiveSeed == seed;
var claimIndex = i; var claimIndex = i;
option.ClaimPressed += args => option.ClaimPressed += _ =>
{ {
SendMessage(new MagnetClaimOfferEvent() SendMessage(new MagnetClaimOfferEvent
{ {
Index = claimIndex Index = claimIndex
}); });
@@ -72,20 +72,20 @@ public sealed class SalvageMagnetBoundUserInterface : BoundUserInterface
{ {
var count = asteroid.MarkerLayers[resource]; var count = asteroid.MarkerLayers[resource];
var container = new BoxContainer() var container = new BoxContainer
{ {
Orientation = BoxContainer.LayoutOrientation.Horizontal, Orientation = BoxContainer.LayoutOrientation.Horizontal,
HorizontalExpand = true, HorizontalExpand = true,
}; };
var resourceLabel = new Label() var resourceLabel = new Label
{ {
Text = Loc.GetString("salvage-magnet-resources", Text = Loc.GetString("salvage-magnet-resources",
("resource", resource)), ("resource", resource)),
HorizontalAlignment = Control.HAlignment.Left, HorizontalAlignment = Control.HAlignment.Left,
}; };
var countLabel = new Label() var countLabel = new Label
{ {
Text = Loc.GetString("salvage-magnet-resources-count", ("count", count)), Text = Loc.GetString("salvage-magnet-resources-count", ("count", count)),
HorizontalAlignment = Control.HAlignment.Right, HorizontalAlignment = Control.HAlignment.Right,
@@ -98,6 +98,9 @@ public sealed class SalvageMagnetBoundUserInterface : BoundUserInterface
option.AddContent(container); option.AddContent(container);
} }
break;
case DebrisOffering debris:
option.Title = Loc.GetString($"salvage-magnet-debris-{debris.Id}");
break; break;
case SalvageOffering salvage: case SalvageOffering salvage:
option.Title = Loc.GetString($"salvage-map-wreck"); option.Title = Loc.GetString($"salvage-map-wreck");

View File

@@ -44,7 +44,7 @@ public sealed partial class SalvageMagnetDataComponent : Component
public List<int> Offered = new(); public List<int> Offered = new();
[DataField] [DataField]
public int OfferCount = 6; public int OfferCount = 5;
[DataField] [DataField]
public int ActiveSeed; public int ActiveSeed;

View File

@@ -4,6 +4,7 @@ using System.Threading.Tasks;
using Content.Server.Salvage.Magnet; using Content.Server.Salvage.Magnet;
using Content.Shared.Humanoid; using Content.Shared.Humanoid;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;
using Content.Shared.Procedural;
using Content.Shared.Radio; using Content.Shared.Radio;
using Content.Shared.Salvage.Magnet; using Content.Shared.Salvage.Magnet;
using Robust.Server.Maps; using Robust.Server.Maps;
@@ -269,6 +270,11 @@ public sealed partial class SalvageSystem
var grid = _mapManager.CreateGridEntity(salvMap); var grid = _mapManager.CreateGridEntity(salvMap);
await _dungeon.GenerateDungeonAsync(asteroid.DungeonConfig, grid.Owner, grid.Comp, Vector2i.Zero, seed); await _dungeon.GenerateDungeonAsync(asteroid.DungeonConfig, grid.Owner, grid.Comp, Vector2i.Zero, seed);
break; break;
case DebrisOffering debris:
var debrisProto = _prototypeManager.Index<DungeonConfigPrototype>(debris.Id);
var debrisGrid = _mapManager.CreateGridEntity(salvMap);
await _dungeon.GenerateDungeonAsync(debrisProto, debrisGrid.Owner, debrisGrid.Comp, Vector2i.Zero, seed);
break;
case SalvageOffering wreck: case SalvageOffering wreck:
var salvageProto = wreck.SalvageMap; var salvageProto = wreck.SalvageMap;
@@ -309,7 +315,7 @@ public sealed partial class SalvageSystem
bounds = bounds?.Union(childAABB) ?? childAABB; bounds = bounds?.Union(childAABB) ?? childAABB;
// Update mass scanner names as relevant. // Update mass scanner names as relevant.
if (offering is AsteroidOffering) if (offering is AsteroidOffering or DebrisOffering)
{ {
_metaData.SetEntityName(mapChild, Loc.GetString("salvage-asteroid-name")); _metaData.SetEntityName(mapChild, Loc.GetString("salvage-asteroid-name"));
_gravity.EnableGravity(mapChild); _gravity.EnableGravity(mapChild);

View File

@@ -2134,7 +2134,7 @@ namespace Content.Shared.CCVar
/// Whether or not world generation is enabled. /// Whether or not world generation is enabled.
/// </summary> /// </summary>
public static readonly CVarDef<bool> WorldgenEnabled = public static readonly CVarDef<bool> WorldgenEnabled =
CVarDef.Create("worldgen.enabled", true, CVar.SERVERONLY); CVarDef.Create("worldgen.enabled", false, CVar.SERVERONLY);
/// <summary> /// <summary>
/// The worldgen config to use. /// The worldgen config to use.

View File

@@ -0,0 +1,9 @@
namespace Content.Shared.Salvage.Magnet;
/// <summary>
/// Space debis offered for the magnet.
/// </summary>
public record struct DebrisOffering : ISalvageMagnetOffering
{
public string Id;
}

View File

@@ -5,6 +5,7 @@ using Content.Shared.Random;
using Content.Shared.Random.Helpers; using Content.Shared.Random.Helpers;
using Content.Shared.Salvage.Magnet; using Content.Shared.Salvage.Magnet;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility; using Robust.Shared.Utility;
namespace Content.Shared.Salvage; namespace Content.Shared.Salvage;
@@ -13,6 +14,13 @@ public abstract partial class SharedSalvageSystem
{ {
private readonly List<SalvageMapPrototype> _salvageMaps = new(); private readonly List<SalvageMapPrototype> _salvageMaps = new();
private Dictionary<ISalvageMagnetOffering, float> _offeringWeights = new()
{
{ new AsteroidOffering(), 3.0f },
{ new DebrisOffering(), 4.0f },
{ new SalvageOffering(), 1.0f }
};
private readonly List<ProtoId<DungeonConfigPrototype>> _asteroidConfigs = new() private readonly List<ProtoId<DungeonConfigPrototype>> _asteroidConfigs = new()
{ {
"BlobAsteroid", "BlobAsteroid",
@@ -25,13 +33,19 @@ public abstract partial class SharedSalvageSystem
private readonly MinMax _asteroidOreCount = new(5, 7); private readonly MinMax _asteroidOreCount = new(5, 7);
private readonly List<ProtoId<DungeonConfigPrototype>> _debrisConfigs = new()
{
"ChunkDebris"
};
public ISalvageMagnetOffering GetSalvageOffering(int seed) public ISalvageMagnetOffering GetSalvageOffering(int seed)
{ {
var rand = new System.Random(seed); var rand = new System.Random(seed);
// Asteroid seed var type = SharedRandomExtensions.Pick(_offeringWeights, rand);
if (seed % 2 == 0) switch (type)
{ {
case AsteroidOffering:
var configId = _asteroidConfigs[rand.Next(_asteroidConfigs.Count)]; var configId = _asteroidConfigs[rand.Next(_asteroidConfigs.Count)];
var configProto =_proto.Index(configId); var configProto =_proto.Index(configId);
var layers = new Dictionary<string, int>(); var layers = new Dictionary<string, int>();
@@ -39,7 +53,7 @@ public abstract partial class SharedSalvageSystem
var data = new DungeonData(); var data = new DungeonData();
data.Apply(configProto.Data); data.Apply(configProto.Data);
var config = new DungeonConfig() var config = new DungeonConfig
{ {
Data = data, Data = data,
Layers = new(configProto.Layers), Layers = new(configProto.Layers),
@@ -68,8 +82,13 @@ public abstract partial class SharedSalvageSystem
DungeonConfig = config, DungeonConfig = config,
MarkerLayers = layers, MarkerLayers = layers,
}; };
} case DebrisOffering:
var id = rand.Pick(_debrisConfigs);
return new DebrisOffering
{
Id = id
};
case SalvageOffering:
// Salvage map seed // Salvage map seed
_salvageMaps.Clear(); _salvageMaps.Clear();
_salvageMaps.AddRange(_proto.EnumeratePrototypes<SalvageMapPrototype>()); _salvageMaps.AddRange(_proto.EnumeratePrototypes<SalvageMapPrototype>());
@@ -77,9 +96,12 @@ public abstract partial class SharedSalvageSystem
var mapIndex = rand.Next(_salvageMaps.Count); var mapIndex = rand.Next(_salvageMaps.Count);
var map = _salvageMaps[mapIndex]; var map = _salvageMaps[mapIndex];
return new SalvageOffering() return new SalvageOffering
{ {
SalvageMap = map, SalvageMap = map,
}; };
default:
throw new NotImplementedException($"Salvage type {type} not implemented!");
}
} }
} }

View File

@@ -31,6 +31,9 @@ salvage-magnet-resources-count = {$count ->
*[other] (Extraordinary) *[other] (Extraordinary)
} }
# Debris
salvage-magnet-debris-ChunkDebris = Space Debris
# Asteroids # Asteroids
dungeon-config-proto-BlobAsteroid = Asteroid clump dungeon-config-proto-BlobAsteroid = Asteroid clump
dungeon-config-proto-ClusterAsteroid = Asteroid cluster dungeon-config-proto-ClusterAsteroid = Asteroid cluster

View File

@@ -0,0 +1,40 @@
- type: dungeonConfig
id: ChunkDebris
# Floor generation
layers:
- !type:NoiseDunGen
tileCap: 500
capStd: 32
iterations: 5
layers:
- tile: FloorSteel
threshold: 0.50
noise:
frequency: 0.05
noiseType: OpenSimplex2
fractalType: FBm
octaves: 3
lacunarity: 3
gain: 0.5
- tile: Plating
threshold: 0.35
noise:
frequency: 0.05
noiseType: OpenSimplex2
fractalType: FBm
octaves: 3
lacunarity: 3
gain: 0.3
- tile: Lattice
threshold: 0.25
noise:
frequency: 0.05
noiseType: OpenSimplex2
fractalType: FBm
octaves: 3
lacunarity: 3
gain: 0.5
# Generate biome
- !type:BiomeDunGen
biomeTemplate: SpaceDebris

View File

@@ -0,0 +1,115 @@
# Asteroid
- type: biomeTemplate
id: SpaceDebris
layers:
- !type:BiomeEntityLayer
threshold: 0.20
noise:
seed: 0
noiseType: OpenSimplex2
fractalType: Ridged
octaves: 4
frequency: 0.065
gain: 5
lacunarity: 1.5
allowedTiles:
- Plating
- FloorSteel
entities:
- WallSolid
- AirlockMaintLocked
- Girder
- Girder
- WallReinforced
- WallSolid
- WallSolid
- !type:BiomeEntityLayer
threshold: 0.5
noise:
seed: 0
noiseType: OpenSimplex2
fractalType: Ridged
octaves: 4
frequency: 0.065
gain: 2
lacunarity: 1.5
allowedTiles:
- Plating
- Lattice
entities:
- Grille
- Grille
- Grille
- GrilleBroken
- !type:BiomeDecalLayer
allowedTiles:
- FloorSteel
threshold: -0.5
divisions: 1
noise:
seed: 1
frequency: 1
decals:
- DirtHeavy
- DirtHeavy
- DirtHeavy
- DirtMedium
- DirtMedium
- DirtLight
- !type:BiomeEntityLayer
threshold: 0.45
noise:
seed: 1
noiseType: OpenSimplex2
fractalType: Ridged
octaves: 4
frequency: 0.065
gain: 2
lacunarity: 1.5
allowedTiles:
- Plating
- FloorSteel
entities:
- WeldingFuelTankFull
- Table
- SalvageCanisterSpawner
- Rack
- ClosetMaintenanceFilledRandom
- ClosetMaintenanceFilledRandom
- !type:BiomeEntityLayer
allowedTiles:
- FloorSteel
- Plating
threshold: 0.2
noise:
seed: 1
frequency: 1
entities:
- SalvageSpawnerScrapCommon
- SalvageSpawnerScrapCommon75
- SalvageSpawnerScrapCommon75
- SalvageSpawnerScrapValuable
- SalvageSpawnerScrapValuable75
- !type:BiomeEntityLayer
allowedTiles:
- FloorSteel
threshold: 0.7
noise:
seed: 1
frequency: 1
entities:
- SalvageSpawnerTreasureValuable
- SalvageSpawnerEquipmentValuable
- SalvageSpawnerTreasure
- SalvageSpawnerTreasure
- SalvageSpawnerEquipment
- SalvageSpawnerEquipment
- !type:BiomeEntityLayer
allowedTiles:
- FloorSteel
threshold: 0.85
noise:
seed: 1
frequency: 1
entities:
- SalvageSpawnerMobMagnet75