private void FinishEntitiesInitialization() { foreach (var entity in Entities) { _serverEntityManager.FinishEntityInitialization(entity); } }
public void TestMapIdInitOrder() { // Tests that if a child initializes before its parent, MapID still gets initialized correctly. // Set private _parent field via reflection here. // This basically simulates the field getting set in ExposeData(), with way less test boilerplate. var field = typeof(TransformComponent).GetField("_parent", BindingFlags.NonPublic | BindingFlags.Instance) !; var parent = EntityManager.CreateEntityUninitialized("mapDummy"); var child1 = EntityManager.CreateEntityUninitialized("dummy"); var child2 = EntityManager.CreateEntityUninitialized("dummy"); field.SetValue(child1.Transform, parent.Uid); field.SetValue(child2.Transform, child1.Uid); EntityManager.FinishEntityInitialization(child2); EntityManager.FinishEntityInitialization(child1); EntityManager.FinishEntityInitialization(parent); Assert.That(child2.Transform.MapID, Is.EqualTo(new MapId(123))); Assert.That(child1.Transform.MapID, Is.EqualTo(new MapId(123))); Assert.That(parent.Transform.MapID, Is.EqualTo(new MapId(123))); }