Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
audio_ambience_volume.hpp
Go to the documentation of this file.
1
8
#pragma once
9
10
#include "
../assets.hpp
"
11
#include "audio_volume.hpp"
12
13
#include <random>
14
15
namespace
toast {
16
24
class
TOAST_API [[ToastNode]]
AmbienceVolume
:
public
AudioVolume
{
25
public
:
26
auto
evaluateTarget
(
const
VolumeTarget
& target,
float
weight = 1.0f) ->
bool
override
;
27
28
void
onAudioTargetEnter(
const
VolumeTarget
& target)
override
;
29
void
onAudioTargetExit(
const
VolumeTarget
& target)
override
;
30
31
private
:
32
void
updateInspectorMessages()
override
;
33
void
onVolumeTick()
override
;
34
35
void
spawnAmbience();
36
void
scheduleNextSpawn();
37
auto
randomEvent() ->
assets::Handle<assets::AudioEvent>
;
38
auto
randomSpawnPosition() -> glm::vec3;
39
40
[[
Reflect
, Name(
"Audio Events"
)]]
41
std::vector<assets::Handle<assets::AudioEvent>> m_events;
42
43
[[
Reflect
, Range(0.25, 30.0), Unit(
"s"
)]]
44
float
m_min_interval = 2.0f;
45
46
[[
Reflect
, Range(0.25, 60.0), Unit(
"s"
)]]
47
float
m_max_interval = 8.0f;
48
49
[[
Reflect
, Range(0.0, 1.0)]]
50
float
m_volume = 1.0f;
51
52
float
m_spawn_timer = 0.0f;
53
std::mt19937 m_rng {std::random_device {}()};
54
};
55
56
}
assets.hpp
assets::Handle
Type-safe smart pointer for assets.
Definition
core_types.hpp:149
toast::AmbienceVolume
Ambient sound generator.
Definition
audio_ambience_volume.hpp:24
toast::AmbienceVolume::evaluateTarget
auto evaluateTarget(const VolumeTarget &target, float weight=1.0f) -> bool override
Evaluates if a target is inside the volume or not.
Definition
audio_ambience_volume.cpp:38
toast::AudioVolume
Base interface for audio-reactive volumes.
Definition
audio_volume.hpp:25
toast::Reflect
Definition
reflect.hpp:244
toast::VolumeTarget
What a volume is being evaluated against: a listener, a camera, anything with a position.
Definition
volume.hpp:19
engine
src
toast
audio
nodes
audio_ambience_volume.hpp
Generated by
1.17.0