use of org.terasology.engine.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.getAllSystems()) {
sys.preSave();
}
saveRequested = false;
saveTransaction = createSaveTransaction();
saveThreadManager.offer(saveTransaction);
if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.NOT_ACTIVATED) {
saveGamePreviewImage();
}
for (ComponentSystem sys : componentSystemManager.getAllSystems()) {
sys.postSave();
}
PerformanceMonitor.endActivity();
entitySetDeltaRecorder = new EntitySetDeltaRecorder(this.entityRefReplacingComponentLibrary);
logger.info("Saving - Snapshot created: Writing phase starts");
}
use of org.terasology.engine.entitySystem.systems.ComponentSystem in project Terasology by MovingBlocks.
the class PreBeginSystems method begin.
@Override
public void begin() {
ComponentSystemManager csm = context.get(ComponentSystemManager.class);
final List<ComponentSystem> componentSystemList = csm.getAllSystems();
componentSystems = componentSystemList.iterator();
setTotalSteps(componentSystemList.size());
}
use of org.terasology.engine.entitySystem.systems.ComponentSystem in project Terasology by MovingBlocks.
the class ComponentSystemManager method shutdown.
public void shutdown() {
for (ComponentSystem system : getAllSystems()) {
system.shutdown();
}
updateSubscribers.clear();
renderSubscribers.clear();
}
use of org.terasology.engine.entitySystem.systems.ComponentSystem in project Terasology by MovingBlocks.
the class ComponentSystemManager method tryToLoadSystem.
/**
* Try to load system. try to rollback changes, when fails.
*
* @param system system's class for creation and loading.
* @param id id of system.
*/
private void tryToLoadSystem(Class<?> system, String id) {
ComponentSystem newSystem = null;
try {
newSystem = (ComponentSystem) system.newInstance();
InjectionHelper.share(newSystem);
register(newSystem, id);
logger.debug("Loaded system {}", id);
} catch (RuntimeException | InstantiationException | IllegalAccessException e) {
logger.error("Failed to load system {}", id, e);
rollbackLoading(newSystem, id);
}
}
use of org.terasology.engine.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.isAuthority(), 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);
if (checkOptionalDependenciesPresent(system)) {
tryToLoadSystem(system, id);
} else {
logger.warn("Skip system {} for loading - possibly missing optional dependencies", id);
}
}
}
}
Aggregations