use of com.artemis.Entity in project commons-gdx by gemserk.
the class EntityBuilder method build.
public Entity build() {
Entity e = world.createEntity();
if (tag != null)
e.setTag(tag);
for (int i = 0; i < components.size(); i++) e.addComponent(components.get(i));
e.refresh();
reset();
return e;
}
use of com.artemis.Entity in project commons-gdx by gemserk.
the class AliveSystem method processEntities.
@Override
protected void processEntities() {
RandomAccessMap<Entity, EntityComponents> allTheEntityComponents = factory.entityComponents;
int entitiesSize = allTheEntityComponents.size();
for (int entityIndex = 0; entityIndex < entitiesSize; entityIndex++) {
EntityComponents entityComponents = allTheEntityComponents.get(entityIndex);
AliveComponent aliveComponent = entityComponents.aliveComponent;
float aliveTime = aliveComponent.getTime() - GlobalTime.getDelta();
aliveComponent.setTime(aliveTime);
if (aliveTime <= 0) {
Entity e = allTheEntityComponents.getKey(entityIndex);
StoreComponent storeComponent = StoreComponent.get(e);
if (storeComponent != null)
storeComponent.store.free(e);
else
e.delete();
}
}
}
use of com.artemis.Entity in project commons-gdx by gemserk.
the class ContainerSystem method disabled.
@Override
protected void disabled(Entity e) {
ContainerComponent containerComponent = ContainerComponent.get(e);
for (int i = 0; i < containerComponent.getChildren().size(); i++) {
Entity child = containerComponent.getChildren().get(i);
// what about the stores?
StoreComponent storeComponent = StoreComponent.get(child);
if (storeComponent != null)
storeComponent.store.free(child);
else
child.delete();
}
}
use of com.artemis.Entity in project commons-gdx by gemserk.
the class PhysicsContactListener method endContact.
@Override
public void endContact(Contact contact) {
Body bodyA = contact.getFixtureA().getBody();
Body bodyB = contact.getFixtureB().getBody();
Entity entityA = (Entity) bodyA.getUserData();
Entity entityB = (Entity) bodyB.getUserData();
removeBodyFromContacts(entityA, contact, true);
removeBodyFromContacts(entityB, contact, false);
}
use of com.artemis.Entity in project commons-gdx by gemserk.
the class PhysicsContactListener method preSolve.
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
if (!contact.isTouching())
return;
Body bodyA = contact.getFixtureA().getBody();
Body bodyB = contact.getFixtureB().getBody();
Entity entityA = (Entity) bodyA.getUserData();
Entity entityB = (Entity) bodyB.getUserData();
executePreSolveListener(entityA, contact, true);
executePreSolveListener(entityB, contact, false);
}
Aggregations