2022-04-09 08:47:20 +00:00
|
|
|
#include "dynos.cpp.h"
|
|
|
|
extern "C" {
|
2024-04-17 17:02:28 +00:00
|
|
|
#include "game/area.h"
|
2022-04-09 08:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct RegisteredMovtexQC {
|
|
|
|
DataNode<MovtexQC>* dataNode;
|
|
|
|
s16 level;
|
|
|
|
s16 area;
|
|
|
|
s16 type;
|
|
|
|
};
|
|
|
|
|
2022-04-20 04:06:18 +00:00
|
|
|
static Array<RegisteredMovtexQC>& DynosRegisteredMovtexQCs() {
|
|
|
|
static Array<RegisteredMovtexQC> sDynosRegisteredMovtexQCs;
|
|
|
|
return sDynosRegisteredMovtexQCs;
|
|
|
|
}
|
2022-04-09 08:47:20 +00:00
|
|
|
|
|
|
|
void DynOS_MovtexQC_Register(const char* name, s16 level, s16 area, s16 type) {
|
2022-04-20 04:06:18 +00:00
|
|
|
auto& _DynosRegisteredMovtexQCs = DynosRegisteredMovtexQCs();
|
|
|
|
|
2022-04-09 08:47:20 +00:00
|
|
|
// check for duplicates
|
2022-04-20 04:06:18 +00:00
|
|
|
for (auto& registered : _DynosRegisteredMovtexQCs) {
|
2022-04-09 08:47:20 +00:00
|
|
|
if (registered.level == level && registered.area == area && registered.type == type) { return; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// find it in the levels
|
|
|
|
for (auto& lvlPair : DynOS_Lvl_GetArray()) {
|
|
|
|
for (auto& node : lvlPair.second->mMovtexQCs) {
|
|
|
|
if (node->mName == name) {
|
|
|
|
// add it
|
2022-04-20 04:06:18 +00:00
|
|
|
_DynosRegisteredMovtexQCs.Add({
|
2022-04-09 08:47:20 +00:00
|
|
|
.dataNode = node,
|
|
|
|
.level = level,
|
|
|
|
.area = area,
|
|
|
|
.type = type
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DataNode<MovtexQC>* DynOS_MovtexQC_GetFromId(u32 id) {
|
2022-04-20 04:06:18 +00:00
|
|
|
auto& _DynosRegisteredMovtexQCs = DynosRegisteredMovtexQCs();
|
|
|
|
|
2022-04-09 08:47:20 +00:00
|
|
|
// find the datanode
|
|
|
|
s16 type = (id & 0xF);
|
2022-04-20 04:06:18 +00:00
|
|
|
for (auto& registered : _DynosRegisteredMovtexQCs) {
|
2022-04-09 08:47:20 +00:00
|
|
|
if (registered.level == gCurrLevelNum && registered.area == gCurrAreaIndex && registered.type == type) {
|
|
|
|
return registered.dataNode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataNode<MovtexQC>* DynOS_MovtexQC_GetFromIndex(s32 index) {
|
|
|
|
GfxData* gfxData = DynOS_Lvl_GetActiveGfx();
|
|
|
|
if (gfxData == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto &mMovtexQCs = gfxData->mMovtexQCs;
|
|
|
|
|
|
|
|
// Sanity check the index we passed.
|
|
|
|
if (index < 0 || index >= mMovtexQCs.Count()) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mMovtexQCs[index];
|
|
|
|
}
|
2022-05-09 14:27:47 +00:00
|
|
|
|
|
|
|
void DynOS_MovtexQC_ModShutdown() {
|
|
|
|
auto& _DynosRegisteredMovtexQCs = DynosRegisteredMovtexQCs();
|
|
|
|
while (_DynosRegisteredMovtexQCs.Count() > 0) {
|
|
|
|
auto& registered = _DynosRegisteredMovtexQCs[0];
|
|
|
|
Delete(registered.dataNode);
|
|
|
|
_DynosRegisteredMovtexQCs.Remove(0);
|
|
|
|
}
|
|
|
|
}
|