Inline GetComponent

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 11:55:25 +01:00
parent c2e6da1e54
commit b835bea086
131 changed files with 363 additions and 299 deletions

View File

@@ -171,12 +171,12 @@ namespace Content.Client.Construction
}
var ghost = EntityManager.SpawnEntity("constructionghost", loc);
var comp = ghost.GetComponent<ConstructionGhostComponent>();
var comp = IoCManager.Resolve<IEntityManager>().GetComponent<ConstructionGhostComponent>(ghost.Uid);
comp.Prototype = prototype;
comp.GhostId = _nextId++;
ghost.Transform.LocalRotation = dir.ToAngle();
_ghosts.Add(comp.GhostId, comp);
var sprite = ghost.GetComponent<SpriteComponent>();
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(ghost.Uid);
sprite.Color = new Color(48, 255, 48, 128);
sprite.AddBlankLayer(0); // There is no way to actually check if this already exists, so we blindly insert a new one
sprite.LayerSetSprite(0, prototype.Icon);

View File

@@ -2,6 +2,7 @@
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Construction
{
@@ -14,7 +15,7 @@ namespace Content.Client.Construction
if (component.TryGetData<int>(MachineFrameVisuals.State, out var data))
{
var sprite = component.Owner.GetComponent<ISpriteComponent>();
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner.Uid);
sprite.LayerSetState(0, $"box_{data}");
}