本文整理汇总了Java中com.badlogic.gdx.ai.btree.annotation.TaskAttribute类的典型用法代码示例。如果您正苦于以下问题:Java TaskAttribute类的具体用法?Java TaskAttribute怎么用?Java TaskAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TaskAttribute类属于com.badlogic.gdx.ai.btree.annotation包,在下文中一共展示了TaskAttribute类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findMetadata
import com.badlogic.gdx.ai.btree.annotation.TaskAttribute; //导入依赖的package包/类
private Metadata findMetadata (Class<?> clazz) {
Metadata metadata = metadataCache.get(clazz);
if (metadata == null) {
Annotation tca = ClassReflection.getAnnotation(clazz, TaskConstraint.class);
if (tca != null) {
TaskConstraint taskConstraint = tca.getAnnotation(TaskConstraint.class);
ObjectMap<String, AttrInfo> taskAttributes = new ObjectMap<String, AttrInfo>();
Field[] fields = ClassReflection.getFields(clazz);
for (Field f : fields) {
Annotation a = f.getDeclaredAnnotation(TaskAttribute.class);
if (a != null) {
AttrInfo ai = new AttrInfo(f.getName(), a.getAnnotation(TaskAttribute.class));
taskAttributes.put(ai.name, ai);
}
}
metadata = new Metadata(taskConstraint.minChildren(), taskConstraint.maxChildren(), taskAttributes);
metadataCache.put(clazz, metadata);
}
}
return metadata;
}
示例2: appendFieldString
import com.badlogic.gdx.ai.btree.annotation.TaskAttribute; //导入依赖的package包/类
private static void appendFieldString (StringBuilder sb, Task<?> task, TaskAttribute ann, Field field) {
// prefer name from annotation if there is one
String name = ann.name();
if (name == null || name.length() == 0) name = field.getName();
Object value;
try {
field.setAccessible(true);
value = field.get(task);
} catch (ReflectionException e) {
Gdx.app.error("", "Failed to get field", e);
return;
}
sb.append(name).append(":");
Class<?> fieldType = field.getType();
if (fieldType.isEnum() || fieldType == String.class) {
sb.append('\"').append(value).append('\"');
} else if (Distribution.class.isAssignableFrom(fieldType)) {
sb.append('\"').append(DAs.toString((Distribution)value)).append('\"');
} else
sb.append(value);
}
示例3: appendTaskAttributes
import com.badlogic.gdx.ai.btree.annotation.TaskAttribute; //导入依赖的package包/类
private static StringBuilder appendTaskAttributes (StringBuilder attrs, Task<?> task) {
Class<?> aClass = task.getClass();
Field[] fields = ClassReflection.getFields(aClass);
for (Field f : fields) {
Annotation a = f.getDeclaredAnnotation(TaskAttribute.class);
if (a == null) continue;
TaskAttribute annotation = a.getAnnotation(TaskAttribute.class);
attrs.append('\n');
appendFieldString(attrs, task, annotation, f);
}
return attrs;
}
示例4: AttrInfo
import com.badlogic.gdx.ai.btree.annotation.TaskAttribute; //导入依赖的package包/类
AttrInfo (String fieldName, TaskAttribute annotation) {
this(annotation.name(), fieldName, annotation.required());
}