Search in sources :

Example 1 with ComponentFieldUri

use of org.terasology.engine.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 = componentMetadata.getUri();
        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.getClassOfType(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.SimpleUri) ComponentFieldUri(org.terasology.engine.ComponentFieldUri)

Aggregations

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