use of com.artemis.Component in project commons-gdx by gemserk.
the class EntityDebugger method debug.
public static void debug(String message, Entity e) {
System.out.println(message);
System.out.println("e.id=" + e.getId());
System.out.println("e.uniqueId=" + e.getUniqueId());
ImmutableBag<Component> components = e.getComponents();
for (int i = 0; i < components.size(); i++) {
Component component = components.get(i);
System.out.println("e.component=" + component.getClass().getSimpleName());
}
}
use of com.artemis.Component in project commons-gdx by gemserk.
the class ComponentMapperInitHelper method config.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void config(Object target, EntityManager entityManager) {
try {
for (Field field : target.getClass().getDeclaredFields()) {
String fieldName = field.getName();
Class<?> fieldType = field.getType();
if (ComponentMapper.class.isAssignableFrom(fieldType)) {
System.out.println("ComponentMapper detected: " + fieldName);
ParameterizedType genericType = (ParameterizedType) field.getGenericType();
Class componentType = (Class) genericType.getActualTypeArguments()[0];
ComponentMapper<Component> componentMapper = new ComponentMapper<Component>(componentType, entityManager);
field.setAccessible(true);
field.set(target, componentMapper);
}
}
} catch (Exception e) {
throw new RuntimeException("Error while setting component mappers", e);
}
}
Aggregations