Search in sources :

Example 1 with ComponentSystemManager

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");
}
Also used : ComponentSystem(org.terasology.entitySystem.systems.ComponentSystem) ComponentSystemManager(org.terasology.engine.ComponentSystemManager)

Example 2 with ComponentSystemManager

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;
}
Also used : LocalPlayer(org.terasology.logic.players.LocalPlayer) UpdateSubscriberSystem(org.terasology.entitySystem.systems.UpdateSubscriberSystem) ClientComponent(org.terasology.network.ClientComponent) ComponentSystemManager(org.terasology.engine.ComponentSystemManager)

Example 3 with ComponentSystemManager

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;
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) EntityManager(org.terasology.entitySystem.entity.EntityManager) EventLibrary(org.terasology.entitySystem.metadata.EventLibrary) NetworkSystem(org.terasology.network.NetworkSystem) BlockEntityRegistry(org.terasology.world.BlockEntityRegistry) ComponentSystemManager(org.terasology.engine.ComponentSystemManager)

Example 4 with ComponentSystemManager

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();
}
Also used : ComponentSystemManager(org.terasology.engine.ComponentSystemManager)

Example 5 with ComponentSystemManager

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));
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) GameInfo(org.terasology.rendering.nui.layers.mainMenu.savedGames.GameInfo) StateLoading(org.terasology.engine.modes.StateLoading) ConsoleImpl(org.terasology.logic.console.ConsoleImpl) CanvasRenderer(org.terasology.rendering.nui.internal.CanvasRenderer) LocalPlayer(org.terasology.logic.players.LocalPlayer) InputSystem(org.terasology.input.InputSystem) CoreCommands(org.terasology.logic.console.commands.CoreCommands) ClientComponent(org.terasology.network.ClientComponent) NUIManagerInternal(org.terasology.rendering.nui.internal.NUIManagerInternal) ComponentSystemManager(org.terasology.engine.ComponentSystemManager) ConsoleSystem(org.terasology.logic.console.ConsoleSystem) GameManifest(org.terasology.game.GameManifest) EventSystem(org.terasology.entitySystem.event.internal.EventSystem) NUIManager(org.terasology.rendering.nui.NUIManager) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Aggregations

ComponentSystemManager (org.terasology.engine.ComponentSystemManager)13 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)4 InputSystem (org.terasology.input.InputSystem)3 ConsoleImpl (org.terasology.logic.console.ConsoleImpl)3 LocalPlayer (org.terasology.logic.players.LocalPlayer)3 ClientComponent (org.terasology.network.ClientComponent)3 Before (org.junit.Before)2 EngineTime (org.terasology.engine.EngineTime)2 ModuleManager (org.terasology.engine.module.ModuleManager)2 EntityRef (org.terasology.entitySystem.entity.EntityRef)2 EventSystem (org.terasology.entitySystem.event.internal.EventSystem)2 EventLibrary (org.terasology.entitySystem.metadata.EventLibrary)2 ComponentSystem (org.terasology.entitySystem.systems.ComponentSystem)2 CameraTargetSystem (org.terasology.input.cameraTarget.CameraTargetSystem)2 ConsoleSystem (org.terasology.logic.console.ConsoleSystem)2 CoreCommands (org.terasology.logic.console.commands.CoreCommands)2 NUIManager (org.terasology.rendering.nui.NUIManager)2 NUIManagerInternal (org.terasology.rendering.nui.internal.NUIManagerInternal)2 BlockEntityRegistry (org.terasology.world.BlockEntityRegistry)2 Path (java.nio.file.Path)1