The sound emitter component
Within the entity component system paradigm, every possible entity parameter or feature is represented as a component. Emitting sounds is definitely one of those features. In order for that to happen, we do have some setting up to do, starting with creating and implementing it in the C_SoundEmitter.h
header. Before that, however, let's define the types of sounds an entity can have:
enum class EntitySound{ None = -1, Footstep, Attack, Hurt,Death };
As you can see, we're only going to be working with four types of sound, one of which is going to be implemented in this chapter. A None
value is also set up in order to make error checking easier.
Every sound that an entity can emit will most likely have different frames it plays during, which calls for a new data structure that encapsulates such information:
struct SoundParameters{ static const int Max_SoundFrames = 5; SoundParameters(){ for (int i = 0; i < Max_SoundFrames; ++i){ m_frames[i] = -1...