blob: 69739493289a6ca9bccd15856137df9b9de3e1ac (
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
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
|
/**
* @file secretManager.c
* @ingroup Managers
*
* @brief Sets a flag and plays a sound if another flag is set.
*
* unk_0a = 0 for testing one flag unk_0a = 1 for testing multiple flags
*/
#include "manager/secretManager.h"
#include "entity.h"
#include "flags.h"
#include "sound.h"
void SecretManager_Type0_Action2(SecretManager*);
void SecretManager_Type0(SecretManager*);
void SecretManager_Type1(SecretManager*);
void SecretManager_Type0_Init(SecretManager*);
void SecretManager_Type0_Action1(SecretManager*);
void SecretManager_Type0_Action2(SecretManager*);
void SecretManager_Type1_Action2(SecretManager*);
void SecretManager_Type1_Action1(SecretManager*);
void SecretManager_Type1_Init(SecretManager*);
void SecretManager_Main(SecretManager* this) {
static void (*const SecretManager_Types[])(SecretManager*) = {
SecretManager_Type0,
SecretManager_Type1,
};
SecretManager_Types[super->type](this);
}
void SecretManager_Type0(SecretManager* this) {
static void (*const SecretManager_Type0_Actions[])(SecretManager*) = {
SecretManager_Type0_Init,
SecretManager_Type0_Action1,
SecretManager_Type0_Action2,
};
SecretManager_Type0_Actions[super->action](this);
}
void SecretManager_Type0_Init(SecretManager* this) {
if (CheckFlags(this->field_0x3c) != 0) {
DeleteThisEntity();
}
if (CheckFlags(this->field_0x3e) != 0) {
SetFlag(this->field_0x3c);
DeleteThisEntity();
}
super->action = 1;
if (super->timer == 0) {
super->timer = 30;
}
SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT);
}
void SecretManager_Type0_Action1(SecretManager* this) {
if ((CheckFlags(this->field_0x3e) != 0) && (gPriorityHandler.priority_timer < 2)) {
super->action = 2;
if (super->timer == 1) {
SecretManager_Type0_Action2(this);
}
RequestPriorityDuration((Entity*)this, super->timer);
}
}
void SecretManager_Type0_Action2(SecretManager* this) {
if (gPriorityHandler.priority_timer == 0) {
if (this->field_0x38 != SFX_NONE) {
SoundReq(this->field_0x38);
} else {
SoundReq(SFX_SECRET);
}
if (this->field_0x3c != 0) {
SetFlag(this->field_0x3c);
}
DeleteThisEntity();
}
}
void SecretManager_Type1(SecretManager* this) {
static void (*const SecretManager_Type1_Actions[])(SecretManager*) = {
SecretManager_Type1_Init,
SecretManager_Type1_Action1,
SecretManager_Type1_Action2,
};
SecretManager_Type1_Actions[super->action](this);
}
void SecretManager_Type1_Init(SecretManager* this) {
CheckFlags(this->field_0x3e);
super->action = 1;
if (super->timer == 0) {
super->timer = 30;
}
super->subtimer = super->timer;
SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT);
}
void SecretManager_Type1_Action1(SecretManager* this) {
if (CheckFlags(this->field_0x3e) != 0) {
super->action = 2;
super->timer = super->subtimer;
}
}
void SecretManager_Type1_Action2(SecretManager* this) {
if (super->timer != 0) {
if (--super->timer == 0) {
Sound sound;
if (this->field_0x38 != SFX_NONE) {
sound = this->field_0x38;
} else {
sound = SFX_SECRET;
}
SoundReq(sound);
SetFlag(this->field_0x3c);
}
} else {
if (CheckFlags(this->field_0x3e) == 0) {
super->action = 1;
ClearFlag(this->field_0x3c);
}
}
}
|