Search in sources :

Example 1 with TypeHandlerLibrary

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

the class HeadlessEnvironment method setupBlockManager.

@Override
protected void setupBlockManager(AssetManager assetManager) {
    WorldAtlas worldAtlas = new NullWorldAtlas();
    BlockManagerImpl blockManager = new BlockManagerImpl(worldAtlas, assetManager);
    context.put(BlockManager.class, blockManager);
    TypeHandlerLibrary typeHandlerLibrary = context.get(TypeHandlerLibrary.class);
    typeHandlerLibrary.addTypeHandler(BlockFamily.class, new BlockFamilyTypeHandler(blockManager));
    typeHandlerLibrary.addTypeHandler(Block.class, new BlockTypeHandler(blockManager));
}
Also used : TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) NullWorldAtlas(org.terasology.engine.world.block.tiles.NullWorldAtlas) BlockTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.BlockTypeHandler) NullWorldAtlas(org.terasology.engine.world.block.tiles.NullWorldAtlas) WorldAtlas(org.terasology.engine.world.block.tiles.WorldAtlas) BlockManagerImpl(org.terasology.engine.world.block.internal.BlockManagerImpl) BlockFamilyTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)

Example 2 with TypeHandlerLibrary

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

the class PojoEventSystemTests method setup.

@BeforeEach
public void setup() {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    Reflections reflections = new Reflections(getClass().getClassLoader());
    TypeHandlerLibrary serializationLibrary = new TypeHandlerLibraryImpl(reflections);
    EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, serializationLibrary);
    compLibrary = entitySystemLibrary.getComponentLibrary();
    entityManager = new PojoEntityManager();
    entityManager.setComponentLibrary(entitySystemLibrary.getComponentLibrary());
    entityManager.setPrefabManager(new PojoPrefabManager(context));
    eventSystem = new EventSystemImpl(true);
    entityManager.setEventSystem(eventSystem);
    entity = entityManager.create();
}
Also used : PojoPrefabManager(org.terasology.engine.entitySystem.prefab.internal.PojoPrefabManager) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) EntitySystemLibrary(org.terasology.engine.entitySystem.metadata.EntitySystemLibrary) PojoEntityManager(org.terasology.engine.entitySystem.entity.internal.PojoEntityManager) ContextImpl(org.terasology.engine.context.internal.ContextImpl) TypeHandlerLibraryImpl(org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl) EventSystemImpl(org.terasology.engine.entitySystem.event.internal.EventSystemImpl) Reflections(org.reflections.Reflections) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with TypeHandlerLibrary

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

the class PrefabTest method setup.

@BeforeEach
public void setup() throws Exception {
    ContextImpl context = new ContextImpl();
    context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
    CoreRegistry.setContext(context);
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManagerImpl();
    AssetType<Prefab, PrefabData> prefabDataAssetType = assetTypeManager.createAssetType(Prefab.class, PojoPrefab::new, "prefabs");
    ComponentLibrary componentLibrary = context.get(ComponentLibrary.class);
    TypeHandlerLibrary typeHandlerLibrary = context.get(TypeHandlerLibrary.class);
    PrefabFormat prefabFormat = new PrefabFormat(componentLibrary, typeHandlerLibrary);
    assetTypeManager.getAssetFileDataProducer(prefabDataAssetType).addAssetFormat(prefabFormat);
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    prefabManager = new PojoPrefabManager(context);
}
Also used : PojoPrefab(org.terasology.engine.entitySystem.prefab.internal.PojoPrefab) PojoPrefabManager(org.terasology.engine.entitySystem.prefab.internal.PojoPrefabManager) PrefabData(org.terasology.engine.entitySystem.prefab.PrefabData) ModuleAwareAssetTypeManager(org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager) NetworkSystem(org.terasology.engine.network.NetworkSystem) PrefabFormat(org.terasology.engine.entitySystem.prefab.internal.PrefabFormat) ModuleAwareAssetTypeManagerImpl(org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManagerImpl) ContextImpl(org.terasology.engine.context.internal.ContextImpl) ModuleManager(org.terasology.engine.core.module.ModuleManager) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) ComponentLibrary(org.terasology.engine.entitySystem.metadata.ComponentLibrary) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) Prefab(org.terasology.engine.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.engine.entitySystem.prefab.internal.PojoPrefab) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with TypeHandlerLibrary

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

the class VectorEventSerializer method setup.

@BeforeEach
public void setup() throws Exception {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    context.put(ReflectFactory.class, reflectFactory);
    context.put(CopyStrategyLibrary.class, copyStrategies);
    ModuleTypeRegistry typeRegistry = new ModuleTypeRegistry(moduleManager.getEnvironment());
    TypeHandlerLibrary typeHandlerLibrary = TypeHandlerLibraryImpl.forModuleEnvironment(moduleManager, typeRegistry);
    entitySystemLibrary = new EntitySystemLibrary(context, typeHandlerLibrary);
    serializer = new EventSerializer(entitySystemLibrary.getEventLibrary(), typeHandlerLibrary);
    registerEvent(Vector3fTestEvent.class);
    serializer.setIdMapping(eventMap);
}
Also used : ModuleTypeRegistry(org.terasology.reflection.ModuleTypeRegistry) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) EntitySystemLibrary(org.terasology.engine.entitySystem.metadata.EntitySystemLibrary) ContextImpl(org.terasology.engine.context.internal.ContextImpl) ModuleManager(org.terasology.engine.core.module.ModuleManager) EventSerializer(org.terasology.engine.persistence.serializers.EventSerializer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with TypeHandlerLibrary

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

the class EventSystemReplayImplTest method setup.

@BeforeEach
public void setup() {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    Reflections reflections = new Reflections(getClass().getClassLoader());
    TypeHandlerLibrary serializationLibrary = new TypeHandlerLibraryImpl(reflections);
    EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, serializationLibrary);
    PojoEntityManager entityManager = new PojoEntityManager();
    entityManager.setComponentLibrary(entitySystemLibrary.getComponentLibrary());
    entityManager.setPrefabManager(new PojoPrefabManager(context));
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    recordAndReplayCurrentStatus = new RecordAndReplayCurrentStatus();
    RecordedEventStore eventStore = new RecordedEventStore();
    RecordAndReplayUtils recordAndReplayUtils = new RecordAndReplayUtils();
    CharacterStateEventPositionMap characterStateEventPositionMap = new CharacterStateEventPositionMap();
    DirectionAndOriginPosRecorderList directionAndOriginPosRecorderList = new DirectionAndOriginPosRecorderList();
    ModuleManager moduleManager = mock(ModuleManager.class);
    when(moduleManager.getEnvironment()).thenReturn(mock(ModuleEnvironment.class));
    RecordAndReplaySerializer recordAndReplaySerializer = new RecordAndReplaySerializer(entityManager, eventStore, recordAndReplayUtils, characterStateEventPositionMap, directionAndOriginPosRecorderList, moduleManager, mock(TypeRegistry.class));
    recordAndReplayCurrentStatus.setStatus(RecordAndReplayStatus.REPLAYING);
    entity = entityManager.create();
    Long id = entity.getId();
    eventStore.add(new RecordedEvent(id, new AttackButton(), 1, 1));
    eventStore.add(new RecordedEvent(id, new AttackButton(), 2, 2));
    eventStore.add(new RecordedEvent(id, new AttackButton(), 3, 3));
    List<Class<?>> selectedClassesToReplay = new ArrayList<>();
    selectedClassesToReplay.add(InputEvent.class);
    eventSystem = new EventSystemReplayImpl(entitySystemLibrary.getEventLibrary(), networkSystem, entityManager, eventStore, recordAndReplaySerializer, recordAndReplayUtils, selectedClassesToReplay, recordAndReplayCurrentStatus);
    entityManager.setEventSystem(eventSystem);
    handler = new TestEventHandler();
    eventSystem.registerEventHandler(handler);
}
Also used : PojoPrefabManager(org.terasology.engine.entitySystem.prefab.internal.PojoPrefabManager) ArrayList(java.util.ArrayList) ContextImpl(org.terasology.engine.context.internal.ContextImpl) ModuleManager(org.terasology.engine.core.module.ModuleManager) TypeRegistry(org.terasology.reflection.TypeRegistry) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) EntitySystemLibrary(org.terasology.engine.entitySystem.metadata.EntitySystemLibrary) Reflections(org.reflections.Reflections) NetworkSystem(org.terasology.engine.network.NetworkSystem) TypeHandlerLibraryImpl(org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl) ModuleEnvironment(org.terasology.gestalt.module.ModuleEnvironment) PojoEntityManager(org.terasology.engine.entitySystem.entity.internal.PojoEntityManager) AttackButton(org.terasology.engine.input.binds.interaction.AttackButton) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

TypeHandlerLibrary (org.terasology.persistence.typeHandling.TypeHandlerLibrary)14 ModuleManager (org.terasology.engine.core.module.ModuleManager)6 EntitySystemLibrary (org.terasology.engine.entitySystem.metadata.EntitySystemLibrary)6 BeforeEach (org.junit.jupiter.api.BeforeEach)5 ContextImpl (org.terasology.engine.context.internal.ContextImpl)5 PojoPrefabManager (org.terasology.engine.entitySystem.prefab.internal.PojoPrefabManager)4 NetworkSystem (org.terasology.engine.network.NetworkSystem)4 Reflections (org.reflections.Reflections)3 PojoEntityManager (org.terasology.engine.entitySystem.entity.internal.PojoEntityManager)3 ComponentLibrary (org.terasology.engine.entitySystem.metadata.ComponentLibrary)3 TypeHandlerLibraryImpl (org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl)3 RecordAndReplayCurrentStatus (org.terasology.engine.recording.RecordAndReplayCurrentStatus)3 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)3 TypeRegistry (org.terasology.reflection.TypeRegistry)3 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 AutoConfigManager (org.terasology.engine.config.flexible.AutoConfigManager)2 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)2 PrefabFormat (org.terasology.engine.entitySystem.prefab.internal.PrefabFormat)2 EventSerializer (org.terasology.engine.persistence.serializers.EventSerializer)2