Add new entity spawn test & fix misc bugs (#19953)

This commit is contained in:
Leon Friedrich
2023-10-16 16:54:10 +11:00
committed by GitHub
parent 1f0c9314fd
commit 00e274ea38
14 changed files with 149 additions and 36 deletions

View File

@@ -78,12 +78,12 @@ public static class EntitySpawnCollection
/// <param name="entries">The entity spawn entries.</param>
/// <param name="random">Resolve param.</param>
/// <returns>A list of entity prototypes that should be spawned.</returns>
public static List<string?> GetSpawns(IEnumerable<EntitySpawnEntry> entries,
public static List<string> GetSpawns(IEnumerable<EntitySpawnEntry> entries,
IRobustRandom? random = null)
{
IoCManager.Resolve(ref random);
var spawned = new List<string?>();
var spawned = new List<string>();
var ungrouped = CollectOrGroups(entries, out var orGroupedSpawns);
foreach (var entry in ungrouped)
@@ -93,6 +93,9 @@ public static class EntitySpawnCollection
if (entry.SpawnProbability != 1f && !random.Prob(entry.SpawnProbability))
continue;
if (entry.PrototypeId == null)
continue;
var amount = (int) entry.GetAmount(random);
for (var i = 0; i < amount; i++)
@@ -116,6 +119,9 @@ public static class EntitySpawnCollection
if (diceRoll > cumulative)
continue;
if (entry.PrototypeId == null)
break;
// Dice roll succeeded, add item and break loop
var amount = (int) entry.GetAmount(random);