use of org.terasology.engine.ComponentSystemManager in project Terasology by MovingBlocks.
the class ReadWriteStorageManager method startAutoSaving.
private void startAutoSaving() {
logger.info("Auto Saving - Creating game snapshot");
PerformanceMonitor.startActivity("Auto Saving");
ComponentSystemManager componentSystemManager = CoreRegistry.get(ComponentSystemManager.class);
for (ComponentSystem sys : componentSystemManager.iterateAll()) {
sys.preAutoSave();
}
saveTransaction = createSaveTransaction();
saveThreadManager.offer(saveTransaction);
for (ComponentSystem sys : componentSystemManager.iterateAll()) {
sys.postAutoSave();
}
scheduleNextAutoSave();
PerformanceMonitor.endActivity();
entitySetDeltaRecorder = new EntitySetDeltaRecorder(this.entityRefReplacingComponentLibrary);
logger.info("Auto Saving - Snapshot created: Writing phase starts");
}
use of org.terasology.engine.ComponentSystemManager in project Terasology by MovingBlocks.
the class AwaitCharacterSpawn method step.
@Override
public boolean step() {
ComponentSystemManager componentSystemManager = context.get(ComponentSystemManager.class);
for (UpdateSubscriberSystem updater : componentSystemManager.iterateUpdateSubscribers()) {
updater.update(0.0f);
}
LocalPlayer localPlayer = context.get(LocalPlayer.class);
ClientComponent client = localPlayer.getClientEntity().getComponent(ClientComponent.class);
if (client != null && client.character.exists()) {
client.character.send(new AwaitedLocalCharacterSpawnEvent());
return true;
} else {
chunkProvider.completeUpdate();
chunkProvider.beginUpdate();
}
return false;
}
use of org.terasology.engine.ComponentSystemManager in project Terasology by MovingBlocks.
the class InitialiseSystems method step.
@Override
public boolean step() {
EngineEntityManager entityManager = (EngineEntityManager) context.get(EntityManager.class);
EventLibrary eventLibrary = context.get(EventLibrary.class);
BlockEntityRegistry blockEntityRegistry = context.get(BlockEntityRegistry.class);
context.get(NetworkSystem.class).connectToEntitySystem(entityManager, eventLibrary, blockEntityRegistry);
ComponentSystemManager csm = context.get(ComponentSystemManager.class);
csm.initialise();
return true;
}
use of org.terasology.engine.ComponentSystemManager in project Terasology by MovingBlocks.
the class PreBeginSystems method begin.
@Override
public void begin() {
ComponentSystemManager csm = context.get(ComponentSystemManager.class);
componentSystems = csm.iterateAll().iterator();
}
use of org.terasology.engine.ComponentSystemManager in project Terasology by MovingBlocks.
the class StateHeadlessSetup method init.
@Override
public void init(GameEngine gameEngine) {
context = gameEngine.createChildContext();
CoreRegistry.setContext(context);
// let's get the entity event system running
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
entityManager = context.get(EngineEntityManager.class);
eventSystem = context.get(EventSystem.class);
context.put(Console.class, new ConsoleImpl(context));
NUIManager nuiManager = new NUIManagerInternal(context.get(CanvasRenderer.class), context);
context.put(NUIManager.class, nuiManager);
componentSystemManager = new ComponentSystemManager(context);
context.put(ComponentSystemManager.class, componentSystemManager);
componentSystemManager.register(new ConsoleSystem(), "engine:ConsoleSystem");
componentSystemManager.register(new CoreCommands(), "engine:CoreCommands");
componentSystemManager.register(context.get(InputSystem.class), "engine:InputSystem");
EntityRef localPlayerEntity = entityManager.create(new ClientComponent());
LocalPlayer localPlayer = new LocalPlayer();
context.put(LocalPlayer.class, localPlayer);
localPlayer.setClientEntity(localPlayerEntity);
componentSystemManager.initialise();
GameManifest gameManifest = null;
List<GameInfo> savedGames = GameProvider.getSavedGames();
if (savedGames.size() > 0) {
gameManifest = savedGames.get(0).getManifest();
} else {
gameManifest = createGameManifest();
}
gameEngine.changeState(new StateLoading(gameManifest, NetworkMode.LISTEN_SERVER));
}
Aggregations