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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/**
* @file metalDoor.c
* @ingroup Objects
*
* @brief Metal Door object
*/
#include "object/lockedDoor.h"
#include "asm.h"
#include "effects.h"
#include "entity.h"
#include "flags.h"
#include "physics.h"
#include "hitbox.h"
#include "room.h"
#include "sound.h"
#include "tiles.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[8];
/*0x70*/ u16 unk_70;
/*0x72*/ u16 unk_72;
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u16 unk_78;
/*0x7a*/ u16 unk_7a;
/*0x7c*/ u8 unused2[8];
/*0x84*/ u16 flag1;
/*0x86*/ u16 flag2;
} MetalDoorEntity;
void sub_080A080C(MetalDoorEntity* this);
void sub_080A0870(MetalDoorEntity* this);
void MetalDoor_Init(MetalDoorEntity* this);
void MetalDoor_Action1(MetalDoorEntity* this);
void MetalDoor_Action2(MetalDoorEntity* this);
void MetalDoor_Action3(MetalDoorEntity* this);
void MetalDoor_Action4(MetalDoorEntity* this);
void MetalDoor(MetalDoorEntity* this) {
static void (*const MetalDoor_Actions[])(MetalDoorEntity*) = {
MetalDoor_Init, MetalDoor_Action1, MetalDoor_Action2, MetalDoor_Action3, MetalDoor_Action4,
};
MetalDoor_Actions[super->action](this);
}
void MetalDoor_Init(MetalDoorEntity* this) {
if ((this->flag1 != 0xffff) && CheckFlags(this->flag1)) {
DeleteThisEntity();
}
super->action = 1;
super->speed = 0x300;
super->spriteSettings.draw = 0;
super->frameIndex = 0;
super->spriteSettings.flipY = 1;
super->hitbox = (Hitbox*)&gHitbox_3;
super->spritePriority.b0 = 5;
this->unk_70 = super->x.HALF.HI;
this->unk_72 = super->y.HALF.HI;
this->unk_74 = COORD_TO_TILE(super);
}
void MetalDoor_Action1(MetalDoorEntity* this) {
if (sub_08083734(super, 2) != 0) {
super->action = 2;
super->timer = 12;
super->spriteSettings.draw = TRUE;
super->direction = 0;
super->y.HALF.HI += 0x24;
sub_080A080C(this);
}
}
void MetalDoor_Action2(MetalDoorEntity* this) {
u8 bVar1;
Entity* fx;
LinearMoveUpdate(super);
if (--super->timer == 0) {
super->action = 3;
super->z.HALF.HI = 0;
super->x.HALF.HI = this->unk_70;
super->y.HALF.HI = this->unk_72;
fx = CreateFx(super, FX_DASH, 0x40);
if (fx != NULL) {
fx->x.HALF.HI += 0xc;
fx->y.HALF.HI -= 0xc;
}
fx = CreateFx(super, FX_DASH, 0x40);
if (fx != NULL) {
fx->x.HALF.HI -= 0xc;
fx->y.HALF.HI -= 0xc;
}
EnqueueSFX(SFX_10B);
}
}
void MetalDoor_Action3(MetalDoorEntity* this) {
if (CheckFlags(this->flag2)) {
super->action = 4;
super->timer = 12;
super->direction = 0x10;
super->y.HALF.HI += 2;
sub_080A0870(this);
SoundReq(SFX_10B);
}
}
void MetalDoor_Action4(MetalDoorEntity* this) {
LinearMoveUpdate(super);
if (--super->timer == 0) {
DeleteThisEntity();
}
}
void sub_080A080C(MetalDoorEntity* this) {
this->unk_76 = GetTileIndex(this->unk_74 - 1, super->collisionLayer);
this->unk_78 = GetTileIndex(this->unk_74, super->collisionLayer);
this->unk_7a = GetTileIndex(this->unk_74 + 1, super->collisionLayer);
SetTile(SPECIAL_TILE_34, this->unk_74 - 1, super->collisionLayer);
SetTile(SPECIAL_TILE_34, this->unk_74, super->collisionLayer);
SetTile(SPECIAL_TILE_34, this->unk_74 + 1, super->collisionLayer);
}
void sub_080A0870(MetalDoorEntity* this) {
SetTile(this->unk_76, this->unk_74 - 1, super->collisionLayer);
SetTile(this->unk_78, this->unk_74, super->collisionLayer);
SetTile(this->unk_7a, this->unk_74 + 1, super->collisionLayer);
}
|