Sound Bakery 
v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
random_container.h
1
#pragma once
2
3
#include "sound_bakery/node/container/container.h"
4
5
namespace
sbk::engine
6
{
7
class
SB_CLASS
RandomContainer
:
public
container
8
{
9
public
:
10
virtual
void
gather_children_for_play
(
gather_children_context
& context)
const override
11
{
12
switch
(m_childNodes.size())
13
{
14
case
0:
15
break
;
16
case
1:
17
context.
sounds
.push_back(m_childNodes.begin()->lookupRaw()->try_convert_object<
container
>());
18
break
;
19
default
:
20
int
randomChildIndex = std::rand() % m_childNodes.size();
21
std::unordered_set<sbk::core::database_ptr<node_base>>::const_iterator childIter =
22
m_childNodes.begin();
23
std::advance(childIter, randomChildIndex);
24
context.
sounds
.push_back(childIter->lookupRaw()->try_convert_object<
container
>());
25
break
;
26
}
27
}
28
29
REGISTER_REFLECTION(
RandomContainer
,
container
)
30
RTTR_REGISTRATION_FRIEND
31
};
32
}
// namespace sbk::engine
sbk::engine::RandomContainer
Definition
random_container.h:8
sbk::engine::RandomContainer::gather_children_for_play
virtual void gather_children_for_play(gather_children_context &context) const override
Collects and gathers sounds on this node and its children for play.
Definition
random_container.h:10
sbk::engine::container
Base container type. Inherited types include sounds, random, sequence etc.
Definition
container.h:49
sbk::engine::gather_children_context
Contains all information required for gathering sounds for runtime playing and selection.
Definition
container.h:13
sbk::engine::gather_children_context::sounds
std::vector< const container * > sounds
Vector of containers that should play this iteration.
Definition
container.h:25
src
sound_bakery
node
container
random_container.h
Generated by
1.9.8