Inline TryGetComponent completely, for real

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:17:01 +01:00
parent 2ff4ec65d5
commit 69b270017b
425 changed files with 1143 additions and 995 deletions

View File

@@ -5,6 +5,7 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -53,7 +54,7 @@ namespace Content.Server.Construction.Completions
var board = entBoardContainer.ContainedEntities[0];
if (!board.TryGetComponent(out MachineBoardComponent? boardComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(board.Uid, out MachineBoardComponent? boardComponent))
{
Logger.Warning($"Machine frame entity {uid} had an invalid entity in container \"{MachineFrameComponent.BoardContainer}\"! Aborting build machine action.");
return;
@@ -91,14 +92,14 @@ namespace Content.Server.Construction.Completions
}
var constructionSystem = entityManager.EntitySysManager.GetEntitySystem<ConstructionSystem>();
if (machine.TryGetComponent(out ConstructionComponent? construction))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(machine.Uid, out ConstructionComponent? construction))
{
// We only add these two container. If some construction needs to take other containers into account, fix this.
constructionSystem.AddContainer(machine.Uid, MachineFrameComponent.BoardContainer, construction);
constructionSystem.AddContainer(machine.Uid, MachineFrameComponent.PartContainer, construction);
}
if (machine.TryGetComponent(out MachineComponent? machineComp))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(machine.Uid, out MachineComponent? machineComp))
{
machineComp.RefreshParts();
}