Search in sources :

Example 1 with NetworkSystemImpl

use of org.terasology.engine.network.internal.NetworkSystemImpl in project Terasology by MovingBlocks.

the class HeadlessEnvironment method setupNetwork.

@Override
protected void setupNetwork() {
    EngineTime mockTime = mock(EngineTime.class);
    context.put(Time.class, mockTime);
    NetworkSystem networkSystem = new NetworkSystemImpl(mockTime, getContext());
    context.put(NetworkSystem.class, networkSystem);
}
Also used : NetworkSystem(org.terasology.engine.network.NetworkSystem) EngineTime(org.terasology.engine.core.EngineTime) NetworkSystemImpl(org.terasology.engine.network.internal.NetworkSystemImpl)

Example 2 with NetworkSystemImpl

use of org.terasology.engine.network.internal.NetworkSystemImpl 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)

Example 3 with NetworkSystemImpl

use of org.terasology.engine.network.internal.NetworkSystemImpl in project Terasology by MovingBlocks.

the class NetworkSubsystem method initialise.

@Override
public void initialise(GameEngine engine, Context rootContext) {
    networkSystem = new NetworkSystemImpl(rootContext.get(Time.class), rootContext);
    rootContext.put(NetworkSystem.class, networkSystem);
}
Also used : NetworkSystemImpl(org.terasology.engine.network.internal.NetworkSystemImpl)

Example 4 with NetworkSystemImpl

use of org.terasology.engine.network.internal.NetworkSystemImpl in project Terasology by MovingBlocks.

the class TestNetwork method testNetwork.

@Test
public void testNetwork() throws Exception {
    EngineEntityManager entityManager = getEntityManager();
    EngineTime time = mock(EngineTime.class);
    NetworkSystem server = new NetworkSystemImpl(time, context);
    server.setContext(context);
    netSystems.add(server);
    server.connectToEntitySystem(entityManager, context.get(EventLibrary.class), null);
    server.host(7777, true);
    Thread.sleep(500);
    NetworkSystem client = new NetworkSystemImpl(time, context);
    client.setContext(context);
    netSystems.add(client);
    client.join("localhost", 7777);
    Thread.sleep(500);
    server.shutdown();
    client.shutdown();
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) EventLibrary(org.terasology.engine.entitySystem.metadata.EventLibrary) EngineTime(org.terasology.engine.core.EngineTime) NetworkSystemImpl(org.terasology.engine.network.internal.NetworkSystemImpl) Test(org.junit.jupiter.api.Test)

Example 5 with NetworkSystemImpl

use of org.terasology.engine.network.internal.NetworkSystemImpl in project Terasology by MovingBlocks.

the class TestNetwork method testEntityNetworkIdChangedOnServerStart.

@Test
public void testEntityNetworkIdChangedOnServerStart() throws HostingFailedException {
    EngineEntityManager entityManager = getEntityManager();
    NetworkComponent netComp = new NetworkComponent();
    netComp.setNetworkId(122);
    EntityRef entity = entityManager.create(netComp);
    EngineTime time = mock(EngineTime.class);
    NetworkSystem server = new NetworkSystemImpl(time, context);
    server.setContext(context);
    netSystems.add(server);
    server.connectToEntitySystem(entityManager, context.get(EventLibrary.class), null);
    server.host(7777, true);
    assertFalse(122 == entity.getComponent(NetworkComponent.class).getNetworkId());
    server.shutdown();
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) EventLibrary(org.terasology.engine.entitySystem.metadata.EventLibrary) EngineTime(org.terasology.engine.core.EngineTime) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) NetworkSystemImpl(org.terasology.engine.network.internal.NetworkSystemImpl) Test(org.junit.jupiter.api.Test)

Aggregations

NetworkSystemImpl (org.terasology.engine.network.internal.NetworkSystemImpl)6 EngineTime (org.terasology.engine.core.EngineTime)4 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)3 Test (org.junit.jupiter.api.Test)2 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)2 EventLibrary (org.terasology.engine.entitySystem.metadata.EventLibrary)2 NetworkSystem (org.terasology.engine.network.NetworkSystem)2 Path (java.nio.file.Path)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ComponentSystemManager (org.terasology.engine.core.ComponentSystemManager)1 LoadPrefabs (org.terasology.engine.core.modes.loadProcesses.LoadPrefabs)1 Game (org.terasology.engine.game.Game)1 ConsoleImpl (org.terasology.engine.logic.console.ConsoleImpl)1 LocalPlayer (org.terasology.engine.logic.players.LocalPlayer)1 ReadWriteStorageManager (org.terasology.engine.persistence.internal.ReadWriteStorageManager)1 CharacterStateEventPositionMap (org.terasology.engine.recording.CharacterStateEventPositionMap)1 DirectionAndOriginPosRecorderList (org.terasology.engine.recording.DirectionAndOriginPosRecorderList)1 RecordAndReplayCurrentStatus (org.terasology.engine.recording.RecordAndReplayCurrentStatus)1 RecordAndReplaySerializer (org.terasology.engine.recording.RecordAndReplaySerializer)1 RecordAndReplayUtils (org.terasology.engine.recording.RecordAndReplayUtils)1