Search in sources :

Example 11 with NetworkSystem

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

the class OwnershipHelperTest method setup.

@BeforeEach
public void setup() {
    ContextImpl context = new ContextImpl();
    context.put(ModuleManager.class, moduleManager);
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    context.put(NetworkSystem.class, networkSystem);
    context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
    CoreRegistry.setContext(context);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    entityManager = context.get(EngineEntityManager.class);
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) NetworkSystem(org.terasology.engine.network.NetworkSystem) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) ContextImpl(org.terasology.engine.context.internal.ContextImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with NetworkSystem

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

the class ComponentSerializerTest method setup.

@BeforeEach
public void setup() {
    context = new ContextImpl();
    context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
    context.put(ModuleManager.class, moduleManager);
    CoreRegistry.setContext(context);
    Reflections reflections = new Reflections(getClass().getClassLoader());
    TypeHandlerLibrary serializationLibrary = new TypeHandlerLibraryImpl(reflections);
    serializationLibrary.addTypeHandler(Vector3f.class, new Vector3fTypeHandler());
    serializationLibrary.addTypeHandler(Quaternionf.class, new QuaternionfTypeHandler());
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    EngineEntityManager entityManager = context.get(EngineEntityManager.class);
    entityManager.getComponentLibrary().register(new ResourceUrn("test", "gettersetter"), GetterSetterComponent.class);
    entityManager.getComponentLibrary().register(new ResourceUrn("test", "string"), StringComponent.class);
    entityManager.getComponentLibrary().register(new ResourceUrn("test", "integer"), IntegerComponent.class);
    ComponentLibrary componentLibrary = entityManager.getComponentLibrary();
    componentSerializer = new ComponentSerializer(componentLibrary, serializationLibrary);
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) QuaternionfTypeHandler(org.terasology.engine.persistence.typeHandling.mathTypes.QuaternionfTypeHandler) Vector3fTypeHandler(org.terasology.engine.persistence.typeHandling.mathTypes.Vector3fTypeHandler) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) NetworkSystem(org.terasology.engine.network.NetworkSystem) ComponentLibrary(org.terasology.engine.entitySystem.metadata.ComponentLibrary) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) ContextImpl(org.terasology.engine.context.internal.ContextImpl) TypeHandlerLibraryImpl(org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) ComponentSerializer(org.terasology.engine.persistence.serializers.ComponentSerializer) Reflections(org.reflections.Reflections) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with NetworkSystem

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

the class PojoEntityPoolTest method setup.

@BeforeEach
public void setup() {
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    entityManager = (PojoEntityManager) context.get(EntityManager.class);
    pool = new PojoEntityPool(entityManager);
}
Also used : PojoEntityPool(org.terasology.engine.entitySystem.entity.internal.PojoEntityPool) NetworkSystem(org.terasology.engine.network.NetworkSystem) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with NetworkSystem

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

the class SetupRemotePlayer method step.

@Override
public boolean step() {
    NetworkSystemImpl networkSystem = (NetworkSystemImpl) context.get(NetworkSystem.class);
    EntityRef client = networkSystem.getServer().getClientEntity();
    if (client.exists()) {
        context.get(LocalPlayer.class).setClientEntity(client);
        return true;
    }
    return false;
}
Also used : LocalPlayer(org.terasology.engine.logic.players.LocalPlayer) NetworkSystem(org.terasology.engine.network.NetworkSystem) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) NetworkSystemImpl(org.terasology.engine.network.internal.NetworkSystemImpl)

Example 15 with NetworkSystem

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

the class GameConfigurationMetric method fetchNetworkMode.

private void fetchNetworkMode() {
    NetworkSystem networkSystem = context.get(NetworkSystem.class);
    networkMode = networkSystem.getMode().toString();
}
Also used : NetworkSystem(org.terasology.engine.network.NetworkSystem)

Aggregations

NetworkSystem (org.terasology.engine.network.NetworkSystem)15 BeforeEach (org.junit.jupiter.api.BeforeEach)9 ModuleManager (org.terasology.engine.core.module.ModuleManager)5 RecordAndReplayCurrentStatus (org.terasology.engine.recording.RecordAndReplayCurrentStatus)5 TypeHandlerLibrary (org.terasology.persistence.typeHandling.TypeHandlerLibrary)5 ContextImpl (org.terasology.engine.context.internal.ContextImpl)4 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)4 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)4 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)4 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)3 PrefabData (org.terasology.engine.entitySystem.prefab.PrefabData)3 PojoPrefab (org.terasology.engine.entitySystem.prefab.internal.PojoPrefab)3 PojoPrefabManager (org.terasology.engine.entitySystem.prefab.internal.PojoPrefabManager)3 Reflections (org.reflections.Reflections)2 PojoEntityManager (org.terasology.engine.entitySystem.entity.internal.PojoEntityManager)2 ComponentLibrary (org.terasology.engine.entitySystem.metadata.ComponentLibrary)2 EntitySystemLibrary (org.terasology.engine.entitySystem.metadata.EntitySystemLibrary)2 NetworkSystemImpl (org.terasology.engine.network.internal.NetworkSystemImpl)2 TypeHandlerLibraryImpl (org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl)2 CharacterStateEventPositionMap (org.terasology.engine.recording.CharacterStateEventPositionMap)2