public void AddCue(ActiveCue cue, GameObject attachedObject) { m_activeCues.Add(cue); if ((attachedObject != null) && (m_perGameObject)) { if (!m_activeCuesPerObject.ContainsKey(attachedObject)) { m_activeCuesPerObject[attachedObject] = new List <ActiveCue>(); } m_activeCuesPerObject[attachedObject].Add(cue); } Limit(attachedObject); }
public void AddCue(ActiveCue cue, GameObject attachedObject) { m_activeCues.Add(cue); if ((attachedObject != null) && (m_perGameObject)) { if (!m_activeCuesPerObject.ContainsKey(attachedObject)) { m_activeCuesPerObject[attachedObject] = new List<ActiveCue>(); } m_activeCuesPerObject[attachedObject].Add(cue); } Limit(attachedObject); }
public ActiveCue Unpause(ActiveCue cue) { if (cue == null) { foreach (ActiveCue fCue in m_currentActiveCues) { fCue.Unpause(); } } else { cue.Unpause(); } return(cue); }
public ActiveCue Stop(ActiveCue cue, float fade) { if (cue == null) { foreach (ActiveCue fCue in m_currentActiveCues) { fCue.Stop(fade); } } else { cue.Stop(fade); } return(cue); }
public ActiveCue Play(ActiveCue cue, float fade, GameObject target) { if (m_instanceLimiter == null || m_instanceLimiter.CanPlay(target)) { if ((cue == null) || (m_retriggerOnSameObjectBehaviour == RetriggerOnSameObject.PlayAnother)) { GameObject newCue = new GameObject("Cue"); cue = newCue.AddComponent <ActiveCue>(); cue.Initialise(gameObject, target); m_currentActiveCues.Add(cue); if (m_beatSynchronizeOnStart) { BeatSyncSource current = BeatSyncSource.GetCurrent(); if (current != null) { cue.Play(fade, current.GetNextBeatTime()); } else { cue.Play(fade); } } else { cue.Play(fade); } if (m_instanceLimiter != null) { m_instanceLimiter.AddCue(cue, target); } } else { if (m_retriggerOnSameObjectBehaviour != RetriggerOnSameObject.DontPlay) { cue.Play(fade); } } } return(cue); }
public AudioSourcePoolItem TryClaimPoolSource(ActiveCue cue) { AudioSourcePoolItem bestSteal = null; int lowestImportance = cue.GetImportance(); float quietestSimilarImportance = 1.0f; foreach (AudioSourcePoolItem aspi in m_audioSourcePool) { if (aspi.m_user == null) { aspi.m_user = cue; return(aspi); } else { if (aspi.m_user.GetImportance() < cue.GetImportance()) { if (aspi.m_user.GetImportance() < lowestImportance) { lowestImportance = aspi.m_user.GetImportance(); bestSteal = aspi; } } else if (aspi.m_user.GetImportance() == lowestImportance) { if (aspi.m_user.GetTheoreticalVolume() < quietestSimilarImportance) { quietestSimilarImportance = aspi.m_user.GetTheoreticalVolume(); bestSteal = aspi; } } } } if (bestSteal != null) { bestSteal.m_user.Virtualise(); bestSteal.m_user = cue; return(bestSteal); } return(null); }
public ActiveCue Unpause(ActiveCue cue) { if (cue == null) { foreach (ActiveCue fCue in m_currentActiveCues) { fCue.Unpause(); } } else { cue.Unpause(); } return cue; }
public ActiveCue Stop(ActiveCue cue, float fade) { if (cue == null) { foreach (ActiveCue fCue in m_currentActiveCues) { fCue.Stop(fade); } } else { cue.Stop(fade); } return cue; }
public ActiveCue Play(ActiveCue cue, float fade, GameObject target) { if (m_instanceLimiter == null || m_instanceLimiter.CanPlay(target)) { if ((cue == null)||(m_retriggerOnSameObjectBehaviour == RetriggerOnSameObject.PlayAnother)) { GameObject newCue = new GameObject("Cue"); cue = newCue.AddComponent<ActiveCue>(); cue.Initialise(gameObject, target); m_currentActiveCues.Add(cue); if (m_beatSynchronizeOnStart) { BeatSyncSource current = BeatSyncSource.GetCurrent(); if ( current != null ) { cue.Play(fade, current.GetNextBeatTime()); } else { cue.Play(fade); } } else { cue.Play(fade); } if (m_instanceLimiter != null) { m_instanceLimiter.AddCue(cue, target); } } else { if (m_retriggerOnSameObjectBehaviour != RetriggerOnSameObject.DontPlay) { cue.Play(fade); } } } return cue; }
public AudioSourcePoolItem TryClaimPoolSource(ActiveCue cue) { AudioSourcePoolItem bestSteal = null; int lowestImportance = cue.GetImportance(); float quietestSimilarImportance = 1.0f; foreach (AudioSourcePoolItem aspi in m_audioSourcePool) { if (aspi.m_user == null) { aspi.m_user = cue; return aspi; } else { if (aspi.m_user.GetImportance() < cue.GetImportance()) { if (aspi.m_user.GetImportance() < lowestImportance) { lowestImportance = aspi.m_user.GetImportance(); bestSteal = aspi; } } else if (aspi.m_user.GetImportance() == lowestImportance) { if (aspi.m_user.GetTheoreticalVolume() < quietestSimilarImportance) { quietestSimilarImportance = aspi.m_user.GetTheoreticalVolume(); bestSteal = aspi; } } } } if (bestSteal != null) { bestSteal.m_user.Virtualise(); bestSteal.m_user = cue; return bestSteal; } return null; }
public void PerformActionInternal(string eventName, GameObject targetObject, List <ActiveCue> cuesOut) { int randomIndex = Random.Range(0, m_audioSources.Length); bool shouldIncreaseSequence = false; int index = 0; if (m_action == Actions.PlayRandomNoRepeats) { int randomP = Random.Range(0, m_availableRandoms.Count); randomIndex = m_availableRandoms[randomP]; m_availableRandoms.Remove(randomIndex); m_previousRandoms.Enqueue(randomIndex); if (m_previousRandoms.Count > Mathf.Min(m_noRepeatsMemory, m_audioSources.Length - 1)) { int toAdd = m_previousRandoms.Dequeue(); m_availableRandoms.Add(toAdd); } } foreach (BaseWingroveAudioSource was in m_audioSources) { ActiveCue useCue = was.GetCueForGameObject(targetObject); switch (m_action) { case Actions.Pause: useCue = was.Pause(useCue); break; case Actions.UnPause: useCue = was.Unpause(useCue); break; case Actions.Play: useCue = was.Play(useCue, m_fadeLength, targetObject); break; case Actions.PlayRandom: if (index == randomIndex) { useCue = was.Play(useCue, m_fadeLength, targetObject); } break; case Actions.PlaySequence: if (index == m_sequenceIndex) { useCue = was.Play(useCue, m_fadeLength, targetObject); shouldIncreaseSequence = true; } break; case Actions.Stop: useCue = was.Stop(useCue, m_fadeLength); break; case Actions.PlayRandomNoRepeats: if (index == randomIndex) { useCue = was.Play(useCue, m_fadeLength, targetObject); } break; } if (cuesOut != null) { cuesOut.Add(useCue); } ++index; } if (shouldIncreaseSequence) { m_sequenceIndex = (m_sequenceIndex + 1) % m_audioSources.Length; } }