d_a_salbage_obj OK

This commit is contained in:
robojumper
2025-08-21 23:10:18 +02:00
parent a416cab97e
commit cbe298e99a
12 changed files with 791 additions and 122 deletions
+167
View File
@@ -0,0 +1,167 @@
#ifndef D_A_SALBAGE_OBJ_H
#define D_A_SALBAGE_OBJ_H
#include "d/a/obj/d_a_obj_base.h"
#include "d/col/bg/d_bg_s_acch.h"
#include "d/col/cc/d_cc_d.h"
#include "d/d_shadow.h"
#include "m/m3d/m_smdl.h"
#include "m/m_mtx.h"
#include "m/m_quat.h"
#include "m/m_vec.h"
#include "s/s_State.hpp"
#include "toBeSorted/dowsing_target.h"
class dAcSalbageObj_c;
class SalbageRelated {
public:
SalbageRelated(dAcSalbageObj_c *obj) : mpObj(obj), mSalvageObjId(6) {}
/* vt 0x08 */ virtual ~SalbageRelated() {}
/* vt 0x0C */ virtual void setCarried() {
mCarried = true;
}
/* vt 0x10 */ virtual void setNotCarried() {
mCarried = false;
}
/* vt 0x14 */ virtual bool isCarried() const {
return mCarried;
}
/* vt 0x18 */ virtual void setHidden() {
mHidden = true;
}
/* vt 0x1C */ virtual void setNotHidden() {
mHidden = false;
}
/* vt 0x20 */ virtual bool isHidden() const {
return mHidden;
}
/* vt 0x24 */ virtual s32 getSalvageObjId() const {
return mSalvageObjId;
}
/* vt 0x28 */ virtual void doDemoThrow();
private:
/* 0x04 */ dAcSalbageObj_c *mpObj;
/* 0x08 */ bool mCarried;
/* 0x09 */ bool mHidden;
/* 0x0C */ s32 mSalvageObjId;
};
/**
* Actor - Object - Salvage
*
* Base class for objects that can be carried by
* the Salvage Robot NPC, AKA Scrapper.
*/
class dAcSalbageObj_c : public dAcObjBase_c {
friend class SalbageRelated;
enum Behavior_e {
/// The object is stationary and disappears when picked up
BEHAVIOR_STATIONARY,
/// The object is being carried and disappears when dropped
BEHAVIOR_CARRY,
/// The object is being carried in the Sky by the salvage robot
BEHAVIOR_FLY,
};
public:
dAcSalbageObj_c() : mStateMgr(*this), mSalbageRelated(this), mDowsingTarget(this, DowsingTarget::SLOT_NONE) {}
virtual ~dAcSalbageObj_c() {}
virtual int preExecute() override;
virtual int draw() override;
virtual int preDraw() override;
virtual int actorExecute() override;
virtual void doInteraction(s32) override;
/* vt 0x80 */ virtual bool vt_0x80() const {
return false;
}
protected:
bool shouldBeActiveDowsingTarget() const;
void initSalbageObj();
void loadBehaviorFromParams();
void calcMtxFromSalbageNpc(mMtx_c &ret);
void addAttentionTargetIfNeeded();
void addAttentionTarget();
void initCcAndBg();
void executeInternal();
void updateCc();
void updateBgAcchCir();
void updateMdl();
/* vt 0x84-0x8C */ STATE_VIRTUAL_FUNC_DECLARE(dAcSalbageObj_c, Wait);
/* vt 0x90-0x98 */ STATE_VIRTUAL_FUNC_DECLARE(dAcSalbageObj_c, Carried);
/* vt 0x9C-0xA4 */ STATE_VIRTUAL_FUNC_DECLARE(dAcSalbageObj_c, Demo);
/* vt 0xA8-0xB0 */ STATE_VIRTUAL_FUNC_DECLARE(dAcSalbageObj_c, DemoThrow);
/* vt 0xB4-0xBC */ STATE_VIRTUAL_FUNC_DECLARE(dAcSalbageObj_c, Fly);
/* vt 0xC0-0xC8 */ STATE_VIRTUAL_FUNC_DECLARE(dAcSalbageObj_c, After);
STATE_FUNC_DECLARE(dAcSalbageObj_c, Kill);
/* vt 0xCC */ virtual mMtx_c calcWorldMtx();
/* vt 0xD0 */ virtual void vt_0xD0() {}
/* vt 0xD4 */ virtual bool isInStateWait() const {
return mStateMgr.isState(StateID_Wait);
}
/* vt 0xD8 */ virtual bool isInStateWaitOrDemoThrow() const {
return mStateMgr.isState(StateID_Wait) || mStateMgr.isState(StateID_DemoThrow);
}
/* vt 0xDC */ virtual DowsingTarget::DowsingSlot getDowsingSlot() const {
return DowsingTarget::SLOT_QUEST;
}
/* vt 0xE0 */ virtual f32 getCcRadius() const {
return 0.0f;
}
/* vt 0xE4 */ virtual f32 getCcHeight() const {
return 0.0f;
}
/* vt 0xE8 */ virtual f32 getBgAcchCirRadius() const {
return 0.0f;
}
/* vt 0xEC */ virtual f32 getBgAcchCirHeight() const {
return 0.0f;
}
/* vt 0xF0 */ virtual f32 getPoscopy2YOffset() const {
return 0.0f;
}
/* vt 0xF4 */ virtual f32 getPoscopy3YOffset() const {
return 0.0f;
}
/* vt 0xF8 */ virtual f32 getDowsingUnusedF32() const {
return 1500.0f;
}
/* vt 0xFC */ virtual f32 getDowsingTargetYOffset() const {
return 50.0f;
}
/* 0x330 */ u8 _0x330[0x334 - 0x330];
/* 0x334 */ m3d::smdl_c *mpMdl;
/* 0x338 */ dShadowCircle_c mShadow;
/* 0x340 */ mQuat_c mShadowRot;
/* 0x350 */ dBgS_AcchCir mBgAcchCir;
/* 0x3AC */ dBgS_ObjAcch mBgObjAcch;
/* 0x75C */ dCcD_Cyl mCcCyl;
/* 0x8AC */ STATE_MGR_DECLARE(dAcSalbageObj_c);
/* 0x8E8 */ s32 mBehavior;
/* 0x8EC */ bool mIsDemoState;
/* 0x8F0 */ SalbageRelated mSalbageRelated;
/* 0x900 */ f32 field_0x900;
/* 0x904 */ s16 field_0x904;
/* 0x908 */ mMtx_c mWorldSRMtx;
/* 0x938 */ f32 field_0x938;
/* 0x93C */ DowsingTarget mDowsingTarget;
/* 0x95C */ mVec3_c field_0x95C;
/* 0x968 */ bool mIsDowsingRegistered;
/* 0x96C */ const sStateID_c *mpNextStateId;
};
#endif
+12 -5
View File
@@ -1,13 +1,13 @@
#ifndef D_A_NPC_SALBAGE_ROBOT_H
#define D_A_NPC_SALBAGE_ROBOT_H
#include "d/a/npc/d_a_npc.h"
#include "d/a/npc/d_a_ordinary_npc.h"
#include "m/m_mtx.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
class dAcNpcSlb_c : public dAcNpc_c {
class dAcNpcSlb_c : public dAcOrdinaryNpc_c {
public:
dAcNpcSlb_c() : mStateMgr(*this, sStateID::null) {}
dAcNpcSlb_c() {}
virtual ~dAcNpcSlb_c() {}
STATE_FUNC_DECLARE(dAcNpcSlb_c, Hide);
@@ -16,8 +16,15 @@ public:
STATE_FUNC_DECLARE(dAcNpcSlb_c, Kill);
STATE_FUNC_DECLARE(dAcNpcSlb_c, Kill2);
// ouch
mMtx_c getCarriedObjMtx() const {
return mCarryObjMtx;
}
private:
/* 0x??? */ STATE_MGR_DECLARE(dAcNpcSlb_c);
u8 _pad[0xD50 - sizeof(dAcOrdinaryNpc_c)];
/* 0xD50 */ mMtx_c mCarryObjMtx;
};
#endif
+16
View File
@@ -0,0 +1,16 @@
#ifndef D_A_NPC_TALK_KENSEI_H
#define D_A_NPC_TALK_KENSEI_H
#include "d/a/npc/d_a_ordinary_npc.h"
class dAcSalbageObj_c;
class dAcNpcTalkKensei_c : public dAcOrdinaryNpc_c {
public:
static dAcNpcTalkKensei_c *GetInstance();
void triggerSalvageQuestion(dAcSalbageObj_c *);
private:
};
#endif
+3 -1
View File
@@ -18,6 +18,8 @@
#include "m/m_vec.h"
#include "m/types_m.h"
class SalbageRelated;
// Ghidra: ActorObjectBase
// size: 0x330
@@ -52,7 +54,7 @@ public:
/* 0x210 */ dLinkage_c mLinkage;
/* 0x2B8 */ u32 mField_0x2B8;
/* 0x2BC */ ActorLighting mLightingInfo;
/* 0x32C */ u32 mField_0x32C;
/* 0x32C */ SalbageRelated *mpSalbageRelated;
public:
mVec3_c &GetOldPosition() {
+6 -5
View File
@@ -1,17 +1,18 @@
#ifndef D_A_OBJ_POT_SAL_H
#define D_A_OBJ_POT_SAL_H
#include "d/a/obj/d_a_obj_base.h"
#include "d/a/d_a_salbage_obj.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
class dAcOpotSal_c : public dAcObjBase_c {
class dAcOpotSal_c : public dAcSalbageObj_c {
public:
dAcOpotSal_c() : mStateMgr(*this, sStateID::null) {}
dAcOpotSal_c() {}
virtual ~dAcOpotSal_c() {}
STATE_VIRTUAL_OVERRIDE_FUNC_DECLARE(dAcOpotSal_c, dAcSalbageObj_c, DemoThrow);
STATE_VIRTUAL_OVERRIDE_FUNC_DECLARE(dAcOpotSal_c, dAcSalbageObj_c, After);
private:
/* 0x??? */ STATE_MGR_DECLARE(dAcOpotSal_c);
};
#endif
+2 -2
View File
@@ -169,10 +169,10 @@ public:
private:
/* 0xBDC */ u8 field_0xBDC;
public:
static AttentionManager *sInstance;
public:
bool create();
bool createHeap();
bool execute();
+4 -1
View File
@@ -2,7 +2,6 @@
#define DOWSING_TARGET_H
#include "d/a/d_a_base.h"
#include "f/f_list_nd.h"
#include "m/m_vec.h"
class DowsingTarget {
@@ -32,6 +31,10 @@ public:
virtual ~DowsingTarget(); // 0x08
virtual void getPosition(mVec3_c &); // 0x0C
void setOffset(const mVec3_c &offset) {
mOffset = offset;
}
bool doRegister();
bool doUnregister();
void initialize(DowsingSlot type, u16 unk, const mVec3_c *offset, f32 f);
+39
View File
@@ -0,0 +1,39 @@
#ifndef D_SALVAGE_MGR_H
#define D_SALVAGE_MGR_H
#include "common.h"
#include "d/a/d_a_base.h"
#include "m/m_mtx.h"
class dAcSalbageObj_c;
class dAcNpcSlb_c;
class dSalvageMgr_c {
public:
// Directly accessing seems to be required
// static dSalvageMgr_c *GetInstance() {
// return sInstance;
// }
bool checkDeliveredStoryflag(const s32& id) const;
bool startedQuestForSalvageObj(const dAcSalbageObj_c *obj) const;
bool hasDowsingForSalvageObj(const dAcSalbageObj_c *obj) const;
mMtx_c getCarryRotMtx(const s32 &id) const;
mMtx_c getCarryRotMtx2(const s32 &id) const {
return getCarryRotMtx(id);
}
s32 getCurrentSalvageObjId() const;
void deleteObjAndSlb();
static dSalvageMgr_c *sInstance;
bool hasObjAndSlb() const {
return mObjRef.isLinked() && mSlbRef.isLinked();
}
/* 0x00 */ dAcRef_c<dAcSalbageObj_c> mObjRef;
/* 0x0C */ dAcRef_c<dAcNpcSlb_c> mSlbRef;
private:
};
#endif