2022-04-09 10:47:20 +02:00
|
|
|
#include "dynos.cpp.h"
|
|
|
|
extern "C" {
|
2024-04-17 19:02:28 +02:00
|
|
|
#include "game/area.h"
|
2022-04-09 10:47:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct RegisteredMovtexQC {
|
|
|
|
DataNode<MovtexQC>* dataNode;
|
|
|
|
s16 level;
|
|
|
|
s16 area;
|
|
|
|
s16 type;
|
|
|
|
};
|
|
|
|
|
2022-04-20 06:06:18 +02:00
|
|
|
static Array<RegisteredMovtexQC>& DynosRegisteredMovtexQCs() {
|
|
|
|
static Array<RegisteredMovtexQC> sDynosRegisteredMovtexQCs;
|
|
|
|
return sDynosRegisteredMovtexQCs;
|
|
|
|
}
|
2022-04-09 10:47:20 +02:00
|
|
|
|
|
|
|
void DynOS_MovtexQC_Register(const char* name, s16 level, s16 area, s16 type) {
|
2022-04-20 06:06:18 +02:00
|
|
|
auto& _DynosRegisteredMovtexQCs = DynosRegisteredMovtexQCs();
|
|
|
|
|
2022-04-09 10:47:20 +02:00
|
|
|
// check for duplicates
|
2022-04-20 06:06:18 +02:00
|
|
|
for (auto& registered : _DynosRegisteredMovtexQCs) {
|
2022-04-09 10:47:20 +02: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 06:06:18 +02:00
|
|
|
_DynosRegisteredMovtexQCs.Add({
|
2022-04-09 10:47:20 +02:00
|
|
|
.dataNode = node,
|
|
|
|
.level = level,
|
|
|
|
.area = area,
|
|
|
|
.type = type
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DataNode<MovtexQC>* DynOS_MovtexQC_GetFromId(u32 id) {
|
2022-04-20 06:06:18 +02:00
|
|
|
auto& _DynosRegisteredMovtexQCs = DynosRegisteredMovtexQCs();
|
|
|
|
|
2022-04-09 10:47:20 +02:00
|
|
|
// find the datanode
|
|
|
|
s16 type = (id & 0xF);
|
2022-04-20 06:06:18 +02:00
|
|
|
for (auto& registered : _DynosRegisteredMovtexQCs) {
|
2022-04-09 10:47:20 +02: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 16:27:47 +02:00
|
|
|
|
|
|
|
void DynOS_MovtexQC_ModShutdown() {
|
|
|
|
auto& _DynosRegisteredMovtexQCs = DynosRegisteredMovtexQCs();
|
|
|
|
while (_DynosRegisteredMovtexQCs.Count() > 0) {
|
|
|
|
auto& registered = _DynosRegisteredMovtexQCs[0];
|
|
|
|
Delete(registered.dataNode);
|
|
|
|
_DynosRegisteredMovtexQCs.Remove(0);
|
|
|
|
}
|
|
|
|
}
|