Implement/match LegoEntity::SwitchSound

This commit is contained in:
Christian Semmler 2024-06-05 13:01:47 -04:00
parent f6c923a84e
commit 81e8b4452c
9 changed files with 62 additions and 15 deletions

View File

@ -22,7 +22,7 @@ struct LegoActorInfo {
const char* m_name; // 0x00
LegoROI* m_roi; // 0x04
LegoExtraActor* m_actor; // 0x08
MxS32 m_unk0x0c; // 0x0c
MxS32 m_sound; // 0x0c
MxS32 m_unk0x10; // 0x10
MxU8 m_mood; // 0x14
Part m_parts[10]; // 0x18

View File

@ -73,7 +73,7 @@ class LegoBuildingManager : public MxCore {
MxResult Read(LegoStorage* p_storage);
LegoBuildingInfo* GetInfo(LegoEntity* p_entity);
MxBool SwitchVariant(LegoEntity* p_entity);
MxBool FUN_1002fe40(LegoEntity* p_entity);
MxBool SwitchSound(LegoEntity* p_entity);
MxBool FUN_1002fe80(LegoEntity* p_entity);
MxBool FUN_1002fed0(LegoEntity* p_entity);
MxU32 GetBuildingEntityId(LegoEntity* p_entity);

View File

@ -69,7 +69,8 @@ class LegoCharacterManager {
LegoExtraActor* GetExtraActor(const char* p_name);
LegoActorInfo* GetActorInfo(const char* p_name);
LegoActorInfo* GetActorInfo(LegoROI* p_roi);
MxBool SwitchHat(LegoROI* p_roi);
MxBool SwitchVariant(LegoROI* p_roi);
MxBool SwitchSound(LegoROI* p_roi);
MxU32 FUN_10085120(LegoROI* p_roi);
MxU32 FUN_10085140(LegoROI* p_roi, MxBool p_und);
MxU8 GetMood(LegoROI* p_roi);

View File

@ -67,7 +67,7 @@ class LegoEntity : public MxEntity {
virtual void ClickSound(MxBool p_und); // vtable+0x34
virtual void ClickAnimation(); // vtable+0x38
virtual void SwitchVariant(); // vtable+0x3c
virtual void VTable0x40(); // vtable+0x40
virtual void SwitchSound(); // vtable+0x40
virtual void VTable0x44(); // vtable+0x44
virtual void VTable0x48(LegoROI* p_roi); // vtable+0x48
virtual void VTable0x4c(); // vtable+0x4c

View File

@ -30,6 +30,7 @@ class LegoPlantManager : public MxCore {
void Write(LegoStorage* p_storage);
MxResult Read(LegoStorage* p_storage);
MxBool FUN_100269e0(LegoEntity* p_entity);
MxBool SwitchSound(LegoEntity* p_entity);
MxU32 FUN_10026b70(LegoEntity* p_entity);
MxU32 FUN_10026ba0(LegoEntity* p_entity, MxBool);
void FUN_10026c50(LegoEntity* p_entity);

View File

@ -471,7 +471,7 @@ MxBool LegoBuildingManager::SwitchVariant(LegoEntity* p_entity)
// FUNCTION: LEGO1 0x1002fe40
// FUNCTION: BETA10 0x100641d3
MxBool LegoBuildingManager::FUN_1002fe40(LegoEntity* p_entity)
MxBool LegoBuildingManager::SwitchSound(LegoEntity* p_entity)
{
MxBool result = FALSE;
LegoBuildingInfo* info = GetInfo(p_entity);

View File

@ -21,6 +21,9 @@
DECOMP_SIZE_ASSERT(LegoCharacter, 0x08)
DECOMP_SIZE_ASSERT(LegoCharacterManager, 0x08)
// GLOBAL: LEGO1 0x100fc4d4
MxU32 g_maxSound = 9;
// GLOBAL: LEGO1 0x100fc4e0
MxU32 g_unk0x100fc4e0 = 10;
@ -113,7 +116,7 @@ MxResult LegoCharacterManager::Write(LegoStorage* p_storage)
for (MxS32 i = 0; i < sizeOfArray(g_actorInfo); i++) {
LegoActorInfo* info = &g_actorInfo[i];
if (p_storage->Write(&info->m_unk0x0c, sizeof(info->m_unk0x0c)) != SUCCESS) {
if (p_storage->Write(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) {
goto done;
}
if (p_storage->Write(&info->m_unk0x10, sizeof(info->m_unk0x10)) != SUCCESS) {
@ -168,7 +171,7 @@ MxResult LegoCharacterManager::Read(LegoStorage* p_storage)
for (MxS32 i = 0; i < sizeOfArray(g_actorInfo); i++) {
LegoActorInfo* info = &g_actorInfo[i];
if (p_storage->Read(&info->m_unk0x0c, sizeof(info->m_unk0x0c)) != SUCCESS) {
if (p_storage->Read(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) {
goto done;
}
if (p_storage->Read(&info->m_unk0x10, sizeof(info->m_unk0x10)) != SUCCESS) {
@ -450,7 +453,7 @@ LegoROI* LegoCharacterManager::CreateActorROI(const char* p_key)
if (!strcmpi(p_key, "pep")) {
LegoActorInfo* pepper = GetActorInfo("pepper");
info->m_unk0x0c = pepper->m_unk0x0c;
info->m_sound = pepper->m_sound;
info->m_unk0x10 = pepper->m_unk0x10;
info->m_mood = pepper->m_mood;
@ -703,7 +706,7 @@ LegoROI* LegoCharacterManager::FindChildROI(LegoROI* p_roi, const char* p_name)
}
// FUNCTION: LEGO1 0x10084ec0
MxBool LegoCharacterManager::SwitchHat(LegoROI* p_roi)
MxBool LegoCharacterManager::SwitchVariant(LegoROI* p_roi)
{
LegoActorInfo* info = GetActorInfo(p_roi->GetName());
@ -756,6 +759,26 @@ MxBool LegoCharacterManager::SwitchHat(LegoROI* p_roi)
return TRUE;
}
// FUNCTION: LEGO1 0x10085090
// FUNCTION: BETA10 0x100766f6
MxBool LegoCharacterManager::SwitchSound(LegoROI* p_roi)
{
MxBool result = FALSE;
LegoActorInfo* info = GetActorInfo(p_roi);
if (info != NULL) {
info->m_sound++;
if (info->m_sound >= g_maxSound) {
info->m_sound = 0;
}
result = TRUE;
}
return result;
}
// FUNCTION: LEGO1 0x10085120
// FUNCTION: BETA10 0x1007680c
MxU32 LegoCharacterManager::FUN_10085120(LegoROI* p_roi)
@ -779,7 +802,7 @@ MxU32 LegoCharacterManager::FUN_10085140(LegoROI* p_roi, MxBool p_und)
}
if (info != NULL) {
return info->m_unk0x0c + g_unk0x100fc4d8;
return info->m_sound + g_unk0x100fc4d8;
}
return 0;

View File

@ -56,6 +56,13 @@ MxBool LegoPlantManager::FUN_100269e0(LegoEntity* p_entity)
return FALSE;
}
// STUB: LEGO1 0x10026ad0
MxBool LegoPlantManager::SwitchSound(LegoEntity* p_entity)
{
// TODO
return FALSE;
}
// STUB: LEGO1 0x10026b70
MxU32 LegoPlantManager::FUN_10026b70(LegoEntity* p_entity)
{

View File

@ -325,7 +325,7 @@ void LegoEntity::SwitchVariant()
{
switch (m_type) {
case e_actor:
CharacterManager()->SwitchHat(m_roi);
CharacterManager()->SwitchVariant(m_roi);
break;
case e_unk1:
break;
@ -341,11 +341,26 @@ void LegoEntity::SwitchVariant()
ClickAnimation();
}
// STUB: LEGO1 0x10011360
// FUNCTION: LEGO1 0x10011360
// FUNCTION: BETA10 0x1007f411
void LegoEntity::VTable0x40()
void LegoEntity::SwitchSound()
{
// TODO
switch (m_type) {
case e_actor:
CharacterManager()->SwitchSound(m_roi);
break;
case e_unk1:
break;
case e_plant:
PlantManager()->SwitchSound(this);
break;
case e_building:
BuildingManager()->SwitchSound(this);
break;
}
ClickSound(FALSE);
ClickAnimation();
}
// STUB: LEGO1 0x100113c0
@ -398,7 +413,7 @@ MxLong LegoEntity::Notify(MxParam& p_param)
}
break;
case LegoActor::c_mama:
VTable0x40();
SwitchSound();
break;
case LegoActor::c_papa:
VTable0x44();