Construction graph improvements (#17960)
This commit is contained in:
committed by
GitHub
parent
fbf1d476f2
commit
9243050e1a
@@ -84,32 +84,6 @@ namespace Content.IntegrationTests.Tests.Construction
|
||||
Assert.That(valid, Is.True, $"One or more SpawnPrototype actions specified invalid entity prototypes!\n{message}");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ConstructionGraphNodeEntityPrototypeValid()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var protoMan = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
var valid = true;
|
||||
var message = new StringBuilder();
|
||||
|
||||
foreach (var graph in protoMan.EnumeratePrototypes<ConstructionGraphPrototype>())
|
||||
{
|
||||
foreach (var node in graph.Nodes.Values)
|
||||
{
|
||||
if (string.IsNullOrEmpty(node.Entity) || protoMan.TryIndex(node.Entity, out EntityPrototype _)) continue;
|
||||
|
||||
valid = false;
|
||||
message.Append($"Invalid entity prototype \"{node.Entity}\" on node \"{node.Name}\" of graph \"{graph.ID}\"\n");
|
||||
}
|
||||
}
|
||||
await pairTracker.CleanReturnAsync();
|
||||
|
||||
Assert.That(valid, Is.True, $"One or more nodes specified invalid entity prototypes!\n{message}");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ConstructionGraphEdgeValid()
|
||||
{
|
||||
|
||||
@@ -124,6 +124,7 @@ namespace Content.IntegrationTests.Tests.Construction
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var protoMan = server.ResolveDependency<IPrototypeManager>();
|
||||
var entMan = server.ResolveDependency<IEntityManager>();
|
||||
|
||||
foreach (var proto in protoMan.EnumeratePrototypes<ConstructionPrototype>())
|
||||
{
|
||||
@@ -135,8 +136,9 @@ namespace Content.IntegrationTests.Tests.Construction
|
||||
Assert.That(graph.TryPath(start, target, out var path), $"Unable to find path from \"{start}\" to \"{target}\" on graph \"{graph.ID}\"");
|
||||
Assert.That(path, Has.Length.GreaterThanOrEqualTo(1), $"Unable to find path from \"{start}\" to \"{target}\" on graph \"{graph.ID}\".");
|
||||
var next = path[0];
|
||||
Assert.That(next.Entity, Is.Not.Null, $"The next node ({next.Name}) in the path from the start node ({start}) to the target node ({target}) must specify an entity! Graph: {graph.ID}");
|
||||
Assert.That(protoMan.TryIndex(next.Entity, out EntityPrototype entity), $"The next node ({next.Name}) in the path from the start node ({start}) to the target node ({target}) specified an invalid entity prototype ({next.Entity})");
|
||||
var nextId = next.Entity.GetId(null, null, new(entMan));
|
||||
Assert.That(nextId, Is.Not.Null, $"The next node ({next.Name}) in the path from the start node ({start}) to the target node ({target}) must specify an entity! Graph: {graph.ID}");
|
||||
Assert.That(protoMan.TryIndex(nextId, out EntityPrototype entity), $"The next node ({next.Name}) in the path from the start node ({start}) to the target node ({target}) specified an invalid entity prototype ({nextId} [{next.Entity}])");
|
||||
Assert.That(entity.Components.ContainsKey("Construction"), $"The next node ({next.Name}) in the path from the start node ({start}) to the target node ({target}) specified an entity prototype ({next.Entity}) without a ConstructionComponent.");
|
||||
#pragma warning restore NUnit2045
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user