Search in sources :

Example 6 with ComponentSystemManager

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

the class AbstractState method initEntityAndComponentManagers.

protected void initEntityAndComponentManagers(boolean isHeadless) {
    verifyNotNull(context);
    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));
    if (!isHeadless) {
        NUIManager nuiManager = new NUIManagerInternal((TerasologyCanvasRenderer) 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");
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) ConsoleSystem(org.terasology.engine.logic.console.ConsoleSystem) ConsoleImpl(org.terasology.engine.logic.console.ConsoleImpl) EventSystem(org.terasology.engine.entitySystem.event.internal.EventSystem) NUIManager(org.terasology.engine.rendering.nui.NUIManager) CoreCommands(org.terasology.engine.logic.console.commands.CoreCommands) NUIManagerInternal(org.terasology.engine.rendering.nui.internal.NUIManagerInternal) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager)

Example 7 with ComponentSystemManager

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

the class ComponentSystemManagerTest method setUp.

@BeforeEach
public void setUp() {
    Context context = mock(Context.class);
    EntityManager entityManager = mock(EntityManager.class);
    when(entityManager.getEventSystem()).thenReturn(mock(EventSystem.class));
    when(context.get(EntityManager.class)).thenReturn(entityManager);
    console = mock(Console.class);
    when(context.get(Console.class)).thenReturn(console);
    systemUnderTest = new ComponentSystemManager(context);
}
Also used : Context(org.terasology.engine.context.Context) EntityManager(org.terasology.engine.entitySystem.entity.EntityManager) Console(org.terasology.engine.logic.console.Console) EventSystem(org.terasology.engine.entitySystem.event.internal.EventSystem) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with ComponentSystemManager

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

the class TerasologyTestingEnvironment method setup.

@BeforeEach
public void setup() throws Exception {
    context.put(ModuleManager.class, moduleManager);
    RecordAndReplayCurrentStatus recordAndReplayCurrentStatus = context.get(RecordAndReplayCurrentStatus.class);
    mockTime = mock(EngineTime.class);
    context.put(Time.class, mockTime);
    NetworkSystemImpl networkSystem = new NetworkSystemImpl(mockTime, context);
    context.put(Game.class, new Game());
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    engineEntityManager = context.get(EngineEntityManager.class);
    // 'mock' added to avoid hiding a field
    BlockManager mockBlockManager = context.get(BlockManager.class);
    ExtraBlockDataManager extraDataManager = context.get(ExtraBlockDataManager.class);
    RecordedEventStore recordedEventStore = new RecordedEventStore();
    RecordAndReplayUtils recordAndReplayUtils = new RecordAndReplayUtils();
    context.put(RecordAndReplayUtils.class, recordAndReplayUtils);
    CharacterStateEventPositionMap characterStateEventPositionMap = new CharacterStateEventPositionMap();
    context.put(CharacterStateEventPositionMap.class, characterStateEventPositionMap);
    DirectionAndOriginPosRecorderList directionAndOriginPosRecorderList = new DirectionAndOriginPosRecorderList();
    context.put(DirectionAndOriginPosRecorderList.class, directionAndOriginPosRecorderList);
    RecordAndReplaySerializer recordAndReplaySerializer = new RecordAndReplaySerializer(engineEntityManager, recordedEventStore, recordAndReplayUtils, characterStateEventPositionMap, directionAndOriginPosRecorderList, moduleManager, context.get(TypeRegistry.class));
    context.put(RecordAndReplaySerializer.class, recordAndReplaySerializer);
    Path savePath = PathManager.getInstance().getSavePath("world1");
    context.put(StorageManager.class, new ReadWriteStorageManager(savePath, moduleManager.getEnvironment(), engineEntityManager, mockBlockManager, extraDataManager, recordAndReplaySerializer, recordAndReplayUtils, recordAndReplayCurrentStatus));
    ComponentSystemManager componentSystemManager = new ComponentSystemManager(context);
    context.put(ComponentSystemManager.class, componentSystemManager);
    LoadPrefabs prefabLoadStep = new LoadPrefabs(context);
    boolean complete = false;
    prefabLoadStep.begin();
    while (!complete) {
        complete = prefabLoadStep.step();
    }
    context.get(ComponentSystemManager.class).initialise();
    context.put(Console.class, new ConsoleImpl(context));
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) Path(java.nio.file.Path) ConsoleImpl(org.terasology.engine.logic.console.ConsoleImpl) EngineTime(org.terasology.engine.core.EngineTime) RecordedEventStore(org.terasology.engine.recording.RecordedEventStore) ExtraBlockDataManager(org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager) TypeRegistry(org.terasology.reflection.TypeRegistry) NetworkSystemImpl(org.terasology.engine.network.internal.NetworkSystemImpl) RecordAndReplaySerializer(org.terasology.engine.recording.RecordAndReplaySerializer) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager) DirectionAndOriginPosRecorderList(org.terasology.engine.recording.DirectionAndOriginPosRecorderList) Game(org.terasology.engine.game.Game) LoadPrefabs(org.terasology.engine.core.modes.loadProcesses.LoadPrefabs) BlockManager(org.terasology.engine.world.block.BlockManager) RecordAndReplayUtils(org.terasology.engine.recording.RecordAndReplayUtils) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) ReadWriteStorageManager(org.terasology.engine.persistence.internal.ReadWriteStorageManager) CharacterStateEventPositionMap(org.terasology.engine.recording.CharacterStateEventPositionMap) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with ComponentSystemManager

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

the class NetworkOwnershipTest method setup.

@BeforeEach
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);
    context.put(ServerConnectListManager.class, new ServerConnectListManager(context));
}
Also used : NetworkComponent(org.terasology.engine.network.NetworkComponent) EventLibrary(org.terasology.engine.entitySystem.metadata.EventLibrary) EngineTime(org.terasology.engine.core.EngineTime) BlockEntityRegistry(org.terasology.engine.world.BlockEntityRegistry) ModuleManager(org.terasology.engine.core.module.ModuleManager) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with ComponentSystemManager

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

the class PostBeginSystems method begin.

@Override
public void begin() {
    ComponentSystemManager manager = context.get(ComponentSystemManager.class);
    final List<ComponentSystem> componentSystemList = manager.getAllSystems();
    componentSystems = componentSystemList.iterator();
    setTotalSteps(componentSystemList.size());
}
Also used : ComponentSystem(org.terasology.engine.entitySystem.systems.ComponentSystem) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager)

Aggregations

ComponentSystemManager (org.terasology.engine.core.ComponentSystemManager)13 ComponentSystem (org.terasology.engine.entitySystem.systems.ComponentSystem)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)3 EngineTime (org.terasology.engine.core.EngineTime)2 ModuleManager (org.terasology.engine.core.module.ModuleManager)2 EntityManager (org.terasology.engine.entitySystem.entity.EntityManager)2 EventSystem (org.terasology.engine.entitySystem.event.internal.EventSystem)2 EventLibrary (org.terasology.engine.entitySystem.metadata.EventLibrary)2 ConsoleImpl (org.terasology.engine.logic.console.ConsoleImpl)2 BlockEntityRegistry (org.terasology.engine.world.BlockEntityRegistry)2 Path (java.nio.file.Path)1 Context (org.terasology.engine.context.Context)1 GameEngine (org.terasology.engine.core.GameEngine)1 TerasologyEngine (org.terasology.engine.core.TerasologyEngine)1 LoadPrefabs (org.terasology.engine.core.modes.loadProcesses.LoadPrefabs)1 EngineSubsystem (org.terasology.engine.core.subsystem.EngineSubsystem)1 UpdateSubscriberSystem (org.terasology.engine.entitySystem.systems.UpdateSubscriberSystem)1 Game (org.terasology.engine.game.Game)1 InputSystem (org.terasology.engine.input.InputSystem)1