summaryrefslogtreecommitdiff
path: root/src/d/snd/d_snd_source_tg_sound.cpp
blob: c7506fc0ee59908187bf6c67b885913bb33dc149 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "d/snd/d_snd_source_tg_sound.h"

#include "common.h"
#include "d/snd/d_snd_player_mgr.h"
#include "d/snd/d_snd_source.h"
#include "sized_string.h"

dSndSourceTgSound_c::dSndSourceTgSound_c(
    s32 sourceType, dAcBase_c *ac, const char *name, dSndSourceGroup_c *pOwnerGroup
)
    : dSoundSource_c(sourceType, ac, name, pOwnerGroup), mTgActive(true) {}

void dSndSourceTgSound_c::postSetup() {
    switch (mSubtype) {
        // TODO subtypes
        case 7:
            mTgActive = false;
            break;
        default:
            mTgActive = true;
            break;
    }

    SizedString<64> label;
    label.sprintf("SE_%s", mpName);
    mTgSoundId = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(label);
}

void dSndSourceTgSound_c::setTgActive(bool active) {
    switch (mSubtype) {
        case 34:
        case 35:
            mTgActive = !active;
            break;
        default:
            mTgActive = active;
            break;
    }
}

void dSndSourceTgSound_c::postCalc() {
    if (mTgSoundId == -1) {
        return;
    }
    if (!mTgActive) {
        return;
    }
    holdSound(mTgSoundId);
}