summaryrefslogtreecommitdiff
path: root/src/object/objectA.c
blob: c0af01b574a64b788466875e54ed9b4f1713508e (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
/**
 * @file objectA.c
 * @ingroup Objects
 *
 * @brief ObjectA object
 */
#include "entity.h"
#include "flags.h"
#include "game.h"
#include "hitbox.h"
#include "object.h"
#include "effects.h"
#include "room.h"
#include "player.h"
#include "tiles.h"

typedef struct {
    /*0x00*/ Entity base;
    /*0x68*/ u8 unused1[8];
    /*0x70*/ u16 unk_70;
    /*0x72*/ u8 unused2[20];
    /*0x86*/ u16 flag;
} ObjectAEntity;

extern u8 gUpdateVisibleTiles;

void ObjectA(ObjectAEntity* this) {
    u32 uVar2;

    if (super->action == 0) {
        super->action = 1;
        super->hitbox = (Hitbox*)&gHitbox_2;
        if (super->collisionLayer == LAYER_BOTTOM) {
            uVar2 = TILE_TYPE_38;
        } else {
            uVar2 = TILE_TYPE_52;
        }
        this->unk_70 = uVar2;
        if (CheckFlags(this->flag) != 0) {
            SetTileType(this->unk_70, COORD_TO_TILE(super), super->collisionLayer);
            if ((gRoomControls.reload_flags & 1) != 0) {
                gUpdateVisibleTiles = 0;
            }
            DeleteThisEntity();
        } else {
            AddInteractableSmallKeyLock(super);
        }
    } else if (super->interactType != INTERACTION_NONE) {
        SetTileType(this->unk_70, COORD_TO_TILE(super), super->collisionLayer);
        SetFlag(this->flag);
        CreateDeathFx(super);
        ModDungeonKeys(-1);
        DeleteThisEntity();
    }
}