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");
}
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);
}
}
}
}
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");
}
}
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");
}
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();
}
Aggregations