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:
@@ -53,9 +53,9 @@ public sealed class SalvageMagnetBoundUserInterface : BoundUserInterface
|
||||
option.Claimed = current.ActiveSeed == seed;
|
||||
var claimIndex = i;
|
||||
|
||||
option.ClaimPressed += args =>
|
||||
option.ClaimPressed += _ =>
|
||||
{
|
||||
SendMessage(new MagnetClaimOfferEvent()
|
||||
SendMessage(new MagnetClaimOfferEvent
|
||||
{
|
||||
Index = claimIndex
|
||||
});
|
||||
@@ -72,20 +72,20 @@ public sealed class SalvageMagnetBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
var count = asteroid.MarkerLayers[resource];
|
||||
|
||||
var container = new BoxContainer()
|
||||
var container = new BoxContainer
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Horizontal,
|
||||
HorizontalExpand = true,
|
||||
};
|
||||
|
||||
var resourceLabel = new Label()
|
||||
var resourceLabel = new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-magnet-resources",
|
||||
("resource", resource)),
|
||||
HorizontalAlignment = Control.HAlignment.Left,
|
||||
};
|
||||
|
||||
var countLabel = new Label()
|
||||
var countLabel = new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-magnet-resources-count", ("count", count)),
|
||||
HorizontalAlignment = Control.HAlignment.Right,
|
||||
@@ -98,6 +98,9 @@ public sealed class SalvageMagnetBoundUserInterface : BoundUserInterface
|
||||
option.AddContent(container);
|
||||
}
|
||||
|
||||
break;
|
||||
case DebrisOffering debris:
|
||||
option.Title = Loc.GetString($"salvage-magnet-debris-{debris.Id}");
|
||||
break;
|
||||
case SalvageOffering salvage:
|
||||
option.Title = Loc.GetString($"salvage-map-wreck");
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed partial class SalvageMagnetDataComponent : Component
|
||||
public List<int> Offered = new();
|
||||
|
||||
[DataField]
|
||||
public int OfferCount = 6;
|
||||
public int OfferCount = 5;
|
||||
|
||||
[DataField]
|
||||
public int ActiveSeed;
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using Content.Server.Salvage.Magnet;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Procedural;
|
||||
using Content.Shared.Radio;
|
||||
using Content.Shared.Salvage.Magnet;
|
||||
using Robust.Server.Maps;
|
||||
@@ -269,6 +270,11 @@ public sealed partial class SalvageSystem
|
||||
var grid = _mapManager.CreateGridEntity(salvMap);
|
||||
await _dungeon.GenerateDungeonAsync(asteroid.DungeonConfig, grid.Owner, grid.Comp, Vector2i.Zero, seed);
|
||||
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:
|
||||
var salvageProto = wreck.SalvageMap;
|
||||
|
||||
@@ -309,7 +315,7 @@ public sealed partial class SalvageSystem
|
||||
bounds = bounds?.Union(childAABB) ?? childAABB;
|
||||
|
||||
// Update mass scanner names as relevant.
|
||||
if (offering is AsteroidOffering)
|
||||
if (offering is AsteroidOffering or DebrisOffering)
|
||||
{
|
||||
_metaData.SetEntityName(mapChild, Loc.GetString("salvage-asteroid-name"));
|
||||
_gravity.EnableGravity(mapChild);
|
||||
|
||||
@@ -2134,7 +2134,7 @@ namespace Content.Shared.CCVar
|
||||
/// Whether or not world generation is enabled.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> WorldgenEnabled =
|
||||
CVarDef.Create("worldgen.enabled", true, CVar.SERVERONLY);
|
||||
CVarDef.Create("worldgen.enabled", false, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// The worldgen config to use.
|
||||
|
||||
9
Content.Shared/Salvage/Magnet/DebrisOffering.cs
Normal file
9
Content.Shared/Salvage/Magnet/DebrisOffering.cs
Normal 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;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Random;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Salvage.Magnet;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Salvage;
|
||||
@@ -13,6 +14,13 @@ public abstract partial class SharedSalvageSystem
|
||||
{
|
||||
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()
|
||||
{
|
||||
"BlobAsteroid",
|
||||
@@ -25,13 +33,19 @@ public abstract partial class SharedSalvageSystem
|
||||
|
||||
private readonly MinMax _asteroidOreCount = new(5, 7);
|
||||
|
||||
private readonly List<ProtoId<DungeonConfigPrototype>> _debrisConfigs = new()
|
||||
{
|
||||
"ChunkDebris"
|
||||
};
|
||||
|
||||
public ISalvageMagnetOffering GetSalvageOffering(int seed)
|
||||
{
|
||||
var rand = new System.Random(seed);
|
||||
|
||||
// Asteroid seed
|
||||
if (seed % 2 == 0)
|
||||
var type = SharedRandomExtensions.Pick(_offeringWeights, rand);
|
||||
switch (type)
|
||||
{
|
||||
case AsteroidOffering:
|
||||
var configId = _asteroidConfigs[rand.Next(_asteroidConfigs.Count)];
|
||||
var configProto =_proto.Index(configId);
|
||||
var layers = new Dictionary<string, int>();
|
||||
@@ -39,7 +53,7 @@ public abstract partial class SharedSalvageSystem
|
||||
var data = new DungeonData();
|
||||
data.Apply(configProto.Data);
|
||||
|
||||
var config = new DungeonConfig()
|
||||
var config = new DungeonConfig
|
||||
{
|
||||
Data = data,
|
||||
Layers = new(configProto.Layers),
|
||||
@@ -68,8 +82,13 @@ public abstract partial class SharedSalvageSystem
|
||||
DungeonConfig = config,
|
||||
MarkerLayers = layers,
|
||||
};
|
||||
}
|
||||
|
||||
case DebrisOffering:
|
||||
var id = rand.Pick(_debrisConfigs);
|
||||
return new DebrisOffering
|
||||
{
|
||||
Id = id
|
||||
};
|
||||
case SalvageOffering:
|
||||
// Salvage map seed
|
||||
_salvageMaps.Clear();
|
||||
_salvageMaps.AddRange(_proto.EnumeratePrototypes<SalvageMapPrototype>());
|
||||
@@ -77,9 +96,12 @@ public abstract partial class SharedSalvageSystem
|
||||
var mapIndex = rand.Next(_salvageMaps.Count);
|
||||
var map = _salvageMaps[mapIndex];
|
||||
|
||||
return new SalvageOffering()
|
||||
return new SalvageOffering
|
||||
{
|
||||
SalvageMap = map,
|
||||
};
|
||||
default:
|
||||
throw new NotImplementedException($"Salvage type {type} not implemented!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ salvage-magnet-resources-count = {$count ->
|
||||
*[other] (Extraordinary)
|
||||
}
|
||||
|
||||
# Debris
|
||||
salvage-magnet-debris-ChunkDebris = Space Debris
|
||||
|
||||
# Asteroids
|
||||
dungeon-config-proto-BlobAsteroid = Asteroid clump
|
||||
dungeon-config-proto-ClusterAsteroid = Asteroid cluster
|
||||
|
||||
40
Resources/Prototypes/Procedural/Magnet/space_debris.yml
Normal file
40
Resources/Prototypes/Procedural/Magnet/space_debris.yml
Normal 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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user