Search in sources :

Example 6 with ComponentSystemManager

use of org.terasology.engine.ComponentSystemManager in project Terasology by MovingBlocks.

the class NetworkOwnershipTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    EngineTime mockTime = mock(EngineTime.class);
    networkSystem = new NetworkSystemImpl(mockTime, context);
    networkSystem.setContext(context);
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    entityManager = (PojoEntityManager) context.get(EntityManager.class);
    context.put(ComponentSystemManager.class, new ComponentSystemManager(context));
    entityManager.clear();
    client = mock(NetClient.class);
    NetworkComponent clientNetComp = new NetworkComponent();
    clientNetComp.replicateMode = NetworkComponent.ReplicateMode.OWNER;
    clientEntity = entityManager.create(clientNetComp);
    when(client.getEntity()).thenReturn(clientEntity);
    when(client.getId()).thenReturn("dummyID");
    networkSystem.mockHost();
    networkSystem.connectToEntitySystem(entityManager, context.get(EventLibrary.class), mock(BlockEntityRegistry.class));
    networkSystem.registerNetworkEntity(clientEntity);
}
Also used : NetworkComponent(org.terasology.network.NetworkComponent) EventLibrary(org.terasology.entitySystem.metadata.EventLibrary) EngineTime(org.terasology.engine.EngineTime) BlockEntityRegistry(org.terasology.world.BlockEntityRegistry) ModuleManager(org.terasology.engine.module.ModuleManager) ComponentSystemManager(org.terasology.engine.ComponentSystemManager) Before(org.junit.Before)

Example 7 with ComponentSystemManager

use of org.terasology.engine.ComponentSystemManager in project Terasology by MovingBlocks.

the class ReadWriteStorageManager method startSaving.

private void startSaving() {
    logger.info("Saving - Creating game snapshot");
    PerformanceMonitor.startActivity("Saving");
    ComponentSystemManager componentSystemManager = CoreRegistry.get(ComponentSystemManager.class);
    for (ComponentSystem sys : componentSystemManager.iterateAll()) {
        sys.preSave();
    }
    saveRequested = false;
    saveTransaction = createSaveTransaction();
    saveThreadManager.offer(saveTransaction);
    for (ComponentSystem sys : componentSystemManager.iterateAll()) {
        sys.postSave();
    }
    PerformanceMonitor.endActivity();
    entitySetDeltaRecorder = new EntitySetDeltaRecorder(this.entityRefReplacingComponentLibrary);
    logger.info("Saving - Snapshot created: Writing phase starts");
}
Also used : ComponentSystem(org.terasology.entitySystem.systems.ComponentSystem) ComponentSystemManager(org.terasology.engine.ComponentSystemManager)

Example 8 with ComponentSystemManager

use of org.terasology.engine.ComponentSystemManager in project Terasology by MovingBlocks.

the class StateMainMenu 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);
    console = new ConsoleImpl(context);
    context.put(Console.class, console);
    nuiManager = new NUIManagerInternal(context.get(CanvasRenderer.class), context);
    context.put(NUIManager.class, nuiManager);
    eventSystem.registerEventHandler(nuiManager);
    componentSystemManager = new ComponentSystemManager(context);
    context.put(ComponentSystemManager.class, componentSystemManager);
    // TODO: Reduce coupling between Input system and CameraTargetSystem,
    // TODO: potentially eliminating the following lines. See Issue #1126
    CameraTargetSystem cameraTargetSystem = new CameraTargetSystem();
    context.put(CameraTargetSystem.class, cameraTargetSystem);
    componentSystemManager.register(cameraTargetSystem, "engine:CameraTargetSystem");
    componentSystemManager.register(new ConsoleSystem(), "engine:ConsoleSystem");
    componentSystemManager.register(new CoreCommands(), "engine:CoreCommands");
    NUIEditorSystem nuiEditorSystem = new NUIEditorSystem();
    context.put(NUIEditorSystem.class, nuiEditorSystem);
    componentSystemManager.register(nuiEditorSystem, "engine:NUIEditorSystem");
    NUISkinEditorSystem nuiSkinEditorSystem = new NUISkinEditorSystem();
    context.put(NUISkinEditorSystem.class, nuiSkinEditorSystem);
    componentSystemManager.register(nuiSkinEditorSystem, "engine:NUISkinEditorSystem");
    inputSystem = context.get(InputSystem.class);
    // TODO: REMOVE this and handle refreshing of core game state at the engine level - see Issue #1127
    new RegisterInputSystem(context).step();
    EntityRef localPlayerEntity = entityManager.create(new ClientComponent());
    LocalPlayer localPlayer = new LocalPlayer();
    context.put(LocalPlayer.class, localPlayer);
    localPlayer.setClientEntity(localPlayerEntity);
    componentSystemManager.initialise();
    storageServiceWorker = context.get(StorageServiceWorker.class);
    playBackgroundMusic();
    // guiManager.openWindow("main");
    context.get(NUIManager.class).pushScreen("engine:mainMenuScreen");
    if (!messageOnLoad.isEmpty()) {
        nuiManager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Error", messageOnLoad);
    }
// TODO: enable it when exposing the telemetry to users
// pushLaunchPopup();
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) NUIEditorSystem(org.terasology.rendering.nui.editor.systems.NUIEditorSystem) ConsoleImpl(org.terasology.logic.console.ConsoleImpl) LocalPlayer(org.terasology.logic.players.LocalPlayer) MessagePopup(org.terasology.rendering.nui.layers.mainMenu.MessagePopup) NUISkinEditorSystem(org.terasology.rendering.nui.editor.systems.NUISkinEditorSystem) RegisterInputSystem(org.terasology.engine.modes.loadProcesses.RegisterInputSystem) RegisterInputSystem(org.terasology.engine.modes.loadProcesses.RegisterInputSystem) 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) EventSystem(org.terasology.entitySystem.event.internal.EventSystem) NUIManager(org.terasology.rendering.nui.NUIManager) EntityRef(org.terasology.entitySystem.entity.EntityRef) StorageServiceWorker(org.terasology.identity.storageServiceClient.StorageServiceWorker) CameraTargetSystem(org.terasology.input.cameraTarget.CameraTargetSystem)

Example 9 with ComponentSystemManager

use of org.terasology.engine.ComponentSystemManager in project Terasology by MovingBlocks.

the class PostBeginSystems method begin.

@Override
public void begin() {
    ComponentSystemManager csm = context.get(ComponentSystemManager.class);
    componentSystems = csm.iterateAll().iterator();
}
Also used : ComponentSystemManager(org.terasology.engine.ComponentSystemManager)

Example 10 with ComponentSystemManager

use of org.terasology.engine.ComponentSystemManager in project Terasology by MovingBlocks.

the class RegisterInputSystem method step.

@Override
public boolean step() {
    ComponentSystemManager componentSystemManager = context.get(ComponentSystemManager.class);
    LocalPlayerSystem localPlayerSystem = new LocalPlayerSystem();
    componentSystemManager.register(localPlayerSystem, "engine:localPlayerSystem");
    context.put(LocalPlayerSystem.class, localPlayerSystem);
    CameraTargetSystem cameraTargetSystem = new CameraTargetSystem();
    context.put(CameraTargetSystem.class, cameraTargetSystem);
    componentSystemManager.register(cameraTargetSystem, "engine:CameraTargetSystem");
    InputSystem inputSystem = context.get(InputSystem.class);
    componentSystemManager.register(inputSystem, "engine:InputSystem");
    return true;
}
Also used : LocalPlayerSystem(org.terasology.logic.players.LocalPlayerSystem) InputSystem(org.terasology.input.InputSystem) ComponentSystemManager(org.terasology.engine.ComponentSystemManager) CameraTargetSystem(org.terasology.input.cameraTarget.CameraTargetSystem)

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