module("EseSoundScene", package.seeall) -- Behavior function OnCreate(selfID, strm) BehaviorAPI.LogMessage(2, "SoundScene::OnCreate") -- Setup initial sound parameters -- local key = BehaviorAPI.GetNextPropertyKey(selfID, "SoundBanks", "") while key ~= "" do local soundBank = BehaviorAPI.GetProperty(selfID, "SoundBanks", key) BehaviorAPI.LogMessage(2, "SoundScene: Loading "..tostring(soundBank).." sound bank.") epgmWwise.LoadSoundBank(tostring(soundBank)) key = BehaviorAPI.GetNextPropertyKey(selfID, "SoundBanks", key) end end -- Behavior function OnEntitySetFinished(selfID, strm) BehaviorAPI.LogMessage(2, "SoundScene::OnEntitySetFinished") while (epgmWwise.ActivateRemoteSpeakers() == false) do -- If it returned false, it is because the system was busy, try again. end local group = BehaviorAPI.GetNextPropertyKey(selfID, "SoundStates", "") while group ~= "" do local state = BehaviorAPI.GetProperty(selfID, "SoundStates", group) BehaviorAPI.LogMessage(2, "SoundScene: Setting "..tostring(group).." to "..tostring(state)..".") epgmWwise.SetSoundState(tostring(group), tostring(state)) group = BehaviorAPI.GetNextPropertyKey(selfID, "SoundStates", group) end local key = BehaviorAPI.GetNextPropertyKey(selfID, "InitialSoundEvents", "") while key ~= "" do local event = BehaviorAPI.GetProperty(selfID, "InitialSoundEvents", key) BehaviorAPI.LogMessage(2, "SoundScene: Playing event "..tostring(event)..".") epgmWwise.PostSoundEvent(tostring(event)) key = BehaviorAPI.GetNextPropertyKey(selfID, "InitialSoundEvents", key) end end -- Behavior function OnDestroy(selfID, strm) BehaviorAPI.LogMessage(2, "SoundScene::OnDestroy") -- Cleanup sound banks -- local key = BehaviorAPI.GetNextPropertyKey(selfID, "SoundBanks", "") while key ~= "" do local soundBank = BehaviorAPI.GetProperty(selfID, "SoundBanks", key) BehaviorAPI.LogMessage(2, "SoundScene: Unloading "..tostring(soundBank).." sound bank.") epgmWwise.UnloadSoundBank(tostring(soundBank)) key = BehaviorAPI.GetNextPropertyKey(selfID, "SoundBanks", key) end epgmWwise.DeactivateRemoteSpeakers( true ) end