Implement/match LegoEntity::SwitchMove

This commit is contained in:
Christian Semmler 2024-06-05 13:18:59 -04:00
parent c7c7ad6aef
commit ece95c4d1a
9 changed files with 79 additions and 28 deletions

View File

@ -23,7 +23,7 @@ struct LegoActorInfo {
LegoROI* m_roi; // 0x04
LegoExtraActor* m_actor; // 0x08
MxS32 m_sound; // 0x0c
MxS32 m_unk0x10; // 0x10
MxS32 m_move; // 0x10
MxU8 m_mood; // 0x14
Part m_parts[10]; // 0x18
};

View File

@ -16,15 +16,15 @@ class LegoPathBoundary;
struct LegoBuildingInfo {
enum {
c_hasVariants = 0x01,
c_playSound = 0x02,
c_bit3 = 0x04,
c_hasSounds = 0x02,
c_hasMoves = 0x04,
c_bit4 = 0x08
};
LegoEntity* m_entity; // 0x00
const char* m_hausName; // 0x04
MxU32 m_sound; // 0x08
MxU32 m_cycle2; // 0x0c
MxU32 m_move; // 0x0c
MxU8 m_cycle3; // 0x10
MxS8 m_unk0x11; // 0x11
MxS8 m_initialUnk0x11; // 0x12 = initial value loaded to m_unk0x11
@ -74,7 +74,7 @@ class LegoBuildingManager : public MxCore {
LegoBuildingInfo* GetInfo(LegoEntity* p_entity);
MxBool SwitchVariant(LegoEntity* p_entity);
MxBool SwitchSound(LegoEntity* p_entity);
MxBool FUN_1002fe80(LegoEntity* p_entity);
MxBool SwitchMove(LegoEntity* p_entity);
MxBool FUN_1002fed0(LegoEntity* p_entity);
MxU32 GetBuildingEntityId(LegoEntity* p_entity);
MxU32 FUN_1002ff40(LegoEntity* p_entity, MxBool);
@ -96,6 +96,8 @@ class LegoBuildingManager : public MxCore {
private:
static char* g_customizeAnimFile;
static MxS32 g_maxMove[16];
static MxU32 g_maxSound;
MxU8 m_nextVariant; // 0x08
MxU8 m_unk0x09; // 0x09

View File

@ -71,6 +71,7 @@ class LegoCharacterManager {
LegoActorInfo* GetActorInfo(LegoROI* p_roi);
MxBool SwitchVariant(LegoROI* p_roi);
MxBool SwitchSound(LegoROI* p_roi);
MxBool SwitchMove(LegoROI* p_roi);
MxU32 FUN_10085120(LegoROI* p_roi);
MxU32 FUN_10085140(LegoROI* p_roi, MxBool p_und);
MxU8 GetMood(LegoROI* p_roi);
@ -86,6 +87,8 @@ class LegoCharacterManager {
MxResult FUN_10085870(LegoROI* p_roi);
static char* g_customizeAnimFile;
static MxU32 g_maxMove;
static MxU32 g_maxSound;
LegoCharacterMap* m_characters; // 0x00
CustomizeAnimFileVariable* m_customizeAnimFile; // 0x04

View File

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

View File

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

View File

@ -193,7 +193,7 @@ LegoBuildingInfo g_buildingInfoInit[16] = {
// clang-format on
// GLOBAL: LEGO1 0x100f3738
MxU32 g_maxSound = 6;
MxU32 LegoBuildingManager::g_maxSound = 6;
// GLOBAL: LEGO1 0x100f373c
MxU32 g_cycleLengthOffset1 = 0x3c;
@ -221,7 +221,7 @@ MxS32 g_buildingManagerConfig = 1;
LegoBuildingInfo g_buildingInfo[16];
// GLOBAL: LEGO1 0x100f3748
MxS32 g_buildingCycle2Length[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0};
MxS32 LegoBuildingManager::g_maxMove[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0};
// FUNCTION: LEGO1 0x1002f8b0
void LegoBuildingManager::configureLegoBuildingManager(MxS32 p_buildingManagerConfig)
@ -333,7 +333,7 @@ MxResult LegoBuildingManager::Write(LegoStorage* p_storage)
if (p_storage->Write(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) {
goto done;
}
if (p_storage->Write(&info->m_cycle2, sizeof(info->m_cycle2)) != SUCCESS) {
if (p_storage->Write(&info->m_move, sizeof(info->m_move)) != SUCCESS) {
goto done;
}
if (p_storage->Write(&info->m_cycle3, sizeof(info->m_cycle3)) != SUCCESS) {
@ -366,7 +366,7 @@ MxResult LegoBuildingManager::Read(LegoStorage* p_storage)
if (p_storage->Read(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) {
goto done;
}
if (p_storage->Read(&info->m_cycle2, sizeof(info->m_cycle2)) != SUCCESS) {
if (p_storage->Read(&info->m_move, sizeof(info->m_move)) != SUCCESS) {
goto done;
}
if (p_storage->Read(&info->m_cycle3, sizeof(info->m_cycle3)) != SUCCESS) {
@ -476,7 +476,7 @@ MxBool LegoBuildingManager::SwitchSound(LegoEntity* p_entity)
MxBool result = FALSE;
LegoBuildingInfo* info = GetInfo(p_entity);
if (info != NULL && info->m_flags & LegoBuildingInfo::c_playSound) {
if (info != NULL && info->m_flags & LegoBuildingInfo::c_hasSounds) {
info->m_sound++;
if (info->m_sound >= g_maxSound) {
@ -491,16 +491,16 @@ MxBool LegoBuildingManager::SwitchSound(LegoEntity* p_entity)
// FUNCTION: LEGO1 0x1002fe80
// FUNCTION: BETA10 0x10064242
MxBool LegoBuildingManager::FUN_1002fe80(LegoEntity* p_entity)
MxBool LegoBuildingManager::SwitchMove(LegoEntity* p_entity)
{
MxBool result = FALSE;
LegoBuildingInfo* info = GetInfo(p_entity);
if (info != NULL && info->m_flags & LegoBuildingInfo::c_bit3) {
info->m_cycle2++;
if (info != NULL && info->m_flags & LegoBuildingInfo::c_hasMoves) {
info->m_move++;
if (info->m_cycle2 >= g_buildingCycle2Length[info - g_buildingInfo]) {
info->m_cycle2 = 0;
if (info->m_move >= g_maxMove[info - g_buildingInfo]) {
info->m_move = 0;
}
result = TRUE;
@ -535,8 +535,8 @@ MxU32 LegoBuildingManager::GetBuildingEntityId(LegoEntity* p_entity)
{
LegoBuildingInfo* info = GetInfo(p_entity);
if (info != NULL && info->m_flags & LegoBuildingInfo::c_bit3) {
return g_buildingEntityId[info - g_buildingInfo] + info->m_cycle2;
if (info != NULL && info->m_flags & LegoBuildingInfo::c_hasMoves) {
return g_buildingEntityId[info - g_buildingInfo] + info->m_move;
}
return 0;
@ -548,7 +548,7 @@ MxU32 LegoBuildingManager::FUN_1002ff40(LegoEntity* p_entity, MxBool p_state)
{
LegoBuildingInfo* info = GetInfo(p_entity);
if (info == NULL || !(info->m_flags & LegoBuildingInfo::c_playSound)) {
if (info == NULL || !(info->m_flags & LegoBuildingInfo::c_hasSounds)) {
return 0;
}

View File

@ -21,8 +21,11 @@
DECOMP_SIZE_ASSERT(LegoCharacter, 0x08)
DECOMP_SIZE_ASSERT(LegoCharacterManager, 0x08)
// GLOBAL: LEGO1 0x100fc4d0
MxU32 LegoCharacterManager::g_maxMove = 4;
// GLOBAL: LEGO1 0x100fc4d4
MxU32 g_maxSound = 9;
MxU32 LegoCharacterManager::g_maxSound = 9;
// GLOBAL: LEGO1 0x100fc4e0
MxU32 g_unk0x100fc4e0 = 10;
@ -119,7 +122,7 @@ MxResult LegoCharacterManager::Write(LegoStorage* p_storage)
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) {
if (p_storage->Write(&info->m_move, sizeof(info->m_move)) != SUCCESS) {
goto done;
}
if (p_storage->Write(&info->m_mood, sizeof(info->m_mood)) != SUCCESS) {
@ -174,7 +177,7 @@ MxResult LegoCharacterManager::Read(LegoStorage* p_storage)
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) {
if (p_storage->Read(&info->m_move, sizeof(info->m_move)) != SUCCESS) {
goto done;
}
if (p_storage->Read(&info->m_mood, sizeof(info->m_mood)) != SUCCESS) {
@ -454,7 +457,7 @@ LegoROI* LegoCharacterManager::CreateActorROI(const char* p_key)
LegoActorInfo* pepper = GetActorInfo("pepper");
info->m_sound = pepper->m_sound;
info->m_unk0x10 = pepper->m_unk0x10;
info->m_move = pepper->m_move;
info->m_mood = pepper->m_mood;
for (i = 0; i < sizeOfArray(info->m_parts); i++) {
@ -779,6 +782,26 @@ MxBool LegoCharacterManager::SwitchSound(LegoROI* p_roi)
return result;
}
// FUNCTION: LEGO1 0x100850c0
// FUNCTION: BETA10 0x10076754
MxBool LegoCharacterManager::SwitchMove(LegoROI* p_roi)
{
MxBool result = FALSE;
LegoActorInfo* info = GetActorInfo(p_roi);
if (info != NULL) {
info->m_move++;
if (info->m_move >= g_maxMove) {
info->m_move = 0;
}
result = TRUE;
}
return result;
}
// FUNCTION: LEGO1 0x10085120
// FUNCTION: BETA10 0x1007680c
MxU32 LegoCharacterManager::FUN_10085120(LegoROI* p_roi)
@ -786,7 +809,7 @@ MxU32 LegoCharacterManager::FUN_10085120(LegoROI* p_roi)
LegoActorInfo* info = GetActorInfo(p_roi);
if (info != NULL) {
return info->m_unk0x10 + g_unk0x100fc4e0;
return info->m_move + g_unk0x100fc4e0;
}
return 0;

View File

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

View File

@ -363,11 +363,26 @@ void LegoEntity::SwitchSound()
ClickAnimation();
}
// STUB: LEGO1 0x100113c0
// FUNCTION: LEGO1 0x100113c0
// FUNCTION: BETA10 0x1007f4c8
void LegoEntity::VTable0x44()
void LegoEntity::SwitchMove()
{
// TODO
switch (m_type) {
case e_actor:
CharacterManager()->SwitchMove(m_roi);
break;
case e_unk1:
break;
case e_plant:
PlantManager()->SwitchMove(this);
break;
case e_building:
BuildingManager()->SwitchMove(this);
break;
}
ClickSound(FALSE);
ClickAnimation();
}
// STUB: LEGO1 0x10011420
@ -416,7 +431,7 @@ MxLong LegoEntity::Notify(MxParam& p_param)
SwitchSound();
break;
case LegoActor::c_papa:
VTable0x44();
SwitchMove();
break;
case LegoActor::c_nick:
VTable0x48(param.GetROI());