Sound Bakery  v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
container.h
1#pragma once
2
3#include "sound_bakery/node/node.h"
4
5namespace SB::Engine
6{
7 class Container;
8
12 struct SB_CLASS GatherChildrenContext
13 {
15 {
16 // We're making the rough assumption that each call to gatherChildrenForPlay
17 // will gather, on average, 3 or less sounds.
18 // This should hopefully save some allocation time in most cases.
19 sounds.reserve(3);
20 }
21
25 std::vector<const Container*> sounds;
26
33
41 unsigned int numTimesPlayed;
42 };
43
48 class SB_CLASS Container : public Node
49 {
50 public:
51 Container() : Node() {}
52
53 void onLoaded() override;
54
55 bool canAddChild(const SB::Core::DatabasePtr<NodeBase>& child) const override
56 {
57 if (child.lookup() && child->getType().is_derived_from<Container>())
58 {
59 return NodeBase::canAddChild(child);
60 }
61 else
62 {
63 return false;
64 }
65 }
66
75 virtual void gatherChildrenForPlay(GatherChildrenContext& context) const = 0;
76
77 REGISTER_REFLECTION(Container, Node)
78 RTTR_REGISTRATION_FRIEND
79 };
80} // namespace SB::Engine
Definition database_ptr.h:23
bool lookup() const
Find the live object referenced by the ID and store it.
Definition database_ptr.h:142
Base container type. Inherited types include sounds, random, sequence etc.
Definition container.h:49
virtual void gatherChildrenForPlay(GatherChildrenContext &context) const =0
Collects and gathers sounds on this node and its children for play.
Root node that builds the core graph of sounds and busses.
Definition node.h:57
Contains all information required for gathering sounds for runtime playing and selection.
Definition container.h:13
unsigned int numTimesPlayed
How many times the voice/node has played.
Definition container.h:41
std::vector< const Container * > sounds
Vector of containers that should play this iteration.
Definition container.h:25
LocalParameterList parameters
List of parameters that are local to this gathering.
Definition container.h:32
Holds a list of parameters and their local value.
Definition parameter.h:233