use of org.terasology.audio.events.PlaySoundEvent in project Terasology by MovingBlocks.
the class DoorSystem method openDoor.
@ReceiveEvent
public void openDoor(OpenDoorEvent event, EntityRef player) {
EntityRef entity = event.getDoorEntity();
DoorComponent door = entity.getComponent(DoorComponent.class);
Side newSide = door.openSide;
BlockRegionComponent regionComp = entity.getComponent(BlockRegionComponent.class);
Block bottomBlock = door.bottomBlockFamily.getBlockForPlacement(worldProvider, blockEntityRegistry, regionComp.region.min(), newSide, Side.TOP);
worldProvider.setBlock(regionComp.region.min(), bottomBlock);
Block topBlock = door.topBlockFamily.getBlockForPlacement(worldProvider, blockEntityRegistry, regionComp.region.max(), newSide, Side.TOP);
worldProvider.setBlock(regionComp.region.max(), topBlock);
if (door.openSound != null) {
entity.send(new PlaySoundEvent(door.openSound, 1f));
}
door.isOpen = true;
}
use of org.terasology.audio.events.PlaySoundEvent in project Terasology by MovingBlocks.
the class BlockDamageAuthoritySystem method onPlayBlockDamageCommon.
private void onPlayBlockDamageCommon(BlockFamily family, Vector3f location, EntityRef entityRef) {
createBlockParticleEffect(family, location);
BlockSounds sounds = family.getArchetypeBlock().getSounds();
if (!sounds.getDigSounds().isEmpty()) {
StaticSound sound = random.nextItem(sounds.getDigSounds());
entityRef.send(new PlaySoundEvent(sound, 1f));
}
}
use of org.terasology.audio.events.PlaySoundEvent in project Terasology by MovingBlocks.
the class HealthAuthoritySystem method onCrash.
@ReceiveEvent
public void onCrash(HorizontalCollisionEvent event, EntityRef entity, CharacterSoundComponent characterSounds, HealthComponent healthComponent) {
Vector3f horizVelocity = new Vector3f(event.getVelocity());
horizVelocity.y = 0;
float velocity = horizVelocity.length();
if (velocity > healthComponent.horizontalDamageSpeedThreshold) {
if (characterSounds.lastSoundTime + CharacterSoundSystem.MIN_TIME < time.getGameTimeInMs()) {
StaticSound sound = random.nextItem(characterSounds.landingSounds);
if (sound != null) {
entity.send(new PlaySoundEvent(sound, characterSounds.landingVolume));
characterSounds.lastSoundTime = time.getGameTimeInMs();
entity.saveComponent(characterSounds);
}
}
}
}
Aggregations