summaryrefslogtreecommitdiff
path: root/src/object/well.c
blob: 29a041812c27f67795f933d59ebee976d9fc359c (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
/**
 * @file well.c
 * @ingroup Objects
 *
 * @brief Well object
 */
#include "asm.h"
#include "entity.h"
#include "functions.h"
#include "global.h"
#include "player.h"
#include "room.h"

void Well_Init(Entity*);
void Well_Action1(Entity*);

void Well(Entity* this) {
    static void (*const Well_Actions[])(Entity*) = {
        Well_Init,
        Well_Action1,
    };
    Well_Actions[this->action](this);
}

void Well_Init(Entity* this) {
    u32 tilePos;

    this->action = 1;
    tilePos = COORD_TO_TILE(this);
    this->field_0x80.HWORD = tilePos;
    SetTile(16509, this->field_0x80.HWORD, 1);
}

void Well_Action1(Entity* this) {
    s32 tileIndex;

    tileIndex = GetTileType(this->field_0x80.HWORD, 1);
    if (tileIndex != 0x407D) {
        sub_08078B48();
        gPlayerEntity.x.WORD = this->x.WORD;
        gPlayerEntity.y.HALF.HI = this->y.HALF.HI + 4;
        DeleteThisEntity();
    }
}