// 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 PlaceableSoundObject extends Actor placeable; var(Sound) float timerInterval; var(Sound) int timeSince; var(Sound) int waitingTime; var(Sound) float averageSecondsBetween; var(Sound) float maxDeviation; var(Sound) array SoundsArray; function PostBeginPlay() { SetTimer(1, true); } function Timer() { UpdateTimer(); } //============================================================================= // 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() { // Log("Update timer:" + timeSince + " - " + waitingTime); 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); 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 }