summaryrefslogtreecommitdiff
path: root/src/00_Core/Actor
diff options
context:
space:
mode:
authorAetias <aetias@outlook.com>2025-07-01 21:27:52 +0200
committerAetias <aetias@outlook.com>2025-07-01 21:27:52 +0200
commita7f149c3af206d90f046c6e7237ea701f0ce7b41 (patch)
tree3321e504a1be2ea314121730767e16f00c43d6a5 /src/00_Core/Actor
parent2b45d3fab70aa81c0c2564aa976a70692c3d455d (diff)
parentcfb0123c4a582a7cd28e1a49e7642cba0260cc6f (diff)
Merge remote-tracking branch 'zeldaret/main' into decomp/MapManager
Diffstat (limited to 'src/00_Core/Actor')
-rw-r--r--src/00_Core/Actor/Actor.cpp24
-rw-r--r--src/00_Core/Actor/ActorManager.cpp11
-rw-r--r--src/00_Core/Actor/ActorSpawner.cpp104
-rw-r--r--src/00_Core/Actor/Dungeon/ActorActionObject.cpp2
-rw-r--r--src/00_Core/Actor/Dungeon/ActorEventIcon.cpp2
-rw-r--r--src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp109
6 files changed, 212 insertions, 40 deletions
diff --git a/src/00_Core/Actor/Actor.cpp b/src/00_Core/Actor/Actor.cpp
index b865c39e..a6af4159 100644
--- a/src/00_Core/Actor/Actor.cpp
+++ b/src/00_Core/Actor/Actor.cpp
@@ -5,6 +5,8 @@ extern "C" {
#include "Actor/Actor.hpp"
#include "Actor/ActorManager.hpp"
#include "Actor/ActorPlayerDummy.hpp"
+#include "DTCM/UnkStruct_027e077c.hpp"
+#include "DTCM/UnkStruct_027e103c.hpp"
#include "Item/ItemManager.hpp"
#include "Map/MapManager.hpp"
#include "Player/EquipSword.hpp"
@@ -46,8 +48,7 @@ ARM Actor::Actor() :
mUnk_010(0),
mUnk_011(0),
mUnk_012(0),
- mUnk_034(-1),
- mUnk_038(-1),
+ mUnk_034(-1, -1),
mUnk_03c(-1),
mUnk_040(-1, -1),
mGravity(FLOAT_TO_Q20(0.0498)),
@@ -111,11 +112,11 @@ ARM Actor::Actor() :
ARM Actor::~Actor() {}
-ARM bool Actor::vfunc_08() {
+ARM bool Actor::Init() {
return true;
}
-ARM void Actor::vfunc_0c() {}
+ARM bool Actor::vfunc_0c() {}
ARM void Actor::vfunc_10(u32 param1) {}
ARM void Actor::vfunc_24() {}
ARM void Actor::vfunc_28() {}
@@ -255,20 +256,9 @@ ARM bool Actor::func_ov00_020c195c() {
return true;
}
-struct UnkStruct2 {
- /* 0 */ u32 mUnk_0;
- /* 4 */ u32 mUnk_4;
- /* 8 */
-};
-extern UnkStruct2 data_027e077c;
-extern u8 data_02056be4[];
-extern "C" bool func_ov05_02103f4c(s32 param1);
-extern s32 data_027e103c;
ARM bool Actor::func_ov00_020c198c() {
- u32 unk1 = data_027e077c.mUnk_0;
- u32 unk2 = data_027e077c.mUnk_4;
- if (data_027e077c.mUnk_0 != data_027e077c.mUnk_4 || (data_02056be4[unk1] & 1) != 0 || (data_02056be4[unk2] & 4) != 0 ||
- func_ov05_02103f4c(data_027e103c) || gPlayer->mHealth <= 0)
+ if (data_027e077c.GetUnk0() != data_027e077c.GetUnk4() || (data_02056be4[data_027e077c.GetUnk0()] & 1) != 0 ||
+ (data_02056be4[data_027e077c.GetUnk4()] & 4) != 0 || data_027e103c->func_ov005_02103f4c() || gPlayer->mHealth <= 0)
{
return false;
}
diff --git a/src/00_Core/Actor/ActorManager.cpp b/src/00_Core/Actor/ActorManager.cpp
index 73ab6bbb..d9dbe8b1 100644
--- a/src/00_Core/Actor/ActorManager.cpp
+++ b/src/00_Core/Actor/ActorManager.cpp
@@ -1,4 +1,5 @@
#include "Actor/ActorManager.hpp"
+#include "DTCM/UnkStruct_027e077c.hpp"
#include "DTCM/UnkStruct_027e103c.hpp"
#include "Map/MapManager.hpp"
@@ -8,8 +9,6 @@ extern "C" Cylinder *func_ov000_020c3ef0(void *, u32 index);
extern "C" bool func_ov000_020c3f08(void *, u32 index);
extern "C" void func_ov000_020c3f3c(void *, u32 index, Cylinder *cylinder);
extern "C" void func_ov000_020c3f54(void *, u32 param2);
-extern s32 data_027e077c;
-extern u8 data_02056be4[];
ARM void ActorManager::DeleteActor(u32 index, bool param2) {
if (!param2) {
@@ -52,7 +51,7 @@ ARM void ActorManager::func_ov00_020c3484(ActorRef *ref, ActorManager *actorMgr,
q20 minDistance = 0x7fffffff;
Actor **actorIter = actorMgr->mActorTable;
- u8 unkByte = data_02056be4[data_027e077c];
+ u8 unkByte = data_02056be4[data_027e077c.GetUnk0()];
bool unk1 = (unkByte & 1) != 0;
Actor **actorTableEnd = actorIter + actorMgr->mMaxActorIndex;
@@ -155,7 +154,7 @@ ARM Actor *ActorManager::GetActor(ActorRef *ref) {
ARM bool FilterActor::Filter(Actor *actor) {
if (mType != actor->mType) return false;
- if (mUnk_08 != -1 && mUnk_08 != actor->mUnk_034) return false;
+ if (mUnk_08 != -1 && mUnk_08 != actor->mUnk_034.id) return false;
if (mExcludeRefs != NULL) {
for (s32 i = 0; mExcludeRefs[i].id != -1; ++i) {
ActorRef *ref = &mExcludeRefs[i];
@@ -313,7 +312,7 @@ ARM s32 ActorManager::func_ov00_020c3bb0(unk32 param1, s32 *param2) {
if (param2 != NULL) *param2 = 0;
AABB boxes[8];
- s32 numBoxes = gMapManager->GetTriggerBoundingBoxes(param1, boxes, ARRAY_LEN(boxes));
+ s32 numBoxes = gMapManager->GetTriggerBoundingBoxes(param1, boxes, ARRAY_LEN_U(boxes));
if (numBoxes <= 0) return 0;
s32 i;
@@ -350,7 +349,7 @@ ARM s32 ActorManager::func_ov00_020c3bb0(unk32 param1, s32 *param2) {
ARM void ActorManager::func_ov00_020c3ce8(unk32 param1, bool param2) {
AABB boxes[8];
- s32 numBoxes = gMapManager->GetTriggerBoundingBoxes(param1, boxes, ARRAY_LEN(boxes));
+ s32 numBoxes = gMapManager->GetTriggerBoundingBoxes(param1, boxes, ARRAY_LEN_U(boxes));
if (numBoxes <= 0) return;
s32 i;
diff --git a/src/00_Core/Actor/ActorSpawner.cpp b/src/00_Core/Actor/ActorSpawner.cpp
index 76b4ae74..55cf1a57 100644
--- a/src/00_Core/Actor/ActorSpawner.cpp
+++ b/src/00_Core/Actor/ActorSpawner.cpp
@@ -1,10 +1,98 @@
#include "Actor/ActorSpawner.hpp"
+#include "Actor/ActorManager.hpp"
+#include "Map/MapManager.hpp"
-ActorSpawner *ActorSpawner::Create() {}
-void ActorSpawner::Destroy() {}
-ActorSpawner::ActorSpawner() {}
-ActorSpawner::~ActorSpawner() {}
-void ActorSpawner::func_ov000_020c4014() {}
-void ActorSpawner::func_ov000_020c4018() {}
-Actor *ActorSpawner::CreateActor(ActorTypeId type) {}
-s32 ActorSpawner::Spawn(ActorTypeId type, Vec3p *pos, void *param3, ActorRef *ref) {}
+extern u32 *data_027e0ce0[];
+ARM ActorSpawner *ActorSpawner::Create() {
+ gActorSpawner = new(data_027e0ce0[1], 4) ActorSpawner();
+}
+
+ARM void ActorSpawner::Destroy() {
+ delete gActorSpawner;
+ gActorSpawner = NULL;
+}
+
+ARM ActorSpawner::ActorSpawner() {}
+
+ARM ActorSpawner::~ActorSpawner() {}
+
+ARM void ActorSpawner::func_ov000_020c4014() {}
+
+ARM void ActorSpawner::func_ov000_020c4018() {}
+
+ARM Actor *ActorSpawner::CreateActor(ActorTypeId typeId) {
+ Actor *actor = NULL;
+ ActorType *type = ActorType::Find(typeId);
+ if (type != NULL) {
+ actor = type->create();
+ }
+ return actor;
+}
+
+extern "C" unk32 GetCardinal(s16 angle);
+ARM s32 ActorSpawner::Spawn(ActorTypeId type, Vec3p *pos, ActorSpawnOptions *options, ActorRef *ref) {
+ ActorManager *actorManager = gActorManager;
+ u16 maxActors = actorManager->mMaxActors;
+ s32 id = -1;
+ s32 index;
+ Actor **actorSlot = actorManager->mActorTable;
+ for (index = 0; index < maxActors; index++, actorSlot++) {
+ if (*actorSlot != NULL) {
+ continue;
+ }
+
+ Actor *actor = this->CreateActor(type);
+ *actorSlot = actor;
+ if (actor == NULL) {
+ if (ref != NULL) {
+ ref->Reset();
+ }
+ return -1;
+ }
+ actor->mType = type;
+ (*actorSlot)->mRef.id = actorManager->mNextActorId;
+ (*actorSlot)->mRef.index = index;
+ (*actorSlot)->mUnk_014 = *pos;
+ (*actorSlot)->mUnk_020 = options->mUnk_00;
+ (*actorSlot)->mAngle = options->mAngle;
+ (*actorSlot)->mUnk_012 = options->mAngle;
+ (*actorSlot)->mUnk_074 = GetCardinal(options->mAngle);
+ if (options->mUnk_18 >= 0xffff) {
+ (*actorSlot)->mUnk_03c = -1;
+ } else {
+ (*actorSlot)->mUnk_03c = options->mUnk_18;
+ }
+ (*actorSlot)->mUnk_034 = options->mUnk_1c;
+ (*actorSlot)->mUnk_140 = options->mUnk_24;
+ (*actorSlot)->mUnk_144 = options->mUnk_28;
+ Actor *actor2 = *actorSlot;
+ actor2->mPos = *pos;
+ actor2->mPrevPos = *pos;
+ (*actorSlot)->mUnk_010 = gMapManager->GetCourseData_Unk_1c();
+ (*actorSlot)->mUnk_011 = gMapManager->GetCourseData_Unk_1d();
+ u16 nextIndex = index + 1;
+ if (actorManager->mMaxActorIndex < nextIndex) {
+ actorManager->mMaxActorIndex = nextIndex;
+ }
+ actorManager->mCacheEmptyActorIndex = index;
+
+ id = actorManager->mNextActorId;
+ if (ref != NULL) {
+ *ref = ActorRef(id, index);
+ }
+ actorManager->mNextActorId += 1;
+ actorManager->mNumActors += 1;
+ if (!(*actorSlot)->Init()) {
+ (*actorSlot)->mAlive = false;
+ if (ref != NULL) {
+ ref->Reset();
+ }
+ return -1;
+ }
+ break;
+ }
+ if ((id == -1) && (ref != NULL)) {
+ ref->Reset();
+ }
+ return id;
+}
diff --git a/src/00_Core/Actor/Dungeon/ActorActionObject.cpp b/src/00_Core/Actor/Dungeon/ActorActionObject.cpp
index 0a2c3970..ea2dfec2 100644
--- a/src/00_Core/Actor/Dungeon/ActorActionObject.cpp
+++ b/src/00_Core/Actor/Dungeon/ActorActionObject.cpp
@@ -18,7 +18,7 @@ ARM ActorActionObject::ActorActionObject() {}
ARM ActorActionObject::~ActorActionObject() {}
// non-matching
-ARM bool ActorActionObject::vfunc_08() {
+ARM bool ActorActionObject::Init() {
mGravity = 0;
mHitbox.pos = gVec3p_ZERO;
mHitbox.size = -1;
diff --git a/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp b/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp
index 94e7381d..22e35d8e 100644
--- a/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp
+++ b/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp
@@ -4,7 +4,7 @@ ActorType ActorEventIcon::gType = ActorType(ActorTypeId_EventIcon, (ActorCreateF
ActorEventIcon *ActorEventIcon::Create() {}
ActorEventIcon::ActorEventIcon() {}
-bool ActorEventIcon::vfunc_08() {}
+bool ActorEventIcon::Init() {}
void ActorEventIcon::vfunc_14(u32 param1) {}
void ActorEventIcon::vfunc_18(u32 param1) {}
u32 ActorEventIcon::func_ov000_02090648(u32 param1) {}
diff --git a/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp b/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp
index 37c4511c..78e229db 100644
--- a/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp
+++ b/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp
@@ -1,15 +1,110 @@
#include "Actor/Dungeon/ActorSwitchObject.hpp"
+#include "Map/MapManager.hpp"
ActorType ActorSwitchObject::gType = ActorType(ActorTypeId_SwitchObject, (ActorCreateFunc) ActorSwitchObject::Create, NULL);
ActorSwitchObject *ActorSwitchObject::Create() {}
-bool ActorSwitchObject::vfunc_08() {}
-void ActorSwitchObject::vfunc_0c() {}
-void ActorSwitchObject::vfunc_14(u32 param1) {}
-void ActorSwitchObject::vfunc_18(u32 param1) {}
-bool ActorSwitchObject::func_ov000_0208fc10(s32 param1) {}
-void ActorSwitchObject::func_ov000_0208fc7c() {}
+
+bool ActorSwitchObject::Init() {
+ Actor::Init();
+ this->func_ov000_0208fc7c();
+ this->mUnk_130 = 0;
+ return true;
+}
+
+bool ActorSwitchObject::vfunc_0c() {
+ return this->func_ov00_020c1bfc(0) ? this->func_ov000_0208fc10(1) : this->func_ov000_0208fc10(0);
+}
+
+void ActorSwitchObject::vfunc_14(u32 param1) {
+ bool bVar1;
+ u32 uVar2;
+ u32 uVar3;
+ s32 iVar4;
+ s32 iVar5;
+
+ bVar1 = this->func_ov00_020c313c(param1);
+ if (bVar1 == NULL) {
+ return;
+ }
+ uVar2 = this->mUnk_130;
+ switch (uVar2) {
+ default:
+ if (uVar2 == 2) {
+ break;
+ }
+ return;
+ case 0:
+ uVar3 = this->func_ov000_0208fcb4();
+ switch (uVar3) {
+ case 1: this->func_ov000_0208fc10(1); return;
+ case 2: this->func_ov000_0208fc10(2); return;
+ default: return;
+ }
+ bVar1 = this->func_ov000_0208fc10(2);
+ return;
+ case 1:
+ iVar4 = this->func_ov000_0208fcb4();
+ if (iVar4 == 1) {
+ return;
+ }
+ bVar1 = this->func_ov000_0208fc10(0);
+ return;
+ }
+
+ iVar5 = this->mActiveFrames + 1;
+ this->mActiveFrames = iVar5;
+ if (iVar5 < 0x1e) {
+ return;
+ }
+
+ this->func_ov000_0209032c();
+ bVar1 = this->func_ov000_0208fc10(0);
+
+ return;
+}
+
+void ActorSwitchObject::vfunc_18(u32 param1) {
+ this->vfunc_14(param1);
+}
+
+bool ActorSwitchObject::func_ov000_0208fc10(s32 param1) {
+ this->mUnk_130 = param1;
+
+ switch (param1) {
+ case 0: this->func_ov00_020c1c20(0, 0); break;
+ case 1:
+ this->func_ov00_020c1c20(0, 1);
+ if (this->mUnk_158 == 0) {
+ this->mAlive = false;
+ }
+ break;
+ case 2:
+ this->func_ov000_0208fef8();
+ this->mActiveFrames = 0;
+ break;
+ }
+
+ return true;
+}
+
+void ActorSwitchObject::func_ov000_0208fc7c() {
+ this->mUnk_158 = this->mUnk_020.mUnk_00[1];
+ this->mUnk_15c = this->mUnk_020.mUnk_00[2];
+ this->mUnk_164 = this->mUnk_020.mUnk_0a[1];
+ this->mUnk_168 = this->mUnk_164 + this->mUnk_020.mUnk_00[0];
+ this->mUnk_16c = this->mUnk_020.mUnk_08[1];
+ this->mUnk_160 = this->mUnk_164;
+}
+
bool ActorSwitchObject::func_ov000_0208fcb4() {}
void ActorSwitchObject::func_ov000_0208fef8() {}
-void ActorSwitchObject::func_ov000_0209032c() {}
+
+void ActorSwitchObject::func_ov000_0209032c() {
+ unk32 i;
+ for (i = this->mUnk_164; i < this->mUnk_168; i++) {
+ gMapManager->func_ov00_02084b38(i, this->mUnk_16c, 0);
+ }
+}
+
ActorSwitchObject::~ActorSwitchObject() {}