Search in sources :

Example 1 with Quat4fTypeHandler

use of org.terasology.persistence.typeHandling.mathTypes.Quat4fTypeHandler in project Terasology by MovingBlocks.

the class TypeSerializationLibrary method createDefaultLibrary.

public static TypeSerializationLibrary createDefaultLibrary(ReflectFactory factory, CopyStrategyLibrary copyStrategies) {
    TypeSerializationLibrary serializationLibrary = new TypeSerializationLibrary(factory, copyStrategies);
    serializationLibrary.add(Color.class, new ColorTypeHandler());
    serializationLibrary.add(Quat4f.class, new Quat4fTypeHandler());
    serializationLibrary.add(Texture.class, new AssetTypeHandler<>(Texture.class));
    serializationLibrary.add(UIElement.class, new AssetTypeHandler<>(UIElement.class));
    serializationLibrary.add(Mesh.class, new AssetTypeHandler<>(Mesh.class));
    serializationLibrary.add(StaticSound.class, new AssetTypeHandler<>(StaticSound.class));
    serializationLibrary.add(StreamingSound.class, new AssetTypeHandler<>(StreamingSound.class));
    serializationLibrary.add(Material.class, new AssetTypeHandler<>(Material.class));
    serializationLibrary.add(Name.class, new NameTypeHandler());
    serializationLibrary.add(SkeletalMesh.class, new AssetTypeHandler<>(SkeletalMesh.class));
    serializationLibrary.add(MeshAnimation.class, new AssetTypeHandler<>(MeshAnimation.class));
    serializationLibrary.add(TextureRegion.class, new TextureRegionTypeHandler());
    serializationLibrary.add(TextureRegionAsset.class, new TextureRegionTypeHandler());
    serializationLibrary.add(Vector4f.class, new Vector4fTypeHandler());
    serializationLibrary.add(Vector3f.class, new Vector3fTypeHandler());
    serializationLibrary.add(Vector2f.class, new Vector2fTypeHandler());
    serializationLibrary.add(Vector3i.class, new Vector3iTypeHandler());
    serializationLibrary.add(Vector2i.class, new Vector2iTypeHandler());
    serializationLibrary.add(Rect2i.class, new Rect2iTypeHandler());
    serializationLibrary.add(Rect2f.class, new Rect2fTypeHandler());
    serializationLibrary.add(Region3i.class, new Region3iTypeHandler());
    serializationLibrary.add(Prefab.class, new PrefabTypeHandler());
    serializationLibrary.add(BehaviorTree.class, new AssetTypeHandler<>(BehaviorTree.class));
    serializationLibrary.add(IntegerRange.class, new IntegerRangeHandler());
    return serializationLibrary;
}
Also used : PrefabTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.PrefabTypeHandler) UIElement(org.terasology.rendering.nui.asset.UIElement) Vector3iTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Vector3iTypeHandler) StreamingSound(org.terasology.audio.StreamingSound) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) Texture(org.terasology.rendering.assets.texture.Texture) Vector2iTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Vector2iTypeHandler) NameTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.NameTypeHandler) MeshAnimation(org.terasology.rendering.assets.animation.MeshAnimation) IntegerRangeHandler(org.terasology.persistence.typeHandling.mathTypes.IntegerRangeHandler) Rect2fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Rect2fTypeHandler) StaticSound(org.terasology.audio.StaticSound) Region3iTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Region3iTypeHandler) Mesh(org.terasology.rendering.assets.mesh.Mesh) SkeletalMesh(org.terasology.rendering.assets.skeletalmesh.SkeletalMesh) Material(org.terasology.rendering.assets.material.Material) BehaviorTree(org.terasology.logic.behavior.asset.BehaviorTree) Vector3fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Vector3fTypeHandler) ColorTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.ColorTypeHandler) Vector4fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Vector4fTypeHandler) Quat4fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Quat4fTypeHandler) Rect2iTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Rect2iTypeHandler) TextureRegionTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.TextureRegionTypeHandler) Vector2fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Vector2fTypeHandler)

Example 2 with Quat4fTypeHandler

use of org.terasology.persistence.typeHandling.mathTypes.Quat4fTypeHandler in project Terasology by MovingBlocks.

the class ComponentSerializerTest method setup.

@Before
public void setup() {
    context = new ContextImpl();
    context.put(ModuleManager.class, moduleManager);
    CoreRegistry.setContext(context);
    TypeSerializationLibrary serializationLibrary = new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary);
    serializationLibrary.add(Vector3f.class, new Vector3fTypeHandler());
    serializationLibrary.add(Quat4f.class, new Quat4fTypeHandler());
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    EngineEntityManager entityManager = context.get(EngineEntityManager.class);
    entityManager.getComponentLibrary().register(new SimpleUri("test", "gettersetter"), GetterSetterComponent.class);
    entityManager.getComponentLibrary().register(new SimpleUri("test", "string"), StringComponent.class);
    entityManager.getComponentLibrary().register(new SimpleUri("test", "integer"), IntegerComponent.class);
    ComponentLibrary componentLibrary = entityManager.getComponentLibrary();
    componentSerializer = new ComponentSerializer(componentLibrary, serializationLibrary);
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) Vector3fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Vector3fTypeHandler) NetworkSystem(org.terasology.network.NetworkSystem) SimpleUri(org.terasology.engine.SimpleUri) ComponentLibrary(org.terasology.entitySystem.metadata.ComponentLibrary) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) Quat4fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Quat4fTypeHandler) ContextImpl(org.terasology.context.internal.ContextImpl) ComponentSerializer(org.terasology.persistence.serializers.ComponentSerializer) Before(org.junit.Before)

Example 3 with Quat4fTypeHandler

use of org.terasology.persistence.typeHandling.mathTypes.Quat4fTypeHandler in project Terasology by MovingBlocks.

the class PojoPrefabManagerTest method setup.

@Before
public void setup() throws Exception {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    ModuleManager moduleManager = ModuleManagerFactory.create();
    ReflectFactory reflectFactory = new ReflectionReflectFactory();
    CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
    TypeSerializationLibrary lib = new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary);
    lib.add(Vector3f.class, new Vector3fTypeHandler());
    lib.add(Quat4f.class, new Quat4fTypeHandler());
    entitySystemLibrary = new EntitySystemLibrary(context, lib);
    componentLibrary = entitySystemLibrary.getComponentLibrary();
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    prefabManager = new PojoPrefabManager(context);
}
Also used : PojoPrefabManager(org.terasology.entitySystem.prefab.internal.PojoPrefabManager) PrefabData(org.terasology.entitySystem.prefab.PrefabData) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) ContextImpl(org.terasology.context.internal.ContextImpl) ModuleManager(org.terasology.engine.module.ModuleManager) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectFactory(org.terasology.reflection.reflect.ReflectFactory) Vector3fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Vector3fTypeHandler) EntitySystemLibrary(org.terasology.entitySystem.metadata.EntitySystemLibrary) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) Quat4fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Quat4fTypeHandler) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) Before(org.junit.Before)

Aggregations

Quat4fTypeHandler (org.terasology.persistence.typeHandling.mathTypes.Quat4fTypeHandler)3 Vector3fTypeHandler (org.terasology.persistence.typeHandling.mathTypes.Vector3fTypeHandler)3 Before (org.junit.Before)2 ContextImpl (org.terasology.context.internal.ContextImpl)2 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)2 ModuleAwareAssetTypeManager (org.terasology.assets.module.ModuleAwareAssetTypeManager)1 StaticSound (org.terasology.audio.StaticSound)1 StreamingSound (org.terasology.audio.StreamingSound)1 SimpleUri (org.terasology.engine.SimpleUri)1 ModuleManager (org.terasology.engine.module.ModuleManager)1 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)1 ComponentLibrary (org.terasology.entitySystem.metadata.ComponentLibrary)1 EntitySystemLibrary (org.terasology.entitySystem.metadata.EntitySystemLibrary)1 Prefab (org.terasology.entitySystem.prefab.Prefab)1 PrefabData (org.terasology.entitySystem.prefab.PrefabData)1 PojoPrefab (org.terasology.entitySystem.prefab.internal.PojoPrefab)1 PojoPrefabManager (org.terasology.entitySystem.prefab.internal.PojoPrefabManager)1 BehaviorTree (org.terasology.logic.behavior.asset.BehaviorTree)1 NetworkSystem (org.terasology.network.NetworkSystem)1 ComponentSerializer (org.terasology.persistence.serializers.ComponentSerializer)1