Fix misc construction bugs (#15600)

This commit is contained in:
Leon Friedrich
2023-04-21 16:01:35 +12:00
committed by GitHub
parent e13e398424
commit d1d13f4ef1
5 changed files with 12 additions and 23 deletions

View File

@@ -14,11 +14,12 @@ namespace Content.Server.Construction.Completions
[DataField("container")] public string Container { get; private set; } = string.Empty;
// TODO use or generalize ConstructionSystem.ChangeEntity();
// TODO pass in node/edge & graph ID for better error logs.
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
{
Logger.Warning($"Computer entity {uid} did not have a container manager! Aborting build computer action.");
Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} did not have a container manager! Aborting build computer action.");
return;
}
@@ -26,20 +27,21 @@ namespace Content.Server.Construction.Completions
if (!containerSystem.TryGetContainer(uid, Container, out var container, containerManager))
{
Logger.Warning($"Computer entity {uid} did not have the specified '{Container}' container! Aborting build computer action.");
Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} did not have the specified '{Container}' container! Aborting build computer action.");
return;
}
if (container.ContainedEntities.Count != 1)
{
Logger.Warning($"Computer entity {uid} did not have exactly one item in the specified '{Container}' container! Aborting build computer action.");
Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} did not have exactly one item in the specified '{Container}' container! Aborting build computer action.");
return;
}
var board = container.ContainedEntities[0];
if (!entityManager.TryGetComponent(board, out ComputerBoardComponent? boardComponent))
{
Logger.Warning($"Computer entity {uid} had an invalid entity in container \"{Container}\"! Aborting build computer action.");
Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} had an invalid entity in container \"{Container}\"! Aborting build computer action.");
return;
}