summaryrefslogtreecommitdiff
path: root/src/enemy/bladeTrap.c
blob: fecaeeca5ab61be7c39c8c4069b7e6ffcb5cf2bc (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
/**
 * @file bladeTrap.c
 * @ingroup Enemies
 *
 * @brief Blade Trap enemy
 */
#include "object.h"
#include "sound.h"
#include "room.h"
#include "physics.h"

typedef struct {
    /*0x00*/ Entity base;
    /*0x68*/ u8 unused1[12];
    /*0x74*/ u16 unk_74;
} BladeTrapEntity;

#define DIR_NOT_MOVING_CHECK 0x80

void BladeTrap(BladeTrapEntity* this) {
    if (super->action == 0) {
        super->action = 1;
        super->child = GetCurrentRoomProperty(super->type);
        UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
    }
    if (!(super->direction & DIR_NOT_MOVING_CHECK)) {
        LinearMoveUpdate(super);
    }

    if (!(--this->unk_74)) {
        if (!(super->direction & DIR_NOT_MOVING_CHECK)) {
            EnqueueSFX(SFX_METAL_CLINK);
        }
        UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
    }
}