summaryrefslogtreecommitdiff
path: root/src/object/heartContainer.c
blob: 046eb0aab2dac7e18aa219d94231945e19fa717c (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
#include "global.h"
#include "audio.h"
#include "entity.h"
#include "flags.h"
#include "functions.h"

static void sub_0808E6A0(Entity*);
static void sub_0808E6E4(Entity*);
static void sub_0808E714(Entity*);
static void sub_0808E764(Entity*);

static void (*const gHeartContainerActions[])(Entity*) = {
    sub_0808E6A0,
    sub_0808E6E4,
    sub_0808E714,
    sub_0808E764,
};

extern Hitbox gUnk_08121C58;

void HeartContainer(Entity* this) {
    gHeartContainerActions[this->action](this);
}

static void sub_0808E6A0(Entity* this) {
    if (CheckFlags(this->cutsceneBeh.HWORD)) {
        DeleteThisEntity();
    }
    this->action = 1;
    this->type = 0x62;
    this->spriteSettings.b.draw = 0;
    this->hitbox = &gUnk_08121C58;
    this->collisionLayer = 3;
    this->scriptedScene = 3;
}

static void sub_0808E6E4(Entity* this) {
    if (CheckFlags(this->field_0x86.HWORD)) {
        this->action = 2;
        this->spriteSettings.b.draw = 1;
        this->spriteRendering.b0 = 3;
        sub_0808E714(this);
    }
}

static void sub_0808E714(Entity* this) {
    int var0 = 0x400 - this->field_0xf * 8;
    if (var0 > 0x100) {
        this->field_0xf++;
        sub_0805EC9C(this, var0, var0, 0);
    } else {
        this->action = 3;
        this->field_0x3c |= 0x10;
        sub_0805EC60(this);
        SoundReq(SFX_HEART_CONTAINER_SPAWN);
    }
    sub_08080CB4(this);
}

static void sub_0808E764(Entity* this) {
    sub_08080CB4(this);
    if (!(gPlayerState.flags.all & 0x80) && sub_08017850(this)) {
        SetFlag(this->cutsceneBeh.HWORD);
        CreateItemEntity(0x62, 0, 0);
        DeleteThisEntity();
    }
}