diff --git a/Content.Server/Parallax/BiomeSystem.cs b/Content.Server/Parallax/BiomeSystem.cs index edf0305e4d..889cd0185b 100644 --- a/Content.Server/Parallax/BiomeSystem.cs +++ b/Content.Server/Parallax/BiomeSystem.cs @@ -362,7 +362,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem var loadedMarkers = component.LoadedMarkers; var spawnSet = new HashSet(); var spawns = new List(); - var frontier = new Queue(); + var frontier = new ValueList(); foreach (var (layer, chunks) in markers) { @@ -426,11 +426,14 @@ public sealed partial class BiomeSystem : SharedBiomeSystem } // BFS search - frontier.Enqueue(point); + frontier.Add(point); var groupCount = layerProto.GroupCount; - while (frontier.TryDequeue(out var node) && groupCount > 0) + while (frontier.Count > 0 && groupCount > 0) { + var frontierIndex = _random.Next(frontier.Count); + var node = frontier[frontierIndex]; + frontier.RemoveSwap(frontierIndex); var enumerator = grid.GetAnchoredEntitiesEnumerator(node); if (enumerator.MoveNext(out _)) @@ -463,7 +466,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem if (!spawnSet.Contains(neighbor)) continue; - frontier.Enqueue(neighbor); + frontier.Add(neighbor); // Rather than doing some uggo remove check on the list we'll defer it until later spawnSet.Remove(neighbor); } diff --git a/Content.Server/Salvage/SpawnSalvageMissionJob.cs b/Content.Server/Salvage/SpawnSalvageMissionJob.cs index 0cc6d6c628..aba46e08dd 100644 --- a/Content.Server/Salvage/SpawnSalvageMissionJob.cs +++ b/Content.Server/Salvage/SpawnSalvageMissionJob.cs @@ -205,6 +205,15 @@ public sealed class SpawnSalvageMissionJob : Job } // Handle loot + // We'll always add this loot if possible + foreach (var lootProto in _prototypeManager.EnumeratePrototypes()) + { + if (!lootProto.Guaranteed) + continue; + + await SpawnDungeonLoot(dungeon, lootProto, mapUid, grid, random, reservedTiles); + } + foreach (var (loot, count) in mission.Loot) { for (var i = 0; i < count; i++) diff --git a/Content.Shared/Procedural/Loot/SalvageLootPrototype.cs b/Content.Shared/Procedural/Loot/SalvageLootPrototype.cs index c485e15cf3..f5f8ab3fb2 100644 --- a/Content.Shared/Procedural/Loot/SalvageLootPrototype.cs +++ b/Content.Shared/Procedural/Loot/SalvageLootPrototype.cs @@ -12,6 +12,11 @@ public sealed class SalvageLootPrototype : IPrototype { [IdDataField] public string ID { get; } = default!; + /// + /// Should this loot always spawn if possible. Used for stuff such as ore. + /// + [DataField("guaranteed")] public bool Guaranteed; + [DataField("desc")] public string Description = string.Empty; /// diff --git a/Content.Shared/Salvage/SharedSalvageSystem.cs b/Content.Shared/Salvage/SharedSalvageSystem.cs index 2461476bd1..0eae88598a 100644 --- a/Content.Shared/Salvage/SharedSalvageSystem.cs +++ b/Content.Shared/Salvage/SharedSalvageSystem.cs @@ -120,7 +120,7 @@ public abstract class SharedSalvageSystem : EntitySystem mods.Add(time.Description); } - var loots = GetLoot(config, _proto.EnumeratePrototypes().ToList(), GetDifficulty(difficulty), seed); + var loots = GetLoot(config, _proto.EnumeratePrototypes().Where(o => !o.Guaranteed).ToList(), GetDifficulty(difficulty), seed); return new SalvageMission(seed, difficulty, dungeon.ID, faction.ID, config, biome.ID, light?.Color, duration, loots, mods); } diff --git a/Resources/Prototypes/Procedural/biome_ore_templates.yml b/Resources/Prototypes/Procedural/biome_ore_templates.yml index 37686eef57..e55eea8be0 100644 --- a/Resources/Prototypes/Procedural/biome_ore_templates.yml +++ b/Resources/Prototypes/Procedural/biome_ore_templates.yml @@ -3,7 +3,7 @@ id: OreTin proto: WallRockTin entityMask: WallRock - maxCount: 5 + maxCount: 15 groupCount: 10 radius: 4 @@ -13,7 +13,7 @@ id: OreGold proto: WallRockGold entityMask: WallRock - maxCount: 5 + maxCount: 15 groupCount: 5 radius: 4 @@ -22,7 +22,7 @@ id: OreSilver proto: WallRockSilver entityMask: WallRock - maxCount: 5 + maxCount: 15 groupCount: 5 radius: 4 @@ -32,7 +32,7 @@ id: OrePlasma proto: WallRockPlasma entityMask: WallRock - maxCount: 2 + maxCount: 6 groupCount: 5 radius: 4 @@ -41,7 +41,7 @@ id: OreUranium proto: WallRockUranium entityMask: WallRock - maxCount: 2 + maxCount: 6 groupCount: 5 radius: 4 @@ -49,6 +49,6 @@ id: OreBananium proto: WallRockBananium entityMask: WallRock - maxCount: 2 + maxCount: 6 groupCount: 5 radius: 4 diff --git a/Resources/Prototypes/Procedural/salvage_loot.yml b/Resources/Prototypes/Procedural/salvage_loot.yml index c02177c617..3b2519b63b 100644 --- a/Resources/Prototypes/Procedural/salvage_loot.yml +++ b/Resources/Prototypes/Procedural/salvage_loot.yml @@ -55,6 +55,7 @@ - type: salvageLoot id: OreTin desc: Veins of steel + guaranteed: true loots: - !type:BiomeMarkerLoot proto: OreTin @@ -63,6 +64,7 @@ - type: salvageLoot id: OreGold desc: Veins of gold ore + guaranteed: true loots: - !type:BiomeMarkerLoot proto: OreGold @@ -70,6 +72,7 @@ - type: salvageLoot id: OreSilver desc: Veins of silver ore + guaranteed: true loots: - !type:BiomeMarkerLoot proto: OreSilver @@ -78,6 +81,7 @@ - type: salvageLoot id: OrePlasma desc: Veins of plasma ore + guaranteed: true loots: - !type:BiomeMarkerLoot proto: OrePlasma @@ -85,6 +89,7 @@ - type: salvageLoot id: OreUranium desc: Veins of uranium ore + guaranteed: true loots: - !type:BiomeMarkerLoot proto: OreUranium diff --git a/Resources/Prototypes/ore.yml b/Resources/Prototypes/ore.yml index 0aa111b9f0..9837e3143f 100644 --- a/Resources/Prototypes/ore.yml +++ b/Resources/Prototypes/ore.yml @@ -2,46 +2,32 @@ - type: ore id: OreSteel oreEntity: SteelOre1 - minOreYield: 3 - maxOreYield: 7 - type: ore id: OreSpaceQuartz oreEntity: SpaceQuartz1 - minOreYield: 3 - maxOreYield: 7 # Medium yields - type: ore id: OreGold oreEntity: GoldOre1 - minOreYield: 2 - maxOreYield: 5 - type: ore id: OreSilver oreEntity: SilverOre1 - minOreYield: 2 - maxOreYield: 5 # Low yields - type: ore id: OrePlasma oreEntity: PlasmaOre1 - minOreYield: 1 - maxOreYield: 3 - type: ore id: OreUranium oreEntity: UraniumOre1 - minOreYield: 1 - maxOreYield: 3 - type: ore id: OreBananium oreEntity: BananiumOre1 - minOreYield: 1 - maxOreYield: 3 - type: weightedRandom id: RandomOreDistributionStandard