Пример #1
0
		internal bool INTERNAL_addCue(Cue newCue)
		{
			lock (activeCues)
			{
				if (activeCues.Count >= maxCueInstances)
				{
					if (maxCueBehavior == MaxInstanceBehavior.Fail)
					{
						return false; // Just ignore us...
					}
					else if (maxCueBehavior == MaxInstanceBehavior.Queue)
					{
						newCue.INTERNAL_startFadeIn(maxFadeInMS);
						activeCues[0].INTERNAL_startFadeOut(maxFadeOutMS);
					}
					else if (maxCueBehavior == MaxInstanceBehavior.ReplaceOldest)
					{
						INTERNAL_removeOldestCue(activeCues[0].Name);
					}
					else if (maxCueBehavior == MaxInstanceBehavior.ReplaceQuietest)
					{
						float lowestVolume = float.MaxValue;
						int lowestIndex = -1;
						for (int i = 0; i < activeCues.Count; i += 1)
						{
							float vol = activeCues[i].INTERNAL_calculateVolume();
							if (vol < lowestVolume)
							{
								lowestVolume = vol;
								lowestIndex = i;
							}
						}
						if (lowestIndex > -1)
						{
							cueInstanceCounts[activeCues[lowestIndex].Name] -= 1;
							activeCues[lowestIndex].Stop(AudioStopOptions.AsAuthored);
						}
					}
					else if (maxCueBehavior == MaxInstanceBehavior.ReplaceLowestPriority)
					{
						// FIXME: Priority?
						INTERNAL_removeOldestCue(activeCues[0].Name);
					}
				}
				cueInstanceCounts[newCue.Name] += 1;
				newCue.SetVariable("NumCueInstances", cueInstanceCounts[newCue.Name]);
				activeCues.Add(newCue);
			}
			return true;
		}