// September 2015 // Levee Patroller / Dijk Patrouille // This source file is (c) by Deltares. This source file is open source but only available to select users. Do not redistribute without written permission of Stichting Deltares, Delft, The Netherlands. // This header has been automatically generated. class GeoTimedSoundObject extends Actor; var float timerInterval; var int timeSince; var int waitingTime; var float averageSecondsBetween; var float maxDeviation; var array SoundsArray; //============================================================================= // Date Id Modification // 2007-10-11 Wsl Created this function // // This function is called by GeoPlayerController. It updates the time // counter and if time limit exceeds, plays a sound and picks a next waiting time //============================================================================= function UpdateTimer() { timeSince++; if(timeSince > waitingTime) { timeSince = 0; determineNextWaitingTime(PlayRandomSound()); } } //============================================================================= // Date Id Modification // 2007-10-11 Wsl Created this function // // Plays a random sound from the available ones and return its duration in seconds //============================================================================= function float PlayRandomSound() { local int index; index = Rand(SoundsArray.length); // Log("Play random sound!"); Owner.PlaySound(SoundsArray[index]); return GetSoundDuration(SoundsArray[index]); } //============================================================================= // Date Id Modification // 2007-10-11 Wsl Created this function // // Determines the time to wait for the next sound to play //============================================================================= function determineNextWaitingTime(float currentDuration) { local int cur, dev, avg; cur = currentDuration * (1.0 / timerInterval); dev = maxDeviation * (1.0 / timerInterval); avg = averageSecondsBetween * (1.0 / timerInterval); waitingTime = cur + avg + Rand(2 * dev) - dev; } function SetAverageSecondsBetween(float avg) { averageSecondsBetween = avg; } function SetMaxDeviation(float dev) { maxDeviation = dev; } function SetSounds(array arr) { SoundsArray = arr; } defaultproperties { bhidden=true; timerInterval=1.0 timeSince=0 waitingTime=20 averageSecondsBetween=6.0 maxDeviation=3.0 }