Search in sources :

Example 1 with ComponentSystem

use of org.terasology.entitySystem.systems.ComponentSystem 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 ComponentSystem

use of org.terasology.entitySystem.systems.ComponentSystem in project Terasology by MovingBlocks.

the class ComponentSystemManager method loadSystems.

public void loadSystems(ModuleEnvironment environment, NetworkMode netMode) {
    DisplayDevice display = context.get(DisplayDevice.class);
    boolean isHeadless = display.isHeadless();
    ListMultimap<Name, Class<?>> systemsByModule = ArrayListMultimap.create();
    for (Class<?> type : environment.getTypesAnnotatedWith(RegisterSystem.class)) {
        if (!ComponentSystem.class.isAssignableFrom(type)) {
            logger.error("Cannot load {}, must be a subclass of ComponentSystem", type.getSimpleName());
            continue;
        }
        Name moduleId = environment.getModuleProviding(type);
        RegisterSystem registerInfo = type.getAnnotation(RegisterSystem.class);
        if (registerInfo.value().isValidFor(netMode, isHeadless) && areOptionalRequirementsContained(registerInfo, environment)) {
            systemsByModule.put(moduleId, type);
        }
    }
    for (Module module : environment.getModulesOrderedByDependencies()) {
        for (Class<?> system : systemsByModule.get(module.getId())) {
            String id = module.getId() + ":" + system.getSimpleName();
            logger.debug("Registering system {}", id);
            try {
                ComponentSystem newSystem = (ComponentSystem) system.newInstance();
                InjectionHelper.share(newSystem);
                register(newSystem, id);
                logger.debug("Loaded system {}", id);
            } catch (RuntimeException | IllegalAccessException | InstantiationException | NoClassDefFoundError e) {
                logger.error("Failed to load system {}", id, e);
            }
        }
    }
}
Also used : DisplayDevice(org.terasology.engine.subsystem.DisplayDevice) ComponentSystem(org.terasology.entitySystem.systems.ComponentSystem) Name(org.terasology.naming.Name) RegisterSystem(org.terasology.entitySystem.systems.RegisterSystem) Module(org.terasology.module.Module)

Example 3 with ComponentSystem

use of org.terasology.entitySystem.systems.ComponentSystem in project Terasology by MovingBlocks.

the class ComponentSystemManager method initialise.

public void initialise() {
    if (!initialised) {
        console = context.get(Console.class);
        for (ComponentSystem system : iterateAll()) {
            initialiseSystem(system);
        }
        initialised = true;
    } else {
        logger.error("ComponentSystemManager got initialized twice");
    }
}
Also used : Console(org.terasology.logic.console.Console) ComponentSystem(org.terasology.entitySystem.systems.ComponentSystem)

Example 4 with ComponentSystem

use of org.terasology.entitySystem.systems.ComponentSystem 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 5 with ComponentSystem

use of org.terasology.entitySystem.systems.ComponentSystem in project Terasology by MovingBlocks.

the class ComponentSystemManager method shutdown.

public void shutdown() {
    for (ComponentSystem system : iterateAll()) {
        system.shutdown();
    }
    updateSubscribers.clear();
    renderSubscribers.clear();
}
Also used : ComponentSystem(org.terasology.entitySystem.systems.ComponentSystem)

Aggregations

ComponentSystem (org.terasology.entitySystem.systems.ComponentSystem)5 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)2 DisplayDevice (org.terasology.engine.subsystem.DisplayDevice)1 RegisterSystem (org.terasology.entitySystem.systems.RegisterSystem)1 Console (org.terasology.logic.console.Console)1 Module (org.terasology.module.Module)1 Name (org.terasology.naming.Name)1