private void StopAudioSources(WeaponRotationSoundComponent sounds) { if (sounds.IsActive) { sounds.StartAudioSource.Stop(); sounds.LoopAudioSource.Stop(); sounds.StopAudioSource.Play(); sounds.IsActive = false; } }
private void StartAudioSources(WeaponRotationSoundComponent sounds) { if (!sounds.IsActive) { sounds.StopAudioSource.Stop(); sounds.StartAudioSource.Play(); double time = AudioSettings.dspTime + sounds.StartAudioSource.clip.length; sounds.LoopAudioSource.PlayScheduled(time); sounds.IsActive = true; } }
public void CreateWeaponRotationSound(NodeAddedEvent evt, [Combine] WeaponSoundNode weaponNode, SingleNode <SoundListenerBattleStateComponent> soundListener) { WeaponRotationSoundComponent weaponRotationSound = weaponNode.weaponRotationSound; GameObject obj2 = Object.Instantiate <GameObject>(weaponRotationSound.Asset); obj2.transform.parent = weaponNode.weaponSoundRoot.gameObject.transform; obj2.transform.localPosition = Vector3.zero; WeaponRotationSoundBehaviour component = obj2.GetComponent <WeaponRotationSoundBehaviour>(); weaponRotationSound.StartAudioSource = component.startAudioSource; weaponRotationSound.LoopAudioSource = component.loopAudioSource; weaponRotationSound.StopAudioSource = component.stopAudioSource; weaponRotationSound.IsActive = false; weaponNode.Entity.AddComponent <WeaponRotationSoundReadyComponent>(); }