use of com.talosvfx.talos.runtime.modules.EmitterModule in project talos by rockbite.
the class ParticleEffectDescriptor method load.
public void load(FileHandle fileHandle) {
Json json = new Json();
ParticleEmitterDescriptor.registerModules();
for (Class clazz : ParticleEmitterDescriptor.registeredModules) {
json.addClassTag(clazz.getSimpleName(), clazz);
}
final ExportData exportData = json.fromJson(ExportData.class, fileHandle.readString());
for (ExportData.EmitterExportData emitter : exportData.emitters) {
ParticleEmitterDescriptor emitterDescriptor = new ParticleEmitterDescriptor(this);
IntMap<AbstractModule> idMap = new IntMap<>();
for (AbstractModule module : emitter.modules) {
module.setModuleGraph(emitterDescriptor);
if (module instanceof ParticleModule) {
emitterDescriptor.particleModule = (ParticleModule) module;
}
if (module instanceof EmitterModule) {
emitterDescriptor.emitterModule = (EmitterModule) module;
}
idMap.put(module.getIndex(), module);
// I cannot understand how this was working before. This is needed so that it can later reset requesters.
emitterDescriptor.modules.add(module);
}
for (ConnectionData connection : emitter.connections) {
final int moduleFromId = connection.moduleFrom;
final int moduleToId = connection.moduleTo;
final int slotFrom = connection.slotFrom;
final int slotTo = connection.slotTo;
AbstractModule moduleFrom = idMap.get(moduleFromId);
AbstractModule moduleTo = idMap.get(moduleToId);
if (moduleFrom == null) {
throw new GdxRuntimeException("No module from found for id: " + moduleFromId);
}
if (moduleTo == null) {
throw new GdxRuntimeException("No module to found for id: " + moduleToId);
}
emitterDescriptor.connectNode(moduleFrom, moduleTo, slotFrom, slotTo);
}
emitterModuleGraphs.add(emitterDescriptor);
}
}
Aggregations