summaryrefslogtreecommitdiff
path: root/src/object/chuchuBossParticle.c
blob: 355405c44ef259b5cc60f544786051976dcef92d (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
50
51
52
53
/**
 * @file chuchuBossParticle.c
 * @ingroup Objects
 *
 * @brief Chuchu Boss Particle object
 */
#include "entity.h"

void ChuchuBossParticle_Init(Entity*);
void ChuchuBossParticle_Action1(Entity*);

void ChuchuBossParticle(Entity* this) {
    static void (*const actionFuncs[])(Entity*) = {
        ChuchuBossParticle_Init,
        ChuchuBossParticle_Action1,
    };

    actionFuncs[this->action](this);
}

void ChuchuBossParticle_Init(Entity* this) {
    this->action = 1;
    this->spriteSettings.draw = 1;
    InitializeAnimation(this, this->animIndex);
}

void ChuchuBossParticle_Action1(Entity* this) {
    if (this->type == 0) {
        GetNextFrame(this);
    }

    if (this->type2 != 0) {
        this->spriteSettings.draw ^= 1;
    }

    if ((int)(this->timer * 0x1000000) >= 0) {
        if (this->timer) {
            if (--this->timer == 0) {
                DeleteThisEntity();
            }
        } else {
            if ((this->frame & ANIM_DONE) != 0) {
                DeleteThisEntity();
            }
        }
    }

    if (this->child != NULL) {
        this->x = this->child->x;
        this->y = this->child->y;
        this->z = this->child->z;
    }
}