use of org.terasology.engine.audio.StaticSound in project Terasology by MovingBlocks.
the class BlockEntitySystem method commonDestroyed.
private void commonDestroyed(DoDestroyEvent event, EntityRef entity, Block block) {
entity.send(new CreateBlockDropsEvent(event.getInstigator(), event.getDirectCause(), event.getDamageType()));
BlockDamageModifierComponent blockDamageModifierComponent = event.getDamageType().getComponent(BlockDamageModifierComponent.class);
// TODO: Configurable via block definition
if (blockDamageModifierComponent == null || !blockDamageModifierComponent.skipPerBlockEffects) {
// dust particle effect
if (entity.hasComponent(LocationComponent.class) && block.isDebrisOnDestroy()) {
// TODO: particle system stuff should be split out better - this is effectively a stealth dependency on
// 'CoreAssets' from the engine
EntityBuilder dustBuilder = entityManager.newBuilder("CoreAssets:dustEffect");
if (dustBuilder.hasComponent(LocationComponent.class)) {
dustBuilder.getComponent(LocationComponent.class).setWorldPosition(entity.getComponent(LocationComponent.class).getWorldPosition(new Vector3f()));
dustBuilder.build();
}
}
// sound to play for destroyed block
BlockSounds sounds = block.getSounds();
if (!sounds.getDestroySounds().isEmpty()) {
StaticSound sound = random.nextItem(sounds.getDestroySounds());
entity.send(new PlaySoundEvent(sound, 0.6f));
}
}
}
Aggregations