summaryrefslogtreecommitdiff
path: root/src/object/fireplace.c
blob: 57a7cef900ea9b2ce6cbc839cea0ab266b7842e7 (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
/**
 * @file fireplace.c
 * @ingroup Objects
 *
 * @brief Fireplace object
 */
#include "functions.h"
#include "object.h"

void Fireplace_Action1(Entity* this);
void sub_0809B7DC(Entity* this);
void sub_0809B7C0(Entity* this);
void Fireplace_Init(Entity* this);

void Fireplace(Entity* e) {
    static void (*const Fireplace_Actions[])(Entity*) = {
        Fireplace_Init,
        Fireplace_Action1,
    };
    Fireplace_Actions[e->action](e);
}

void Fireplace_Init(Entity* this) {
    this->action = 1;
    this->spriteSettings.draw = 1;
    this->speed = 0x80;
    if (CheckFlags(this->field_0x86.HWORD)) {
        sub_0809B7DC(this);
        DeleteThisEntity();
    } else {
        sub_0807B7D8(0x30b, TILE(this->x.HALF.HI, this->y.HALF.HI), 2);
        SetTile(0x4061, TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer);
    }
    Fireplace_Action1(this);
}

void Fireplace_Action1(Entity* this) {
    sub_0809B7C0(this);
    if (this->timer) {
        SetFlag(this->field_0x86.HWORD);
        DeleteThisEntity();
    }
}

void sub_0809B7C0(Entity* this) {
    u32 tileType = GetTileTypeByEntity(this);
    if (tileType != 0x4061 && tileType != 0x4062) {
        sub_0809B7DC(this);
    }
}

void sub_0809B7DC(Entity* this) {
    sub_0807B7D8(0xc3 << 2, TILE(this->x.HALF.HI, this->y.HALF.HI), 2);
    SetTile(0x4062, TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer);
    this->timer = 1;
}