private void HandleEmitSoundOnActivateInWorld(EntityUid eUI, BaseEmitSoundComponent component, ActivateInWorldEvent arg) { if (arg.Handled) { return; } arg.Handled = true; TryEmitSound(component); }
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); }
private void HandleEmitSoundOnActivateInWorld(EntityUid eUI, BaseEmitSoundComponent component, ActivateInWorldEvent arg) { TryEmitSound(component); }
private static void PlaySingleSound(string soundName, BaseEmitSoundComponent component) { SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); }
private void PlayRandomSoundFromCollection(BaseEmitSoundComponent component) { var file = SelectRandomSoundFromSoundCollection(component.SoundCollectionName !); PlaySingleSound(file, component); }
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); }
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); }