summaryrefslogtreecommitdiff
path: root/src/object/mulldozerSpawnPoint.c
blob: 611f77ddd11751f497f95f96f4bdb50f0650432c (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
/**
 * @file mulldozerSpawnPoint.c
 * @ingroup Objects
 *
 * @brief Mulldozer Spawn Point object
 */
#include "entity.h"
#include "sound.h"
#include "enemy.h"

void MulldozerSpawnPoint_Init(Entity*);
void MulldozerSpawnPoint_Action1(Entity*);

void MulldozerSpawnPoint(Entity* this) {
    static void (*const MulldozerSpawnPoint_Actions[])(Entity*) = {
        MulldozerSpawnPoint_Init,
        MulldozerSpawnPoint_Action1,
        DeleteEntity,
    };

    MulldozerSpawnPoint_Actions[this->action]((Entity*)this);
}

void MulldozerSpawnPoint_Init(Entity* this) {
    static const u8 typeAnimationStates[] = { 0x2, 0x0, 0x43, 0x0 };
    static const u16 typeSounds[] = { SFX_124, SFX_197, SFX_11D, SFX_NONE };
    this->action = 1;
    InitializeAnimation(this, typeAnimationStates[this->type]);
    SoundReq(typeSounds[this->type]);
}

void MulldozerSpawnPoint_Action1(Entity* this) {
    Entity* parent;

    GetNextFrame(this);
    if (this->frame & 0x80) {
        this->action = 2;
        parent = this->parent;
        parent->flags = this->timer;
        parent->spriteSettings.draw = this->subtimer;
        ((Enemy*)parent)->enemyFlags &= ~EM_FLAG_SUPPORT;
    }
}