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();
}
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);
}
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);
}
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();
}
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;
}
Aggregations