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);
}
}
}
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);
}
}
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());
}
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;
}
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;
}
Aggregations