Search in sources :

Example 1 with ComponentFieldUri

use of org.terasology.engine.core.ComponentFieldUri in project Terasology by MovingBlocks.

the class BehaviorNodeFactory method determineAnimationPoolUris.

private List<ComponentFieldUri> determineAnimationPoolUris() {
    final List<ComponentFieldUri> animationSetUris = Lists.newArrayList();
    for (ComponentMetadata<?> componentMetadata : componentLibrary.iterateComponentMetadata()) {
        SimpleUri uri = new SimpleUri(componentMetadata.getId().toString());
        for (FieldMetadata<?, ?> fieldMetadata : componentMetadata.getFields()) {
            if (fieldMetadata.getType().isAssignableFrom(List.class)) {
                Type fieldType = fieldMetadata.getField().getGenericType();
                if (fieldType instanceof ParameterizedType) {
                    ParameterizedType parameterizedType = (ParameterizedType) fieldType;
                    Type[] typeArguments = parameterizedType.getActualTypeArguments();
                    if (typeArguments.length == 1) {
                        Class<?> typeClass = ReflectionUtil.getRawType(typeArguments[0]);
                        if (typeClass.isAssignableFrom(MeshAnimation.class)) {
                            animationSetUris.add(new ComponentFieldUri(uri, fieldMetadata.getName()));
                        }
                    }
                }
            }
        }
    }
    return animationSetUris;
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) SimpleUri(org.terasology.engine.core.SimpleUri) ComponentFieldUri(org.terasology.engine.core.ComponentFieldUri)

Aggregations

ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 ComponentFieldUri (org.terasology.engine.core.ComponentFieldUri)1 SimpleUri (org.terasology.engine.core.SimpleUri)1