summaryrefslogtreecommitdiff
path: root/src/d/a/obj/d_a_obj_tbox.cpp
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2024-11-15 14:47:10 +0100
committerrobojumper <robojumper@gmail.com>2024-11-15 14:54:17 +0100
commit4a146f7b4d6ca4132d73e18c8f6a8b2ea9f60ad6 (patch)
tree4359a979561381b1abceae7a8b9d84b6c6c7521e /src/d/a/obj/d_a_obj_tbox.cpp
parent37cfe931152b5e328147c99afe30a98e0055d1fb (diff)
dAcTbox_c WIP
Diffstat (limited to 'src/d/a/obj/d_a_obj_tbox.cpp')
-rw-r--r--src/d/a/obj/d_a_obj_tbox.cpp197
1 files changed, 192 insertions, 5 deletions
diff --git a/src/d/a/obj/d_a_obj_tbox.cpp b/src/d/a/obj/d_a_obj_tbox.cpp
index 52f092b9..8b38c261 100644
--- a/src/d/a/obj/d_a_obj_tbox.cpp
+++ b/src/d/a/obj/d_a_obj_tbox.cpp
@@ -1,14 +1,20 @@
#include "d/a/obj/d_a_obj_tbox.h"
+
+#include "common.h"
+#include "d/flag/storyflag_manager.h"
+#include "m/m_mtx.h"
#include "m/m_vec.h"
+#include "nw4r/g3d/g3d_resanmchr.h"
+#include "nw4r/g3d/g3d_resanmtexpat.h"
+#include "nw4r/g3d/g3d_resanmtexsrt.h"
+#include "nw4r/g3d/g3d_resfile.h"
+#include "nw4r/g3d/g3d_resmdl.h"
#include "toBeSorted/dowsing_target.h"
SPECIAL_ACTOR_PROFILE(TBOX, dAcTbox_c, fProfile::TBOX, 0x018D, 0, 6);
extern "C" mVec3_c vecs[] = {
- mVec3_c(0.0f, 54.0f, 0.0f),
- mVec3_c(0.0f, 34.0f, 0.0f),
- mVec3_c(0.0f, 66.5f, 0.0f),
- mVec3_c(0.0f, 49.0f, 0.0f)
+ mVec3_c(0.0f, 54.0f, 0.0f), mVec3_c(0.0f, 34.0f, 0.0f), mVec3_c(0.0f, 66.5f, 0.0f), mVec3_c(0.0f, 49.0f, 0.0f)
};
extern "C" mVec3_c v1 = mVec3_c(0.0f, 0.0f, -2.0f);
@@ -32,14 +38,191 @@ STATE_DEFINE(dAcTbox_c, GoddessWait);
fLiMgBa_c dAcTbox_c::sTboxActorList;
-dAcTbox_c::dAcTbox_c() : mStateMgr(*this, sStateID::null), mScnCallback(this), mEvent(*this, nullptr), mTboxListNode(this), mDowsingTarget1(this, DowsingTarget::SLOT_NONE), mDowsingTarget2(this, DowsingTarget::SLOT_NONE) {
+static char *const sArcNames[] = {
+ "TBoxNormalT",
+ "TBoxSmallT",
+ "TBoxBossT",
+ "GoddessTBox",
+};
+
+static const char *const sOpenArcName = "FX_TBoxOpen";
+static const char *const sOpenMdlName = "FX_TBoxOpen";
+static const char *const sOpenAnmChrName = "FX_TBoxOpen";
+static const char *const sOpenAnmTexSrtName = "FX_TBoxOpen";
+static const char *const sOpenAnmClrName = "FX_TBoxOpen";
+
+static const char *const sAppearAnmName = "TBoxNormalT_appear";
+
+extern "C" char *const sOpenEventNames[] = {
+ "TreasureBoxOpen",
+ "TreasureBoxOpenSmall",
+ "TreasureBoxOpenBoss",
+ "TreasureBoxOpen",
+};
+
+static char *const sMdlNames[] = {
+ "TBoxNormalT",
+ "TBoxSmallT",
+ "TBoxBossT",
+ "GoddessTBox",
+};
+
+static char *const sAnmNames[] = {
+ "TBoxNormalT",
+ "TBoxSmallT",
+ "TBoxBossT",
+ "TBoxNormalT",
+};
+
+static char *const sCloseCcNames[] = {
+ "TBoxNormalTClose",
+ "TBoxSmallTClose",
+ "TBoxBossTClose",
+ "GoddessTBoxClose",
+};
+
+static char *const sOpenCcNames[] = {
+ "TBoxNormalTOpen",
+ "TBoxSmallTOpen",
+ "TBoxBossTOpen",
+ "GoddessTBoxOpen",
+};
+
+dAcTbox_c::dAcTbox_c()
+ : mStateMgr(*this, sStateID::null), mScnCallback(this), mEvent(*this, nullptr), mTboxListNode(this),
+ mDowsingTarget1(this, DowsingTarget::SLOT_NONE), mDowsingTarget2(this, DowsingTarget::SLOT_NONE),
+ field_0x4E8(-1) {
sTboxActorList.append(&mTboxListNode);
unkByteTargetFiRelated = 2;
}
+
dAcTbox_c::~dAcTbox_c() {
sTboxActorList.remove(&mTboxListNode);
}
+bool dAcTbox_c::createHeap() {
+ void *data = getOarcResFile(sArcNames[mVariant]);
+ if (data == nullptr) {
+ return false;
+ }
+ if (!mMdl1.create(data, data, sMdlNames[mVariant], sAnmNames[mVariant], &heap_allocator, 0x32F, 1, nullptr)) {
+ return false;
+ }
+ mMdl1.getModel().setLocalMtx(mWorldMtx);
+ mScnCallback.attach(mMdl1.getModel());
+ if (!initBgW(mBgWs[0], sArcNames[mVariant], sCloseCcNames[mVariant])) {
+ return false;
+ }
+ if (!initBgW(mBgWs[1], sArcNames[mVariant], sOpenCcNames[mVariant])) {
+ return false;
+ }
+
+ if (mVariant == 3) {
+ if (data == nullptr) {
+ return false;
+ }
+ nw4r::g3d::ResFile res = data;
+ nw4r::g3d::ResMdl mdl = mMdl1.getModel().getResMdl();
+ if (!mdl.IsValid()) {
+ return false;
+ }
+ nw4r::g3d::ResAnmTexPat anmTexPat = res.GetResAnmTexPat("GoddessTBox");
+ if (!anmTexPat.mAnmTexPat.IsValid()) {
+ return false;
+ }
+ if (!mAnmGoddessPat.create(mdl, anmTexPat, &heap_allocator, nullptr, 1)) {
+ return false;
+ }
+ mMdl1.getModel().setAnm(mAnmGoddessPat);
+ u16 goddessTBoxActive = getParams2Lower();
+ if (StoryflagManager::sInstance->getCounterOrFlag(goddessTBoxActive) && !mHasBeenOpened) {
+ nw4r::g3d::ResAnmTexSrt anmTexSrt = res.GetResAnmTexSrt("GoddessTBox");
+ if (!anmTexSrt.mAnmTexSrt.IsValid()) {
+ return false;
+ }
+ if (!mAnmGoddessTexSrt.create(mdl, anmTexSrt, &heap_allocator, nullptr, 1)) {
+ return false;
+ }
+ mMdl1.getModel().setAnm(mAnmGoddessTexSrt);
+ }
+ } else if (mVariant == 0) {
+ if (data == nullptr) {
+ return false;
+ }
+ nw4r::g3d::ResFile res = data;
+ nw4r::g3d::ResAnmClr anmClr = res.GetResAnmClr("TBoxNormalTAppear");
+ if (!anmClr.mAnmClr.IsValid()) {
+ return false;
+ }
+ nw4r::g3d::ResMdl mdl = mMdl1.getModel().getResMdl();
+ if (!mdl.IsValid()) {
+ return false;
+ }
+ if (!mAnmMatClr1.create(mdl, anmClr, &heap_allocator, nullptr, 1)) {
+ return false;
+ }
+ mAnmMatClr1.setRate(1.0f, 0);
+ mMdl1.getModel().setAnm(mAnmMatClr1);
+ }
+
+ if (isNotSmall()) {
+ void *fxData = getOarcResFile(sOpenArcName);
+ if (fxData == nullptr) {
+ return false;
+ }
+ nw4r::g3d::ResFile fxRes = fxData;
+ if (!fxRes.mFile.IsValid()) {
+ return false;
+ }
+
+ nw4r::g3d::ResMdl openMdl = fxRes.GetResMdl(sOpenMdlName);
+ if (!openMdl.IsValid()) {
+ return false;
+ }
+ if (!mOpenFxMdl.create(openMdl, &heap_allocator, 0x120)) {
+ return false;
+ }
+ mOpenFxMdl.setPriorityDraw(0x7F, 0x86);
+
+ nw4r::g3d::ResAnmChr openAnm = fxRes.GetResAnmChr(sOpenAnmChrName);
+ if (!openAnm.mAnmChr.IsValid()) {
+ return false;
+ }
+ if (!mAnmChr.create(openMdl, openAnm, &heap_allocator, nullptr)) {
+ return false;
+ }
+ mOpenFxMdl.setAnm(mAnmChr);
+
+ nw4r::g3d::ResAnmTexSrt anmTexSrt = fxRes.GetResAnmTexSrt(sOpenAnmTexSrtName);
+ if (!anmTexSrt.mAnmTexSrt.IsValid()) {
+ return false;
+ }
+ if (!mAnmTexSrt1.create(openMdl, anmTexSrt, &heap_allocator, nullptr, 1)) {
+ return false;
+ }
+ mOpenFxMdl.setAnm(mAnmTexSrt1);
+
+ nw4r::g3d::ResAnmClr anmClr = fxRes.GetResAnmClr(sOpenAnmClrName);
+ if (!anmClr.mAnmClr.IsValid()) {
+ return false;
+ }
+ if (!mAnmMatClr2.create(openMdl, anmClr, &heap_allocator, nullptr, 1)) {
+ return false;
+ }
+ mOpenFxMdl.setAnm(mAnmMatClr2);
+ mVec3_c fxPos;
+ fn_8026B380(fxPos);
+ mMtx_c fxTransform;
+ fxTransform.transS(fxPos);
+ // TODO address calculations here
+ fxTransform.ZXYrotM(rotation.x, rotation.y, rotation.y);
+ mOpenFxMdl.setLocalMtx(mWorldMtx);
+ mOpenFxMdl.setScale(fn_8026B3C0());
+ }
+
+ return true;
+}
+
void dAcTbox_c::initializeState_DugOut() {}
void dAcTbox_c::executeState_DugOut() {}
void dAcTbox_c::finalizeState_DugOut() {}
@@ -79,3 +262,7 @@ void dAcTbox_c::finalizeState_Wait() {}
void dAcTbox_c::initializeState_GoddessWait() {}
void dAcTbox_c::executeState_GoddessWait() {}
void dAcTbox_c::finalizeState_GoddessWait() {}
+
+bool dAcTbox_c::isNotSmall() const {
+ return mVariant != 1;
+}