use of org.terasology.reflection.TypeRegistry in project Terasology by MovingBlocks.
the class TypeWidgetLibraryImpl method getBaseTypeWidget.
@Override
public <T> Optional<UIWidget> getBaseTypeWidget(Binding<T> binding, TypeInfo<T> baseType) {
try (ModuleContext.ContextSpan ignored = ModuleContext.setContext(contextModule)) {
if (Primitives.isWrapperType(baseType.getRawType()) || baseType.getRawType().isPrimitive()) {
return getWidget(binding, baseType);
}
ModuleManager moduleManager = context.get(ModuleManager.class);
TypeRegistry typeRegistry = context.get(TypeRegistry.class);
SubtypeLayoutBuilder<T> builder = new SubtypeLayoutBuilder<>(baseType, this, moduleManager, typeRegistry);
return Optional.of(builder.build(binding));
}
}
use of org.terasology.reflection.TypeRegistry in project Terasology by MovingBlocks.
the class EntitySystemSetupUtil method addReflectionBasedLibraries.
public static void addReflectionBasedLibraries(Context context) {
ReflectionReflectFactory reflectFactory = new ReflectionReflectFactory();
context.put(ReflectFactory.class, reflectFactory);
CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
context.put(CopyStrategyLibrary.class, copyStrategyLibrary);
ModuleManager moduleManager = context.get(ModuleManager.class);
TypeRegistry typeRegistry = context.get(TypeRegistry.class);
TypeHandlerLibrary typeHandlerLibrary = TypeHandlerLibraryImpl.forModuleEnvironment(moduleManager, typeRegistry);
context.put(TypeHandlerLibrary.class, typeHandlerLibrary);
EntitySystemLibrary library = new EntitySystemLibrary(context, typeHandlerLibrary);
context.put(EntitySystemLibrary.class, library);
context.put(ComponentLibrary.class, library.getComponentLibrary());
context.put(EventLibrary.class, library.getEventLibrary());
}
Aggregations