use of com.artemis.Entity in project commons-gdx by gemserk.
the class GetComponentPerformanceTest method testTimeWithGetComponentUsingTypeAndClass.
public long testTimeWithGetComponentUsingTypeAndClass(int iterations) {
World world = new World();
Entity e = world.createEntity();
e.addComponent(new MyTestComponent());
e.refresh();
ComponentType myTestComponentType = ComponentTypeManager.getTypeFor(MyTestComponent.class);
long startNanoTime = System.nanoTime();
for (int i = 0; i < iterations; i++) {
// MyTestComponent myTestComponent = MyTestComponent.class.cast(e.getComponent(myTestComponentType.getId()));
MyTestComponent.class.cast(e.getComponent(myTestComponentType.getId()));
}
return System.nanoTime() - startNanoTime;
}
use of com.artemis.Entity in project commons-gdx by gemserk.
the class EntityBuilderNew method build.
public Entity build() {
checkEntityCreated();
Entity builtEntity = entity;
entity = null;
builtEntity.refresh();
return builtEntity;
}
use of com.artemis.Entity in project commons-gdx by gemserk.
the class HierarchySystem method removed.
@Override
protected void removed(Entity entity) {
ParentComponent parentComponent = entity.getComponent(ParentComponent.class);
// if for some reason the entity parent component was removed before this method was called
if (parentComponent == null)
return;
entity.removeComponent(parentComponent);
ArrayList<Entity> children = parentComponent.getChildren();
for (int i = 0; i < children.size(); i++) {
Entity child = children.get(i);
world.deleteEntity(child);
}
}
use of com.artemis.Entity in project commons-gdx by gemserk.
the class OrderedByLayerEntitiesTest method shouldReturnSubEntityBeforeAnotherEntityIfParentEntityBeforeThatOne.
@Test
public void shouldReturnSubEntityBeforeAnotherEntityIfParentEntityBeforeThatOne() {
World world = new World();
Entity e1 = world.createEntity();
Entity e2 = world.createEntity();
Entity e3 = world.createEntity();
e1.addComponent(new RenderableComponent(5, 0));
e2.addComponent(new RenderableComponent(5));
e3.addComponent(new RenderableComponent(5, 1, true));
e3.addComponent(new OwnerComponent(e1));
orderedByLayerEntities.add(e1);
orderedByLayerEntities.add(e2);
orderedByLayerEntities.add(e3);
assertSame(orderedByLayerEntities.get(0), e1);
assertSame(orderedByLayerEntities.get(1), e3);
assertSame(orderedByLayerEntities.get(2), e2);
}
use of com.artemis.Entity in project commons-gdx by gemserk.
the class OrderedByLayerEntitiesTest method bugEntityWithNullOwner.
@Test
public void bugEntityWithNullOwner() {
World world = new World();
Entity e1 = world.createEntity();
Entity e2 = world.createEntity();
e1.addComponent(new RenderableComponent(5));
e2.addComponent(new RenderableComponent(5));
e2.addComponent(new OwnerComponent(null));
orderedByLayerEntities.add(e1);
orderedByLayerEntities.add(e2);
assertSame(orderedByLayerEntities.get(0), e1);
assertSame(orderedByLayerEntities.get(1), e2);
}
Aggregations