Fix spawning glass shard for each glass sheet in stack (#25308)
* fix: SpawnEntitiesBehavior now works with stacks Fixed the issue of SpawnEntitiesBehavior not executing multiple times on entities with stack conponent. Fixes #25287 * fix: reduced dictionary iterations
This commit is contained in:
@@ -31,7 +31,15 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
|
||||
var getRandomVector = () => new Vector2(system.Random.NextFloat(-Offset, Offset), system.Random.NextFloat(-Offset, Offset));
|
||||
|
||||
var executions = 1;
|
||||
if (system.EntityManager.TryGetComponent<StackComponent>(owner, out var stack))
|
||||
{
|
||||
executions = stack.Count;
|
||||
}
|
||||
|
||||
foreach (var (entityId, minMax) in Spawn)
|
||||
{
|
||||
for (var execution = 0; execution < executions; execution++)
|
||||
{
|
||||
var count = minMax.Min >= minMax.Max
|
||||
? minMax.Min
|
||||
@@ -57,6 +65,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void TransferForensics(EntityUid spawned, DestructibleSystem system, EntityUid owner)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user