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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
#include "ac_set_manager.h"
#include "m_lib.h"
#include "m_actor_dlftbls.h"
#include "m_object.h"
#include "m_player_lib.h"
#include "m_field_info.h"
#include "ovlmgr.h"
#include "attributes.h"
#include "overlays/gamestates/ovl_play/m_play.h"
#include "overlays/actors/player_actor/m_player.h"
// Fish and Insect overlay managers
#include "overlays/managers/ac_set_ovl_insect/ac_set_ovl_insect.h"
#include "overlays/managers/ac_set_ovl_gyoei/ac_set_ovl_gyoei.h"
void aSetMgr_ct(Actor* thisx, Game_Play* game_play);
void aSetMgr_dt(Actor* thisx, Game_Play* game_play);
void aSetMgr_move(Actor* thisx, Game_Play* play);
s32 aSetMgr_check_player_wade_end(void);
s32 aSetMgr_check_player_wade_start(void);
SetMgrOvlInfo proc_table[SETMGR_OVERLAY_MAX] = {
SETMGR_OVERLAY(ac_set_ovl_insect, func_8092A030_jp, func_8092AF0C_jp),
SETMGR_OVERLAY(ac_set_ovl_gyoei, func_8092DBC0_jp, func_8092ECAC_jp),
};
s32 aSetMgr_get_player_block(s32* bx, s32* bz, Game_Play* play) {
s32 res = FALSE;
Player* player = get_player_actor_withoutCheck(play);
if (player != NULL) {
xyz_t pos = player->actor.world.pos;
res = mFI_Wpos2BlockNum(bx, bz, pos);
}
return res;
}
s32 aSetMgr_renewal_player_next_pos(s32* next_bx, s32* next_bz) {
xyz_t endpos = { 0.0f, 0.0f, 0.0f };
s32 endPosRes;
endPosRes = get_player_actor_withoutCheck((Game_Play*)gamePT)->getEndPos(gamePT, &endpos);
return mFI_Wpos2BlockNum(next_bx, next_bz, endpos) | endPosRes;
}
void aSetMgr_renewal_player_pos(Game_Play* play, SetMgrPlayerPos* playerPos) {
s32 bx;
s32 bz;
s32 pad UNUSED;
playerPos->prevBx = playerPos->curBx;
playerPos->prevBz = playerPos->curBz;
if (aSetMgr_get_player_block(&bx, &bz, play) == TRUE) {
playerPos->curBx = bx;
playerPos->curBz = bz;
}
}
s32 aSetMgr_check_player_wade_start() {
return mFI_CheckPlayerWade(1);
}
s32 aSetMgr_check_player_wade_end() {
return mFI_CheckPlayerWade(3);
}
void aSetMgr_clear_set_ovl(SetMgrOvl* ovl) {
bzero(ovl->buf, SETMGR_OVERLAY_BUFFER_SIZE);
ovl->ovlProc = NULL;
}
s32 aSetMgr_ovl(SetMgrOvl* ovl, s32 type) {
s32 pad UNUSED;
SetMgrOvlInfo* mgrType = &proc_table[type];
ovlmgr_Load(mgrType->vromStart, mgrType->vromEnd, mgrType->vramStart, mgrType->vramEnd, &ovl->buf);
ovl->ovlProc = (void*)(&ovl->buf[(uintptr_t)mgrType->ovlTypeEnd] - (uintptr_t)mgrType->vramStart);
return 1;
}
void aSetMgr_clear_keep(SetMgrKeep* keep) {
bzero(keep, sizeof(SetMgrKeep));
}
s32 aSetMgr_move_check_set(Game_Play* play UNUSED, Set_Manager* setmgr) {
s32 move = FALSE;
aSetMgr_renewal_player_pos(play, &setmgr->playerPos);
if (aSetMgr_check_player_wade_start() == TRUE) {
aSetMgr_renewal_player_next_pos(&setmgr->playerPos.nextBx, &setmgr->playerPos.nextBz);
setmgr->nextMove = 1;
move = TRUE;
}
return move;
}
s32 aSetMgr_move_check_wait(Game_Play* play UNUSED, Set_Manager* set_manager) {
s32 timer;
s32 res = FALSE;
if (set_manager->nextMove == SETMGR_MOVE_CHECK_WAIT) {
if (set_manager->timer == 0) {
timer = 0;
} else {
timer = --set_manager->timer;
}
if (timer == 0) {
set_manager->nextMove = SETMGR_MOVE_SET;
set_manager->timer = SETMGR_TIMER;
res = TRUE;
}
}
return res;
}
s32 aSetMgr_move_set(Game_Play* play UNUSED, Set_Manager* set_manager) {
s32 pad UNUSED;
s32 res = FALSE;
if (aSetMgr_ovl(&set_manager->setOverlay, set_manager->setOvlType) == TRUE &&
set_manager->setOverlay.ovlProc != NULL) {
s32 requiredScopedTemp UNUSED;
set_manager->setOverlay.ovlProc(set_manager, play);
set_manager->setOvlType++;
} else {
set_manager->setOvlType++;
}
if (set_manager->setOvlType >= SETMGR_OVERLAY_MAX) {
set_manager->nextMove = SETMGR_MOVE_CHECK_SET;
set_manager->setOvlType = SETMGR_OVERLAY_START;
res = TRUE;
}
if (aSetMgr_check_player_wade_end() == TRUE) {
set_manager->nextMove = SETMGR_MOVE_CHECK_SET;
set_manager->setOvlType = SETMGR_OVERLAY_START;
res = TRUE;
}
return res;
}
SetManagerMoveProc move[] = { aSetMgr_move_check_set, aSetMgr_move_check_wait, aSetMgr_move_set };
void aSetMgr_move(Actor* thisx, Game_Play* play) {
Set_Manager* setManager = (Set_Manager*)thisx;
u8 proc = setManager->moveProc;
if (move[proc](play, setManager) == TRUE) {
setManager->moveProc = setManager->nextMove;
}
}
void aSetMgr_ct(Actor* thisx, Game_Play* game UNUSED) {
Set_Manager* setManager = (Set_Manager*)thisx;
setManager->moveProc = SETMGR_MOVE_CHECK_SET;
setManager->nextMove = SETMGR_MOVE_CHECK_SET;
setManager->setOvlType = SETMGR_OVERLAY_START;
aSetMgr_clear_set_ovl(&setManager->setOverlay);
setManager->playerPos.nextBx = 0;
setManager->playerPos.nextBz = 0;
setManager->playerPos.curBx = 0;
setManager->playerPos.curBz = 0;
setManager->playerPos.prevBx = 0;
setManager->playerPos.prevBz = 0;
setManager->timer = SETMGR_TIMER;
aSetMgr_clear_keep(&setManager->keep);
}
void aSetMgr_dt(Actor* thisx UNUSED, Game_Play* play UNUSED) {
}
ActorProfile Set_Manager_Profile = {
/* */ ACTOR_SET_MANAGER,
/* */ ACTOR_PART_7,
/* */ ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_20000000,
/* */ 0x0000,
/* */ GAMEPLAY_KEEP,
/* */ sizeof(Set_Manager),
/* */ aSetMgr_ct,
/* */ aSetMgr_dt,
/* */ aSetMgr_move,
/* */ (void*)none_proc1,
/* */ NULL,
};
|