public void RemovedEntitiesDontExists() { var a = entityManager.CreateEntity(empty); var b = entityManager.CreateEntity(empty); Assert.AreNotEqual(a, b); entityManager.DestroyEntity(a); entityManager.DestroyEntity(b); Assert.IsFalse(entityManager.Exist(a)); Assert.IsFalse(entityManager.Exist(b)); }
public void ReusedEntityClearsData() { var e = entityManager.CreateEntity(archetype); entityManager.GetComponent <ComponentA>(e).a = 5; entityManager.GetComponent <ComponentA>(e).b = 4; entityManager.GetComponent <ComponentB>(e).x = int.MaxValue; entityManager.DestroyEntity(e); e = entityManager.CreateEntity(archetype); Assert.AreEqual(0, entityManager.GetComponent <ComponentA>(e).a); Assert.AreEqual(0, entityManager.GetComponent <ComponentA>(e).b); Assert.AreEqual(0, entityManager.GetComponent <ComponentB>(e).x); }
public void TestCreateEntity_ReusingEntities_ReturnsPreviouslyCreatedEntity() { Assert.NotNull(mEntityManager); IEntity newEntity = null; for (uint i = 0; i < 5; ++i) { newEntity = mEntityManager.CreateEntity(null); Assert.NotNull(newEntity); Assert.AreEqual(newEntity.Name, $"Entity{i}"); Assert.AreEqual(newEntity.Id, (EntityId)i); } /// remove some of entities Assert.IsTrue(mEntityManager.DestroyEntity((EntityId)2)); Assert.IsTrue(mEntityManager.DestroyEntity((EntityId)3)); /// recreate them newEntity = mEntityManager.CreateEntity(); Assert.NotNull(newEntity); Assert.AreEqual(newEntity.Id, (EntityId)2); newEntity = mEntityManager.CreateEntity(); Assert.NotNull(newEntity); Assert.AreEqual(newEntity.Id, (EntityId)3); }
/// <summary> /// The method destroy an entity with a given identifier /// </summary> /// <param name="entityId">An entity's identifier</param> /// <returns>The method returns true if the entity was successfully destroyed and false in other cases</returns> public bool DestroyEntity(EntityId entityId) { return(mEntityManager.DestroyEntity(entityId)); }