Search in sources :

Example 6 with NetworkSystem

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

the class PojoEventSystemTests method setup.

@Before
public void setup() {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    ReflectFactory reflectFactory = new ReflectionReflectFactory();
    CopyStrategyLibrary copyStrategies = new CopyStrategyLibrary(reflectFactory);
    TypeSerializationLibrary serializationLibrary = new TypeSerializationLibrary(reflectFactory, copyStrategies);
    EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, serializationLibrary);
    compLibrary = entitySystemLibrary.getComponentLibrary();
    entityManager = new PojoEntityManager();
    entityManager.setComponentLibrary(entitySystemLibrary.getComponentLibrary());
    entityManager.setPrefabManager(new PojoPrefabManager(context));
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    eventSystem = new EventSystemImpl(entitySystemLibrary.getEventLibrary(), networkSystem);
    entityManager.setEventSystem(eventSystem);
    entity = entityManager.create();
}
Also used : ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectFactory(org.terasology.reflection.reflect.ReflectFactory) PojoPrefabManager(org.terasology.entitySystem.prefab.internal.PojoPrefabManager) EntitySystemLibrary(org.terasology.entitySystem.metadata.EntitySystemLibrary) PojoEntityManager(org.terasology.entitySystem.entity.internal.PojoEntityManager) NetworkSystem(org.terasology.network.NetworkSystem) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) ContextImpl(org.terasology.context.internal.ContextImpl) EventSystemImpl(org.terasology.entitySystem.event.internal.EventSystemImpl) Before(org.junit.Before)

Example 7 with NetworkSystem

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

the class PrefabTest method setup.

@Before
public void setup() throws Exception {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, "prefabs");
    ComponentLibrary componentLibrary = context.get(ComponentLibrary.class);
    TypeSerializationLibrary typeSerializationLibrary = context.get(TypeSerializationLibrary.class);
    PrefabFormat prefabFormat = new PrefabFormat(componentLibrary, typeSerializationLibrary);
    assetTypeManager.registerCoreFormat(Prefab.class, 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 : PojoPrefabManager(org.terasology.entitySystem.prefab.internal.PojoPrefabManager) PrefabData(org.terasology.entitySystem.prefab.PrefabData) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) NetworkSystem(org.terasology.network.NetworkSystem) ComponentLibrary(org.terasology.entitySystem.metadata.ComponentLibrary) PrefabFormat(org.terasology.entitySystem.prefab.internal.PrefabFormat) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) ContextImpl(org.terasology.context.internal.ContextImpl) ModuleManager(org.terasology.engine.module.ModuleManager) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) Before(org.junit.Before)

Example 8 with NetworkSystem

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

Example 9 with NetworkSystem

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

the class ReadWriteStorageManager method createSaveTransaction.

private SaveTransaction createSaveTransaction() {
    SaveTransactionBuilder saveTransactionBuilder = new SaveTransactionBuilder(privateEntityManager, entitySetDeltaRecorder, isStoreChunksInZips(), getStoragePathProvider(), worldDirectoryWriteLock);
    ChunkProvider chunkProvider = CoreRegistry.get(ChunkProvider.class);
    NetworkSystem networkSystem = CoreRegistry.get(NetworkSystem.class);
    addChunksToSaveTransaction(saveTransactionBuilder, chunkProvider);
    addPlayersToSaveTransaction(saveTransactionBuilder, networkSystem);
    addGlobalStoreBuilderToSaveTransaction(saveTransactionBuilder);
    addGameManifestToSaveTransaction(saveTransactionBuilder);
    return saveTransactionBuilder.build();
}
Also used : NetworkSystem(org.terasology.network.NetworkSystem) ChunkProvider(org.terasology.world.chunks.ChunkProvider)

Example 10 with NetworkSystem

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

the class RegisterBiomes method step.

@Override
public boolean step() {
    NetworkSystem networkSystem = context.get(NetworkSystem.class);
    ModuleEnvironment moduleEnvironment = context.get(ModuleManager.class).getEnvironment();
    BiomeManager biomeManager;
    if (networkSystem.getMode().isAuthority()) {
        biomeManager = new BiomeManager(moduleEnvironment, gameManifest.getBiomeIdMap());
    // biomeManager.subscribe(CoreRegistry.get(NetworkSystem.class));
    // TODO figure out what this does
    } else {
        biomeManager = new BiomeManager(moduleEnvironment, gameManifest.getBiomeIdMap());
    }
    context.put(BiomeManager.class, biomeManager);
    // This registration is for other modules
    context.put(BiomeRegistry.class, biomeManager);
    return true;
}
Also used : BiomeManager(org.terasology.world.biomes.BiomeManager) ModuleEnvironment(org.terasology.module.ModuleEnvironment) NetworkSystem(org.terasology.network.NetworkSystem) ModuleManager(org.terasology.engine.module.ModuleManager)

Aggregations

NetworkSystem (org.terasology.network.NetworkSystem)11 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)5 Before (org.junit.Before)4 ContextImpl (org.terasology.context.internal.ContextImpl)3 ModuleManager (org.terasology.engine.module.ModuleManager)3 PojoPrefabManager (org.terasology.entitySystem.prefab.internal.PojoPrefabManager)3 ModuleEnvironment (org.terasology.module.ModuleEnvironment)3 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)2 PojoEntityManager (org.terasology.entitySystem.entity.internal.PojoEntityManager)2 EventSystemImpl (org.terasology.entitySystem.event.internal.EventSystemImpl)2 ComponentLibrary (org.terasology.entitySystem.metadata.ComponentLibrary)2 EntitySystemLibrary (org.terasology.entitySystem.metadata.EntitySystemLibrary)2 NetworkSystemImpl (org.terasology.network.internal.NetworkSystemImpl)2 BiomeManager (org.terasology.world.biomes.BiomeManager)2 FileSystem (java.nio.file.FileSystem)1 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)1 ResourceUrn (org.terasology.assets.ResourceUrn)1 AssetManager (org.terasology.assets.management.AssetManager)1 ModuleAwareAssetTypeManager (org.terasology.assets.module.ModuleAwareAssetTypeManager)1 Config (org.terasology.config.Config)1