From 710f07e632f2e65918ecccc87f8d2e78e2060842 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 17 May 2024 14:21:48 -0400 Subject: [PATCH] Implement/match LegoAnimationManager::FUN_10064380 (#928) * Implement/match LegoAnimationManager::FUN_10064380 * Fix naming * Revert --- .../legoomni/include/legoanimationmanager.h | 17 +- LEGO1/lego/legoomni/include/legoextraactor.h | 3 +- .../src/common/legoanimationmanager.cpp | 303 +++++++++++++++++- .../legoomni/src/paths/legoextraactor.cpp | 4 +- 4 files changed, 317 insertions(+), 10 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimationmanager.h b/LEGO1/lego/legoomni/include/legoanimationmanager.h index 78dfa737..3e362e5a 100644 --- a/LEGO1/lego/legoomni/include/legoanimationmanager.h +++ b/LEGO1/lego/legoomni/include/legoanimationmanager.h @@ -36,7 +36,7 @@ class LegoAnimationManager : public MxCore { MxS32 m_unk0x10; // 0x10 MxBool m_active; // 0x14 MxU8 m_unk0x15; // 0x15 - MxU8 m_unk0x16; // 0x16 + MxS8 m_unk0x16; // 0x16 }; // SIZE 0x08 @@ -53,7 +53,7 @@ class LegoAnimationManager : public MxCore { MxLong m_unk0x08; // 0x08 MxBool m_unk0x0c; // 0x0c MxBool m_unk0x0d; // 0x0d - float m_unk0x10; // 0x10 + float m_speed; // 0x10 MxBool m_unk0x14; // 0x14 }; @@ -150,6 +150,19 @@ class LegoAnimationManager : public MxCore { void FUN_10063d10(); MxBool FUN_10063fb0(LegoLocation::Boundary* p_boundary, LegoWorld* p_world); MxBool FUN_10064120(LegoLocation::Boundary* p_boundary, MxBool, MxBool); + MxResult FUN_10064380( + const char* p_name, + const char* p_boundaryName, + MxS32 p_src, + float p_srcScale, + MxS32 p_dest, + float p_destScale, + MxU32 p_undIdx1, + MxS32 p_unk0x0c, + MxU32 p_undIdx2, + MxS32 p_unk0x10, + float p_speed + ); void FUN_100648f0(LegoTranInfo*, MxLong); void FUN_10064b50(MxLong p_time); diff --git a/LEGO1/lego/legoomni/include/legoextraactor.h b/LEGO1/lego/legoomni/include/legoextraactor.h index d2c846f3..ea3fdeb1 100644 --- a/LEGO1/lego/legoomni/include/legoextraactor.h +++ b/LEGO1/lego/legoomni/include/legoextraactor.h @@ -49,7 +49,8 @@ class LegoExtraActor : public virtual LegoAnimActor { MxResult WaitForAnimation() override; // vtable+0x9c void VTable0xa4(MxU8& p_und1, MxS32& p_und2) override; // vtable+0xa4 void VTable0xc4() override; // vtable+0xc4 - virtual MxResult VTable0xc8(); // vtable+0xc8 + + virtual MxResult FUN_1002aae0(); void Restart(); inline void FUN_1002ad8a(); diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 95b8963c..a8bcc375 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -11,6 +11,7 @@ #include "legoendanimnotificationparam.h" #include "legoextraactor.h" #include "legogamestate.h" +#include "legolocomotionanimpresenter.h" #include "legomain.h" #include "legonavcontroller.h" #include "legoroilist.h" @@ -49,6 +50,197 @@ LegoAnimationManager::Vehicle g_vehicles[] = { {"board", 0, FALSE} }; +// GLOBAL: LEGO1 0x100f6d58 +const char* g_unk0x100f6d58[11][17] = { + {"CNs001xx", + "CNs002xx", + "CNs003xx", + "CNs004xx", + "CNs005xx", + "CNs007xx", + "CNs006xx", + "CNs008xx", + "CNs009xx", + "CNs010xx", + "CNs011xx", + "CNs012xx", + NULL, + NULL, + NULL, + NULL, + NULL}, + {"CNs001Pe", + "CNs002Pe", + "CNs003Pe", + "CNs004Pe", + "CNs005Pe", + "CNs007Pe", + "CNs006Pe", + "CNs008Pe", + "CNs009Pe", + "CNs010Pe", + "CNs001sk", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL}, + {"CNs001Ma", + "CNs002Ma", + "CNs003Ma", + "CNs004Ma", + "CNs005Ma", + "CNs007Ma", + "CNs006Ma", + "CNs008Ma", + "CNs009Ma", + "CNs010Ma", + "CNs0x4Ma", + NULL, + NULL, + "CNs011Ma", + "CNs012Ma", + "CNs013Ma", + NULL}, + {"CNs001Pa", + "CNs002Pa", + "CNs003Pa", + "CNs004Pa", + "CNs005Pa", + "CNs007Pa", + "CNs006Pa", + "CNs008Pa", + "CNs009Pa", + "CNs010Pa", + "CNs0x4Pa", + NULL, + NULL, + "CNs011Pa", + "CNs012Pa", + "CNs013Pa", + NULL}, + {"CNs001Ni", + "CNs002Ni", + "CNs003Ni", + "CNs004Ni", + "CNs005Ni", + "CNs007Ni", + "CNs006Ni", + "CNs008Ni", + "CNs009Ni", + "CNs010Ni", + "CNs011Ni", + "CNsx11Ni", + NULL, + NULL, + NULL, + NULL, + NULL}, + {"CNs001La", + "CNs002La", + "CNs003La", + "CNs004La", + "CNs005La", + "CNs007La", + "CNs006La", + "CNs008La", + "CNs009La", + "CNs010La", + "CNs011La", + "CNsx11La", + NULL, + NULL, + NULL, + NULL, + NULL}, + {"CNs001Br", + "CNs002Br", + "CNs003Br", + "CNs004Br", + "CNs005Br", + "CNs007Br", + "CNs006Br", + "CNs008Br", + "CNs009Br", + "CNs010Br", + "CNs011Br", + "CNs900Br", + "CNs901Br", + "CNs011Br", + "CNs012Br", + "CNs013Br", + "CNs014Br"}, + {"CNs001xx", + "CNs002xx", + "CNs003xx", + "CNs004xx", + "CNs005xx", + "CNs007xx", + "CNs006xx", + "CNs008xx", + "CNs009xx", + "CNs010xx", + "CNs001Bd", + "CNs012xx", + NULL, + NULL, + NULL, + NULL, + NULL}, + {"CNs001xx", + "CNs002xx", + "CNs003xx", + "CNs004xx", + "CNs005xx", + "CNs007xx", + "CNs006xx", + "CNs008xx", + "CNs009xx", + "CNs010xx", + "CNs001Pg", + "CNs012xx", + NULL, + NULL, + NULL, + NULL, + NULL}, + {"CNs001xx", + "CNs002xx", + "CNs003xx", + "CNs004xx", + "CNs005xx", + "CNs007xx", + "CNs006xx", + "CNs008xx", + "CNs009xx", + "CNs010xx", + "CNs001Rd", + "CNs012xx", + NULL, + NULL, + NULL, + NULL, + NULL}, + {"CNs001xx", + "CNs002xx", + "CNs003xx", + "CNs004xx", + "CNs005xx", + "CNs007xx", + "CNs006xx", + "CNs008xx", + "CNs009xx", + "CNs010xx", + "CNs001Sy", + "CNs012xx", + NULL, + NULL, + NULL, + NULL, + NULL} +}; + // GLOBAL: LEGO1 0x100f7048 LegoAnimationManager::Character g_characters[47] = { {"pepper", FALSE, 6, 0, FALSE, FALSE, TRUE, 1500, 20000, FALSE, 50, 1}, @@ -263,7 +455,7 @@ void LegoAnimationManager::Suspend() m_extras[i].m_roi = NULL; m_extras[i].m_characterId = -1; - m_extras[i].m_unk0x10 = -1.0f; + m_extras[i].m_speed = -1.0f; } m_unk0x18 = 0; @@ -316,7 +508,7 @@ void LegoAnimationManager::Init() for (i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { m_extras[i].m_roi = NULL; m_extras[i].m_characterId = -1; - m_extras[i].m_unk0x10 = -1.0f; + m_extras[i].m_speed = -1.0f; m_extras[i].m_unk0x14 = FALSE; } @@ -1743,7 +1935,7 @@ void LegoAnimationManager::AddExtra(MxS32 p_location, MxBool p_und) m_extras[i].m_characterId = m_lastExtraCharacterId; g_characters[m_lastExtraCharacterId].m_unk0x04 = TRUE; m_extras[i].m_unk0x08 = Timer()->GetTime(); - m_extras[i].m_unk0x10 = -1; + m_extras[i].m_speed = -1; m_extras[i].m_unk0x0d = FALSE; m_unk0x414++; return; @@ -1842,7 +2034,7 @@ void LegoAnimationManager::FUN_10063d10() LegoExtraActor* actor = CharacterManager()->GetActor(roi->GetName()); if (actor != NULL) { - float speed = m_extras[i].m_unk0x10; + float speed = m_extras[i].m_speed; if (speed < 0.0f) { if (m_extras[i].m_unk0x14) { @@ -1883,6 +2075,108 @@ MxBool LegoAnimationManager::FUN_10064120(LegoLocation::Boundary* p_boundary, Mx return TRUE; } +// FUNCTION: LEGO1 0x10064380 +// FUNCTION: BETA10 0x1004583a +MxResult LegoAnimationManager::FUN_10064380( + const char* p_name, + const char* p_boundaryName, + MxS32 p_src, + float p_srcScale, + MxS32 p_dest, + float p_destScale, + MxU32 p_undIdx1, + MxS32 p_unk0x0c, + MxU32 p_undIdx2, + MxS32 p_unk0x10, + float p_speed +) +{ + LegoWorld* world = CurrentWorld(); + MxS32 extraIndex = -1; + LegoExtraActor* actor = NULL; + MxS32 i; + + for (i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { + LegoROI* roi = m_extras[i].m_roi; + + if (roi == NULL && extraIndex == -1) { + extraIndex = i; + } + + if (roi != NULL && !strcmpi(roi->GetName(), p_name)) { + actor = CharacterManager()->GetActor(p_name); + + if (actor != NULL && actor->GetController() != NULL) { + actor->GetController()->RemoveActor(actor); + actor->SetController(NULL); + actor->ClearMaps(); + } + + break; + } + } + + if (actor == NULL && extraIndex != -1) { + i = extraIndex; + + MxS32 characterId; + for (characterId = 0; characterId < (MxS32) sizeOfArray(g_characters); characterId++) { + if (!strcmpi(g_characters[characterId].m_name, p_name)) { + break; + } + } + + if (characterId > sizeOfArray(g_characters)) { + return FAILURE; + } + + m_extras[extraIndex].m_roi = CharacterManager()->GetROI(p_name, TRUE); + m_extras[extraIndex].m_characterId = characterId; + m_extras[extraIndex].m_speed = p_speed; + + actor = CharacterManager()->GetActor(p_name); + m_unk0x414++; + } + + if (actor != NULL) { + MxU8 unk0x0c = rand() % 2 != 0 ? 1 : 2; + actor->SetUnknown0x0c(unk0x0c); + actor->SetWorldSpeed(0.0f); + + if (world->PlaceActor(actor, p_boundaryName, p_src, p_srcScale, p_dest, p_destScale) != SUCCESS) { + CharacterManager()->FUN_10083db0(m_extras[i].m_roi); + m_extras[i].m_roi = NULL; + m_unk0x414--; + return FAILURE; + } + + MxS32 characterId = m_extras[i].m_characterId; + const char** unk0x100f6d58 = g_unk0x100f6d58[g_characters[characterId].m_unk0x16]; + + LegoLocomotionAnimPresenter* presenter = + (LegoLocomotionAnimPresenter*) world->Find("LegoAnimPresenter", unk0x100f6d58[p_undIdx1]); + if (presenter != NULL) { + presenter->FUN_1006d680(actor, 0.0f); + } + + presenter = (LegoLocomotionAnimPresenter*) world->Find("LegoAnimPresenter", unk0x100f6d58[p_undIdx2]); + if (presenter != NULL) { + presenter->FUN_1006d680(actor, 4.0f); + } + + m_extras[i].m_unk0x08 = Timer()->GetTime(); + m_extras[i].m_unk0x0c = TRUE; + m_extras[i].m_speed = p_speed; + + g_characters[characterId].m_unk0x0c = p_unk0x0c; + g_characters[characterId].m_unk0x10 = p_unk0x10; + g_characters[characterId].m_unk0x04 = TRUE; + return SUCCESS; + } + + return FAILURE; +} + // STUB: LEGO1 0x10064670 void LegoAnimationManager::FUN_10064670(Vector3*) { @@ -1892,7 +2186,6 @@ void LegoAnimationManager::FUN_10064670(Vector3*) // STUB: LEGO1 0x10064740 void LegoAnimationManager::FUN_10064740(Vector3*) { - // TODO } // STUB: LEGO1 0x100648f0 diff --git a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp index a88ca7b3..d1600d13 100644 --- a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp @@ -128,7 +128,7 @@ void LegoExtraActor::VTable0xa4(MxU8& p_und1, MxS32& p_und2) } // FUNCTION: LEGO1 0x1002aae0 -MxResult LegoExtraActor::VTable0xc8() +MxResult LegoExtraActor::FUN_1002aae0() { LegoPathBoundary* oldEdge = m_boundary; Vector3 rightRef(m_unk0xec[0]); @@ -203,7 +203,7 @@ MxResult LegoExtraActor::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) } m_unk0x15 = 100; - VTable0xc8(); + FUN_1002aae0(); } else { MxU32 b = FALSE;