Add new entity spawn test & fix misc bugs (#19953)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ using Robust.Shared.Network;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -260,9 +261,12 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
}
|
||||
|
||||
_joints.RecursiveClearJoints(toInsert);
|
||||
if (!component.Contents.Insert(toInsert, EntityManager))
|
||||
return false;
|
||||
|
||||
var inside = EnsureComp<InsideEntityStorageComponent>(toInsert);
|
||||
inside.Storage = container;
|
||||
return component.Contents.Insert(toInsert, EntityManager);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Remove(EntityUid toRemove, EntityUid container, SharedEntityStorageComponent? component = null, TransformComponent? xform = null)
|
||||
|
||||
Reference in New Issue
Block a user