예제 #1
0
        private void HandleEmitSoundOnActivateInWorld(EntityUid eUI, BaseEmitSoundComponent component, ActivateInWorldEvent arg)
        {
            if (arg.Handled)
            {
                return;
            }

            arg.Handled = true;
            TryEmitSound(component);
        }
예제 #2
0
 private static void TryEmitSound(BaseEmitSoundComponent component)
 {
     if (!string.IsNullOrWhiteSpace(component.Sound.GetSound()))
     {
         SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f));
     }
     else
     {
         Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has no {nameof(component.Sound)} to play.");
     }
 }
        private void HandleEmitSoundOnLand(EntityUid eUI, BaseEmitSoundComponent component, LandEvent arg)
        {
            if (!TryComp <TransformComponent>(eUI, out var xform) ||
                !_mapManager.TryGetGrid(xform.GridUid, out var grid))
            {
                return;
            }

            var tile = grid.GetTileRef(xform.Coordinates);

            if (tile.IsSpace(_tileDefMan))
            {
                return;
            }

            TryEmitSound(component);
        }
예제 #4
0
 private static void TryEmitSound(BaseEmitSoundComponent component)
 {
     SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f));
 }
예제 #5
0
 private void HandleEmitSoundOnThrown(EntityUid eUI, BaseEmitSoundComponent component, ThrownEvent arg)
 {
     TryEmitSound(component);
 }
예제 #6
0
 private void HandleEmitSoundOnLand(EntityUid eUI, BaseEmitSoundComponent component, LandEvent arg)
 {
     TryEmitSound(component);
 }
예제 #7
0
 private void HandleEmitSoundOnActivateInWorld(EntityUid eUI, BaseEmitSoundComponent component, ActivateInWorldEvent arg)
 {
     TryEmitSound(component);
 }
예제 #8
0
 private static void PlaySingleSound(string soundName, BaseEmitSoundComponent component)
 {
     SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner,
                      AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f));
 }
예제 #9
0
        private void PlayRandomSoundFromCollection(BaseEmitSoundComponent component)
        {
            var file = SelectRandomSoundFromSoundCollection(component.SoundCollectionName !);

            PlaySingleSound(file, component);
        }
예제 #10
0
 private void PlaySound(BaseEmitSoundComponent component)
 {
     PlayRandomSoundFromCollection(component);
 }
        private void TryEmitSound(BaseEmitSoundComponent component)
        {
            var audioParams = component.AudioParams.WithPitchScale((float)_random.NextGaussian(1, component.PitchVariation));

            SoundSystem.Play(component.Sound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, audioParams);
        }
 private void HandleEmitSoundOnUIOpen(EntityUid eUI, BaseEmitSoundComponent component, AfterActivatableUIOpenEvent arg)
 {
     TryEmitSound(component);
 }
예제 #13
0
 private void HandleEmitSoundOnActivateInWorld(EntityUid eUI, BaseEmitSoundComponent component, ActivateInWorldEvent arg)
 {
     // Intentionally not handling interaction. This component is an easy way to add sounds in addition to other behavior.
     TryEmitSound(component);
 }