summaryrefslogtreecommitdiff
path: root/src/object/smokeParticle.c
blob: 4c24717ac28a07ac69376fd8e91ff65677cc14d2 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
 * @file smokeParticle.c
 * @ingroup Objects
 *
 * @brief Smoke Particle object
 */
#include "functions.h"
#include "object.h"

void SmokeParticle_Init(Entity*);
void SmokeParticle_Action1(Entity*);
void sub_080878CC(Entity*);

void (*const SmokeParticle_Actions[])(Entity*) = {
    SmokeParticle_Init,
    SmokeParticle_Action1,
};
const Hitbox3D gUnk_08120A30 = { 0, 0, { 0, 0, 0, 0 }, 6, 6, 10, { 0, 0, 0 } };
const Hitbox3D gUnk_08120A3C = { 0, 0, { 0, 0, 0, 0 }, 12, 12, 16, { 0, 0, 0 } };
const Hitbox3D gUnk_08120A48 = { 0, 0, { 0, 0, 0, 0 }, 16, 16, 20, { 0, 0, 0 } };
const Hitbox3D* const gUnk_08120A54[] = { &gUnk_08120A30, &gUnk_08120A30, &gUnk_08120A48, &gUnk_08120A3C,
                                          &gUnk_08120A3C };

void SmokeParticle(Entity* this) {
    SmokeParticle_Actions[this->action](this);
}

void SmokeParticle_Init(Entity* this) {
    if (this->collisionLayer == 0) {
        ResolveCollisionLayer(this);
    }
    this->action = 1;
    this->flags |= 0x80;
    this->collisionFlags = 0x13;
    this->health = 0xff;
    this->hitType = 0xa9;
    this->hurtType = 0x16;
    this->hitbox = (Hitbox*)gUnk_08120A54[0];
    this->flags2 = 0x8b;
    sub_080878CC(this);
    InitializeAnimation(this, 1);
    sub_0801766C(this);
    EnqueueSFX(SFX_ITEM_BOMB_EXPLODE);
}

void SmokeParticle_Action1(Entity* this) {
    GetNextFrame(this);
    if ((this->frame & ANIM_DONE) != 0) {
        DeleteThisEntity();
    } else {
        if (this->frame < 5) {
            this->hitbox = (Hitbox*)gUnk_08120A54[this->frame];
        } else {
            this->flags &= ~0x80;
        }
    }
}

void sub_080878CC(Entity* this) {
    s32 x;
    s32 y;
    s32 itX;
    s32 itY;
    u32 layer;
    u32 pos;

    x = this->x.HALF.HI;
    y = this->y.HALF.HI;
    layer = this->collisionLayer;
    for (itX = -0x10; itX < 0x11; itX += 0x10) {
        for (itY = -0x10; itY < 0x11; itY += 0x10) {
            pos = TILE((u32)x + itX, (u32)y + itY);
            if (sub_080B1AE0(pos, (u8)layer) == 0x2e) {
                switch (GetTileType(pos, layer)) {
                    case 0x368:
                    case 0x367:
                        DoTileInteraction(this, 3, x + itX, y + itY);
                        break;
                    default:
                        SetBottomTile(0x4022, pos, layer);
                        break;
                }
            } else {
                DoTileInteraction(this, 3, x + itX, y + itY);
            }
        }
    }
}