Search in sources :

Example 16 with PlaySoundEvent

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;
}
Also used : Side(org.terasology.math.Side) BlockRegionComponent(org.terasology.world.block.regions.BlockRegionComponent) PlaySoundEvent(org.terasology.audio.events.PlaySoundEvent) Block(org.terasology.world.block.Block) EntityRef(org.terasology.entitySystem.entity.EntityRef) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Example 17 with PlaySoundEvent

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));
    }
}
Also used : BlockSounds(org.terasology.world.block.sounds.BlockSounds) StaticSound(org.terasology.audio.StaticSound) PlaySoundEvent(org.terasology.audio.events.PlaySoundEvent)

Example 18 with PlaySoundEvent

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);
            }
        }
    }
}
Also used : StaticSound(org.terasology.audio.StaticSound) Vector3f(org.terasology.math.geom.Vector3f) PlaySoundEvent(org.terasology.audio.events.PlaySoundEvent) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Aggregations

PlaySoundEvent (org.terasology.audio.events.PlaySoundEvent)18 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)15 StaticSound (org.terasology.audio.StaticSound)13 Block (org.terasology.world.block.Block)6 EntityRef (org.terasology.entitySystem.entity.EntityRef)4 Side (org.terasology.math.Side)4 Vector3f (org.terasology.math.geom.Vector3f)4 Vector3i (org.terasology.math.geom.Vector3i)4 LocationComponent (org.terasology.logic.location.LocationComponent)3 BlockRegionComponent (org.terasology.world.block.regions.BlockRegionComponent)3 EntityBuilder (org.terasology.entitySystem.entity.EntityBuilder)2 BlockComponent (org.terasology.world.block.BlockComponent)2 PlaceBlocks (org.terasology.world.block.entity.placement.PlaceBlocks)2 BlockSounds (org.terasology.world.block.sounds.BlockSounds)2 HashMap (java.util.HashMap)1 PlaySoundForOwnerEvent (org.terasology.audio.events.PlaySoundForOwnerEvent)1 DoDamageEvent (org.terasology.logic.health.DoDamageEvent)1 BlockDamageModifierComponent (org.terasology.world.block.entity.damage.BlockDamageModifierComponent)1 BlockFamily (org.terasology.world.block.family.BlockFamily)1