Search in sources :

Example 1 with CharacterStateEventPositionMap

use of org.terasology.engine.recording.CharacterStateEventPositionMap in project Terasology by MovingBlocks.

the class StorageManagerTest method setup.

@BeforeEach
public void setup(@TempDir Path tempHome) throws Exception {
    super.setup();
    PathManager.getInstance().useOverrideHomePath(tempHome);
    savePath = PathManager.getInstance().getSavePath("testSave");
    assert !Files.isRegularFile(tempHome.resolve("global.dat"));
    entityManager = context.get(EngineEntityManager.class);
    moduleEnvironment = mock(ModuleEnvironment.class);
    blockManager = context.get(BlockManager.class);
    extraDataManager = context.get(ExtraBlockDataManager.class);
    ModuleManager moduleManager = mock(ModuleManager.class);
    when(moduleManager.getEnvironment()).thenReturn(moduleEnvironment);
    RecordedEventStore recordedEventStore = new RecordedEventStore();
    recordAndReplayUtils = new RecordAndReplayUtils();
    CharacterStateEventPositionMap characterStateEventPositionMap = new CharacterStateEventPositionMap();
    DirectionAndOriginPosRecorderList directionAndOriginPosRecorderList = new DirectionAndOriginPosRecorderList();
    recordAndReplaySerializer = new RecordAndReplaySerializer(entityManager, recordedEventStore, recordAndReplayUtils, characterStateEventPositionMap, directionAndOriginPosRecorderList, moduleManager, mock(TypeRegistry.class));
    recordAndReplayCurrentStatus = context.get(RecordAndReplayCurrentStatus.class);
    esm = new ReadWriteStorageManager(savePath, moduleEnvironment, entityManager, blockManager, extraDataManager, false, recordAndReplaySerializer, recordAndReplayUtils, recordAndReplayCurrentStatus);
    context.put(StorageManager.class, esm);
    this.character = entityManager.create();
    Client client = createClientMock(PLAYER_ID, character);
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    when(networkSystem.getPlayers()).thenReturn(Arrays.asList(client));
    context.put(NetworkSystem.class, networkSystem);
    AssetManager assetManager = context.get(AssetManager.class);
    BlockFamilyDefinitionData data = new BlockFamilyDefinitionData();
    data.setBlockFamily(SymmetricFamily.class);
    assetManager.loadAsset(new ResourceUrn("test:testblock"), data, BlockFamilyDefinition.class);
    assetManager.loadAsset(new ResourceUrn("test:testblock2"), data, BlockFamilyDefinition.class);
    testBlock = context.get(BlockManager.class).getBlock("test:testblock");
    testBlock2 = context.get(BlockManager.class).getBlock("test:testblock2");
    context.put(ChunkProvider.class, mock(ChunkProvider.class));
    WorldProvider worldProvider = mock(WorldProvider.class);
    when(worldProvider.getWorldInfo()).thenReturn(new WorldInfo());
    context.put(WorldProvider.class, worldProvider);
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) AssetManager(org.terasology.gestalt.assets.management.AssetManager) NetworkSystem(org.terasology.engine.network.NetworkSystem) RecordedEventStore(org.terasology.engine.recording.RecordedEventStore) ExtraBlockDataManager(org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager) ModuleManager(org.terasology.engine.core.module.ModuleManager) RecordAndReplaySerializer(org.terasology.engine.recording.RecordAndReplaySerializer) DirectionAndOriginPosRecorderList(org.terasology.engine.recording.DirectionAndOriginPosRecorderList) BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) ModuleEnvironment(org.terasology.gestalt.module.ModuleEnvironment) BlockManager(org.terasology.engine.world.block.BlockManager) RecordAndReplayUtils(org.terasology.engine.recording.RecordAndReplayUtils) WorldProvider(org.terasology.engine.world.WorldProvider) WorldInfo(org.terasology.engine.world.internal.WorldInfo) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) Client(org.terasology.engine.network.Client) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) ChunkProvider(org.terasology.engine.world.chunks.ChunkProvider) CharacterStateEventPositionMap(org.terasology.engine.recording.CharacterStateEventPositionMap) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with CharacterStateEventPositionMap

use of org.terasology.engine.recording.CharacterStateEventPositionMap in project Terasology by MovingBlocks.

the class EntitySystemSetupUtil method addEntityManagementRelatedClasses.

/**
 * Objects for the following classes must be available in the context:
 * <ul>
 * <li>{@link ModuleEnvironment}</li>
 * <li>{@link NetworkSystem}</li>
 * <li>{@link ReflectFactory}</li>
 * <li>{@link CopyStrategyLibrary}</li>
 * <li>{@link TypeHandlerLibrary}</li>
 * </ul>
 * <p>
 * The method will make objects for the following classes available in the context:
 * <ul>
 * <li>{@link EngineEntityManager}</li>
 * <li>{@link ComponentLibrary}</li>
 * <li>{@link EventLibrary}</li>
 * <li>{@link PrefabManager}</li>
 * <li>{@link EventSystem}</li>
 * </ul>
 */
public static void addEntityManagementRelatedClasses(Context context) {
    ModuleManager moduleManager = context.get(ModuleManager.class);
    ModuleEnvironment environment = moduleManager.getEnvironment();
    NetworkSystem networkSystem = context.get(NetworkSystem.class);
    // Entity Manager
    PojoEntityManager entityManager = new PojoEntityManager();
    context.put(EntityManager.class, entityManager);
    context.put(EngineEntityManager.class, entityManager);
    // Standard serialization library
    TypeHandlerLibrary typeHandlerLibrary = context.get(TypeHandlerLibrary.class);
    typeHandlerLibrary.addTypeHandler(EntityRef.class, new EntityRefTypeHandler(entityManager));
    entityManager.setTypeSerializerLibrary(typeHandlerLibrary);
    // Prefab Manager
    PrefabManager prefabManager = new PojoPrefabManager(context);
    entityManager.setPrefabManager(prefabManager);
    context.put(PrefabManager.class, prefabManager);
    EntitySystemLibrary library = context.get(EntitySystemLibrary.class);
    entityManager.setComponentLibrary(library.getComponentLibrary());
    // Record and Replay
    RecordAndReplayCurrentStatus recordAndReplayCurrentStatus = context.get(RecordAndReplayCurrentStatus.class);
    RecordAndReplayUtils recordAndReplayUtils = context.get(RecordAndReplayUtils.class);
    CharacterStateEventPositionMap characterStateEventPositionMap = context.get(CharacterStateEventPositionMap.class);
    DirectionAndOriginPosRecorderList directionAndOriginPosRecorderList = context.get(DirectionAndOriginPosRecorderList.class);
    RecordedEventStore recordedEventStore = new RecordedEventStore();
    RecordAndReplaySerializer recordAndReplaySerializer = new RecordAndReplaySerializer(entityManager, recordedEventStore, recordAndReplayUtils, characterStateEventPositionMap, directionAndOriginPosRecorderList, moduleManager, context.get(TypeRegistry.class));
    context.put(RecordAndReplaySerializer.class, recordAndReplaySerializer);
    // Event System
    EventSystem eventSystem = createEventSystem(networkSystem, entityManager, library, recordedEventStore, recordAndReplaySerializer, recordAndReplayUtils, recordAndReplayCurrentStatus);
    entityManager.setEventSystem(eventSystem);
    context.put(EventSystem.class, eventSystem);
    // TODO: Review - NodeClassLibrary related to the UI for behaviours. Should not be here and probably not even in the CoreRegistry
    context.put(OneOfProviderFactory.class, new OneOfProviderFactory());
    registerComponents(library.getComponentLibrary(), environment);
    registerEvents(entityManager.getEventSystem(), environment);
}
Also used : PojoPrefabManager(org.terasology.engine.entitySystem.prefab.internal.PojoPrefabManager) PrefabManager(org.terasology.engine.entitySystem.prefab.PrefabManager) PojoPrefabManager(org.terasology.engine.entitySystem.prefab.internal.PojoPrefabManager) NetworkSystem(org.terasology.engine.network.NetworkSystem) RecordedEventStore(org.terasology.engine.recording.RecordedEventStore) ModuleManager(org.terasology.engine.core.module.ModuleManager) TypeRegistry(org.terasology.reflection.TypeRegistry) RecordAndReplaySerializer(org.terasology.engine.recording.RecordAndReplaySerializer) DirectionAndOriginPosRecorderList(org.terasology.engine.recording.DirectionAndOriginPosRecorderList) OneOfProviderFactory(org.terasology.nui.properties.OneOfProviderFactory) ModuleEnvironment(org.terasology.gestalt.module.ModuleEnvironment) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) EntitySystemLibrary(org.terasology.engine.entitySystem.metadata.EntitySystemLibrary) RecordAndReplayUtils(org.terasology.engine.recording.RecordAndReplayUtils) PojoEntityManager(org.terasology.engine.entitySystem.entity.internal.PojoEntityManager) EntityRefTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.EntityRefTypeHandler) EventSystem(org.terasology.engine.entitySystem.event.internal.EventSystem) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) CharacterStateEventPositionMap(org.terasology.engine.recording.CharacterStateEventPositionMap)

Example 3 with CharacterStateEventPositionMap

use of org.terasology.engine.recording.CharacterStateEventPositionMap in project Terasology by MovingBlocks.

the class TerasologyTestingEnvironment method setup.

@BeforeEach
public void setup() throws Exception {
    context.put(ModuleManager.class, moduleManager);
    RecordAndReplayCurrentStatus recordAndReplayCurrentStatus = context.get(RecordAndReplayCurrentStatus.class);
    mockTime = mock(EngineTime.class);
    context.put(Time.class, mockTime);
    NetworkSystemImpl networkSystem = new NetworkSystemImpl(mockTime, context);
    context.put(Game.class, new Game());
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    engineEntityManager = context.get(EngineEntityManager.class);
    // 'mock' added to avoid hiding a field
    BlockManager mockBlockManager = context.get(BlockManager.class);
    ExtraBlockDataManager extraDataManager = context.get(ExtraBlockDataManager.class);
    RecordedEventStore recordedEventStore = new RecordedEventStore();
    RecordAndReplayUtils recordAndReplayUtils = new RecordAndReplayUtils();
    context.put(RecordAndReplayUtils.class, recordAndReplayUtils);
    CharacterStateEventPositionMap characterStateEventPositionMap = new CharacterStateEventPositionMap();
    context.put(CharacterStateEventPositionMap.class, characterStateEventPositionMap);
    DirectionAndOriginPosRecorderList directionAndOriginPosRecorderList = new DirectionAndOriginPosRecorderList();
    context.put(DirectionAndOriginPosRecorderList.class, directionAndOriginPosRecorderList);
    RecordAndReplaySerializer recordAndReplaySerializer = new RecordAndReplaySerializer(engineEntityManager, recordedEventStore, recordAndReplayUtils, characterStateEventPositionMap, directionAndOriginPosRecorderList, moduleManager, context.get(TypeRegistry.class));
    context.put(RecordAndReplaySerializer.class, recordAndReplaySerializer);
    Path savePath = PathManager.getInstance().getSavePath("world1");
    context.put(StorageManager.class, new ReadWriteStorageManager(savePath, moduleManager.getEnvironment(), engineEntityManager, mockBlockManager, extraDataManager, recordAndReplaySerializer, recordAndReplayUtils, recordAndReplayCurrentStatus));
    ComponentSystemManager componentSystemManager = new ComponentSystemManager(context);
    context.put(ComponentSystemManager.class, componentSystemManager);
    LoadPrefabs prefabLoadStep = new LoadPrefabs(context);
    boolean complete = false;
    prefabLoadStep.begin();
    while (!complete) {
        complete = prefabLoadStep.step();
    }
    context.get(ComponentSystemManager.class).initialise();
    context.put(Console.class, new ConsoleImpl(context));
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) Path(java.nio.file.Path) ConsoleImpl(org.terasology.engine.logic.console.ConsoleImpl) EngineTime(org.terasology.engine.core.EngineTime) RecordedEventStore(org.terasology.engine.recording.RecordedEventStore) ExtraBlockDataManager(org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager) TypeRegistry(org.terasology.reflection.TypeRegistry) NetworkSystemImpl(org.terasology.engine.network.internal.NetworkSystemImpl) RecordAndReplaySerializer(org.terasology.engine.recording.RecordAndReplaySerializer) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager) DirectionAndOriginPosRecorderList(org.terasology.engine.recording.DirectionAndOriginPosRecorderList) Game(org.terasology.engine.game.Game) LoadPrefabs(org.terasology.engine.core.modes.loadProcesses.LoadPrefabs) BlockManager(org.terasology.engine.world.block.BlockManager) RecordAndReplayUtils(org.terasology.engine.recording.RecordAndReplayUtils) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) ReadWriteStorageManager(org.terasology.engine.persistence.internal.ReadWriteStorageManager) CharacterStateEventPositionMap(org.terasology.engine.recording.CharacterStateEventPositionMap) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

CharacterStateEventPositionMap (org.terasology.engine.recording.CharacterStateEventPositionMap)3 DirectionAndOriginPosRecorderList (org.terasology.engine.recording.DirectionAndOriginPosRecorderList)3 RecordAndReplayCurrentStatus (org.terasology.engine.recording.RecordAndReplayCurrentStatus)3 RecordAndReplaySerializer (org.terasology.engine.recording.RecordAndReplaySerializer)3 RecordAndReplayUtils (org.terasology.engine.recording.RecordAndReplayUtils)3 RecordedEventStore (org.terasology.engine.recording.RecordedEventStore)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ModuleManager (org.terasology.engine.core.module.ModuleManager)2 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)2 NetworkSystem (org.terasology.engine.network.NetworkSystem)2 BlockManager (org.terasology.engine.world.block.BlockManager)2 ExtraBlockDataManager (org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager)2 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)2 TypeRegistry (org.terasology.reflection.TypeRegistry)2 Path (java.nio.file.Path)1 ComponentSystemManager (org.terasology.engine.core.ComponentSystemManager)1 EngineTime (org.terasology.engine.core.EngineTime)1 LoadPrefabs (org.terasology.engine.core.modes.loadProcesses.LoadPrefabs)1 PojoEntityManager (org.terasology.engine.entitySystem.entity.internal.PojoEntityManager)1 EventSystem (org.terasology.engine.entitySystem.event.internal.EventSystem)1