Search in sources :

Example 41 with Entity

use of com.artemis.Entity in project commons-gdx by gemserk.

the class ScriptSystem 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);
        ArrayList<Script> scripts = entityComponents.scripts;
        int size = scripts.size();
        for (int i = 0; i < size; i++) {
            Script script = scripts.get(i);
            Entity entity = allTheEntityComponents.getKey(entityIndex);
            script.update(world, entity);
        }
    }
}
Also used : Entity(com.artemis.Entity) Script(com.gemserk.commons.artemis.scripts.Script)

Example 42 with Entity

use of com.artemis.Entity in project commons-gdx by gemserk.

the class SpriteUpdateSystem method processEntities.

@Override
protected void processEntities() {
    RandomAccessMap<Entity, EntityComponents> allTheEntityComponents = factory.entityComponents;
    int entitiesSize = allTheEntityComponents.size();
    for (int entityIndex = 0; entityIndex < entitiesSize; entityIndex++) {
        EntityComponents components = allTheEntityComponents.get(entityIndex);
        SpatialComponent spatialComponent = components.spatialComponent;
        SpriteComponent spriteComponent = components.spriteComponent;
        PreviousStateSpatialComponent previousStateSpatialComponent = components.previousStateSpatialComponent;
        Spatial spatial = spatialComponent.getSpatial();
        float x = spatial.getX();
        float y = spatial.getY();
        float angle = spatial.getAngle();
        if (previousStateSpatialComponent != null) {
            float interpolationAlpha = timeStepProvider.getAlpha();
            Spatial previousSpatial = previousStateSpatialComponent.getSpatial();
            x = FloatInterpolator.interpolate(previousSpatial.getX(), spatial.getX(), interpolationAlpha);
            y = FloatInterpolator.interpolate(previousSpatial.getY(), spatial.getY(), interpolationAlpha);
            float angleDiff = (float) AngleUtils.minimumDifference(previousSpatial.getAngle(), spatial.getAngle());
            angle = FloatInterpolator.interpolate(spatial.getAngle() - angleDiff, spatial.getAngle(), interpolationAlpha);
        }
        spriteComponent.update(x, y, spatial.getWidth(), spatial.getHeight(), angle);
    }
}
Also used : Entity(com.artemis.Entity) SpriteComponent(com.gemserk.commons.artemis.components.SpriteComponent) Spatial(com.gemserk.commons.gdx.games.Spatial) PreviousStateSpatialComponent(com.gemserk.commons.artemis.components.PreviousStateSpatialComponent) SpatialComponent(com.gemserk.commons.artemis.components.SpatialComponent) PreviousStateSpatialComponent(com.gemserk.commons.artemis.components.PreviousStateSpatialComponent)

Example 43 with Entity

use of com.artemis.Entity in project commons-gdx by gemserk.

the class TagSystem method removed.

@Override
protected void removed(Entity e) {
    super.removed(e);
    TagComponent tagComponent = e.getComponent(tagComponentClass);
    Entity entityWithTag = world.getTagManager().getEntity(tagComponent.getTag());
    if (entityWithTag == null)
        return;
    if (entityWithTag != e)
        return;
    world.getTagManager().unregister(tagComponent.getTag());
}
Also used : Entity(com.artemis.Entity) TagComponent(com.gemserk.commons.artemis.components.TagComponent)

Example 44 with Entity

use of com.artemis.Entity in project commons-gdx by gemserk.

the class EntityFactoryImpl method instantiate.

@Override
public Entity instantiate(EntityTemplate template, Parameters parameters) {
    Entity entity = world.createEntity();
    template.setParameters(parameters);
    template.apply(entity);
    entity.refresh();
    return entity;
}
Also used : Entity(com.artemis.Entity)

Example 45 with Entity

use of com.artemis.Entity in project commons-gdx by gemserk.

the class EntityFactoryImpl method instantiate.

@Override
public Entity instantiate() {
    Entity entity = world.createEntity();
    entity.refresh();
    return entity;
}
Also used : Entity(com.artemis.Entity)

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