MaterialComponent cleanup (#13326)

This commit is contained in:
Leon Friedrich
2023-01-08 11:36:32 +13:00
committed by GitHub
parent 89301629f5
commit 1f5bae751f
12 changed files with 70 additions and 75 deletions

View File

@@ -38,20 +38,30 @@ namespace Content.IntegrationTests.Tests.Materials
var allMaterialProtos = prototypeManager.EnumeratePrototypes<MaterialPrototype>();
var coords = testMap.GridCoords;
foreach (var proto in allMaterialProtos)
Assert.Multiple(() =>
{
if (proto.StackEntity == "")
continue;
foreach (var proto in allMaterialProtos)
{
if (proto.StackEntity == "")
continue;
var spawned = entityManager.SpawnEntity(proto.StackEntity, coords);
var spawned = entityManager.SpawnEntity(proto.StackEntity, coords);
Assert.That(entityManager.HasComponent<StackComponent>(spawned),
$"{proto.ID} 'stack entity' {proto.StackEntity} has the stack component");
Assert.That(entityManager.TryGetComponent<StackComponent>(spawned, out var stack),
$"{proto.ID} 'stack entity' {proto.StackEntity} does not have the stack component");
Assert.That(entityManager.HasComponent<MaterialComponent>(spawned),
$"{proto.ID} 'material stack' {proto.StackEntity} has the material component");
}
Assert.That(entityManager.HasComponent<MaterialComponent>(spawned),
$"{proto.ID} 'material stack' {proto.StackEntity} does not have the material component");
StackPrototype? stackProto = null;
Assert.That(stack?.StackTypeId != null && prototypeManager.TryIndex(stack.StackTypeId, out stackProto),
$"{proto.ID} material has no stack prototype");
if (stackProto != null)
Assert.That(proto.StackEntity, Is.EqualTo(stackProto.Spawn));
}
});
mapManager.DeleteMap(testMap.MapId);
});
}