Implement/match LegoEntity::SwitchSound / SwitchMove / SwitchColor / SwitchMood ()

* Implement/match LegoEntity::SwitchSound

* Name

* Name

* Implement/match LegoEntity::SwitchMove

* Mood
This commit is contained in:
Christian Semmler 2024-06-05 13:40:44 -04:00 committed by GitHub
parent f6c923a84e
commit 49c17c9c6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 262 additions and 78 deletions

View file

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

View file

@ -15,17 +15,17 @@ class LegoPathBoundary;
// SIZE 0x2c
struct LegoBuildingInfo {
enum {
c_bit1 = 0x01,
c_bit2 = 0x02,
c_bit3 = 0x04,
c_bit4 = 0x08
c_hasVariants = 0x01,
c_hasSounds = 0x02,
c_hasMoves = 0x04,
c_hasMoods = 0x08
};
LegoEntity* m_entity; // 0x00
const char* m_hausName; // 0x04
MxU32 m_cycle1; // 0x08
MxU32 m_cycle2; // 0x0c
MxU8 m_cycle3; // 0x10
MxU32 m_sound; // 0x08
MxU32 m_move; // 0x0c
MxU8 m_mood; // 0x10
MxS8 m_unk0x11; // 0x11
MxS8 m_initialUnk0x11; // 0x12 = initial value loaded to m_unk0x11
MxU8 m_flags; // 0x13
@ -73,9 +73,9 @@ public:
MxResult Read(LegoStorage* p_storage);
LegoBuildingInfo* GetInfo(LegoEntity* p_entity);
MxBool SwitchVariant(LegoEntity* p_entity);
MxBool FUN_1002fe40(LegoEntity* p_entity);
MxBool FUN_1002fe80(LegoEntity* p_entity);
MxBool FUN_1002fed0(LegoEntity* p_entity);
MxBool SwitchSound(LegoEntity* p_entity);
MxBool SwitchMove(LegoEntity* p_entity);
MxBool SwitchMood(LegoEntity* p_entity);
MxU32 GetBuildingEntityId(LegoEntity* p_entity);
MxU32 FUN_1002ff40(LegoEntity* p_entity, MxBool);
MxBool FUN_10030000(LegoEntity* p_entity);
@ -96,6 +96,8 @@ public:
private:
static char* g_customizeAnimFile;
static MxS32 g_maxMove[16];
static MxU32 g_maxSound;
MxU8 m_nextVariant; // 0x08
MxU8 m_unk0x09; // 0x09

View file

@ -69,7 +69,11 @@ public:
LegoExtraActor* GetExtraActor(const char* p_name);
LegoActorInfo* GetActorInfo(const char* p_name);
LegoActorInfo* GetActorInfo(LegoROI* p_roi);
MxBool SwitchHat(LegoROI* p_roi);
MxBool SwitchColor(LegoROI* p_roi, LegoROI* p_targetROI);
MxBool SwitchVariant(LegoROI* p_roi);
MxBool SwitchSound(LegoROI* p_roi);
MxBool SwitchMove(LegoROI* p_roi);
MxBool SwitchMood(LegoROI* p_roi);
MxU32 FUN_10085120(LegoROI* p_roi);
MxU32 FUN_10085140(LegoROI* p_roi, MxBool p_und);
MxU8 GetMood(LegoROI* p_roi);
@ -85,6 +89,8 @@ private:
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

@ -64,13 +64,13 @@ public:
// FUNCTION: LEGO1 0x10001090
virtual void SetWorldSpeed(MxFloat p_worldSpeed) { m_worldSpeed = p_worldSpeed; } // vtable+0x30
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 VTable0x44(); // vtable+0x44
virtual void VTable0x48(LegoROI* p_roi); // vtable+0x48
virtual void VTable0x4c(); // vtable+0x4c
virtual void ClickSound(MxBool p_und); // vtable+0x34
virtual void ClickAnimation(); // vtable+0x38
virtual void SwitchVariant(); // vtable+0x3c
virtual void SwitchSound(); // vtable+0x40
virtual void SwitchMove(); // vtable+0x44
virtual void SwitchColor(LegoROI* p_roi); // vtable+0x48
virtual void SwitchMood(); // vtable+0x4c
void FUN_10010c30();
void SetType(MxU8 p_type);

View file

@ -29,7 +29,11 @@ public:
void FUN_100263a0(undefined4 p_und);
void Write(LegoStorage* p_storage);
MxResult Read(LegoStorage* p_storage);
MxBool FUN_100269e0(LegoEntity* p_entity);
MxBool SwitchColor(LegoEntity* p_entity);
MxBool SwitchVariant(LegoEntity* p_entity);
MxBool SwitchSound(LegoEntity* p_entity);
MxBool SwitchMove(LegoEntity* p_entity);
MxBool SwitchMood(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_buildingCycle1Length = 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)
@ -330,13 +330,13 @@ MxResult LegoBuildingManager::Write(LegoStorage* p_storage)
for (MxS32 i = 0; i < sizeOfArray(g_buildingInfo); i++) {
LegoBuildingInfo* info = &g_buildingInfo[i];
if (p_storage->Write(&info->m_cycle1, sizeof(info->m_cycle1)) != SUCCESS) {
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) {
if (p_storage->Write(&info->m_mood, sizeof(info->m_mood)) != SUCCESS) {
goto done;
}
if (p_storage->Write(&info->m_initialUnk0x11, sizeof(info->m_initialUnk0x11)) != SUCCESS) {
@ -363,13 +363,13 @@ MxResult LegoBuildingManager::Read(LegoStorage* p_storage)
for (MxS32 i = 0; i < sizeOfArray(g_buildingInfo); i++) {
LegoBuildingInfo* info = &g_buildingInfo[i];
if (p_storage->Read(&info->m_cycle1, sizeof(info->m_cycle1)) != SUCCESS) {
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) {
if (p_storage->Read(&info->m_mood, sizeof(info->m_mood)) != SUCCESS) {
goto done;
}
if (p_storage->Read(&info->m_unk0x11, sizeof(info->m_unk0x11)) != SUCCESS) {
@ -449,7 +449,7 @@ MxBool LegoBuildingManager::SwitchVariant(LegoEntity* p_entity)
LegoBuildingInfo* info = GetInfo(p_entity);
if (info != NULL && info->m_flags & LegoBuildingInfo::c_bit1 && info->m_unk0x11 == -1) {
if (info != NULL && info->m_flags & LegoBuildingInfo::c_hasVariants && info->m_unk0x11 == -1) {
LegoROI* roi = p_entity->GetROI();
if (++m_nextVariant >= sizeOfArray(g_buildingInfoHausName)) {
m_nextVariant = 0;
@ -471,16 +471,16 @@ 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);
if (info != NULL && info->m_flags & LegoBuildingInfo::c_bit2) {
info->m_cycle1++;
if (info != NULL && info->m_flags & LegoBuildingInfo::c_hasSounds) {
info->m_sound++;
if (info->m_cycle1 >= g_buildingCycle1Length) {
info->m_cycle1 = 0;
if (info->m_sound >= g_maxSound) {
info->m_sound = 0;
}
result = TRUE;
@ -491,16 +491,16 @@ MxBool LegoBuildingManager::FUN_1002fe40(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;
@ -511,16 +511,16 @@ MxBool LegoBuildingManager::FUN_1002fe80(LegoEntity* p_entity)
// FUNCTION: LEGO1 0x1002fed0
// FUNCTION: BETA10 0x100642c2
MxBool LegoBuildingManager::FUN_1002fed0(LegoEntity* p_entity)
MxBool LegoBuildingManager::SwitchMood(LegoEntity* p_entity)
{
MxBool result = FALSE;
LegoBuildingInfo* info = GetInfo(p_entity);
if (info != NULL && info->m_flags & LegoBuildingInfo::c_bit4) {
info->m_cycle3++;
if (info != NULL && info->m_flags & LegoBuildingInfo::c_hasMoods) {
info->m_mood++;
if (info->m_cycle3 > 3) {
info->m_cycle3 = 0;
if (info->m_mood > 3) {
info->m_mood = 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,16 +548,16 @@ MxU32 LegoBuildingManager::FUN_1002ff40(LegoEntity* p_entity, MxBool p_state)
{
LegoBuildingInfo* info = GetInfo(p_entity);
if (info == NULL || !(info->m_flags & LegoBuildingInfo::c_bit2)) {
if (info == NULL || !(info->m_flags & LegoBuildingInfo::c_hasSounds)) {
return 0;
}
if (p_state) {
return info->m_cycle3 + g_cycleLengthOffset3;
return info->m_mood + g_cycleLengthOffset3;
}
if (info != NULL) {
return info->m_cycle1 + g_cycleLengthOffset1;
return info->m_sound + g_cycleLengthOffset1;
}
return 0;

View file

@ -21,6 +21,12 @@
DECOMP_SIZE_ASSERT(LegoCharacter, 0x08)
DECOMP_SIZE_ASSERT(LegoCharacterManager, 0x08)
// GLOBAL: LEGO1 0x100fc4d0
MxU32 LegoCharacterManager::g_maxMove = 4;
// GLOBAL: LEGO1 0x100fc4d4
MxU32 LegoCharacterManager::g_maxSound = 9;
// GLOBAL: LEGO1 0x100fc4e0
MxU32 g_unk0x100fc4e0 = 10;
@ -113,10 +119,10 @@ 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) {
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) {
@ -168,10 +174,10 @@ 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) {
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) {
@ -450,8 +456,8 @@ LegoROI* LegoCharacterManager::CreateActorROI(const char* p_key)
if (!strcmpi(p_key, "pep")) {
LegoActorInfo* pepper = GetActorInfo("pepper");
info->m_unk0x0c = pepper->m_unk0x0c;
info->m_unk0x10 = pepper->m_unk0x10;
info->m_sound = pepper->m_sound;
info->m_move = pepper->m_move;
info->m_mood = pepper->m_mood;
for (i = 0; i < sizeOfArray(info->m_parts); i++) {
@ -702,8 +708,16 @@ LegoROI* LegoCharacterManager::FindChildROI(LegoROI* p_roi, const char* p_name)
return NULL;
}
// STUB: LEGO1 0x10084d50
// FUNCTION: BETA10 0x10076223
MxBool LegoCharacterManager::SwitchColor(LegoROI* p_roi, LegoROI* p_targetROI)
{
// TODO
return FALSE;
}
// FUNCTION: LEGO1 0x10084ec0
MxBool LegoCharacterManager::SwitchHat(LegoROI* p_roi)
MxBool LegoCharacterManager::SwitchVariant(LegoROI* p_roi)
{
LegoActorInfo* info = GetActorInfo(p_roi->GetName());
@ -756,6 +770,66 @@ 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 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 0x100850f0
// FUNCTION: BETA10 0x100767b2
MxBool LegoCharacterManager::SwitchMood(LegoROI* p_roi)
{
MxBool result = FALSE;
LegoActorInfo* info = GetActorInfo(p_roi);
if (info != NULL) {
info->m_mood++;
if (info->m_mood > 3) {
info->m_mood = 0;
}
result = TRUE;
}
return result;
}
// FUNCTION: LEGO1 0x10085120
// FUNCTION: BETA10 0x1007680c
MxU32 LegoCharacterManager::FUN_10085120(LegoROI* p_roi)
@ -763,7 +837,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;
@ -779,7 +853,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

@ -49,8 +49,36 @@ MxResult LegoPlantManager::Read(LegoStorage* p_storage)
return SUCCESS;
}
// STUB: LEGO1 0x10026920
MxBool LegoPlantManager::SwitchColor(LegoEntity* p_entity)
{
// TODO
return FALSE;
}
// STUB: LEGO1 0x100269e0
MxBool LegoPlantManager::FUN_100269e0(LegoEntity* p_entity)
MxBool LegoPlantManager::SwitchVariant(LegoEntity* p_entity)
{
// TODO
return FALSE;
}
// STUB: LEGO1 0x10026ad0
MxBool LegoPlantManager::SwitchSound(LegoEntity* p_entity)
{
// TODO
return FALSE;
}
// STUB: LEGO1 0x10026b00
MxBool LegoPlantManager::SwitchMove(LegoEntity* p_entity)
{
// TODO
return FALSE;
}
// STUB: LEGO1 0x10026b40
MxBool LegoPlantManager::SwitchMood(LegoEntity* p_entity)
{
// TODO
return FALSE;

View file

@ -325,48 +325,118 @@ void LegoEntity::SwitchVariant()
{
switch (m_type) {
case e_actor:
CharacterManager()->SwitchHat(m_roi);
CharacterManager()->SwitchVariant(m_roi);
break;
case e_unk1:
break;
case e_plant:
PlantManager()->FUN_100269e0(this);
PlantManager()->SwitchVariant(this);
break;
case e_building:
BuildingManager()->SwitchVariant(this);
break;
case e_autoROI:
break;
}
ClickSound(FALSE);
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;
case e_autoROI:
break;
}
ClickSound(FALSE);
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;
case e_autoROI:
break;
}
ClickSound(FALSE);
ClickAnimation();
}
// STUB: LEGO1 0x10011420
// FUNCTION: LEGO1 0x10011420
// FUNCTION: BETA10 0x1007f57f
void LegoEntity::VTable0x48(LegoROI* p_roi)
void LegoEntity::SwitchColor(LegoROI* p_roi)
{
// TODO
switch (m_type) {
case e_actor:
CharacterManager()->SwitchColor(m_roi, p_roi);
break;
case e_unk1:
break;
case e_plant:
PlantManager()->SwitchColor(this);
break;
case e_building:
break;
case e_autoROI:
break;
}
ClickSound(FALSE);
ClickAnimation();
}
// STUB: LEGO1 0x10011470
// FUNCTION: LEGO1 0x10011470
// FUNCTION: BETA10 0x1007f62c
void LegoEntity::VTable0x4c()
void LegoEntity::SwitchMood()
{
// TODO
switch (m_type) {
case e_actor:
CharacterManager()->SwitchMood(m_roi);
break;
case e_unk1:
break;
case e_plant:
PlantManager()->SwitchMood(this);
break;
case e_building:
BuildingManager()->SwitchMood(this);
break;
case e_autoROI:
break;
}
ClickSound(TRUE);
ClickSound(FALSE);
ClickAnimation();
}
// FUNCTION: LEGO1 0x100114e0
@ -398,16 +468,16 @@ MxLong LegoEntity::Notify(MxParam& p_param)
}
break;
case LegoActor::c_mama:
VTable0x40();
SwitchSound();
break;
case LegoActor::c_papa:
VTable0x44();
SwitchMove();
break;
case LegoActor::c_nick:
VTable0x48(param.GetROI());
SwitchColor(param.GetROI());
break;
case LegoActor::c_laura:
VTable0x4c();
SwitchMood();
break;
case LegoActor::c_brickster:
switch (m_type) {