Inline GetComponent

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 11:55:25 +01:00
parent e10bd576ff
commit 86d05dfa1e
26 changed files with 85 additions and 62 deletions

View File

@@ -2,6 +2,7 @@ using System;
using JetBrains.Annotations;
using Robust.Shared.Animations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Robust.Client.Animations
{
@@ -19,7 +20,7 @@ namespace Robust.Client.Animations
}
var entity = (IEntity) context;
var component = entity.GetComponent(ComponentType);
var component = IoCManager.Resolve<IEntityManager>().GetComponent(entity.Uid, ComponentType);
if (component is IAnimationProperties properties)
{

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
namespace Robust.Client.Animations
@@ -39,7 +40,7 @@ namespace Robust.Client.Animations
DebugTools.AssertNotNull(LayerKey);
var entity = (IEntity) context;
var sprite = entity.GetComponent<ISpriteComponent>();
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity.Uid);
var playingTime = prevPlayingTime + frameTime;
var keyFrameIndex = prevKeyFrameIndex;

View File

@@ -43,10 +43,12 @@ namespace Robust.Client.GameObjects
foreach (var grid in _mapManager.FindGridsIntersecting(mapId, worldBounds))
{
yield return EntityManager.GetEntity(grid.GridEntityId).GetComponent<RenderingTreeComponent>();
IEntity tempQualifier = EntityManager.GetEntity(grid.GridEntityId);
yield return IoCManager.Resolve<IEntityManager>().GetComponent<RenderingTreeComponent>(tempQualifier.Uid);
}
yield return _mapManager.GetMapEntity(mapId).GetComponent<RenderingTreeComponent>();
IEntity tempQualifier1 = _mapManager.GetMapEntity(mapId);
yield return IoCManager.Resolve<IEntityManager>().GetComponent<RenderingTreeComponent>(tempQualifier1.Uid);
}
internal IEnumerable<RenderingTreeComponent> GetRenderTrees(MapId mapId, Box2 worldAABB)
@@ -55,10 +57,12 @@ namespace Robust.Client.GameObjects
foreach (var grid in _mapManager.FindGridsIntersecting(mapId, worldAABB))
{
yield return EntityManager.GetEntity(grid.GridEntityId).GetComponent<RenderingTreeComponent>();
IEntity tempQualifier = EntityManager.GetEntity(grid.GridEntityId);
yield return IoCManager.Resolve<IEntityManager>().GetComponent<RenderingTreeComponent>(tempQualifier.Uid);
}
yield return _mapManager.GetMapEntity(mapId).GetComponent<RenderingTreeComponent>();
IEntity tempQualifier1 = _mapManager.GetMapEntity(mapId);
yield return IoCManager.Resolve<IEntityManager>().GetComponent<RenderingTreeComponent>(tempQualifier1.Uid);
}
public override void Initialize()

View File

@@ -6,6 +6,7 @@ using Robust.Client.GameObjects;
using Robust.Client.ResourceManagement;
using Robust.Shared;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
@@ -329,7 +330,8 @@ namespace Robust.Client.Graphics.Clyde
var mapId = eye.Position.MapId;
// If this map has lighting disabled, return
if (!_mapManager.GetMapEntity(mapId).GetComponent<IMapComponent>().LightingEnabled)
IEntity tempQualifier = _mapManager.GetMapEntity(mapId);
if (!IoCManager.Resolve<IEntityManager>().GetComponent<IMapComponent>(tempQualifier.Uid).LightingEnabled)
{
return;
}

View File

@@ -130,7 +130,7 @@ namespace Robust.Client.Graphics.Clyde
throw new ArgumentException("Tried to draw an entity has been deleted.", nameof(entity));
}
var sprite = entity.GetComponent<SpriteComponent>();
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(entity.Uid);
var oldProj = _clyde._currentMatrixProj;
var oldView = _clyde._currentMatrixView;

View File

@@ -90,7 +90,7 @@ namespace Robust.Client.Placement
var sce = pManager.CurrentPlacementOverlayEntity;
if (sce == null || (!IoCManager.Resolve<IEntityManager>().EntityExists(sce.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(sce.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)
return;
var sc = sce.GetComponent<SpriteComponent>();
var sc = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(sce.Uid);
IEnumerable<EntityCoordinates> locationcollection;
switch (pManager.PlacementType)

View File

@@ -87,7 +87,7 @@ namespace Robust.Client.Player
var previous = ControlledEntity;
if (previous is {((!IoCManager.Resolve<IEntityManager>().EntityExists(Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Uid).EntityLifeStage) >= EntityLifeStage.Initialized): true, ((!IoCManager.Resolve<IEntityManager>().EntityExists(Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Uid).EntityLifeStage) >= EntityLifeStage.Deleted): false})
{
previous.GetComponent<EyeComponent>().Current = false;
IoCManager.Resolve<IEntityManager>().GetComponent<EyeComponent>(previous.Uid).Current = false;
// notify ECS Systems
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new PlayerAttachSysMessage(null));

View File

@@ -111,7 +111,8 @@ namespace Robust.Server.Console.Commands
if (mapId == MapId.Nullspace) return;
var pauseManager = IoCManager.Resolve<IPauseManager>();
pauseManager.SetMapPaused(mapId, false);
IoCManager.Resolve<IMapManager>().GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().Gravity = new Vector2(0, -9.8f);
IEntity tempQualifier = IoCManager.Resolve<IMapManager>().GetMapEntity(mapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid).Gravity = new Vector2(0, -9.8f);
return;
}

View File

@@ -447,7 +447,8 @@ namespace Robust.Server.Maps
{
var gridInternal = (IMapGridInternal) grid;
var body = entManager.EnsureComponent<PhysicsComponent>(grid.GridEntityId);
body.Broadphase = _mapManager.GetMapEntity(grid.ParentMapId).GetComponent<BroadphaseComponent>();
IEntity tempQualifier = _mapManager.GetMapEntity(grid.ParentMapId);
body.Broadphase = IoCManager.Resolve<IEntityManager>().GetComponent<BroadphaseComponent>(tempQualifier.Uid);
var fixtures = entManager.EnsureComponent<FixturesComponent>(grid.GridEntityId);
gridFixtures.ProcessGrid(gridInternal);

View File

@@ -53,7 +53,8 @@ namespace Robust.Shared.Scripting
public T gcm<T>(int i)
{
return getent(i).GetComponent<T>();
IEntity tempQualifier = getent(i);
return IoCManager.Resolve<IEntityManager>().GetComponent<T>(tempQualifier.Uid);
}
public IEntity getent(EntityUid uid)

View File

@@ -842,7 +842,10 @@ namespace Robust.Shared.GameObjects
// TODO: Ordering fuckery need a new PR to fix some of this stuff
if (Owner.Transform.MapID != MapId.Nullspace)
PhysicsMap = IoCManager.Resolve<IMapManager>().GetMapEntity(Owner.Transform.MapID).GetComponent<SharedPhysicsMapComponent>();
{
IEntity tempQualifier = IoCManager.Resolve<IMapManager>().GetMapEntity(Owner.Transform.MapID);
PhysicsMap = IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid);
}
Dirty();
// Yeah yeah TODO Combine these

View File

@@ -427,7 +427,8 @@ namespace Robust.Shared.GameObjects
{
if (value && _mapManager.TryFindGridAt(MapPosition, out var grid))
{
_anchored = IoCManager.Resolve<IEntityManager>().GetEntity(grid.GridEntityId).GetComponent<IMapGridComponent>().AnchorEntity(this);
IEntity tempQualifier = IoCManager.Resolve<IEntityManager>().GetEntity(grid.GridEntityId);
_anchored = IoCManager.Resolve<IEntityManager>().GetComponent<IMapGridComponent>(tempQualifier.Uid).AnchorEntity(this);
}
// If no grid found then unanchor it.
else
@@ -437,7 +438,8 @@ namespace Robust.Shared.GameObjects
}
else if (value && !_anchored && _mapManager.TryFindGridAt(MapPosition, out var grid))
{
_anchored = IoCManager.Resolve<IEntityManager>().GetEntity(grid.GridEntityId).GetComponent<IMapGridComponent>().AnchorEntity(this);
IEntity tempQualifier = IoCManager.Resolve<IEntityManager>().GetEntity(grid.GridEntityId);
_anchored = IoCManager.Resolve<IEntityManager>().GetComponent<IMapGridComponent>(tempQualifier.Uid).AnchorEntity(this);
}
else if (!value && _anchored)
{

View File

@@ -259,7 +259,7 @@ namespace Robust.Shared.GameObjects
/// <summary>
/// A list of type references that can be used to get a reference to an instance of this component,
/// for methods like <see cref="Robust.Shared.GameObjects.IEntity.GetComponent{T}" />.
/// for methods like GetComponent.
/// These are not unique and can overlap with other components.
/// </summary>
IReadOnlyList<Type> References { get; }

View File

@@ -41,10 +41,6 @@ namespace Robust.Shared.GameObjects
#endregion Initialization
#region Component Messaging
#endregion Component Messaging
#region Components
public bool HasComponent<T>()
@@ -57,16 +53,6 @@ namespace Robust.Shared.GameObjects
return IoCManager.Resolve<IEntityManager>().HasComponent(Uid, type);
}
public T GetComponent<T>()
{
return IoCManager.Resolve<IEntityManager>().GetComponent<T>(Uid);
}
public IComponent GetComponent(Type type)
{
return IoCManager.Resolve<IEntityManager>().GetComponent(Uid, type);
}
public bool TryGetComponent<T>([NotNullWhen(true)] out T? component) where T : class
{
return IoCManager.Resolve<IEntityManager>().TryGetComponent(Uid, out component);

View File

@@ -306,7 +306,8 @@ namespace Robust.Shared.GameObjects
}
_final = true;
component = _mapManager.GetMapEntity(_mapId).GetComponent<EntityLookupComponent>();
IEntity tempQualifier = _mapManager.GetMapEntity(_mapId);
component = IoCManager.Resolve<IEntityManager>().GetComponent<EntityLookupComponent>(tempQualifier.Uid);
return true;
}

View File

@@ -38,10 +38,12 @@ namespace Robust.Shared.GameObjects
foreach (var grid in _mapManager.FindGridsIntersecting(mapId, worldAABB))
{
yield return EntityManager.GetEntity(grid.GridEntityId).GetComponent<OccluderTreeComponent>();
IEntity tempQualifier = EntityManager.GetEntity(grid.GridEntityId);
yield return IoCManager.Resolve<IEntityManager>().GetComponent<OccluderTreeComponent>(tempQualifier.Uid);
}
yield return _mapManager.GetMapEntity(mapId).GetComponent<OccluderTreeComponent>();
IEntity tempQualifier1 = _mapManager.GetMapEntity(mapId);
yield return IoCManager.Resolve<IEntityManager>().GetComponent<OccluderTreeComponent>(tempQualifier1.Uid);
}
private void HandleOccluderInit(EntityUid uid, OccluderComponent component, ComponentInit args)

View File

@@ -241,13 +241,15 @@ namespace Robust.Shared.GameObjects
var oldMapId = message.OldMapId;
if (oldMapId != MapId.Nullspace)
{
MapManager.GetMapEntity(oldMapId).GetComponent<SharedPhysicsMapComponent>().RemoveBody(physicsComponent);
IEntity tempQualifier = MapManager.GetMapEntity(oldMapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid).RemoveBody(physicsComponent);
}
var newMapId = message.Entity.Transform.MapID;
if (newMapId != MapId.Nullspace)
{
MapManager.GetMapEntity(newMapId).GetComponent<SharedPhysicsMapComponent>().AddBody(physicsComponent);
IEntity tempQualifier = MapManager.GetMapEntity(newMapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid).AddBody(physicsComponent);
}
}
@@ -260,11 +262,13 @@ namespace Robust.Shared.GameObjects
if (message.Component.Deleted || !message.Component.CanCollide)
{
MapManager.GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().RemoveBody(message.Component);
IEntity tempQualifier = MapManager.GetMapEntity(mapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid).RemoveBody(message.Component);
}
else
{
MapManager.GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().AddBody(message.Component);
IEntity tempQualifier = MapManager.GetMapEntity(mapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid).AddBody(message.Component);
}
}
@@ -275,7 +279,8 @@ namespace Robust.Shared.GameObjects
if (mapId == MapId.Nullspace)
return;
MapManager.GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().AddAwakeBody(message.Body);
IEntity tempQualifier = MapManager.GetMapEntity(mapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid).AddAwakeBody(message.Body);
}
private void HandleSleepMessage(PhysicsSleepMessage message)
@@ -285,7 +290,8 @@ namespace Robust.Shared.GameObjects
if (mapId == MapId.Nullspace)
return;
MapManager.GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().RemoveSleepBody(message.Body);
IEntity tempQualifier = MapManager.GetMapEntity(mapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid).RemoveSleepBody(message.Body);
}
private void HandleContainerInserted(EntInsertedIntoContainerMessage message)
@@ -299,7 +305,10 @@ namespace Robust.Shared.GameObjects
Get<SharedJointSystem>().ClearJoints(physicsComponent);
if (mapId != MapId.Nullspace)
MapManager.GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().RemoveBody(physicsComponent);
{
IEntity tempQualifier = MapManager.GetMapEntity(mapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid).RemoveBody(physicsComponent);
}
}
private void HandleContainerRemoved(EntRemovedFromContainerMessage message)
@@ -309,7 +318,10 @@ namespace Robust.Shared.GameObjects
var mapId = message.Container.Owner.Transform.MapID;
if (mapId != MapId.Nullspace)
MapManager.GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().AddBody(physicsComponent);
{
IEntity tempQualifier = MapManager.GetMapEntity(mapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid).AddBody(physicsComponent);
}
}
/// <summary>

View File

@@ -52,8 +52,10 @@ namespace Robust.Shared.Physics.Dynamics.Joints
public override Joint GetJoint()
{
var entityManager = IoCManager.Resolve<IEntityManager>();
var bodyA = entityManager.GetEntity(UidA).GetComponent<PhysicsComponent>();
var bodyB = entityManager.GetEntity(UidB).GetComponent<PhysicsComponent>();
IEntity tempQualifier = entityManager.GetEntity(UidA);
var bodyA = IoCManager.Resolve<IEntityManager>().GetComponent<PhysicsComponent>(tempQualifier.Uid);
IEntity tempQualifier1 = entityManager.GetEntity(UidB);
var bodyB = IoCManager.Resolve<IEntityManager>().GetComponent<PhysicsComponent>(tempQualifier1.Uid);
var joint = new FrictionJoint(bodyA, bodyB)
{

View File

@@ -280,7 +280,8 @@ namespace Robust.Shared.Physics
// FindNewContacts is inherently going to be a lot slower than Box2D's normal version so we need
// to cache a bunch of stuff to make up for it.
var contactManager = _mapManager.GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().ContactManager;
IEntity tempQualifier = _mapManager.GetMapEntity(mapId);
var contactManager = IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier.Uid).ContactManager;
// TODO: Could store fixtures by broadphase for more perf?
foreach (var (proxy, worldAABB) in moveBuffer)

View File

@@ -44,7 +44,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
Assert.That(container.ID, Is.EqualTo("dummy"));
Assert.That(container.Owner, Is.EqualTo(entity));
var manager = entity.GetComponent<IContainerManager>();
var manager = IoCManager.Resolve<IEntityManager>().GetComponent<IContainerManager>(entity.Uid);
Assert.That(container.Manager, Is.EqualTo(manager));
Assert.That(() => ContainerHelpers.CreateContainer<Container>(entity, "dummy"), Throws.ArgumentException);
@@ -264,7 +264,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
container.ShowContents = true;
container.Insert(childEnt);
var containerMan = entity.GetComponent<IContainerManager>();
var containerMan = IoCManager.Resolve<IEntityManager>().GetComponent<IContainerManager>(entity.Uid);
var state = (ContainerManagerComponent.ContainerManagerComponentState)containerMan.GetComponentState();
Assert.That(state.ContainerSet.Count, Is.EqualTo(1));

View File

@@ -117,7 +117,7 @@ entities:
Assert.That(grid, NUnit.Framework.Is.Not.Null);
var entity = entMan.GetEntity(grid!.GridEntityId).Transform.Children.Single().Owner;
var c = entity.GetComponent<MapDeserializeTestComponent>();
var c = IoCManager.Resolve<IEntityManager>().GetComponent<MapDeserializeTestComponent>(entity.Uid);
Assert.That(c.Bar, Is.EqualTo(2));
Assert.That(c.Foo, Is.EqualTo(3));

View File

@@ -183,7 +183,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
Assert.That(dummyOne, Is.Not.Null);
var dummyComp = dummyOne.GetComponent<TestOneComponent>();
var dummyComp = IoCManager.Resolve<IEntityManager>().GetComponent<TestOneComponent>(dummyOne.Uid);
Assert.That(dummyComp.TestTwo, Is.Not.Null);
Assert.That(dummyComp.TestThree, Is.Not.Null);
@@ -205,7 +205,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
Assert.That(dummyTwo, Is.Not.Null);
var dummyTwoComp = dummyTwo.GetComponent<TestTwoComponent>();
var dummyTwoComp = IoCManager.Resolve<IEntityManager>().GetComponent<TestTwoComponent>(dummyTwo.Uid);
// This dependency should be resolved.
Assert.That(dummyTwoComp.TestTwo, Is.Not.Null);
@@ -216,7 +216,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
Assert.That(dummyThree, Is.Not.Null);
var dummyThreeComp = dummyThree.GetComponent<TestThreeComponent>();
var dummyThreeComp = IoCManager.Resolve<IEntityManager>().GetComponent<TestThreeComponent>(dummyThree.Uid);
// This dependency should be unresolved.
Assert.That(dummyThreeComp.TestOne, Is.Null);
@@ -226,7 +226,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
Assert.That(dummyFour, Is.Not.Null);
var dummyFourComp = dummyFour.GetComponent<TestFourComponent>();
var dummyFourComp = IoCManager.Resolve<IEntityManager>().GetComponent<TestFourComponent>(dummyFour.Uid);
// This dependency should be resolved.
Assert.That(dummyFourComp.TestInterface, Is.Not.Null);
@@ -242,7 +242,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
Assert.That(dummyThree, Is.Not.Null);
var dummyThreeComp = dummyThree.GetComponent<TestThreeComponent>();
var dummyThreeComp = IoCManager.Resolve<IEntityManager>().GetComponent<TestThreeComponent>(dummyThree.Uid);
// This dependency should be unresolved at first.
Assert.That(dummyThreeComp.TestOne, Is.Null);
@@ -292,7 +292,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
Assert.That(dummyOne, Is.Not.Null);
var dummyComp = dummyOne.GetComponent<TestOneComponent>();
var dummyComp = IoCManager.Resolve<IEntityManager>().GetComponent<TestOneComponent>(dummyOne.Uid);
// They must be resolved.
Assert.That(dummyComp.TestTwo, Is.Not.Null);
@@ -418,7 +418,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
Assert.That(dummyFour, Is.Not.Null);
var dummyComp = dummyFour.GetComponent<TestFourComponent>();
var dummyComp = IoCManager.Resolve<IEntityManager>().GetComponent<TestFourComponent>(dummyFour.Uid);
// TestInterface must be resolved.
Assert.That(dummyComp.TestInterface, Is.Not.Null);
@@ -437,7 +437,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
Assert.That(dummyFour, Is.Not.Null);
var dummyComp = dummyFour.GetComponent<TestFourComponent>();
var dummyComp = IoCManager.Resolve<IEntityManager>().GetComponent<TestFourComponent>(dummyFour.Uid);
// TestInterface must be resolved.
Assert.That(dummyComp.TestInterface, Is.Not.Null);

View File

@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
@@ -34,8 +35,8 @@ namespace Robust.UnitTesting.Shared.Map
gridId2 = mapManager.CreateGrid(mapId);
gridEnt1 = entManager.GetEntity(gridId1.GridEntityId);
gridEnt2 = entManager.GetEntity(gridId2.GridEntityId);
physics1 = gridEnt1.GetComponent<PhysicsComponent>();
physics2 = gridEnt2.GetComponent<PhysicsComponent>();
physics1 = IoCManager.Resolve<IEntityManager>().GetComponent<PhysicsComponent>(gridEnt1.Uid);
physics2 = IoCManager.Resolve<IEntityManager>().GetComponent<PhysicsComponent>(gridEnt2.Uid);
// Can't collide static bodies and grids (at time of this writing) start as static
// (given most other games would probably prefer them as static) hence we need to make them dynamic.
physics1.BodyType = BodyType.Dynamic;

View File

@@ -121,7 +121,7 @@ namespace Robust.UnitTesting.Shared.Map
Assert.That((!IoCManager.Resolve<IEntityManager>().EntityExists(oldMapEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(oldMapEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted);
Assert.That(newMapEntity.HasComponent<IMapComponent>());
var mapComp = newMapEntity.GetComponent<IMapComponent>();
var mapComp = IoCManager.Resolve<IEntityManager>().GetComponent<IMapComponent>(newMapEntity.Uid);
Assert.That(mapComp.WorldMap == mapID);
}

View File

@@ -61,7 +61,8 @@ namespace Robust.UnitTesting.Shared.Physics
{
mapId = mapManager.CreateMap();
mapManager.GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().Gravity = new Vector2(0, -9.8f);
IEntity tempQualifier2 = mapManager.GetMapEntity(mapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier2.Uid).Gravity = new Vector2(0, -9.8f);
IEntity tempQualifier = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId));
var ground = IoCManager.Resolve<IEntityManager>().AddComponent<PhysicsComponent>(tempQualifier);
@@ -177,7 +178,8 @@ namespace Robust.UnitTesting.Shared.Physics
await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
mapManager.GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().Gravity = new Vector2(0, -9.8f);
IEntity tempQualifier2 = mapManager.GetMapEntity(mapId);
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(tempQualifier2.Uid).Gravity = new Vector2(0, -9.8f);
IEntity tempQualifier = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId));
var ground = IoCManager.Resolve<IEntityManager>().AddComponent<PhysicsComponent>(tempQualifier);

View File

@@ -59,7 +59,7 @@ namespace Robust.UnitTesting.Shared.Prototypes
{
_maps.CreateNewMapEntity(new MapId(0));
var entity = _entities.SpawnEntity(DummyId, MapCoordinates.Nullspace);
var entityComponent = entity.GetComponent<HotReloadTestComponentOne>();
var entityComponent = IoCManager.Resolve<IEntityManager>().GetComponent<HotReloadTestComponentOne>(entity.Uid);
Assert.That(entityComponent.Value, Is.EqualTo(5));
Assert.False(entity.HasComponent<HotReloadTestComponentTwo>());