Search in sources :

Example 1 with Entity

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;
}
Also used : Entity(com.artemis.Entity)

Example 2 with Entity

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();
        }
    }
}
Also used : Entity(com.artemis.Entity) AliveComponent(com.gemserk.commons.artemis.components.AliveComponent) StoreComponent(com.gemserk.commons.artemis.components.StoreComponent)

Example 3 with Entity

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();
    }
}
Also used : Entity(com.artemis.Entity) ContainerComponent(com.gemserk.commons.artemis.components.ContainerComponent) StoreComponent(com.gemserk.commons.artemis.components.StoreComponent)

Example 4 with Entity

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);
}
Also used : Entity(com.artemis.Entity) Body(com.badlogic.gdx.physics.box2d.Body)

Example 5 with Entity

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);
}
Also used : Entity(com.artemis.Entity) Body(com.badlogic.gdx.physics.box2d.Body)

Aggregations

Entity (com.artemis.Entity)59 World (com.artemis.World)38 Test (org.junit.Test)31 RenderableComponent (com.gemserk.commons.artemis.components.RenderableComponent)16 OwnerComponent (com.gemserk.commons.artemis.components.OwnerComponent)15 WorldWrapper (com.gemserk.commons.artemis.WorldWrapper)8 EntityFactory (com.gemserk.commons.artemis.templates.EntityFactory)6 EntityFactoryImpl (com.gemserk.commons.artemis.templates.EntityFactoryImpl)6 EntityTemplate (com.gemserk.commons.artemis.templates.EntityTemplate)6 Spatial (com.gemserk.commons.gdx.games.Spatial)6 SpatialComponent (com.gemserk.commons.artemis.components.SpatialComponent)5 Body (com.badlogic.gdx.physics.box2d.Body)4 ContainerComponent (com.gemserk.commons.artemis.components.ContainerComponent)4 StoreComponent (com.gemserk.commons.artemis.components.StoreComponent)4 ParametersWrapper (com.gemserk.componentsengine.utils.ParametersWrapper)3 ComponentType (com.artemis.ComponentType)2 PreviousStateSpatialComponent (com.gemserk.commons.artemis.components.PreviousStateSpatialComponent)2 SpriteComponent (com.gemserk.commons.artemis.components.SpriteComponent)2 Script (com.gemserk.commons.artemis.scripts.Script)2 Container (com.gemserk.componentsengine.utils.Container)2