private void HandleEmitSoundOnActivateInWorld(EntityUid eUI, BaseEmitSoundComponent component, ActivateInWorldEvent arg)
        {
            if (arg.Handled)
            {
                return;
            }

            arg.Handled = true;
            TryEmitSound(component);
        }
Exemple #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);
        }
 private static void TryEmitSound(BaseEmitSoundComponent component)
 {
     SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f));
 }
 private void HandleEmitSoundOnThrown(EntityUid eUI, BaseEmitSoundComponent component, ThrownEvent arg)
 {
     TryEmitSound(component);
 }
 private void HandleEmitSoundOnLand(EntityUid eUI, BaseEmitSoundComponent component, LandEvent arg)
 {
     TryEmitSound(component);
 }
Exemple #7
0
 private void HandleEmitSoundOnActivateInWorld(EntityUid eUI, BaseEmitSoundComponent component, ActivateInWorldEvent arg)
 {
     TryEmitSound(component);
 }
Exemple #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));
 }
Exemple #9
0
        private void PlayRandomSoundFromCollection(BaseEmitSoundComponent component)
        {
            var file = SelectRandomSoundFromSoundCollection(component.SoundCollectionName !);

            PlaySingleSound(file, component);
        }
Exemple #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);
 }
Exemple #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);
 }