use of org.terasology.engine.particles.components.ParticleEmitterComponent in project Terasology by MovingBlocks.
the class ParticleUpdaterImplTest method testEmitterRegistration.
@Test
public void testEmitterRegistration() {
EntityRef emitterEntity = mock(EntityRef.class);
when(emitterEntity.getComponent(ParticleEmitterComponent.class)).thenReturn(new ParticleEmitterComponent());
particleUpdater.addEmitter(emitterEntity);
}
use of org.terasology.engine.particles.components.ParticleEmitterComponent in project Terasology by MovingBlocks.
the class ParticleUpdaterImpl method configureEmitter.
@Override
public void configureEmitter(final ParticleEmitterComponent emitter) {
emitter.generatorFunctionMap.clear();
emitter.affectorFunctionMap.clear();
for (Component c : emitter.ownerEntity.iterateComponents()) {
if (registeredGeneratorFunctions.containsKey(c.getClass())) {
emitter.generatorFunctionMap.put(c, registeredGeneratorFunctions.get(c.getClass()));
} else if (registeredAffectorFunctions.containsKey(c.getClass())) {
emitter.affectorFunctionMap.put(c, registeredAffectorFunctions.get(c.getClass()));
}
}
}
use of org.terasology.engine.particles.components.ParticleEmitterComponent in project Terasology by MovingBlocks.
the class ParticleUpdaterImplTest method testEmitterConfiguration.
@Test
public void testEmitterConfiguration() {
EntityRef emitterEntity = mock(EntityRef.class);
Iterator<Component> componentIterator = getTestGeneratorsAndAffectors();
when(emitterEntity.iterateComponents()).thenReturn(() -> componentIterator);
ParticleEmitterComponent particleEmitterComponent = new ParticleEmitterComponent();
particleEmitterComponent.ownerEntity = emitterEntity;
when(emitterEntity.getComponent(ParticleEmitterComponent.class)).thenReturn(particleEmitterComponent);
particleUpdater.addEmitter(emitterEntity);
particleUpdater.configureEmitter(particleEmitterComponent);
for (Component component : (Iterable<Component>) () -> componentIterator) {
if (component.getClass() == EnergyRangeGeneratorComponent.class) {
assertTrue(particleEmitterComponent.generatorFunctionMap.containsKey(component));
} else if (component.getClass() == VelocityAffectorComponent.class) {
assertTrue(particleEmitterComponent.affectorFunctionMap.containsKey(component));
}
}
}
use of org.terasology.engine.particles.components.ParticleEmitterComponent in project Terasology by MovingBlocks.
the class ParticleUpdaterImpl method addEmitter.
@Override
public void addEmitter(final EntityRef emitter) {
Preconditions.checkArgument(emitter != null, "Argument can not be null");
ParticleEmitterComponent emitterComponent = emitter.getComponent(ParticleEmitterComponent.class);
Preconditions.checkArgument(emitterComponent != null, "Entity %s does not have a ParticleEmitterComponent", emitter);
registeredParticleSystems.add(emitterComponent);
}
use of org.terasology.engine.particles.components.ParticleEmitterComponent in project Terasology by MovingBlocks.
the class ParticleUpdaterImpl method removeEmitter.
@Override
public void removeEmitter(final EntityRef emitter) {
Preconditions.checkArgument(emitter != null, "Argument can not be null");
ParticleEmitterComponent emitterComponent = emitter.getComponent(ParticleEmitterComponent.class);
Preconditions.checkState(registeredParticleSystems.contains(emitterComponent), "Entity %s is not a registered entity", emitter);
registeredParticleSystems.remove(emitterComponent);
}
Aggregations