mirror of
https://github.com/isledecomp/isle-portable.git
synced 2024-11-21 23:17:53 -05:00
Implement/match more LegoPlantManager functions (#1040)
This commit is contained in:
parent
e507f42717
commit
656e7fc674
5 changed files with 132 additions and 21 deletions
|
@ -68,7 +68,7 @@ class LegoBuildingManager : public MxCore {
|
|||
void Init();
|
||||
void FUN_1002fa00();
|
||||
void CreateBuilding(MxS32 p_index, LegoWorld* p_world);
|
||||
void FUN_1002fb30();
|
||||
void Reset();
|
||||
MxResult Write(LegoStorage* p_storage);
|
||||
MxResult Read(LegoStorage* p_storage);
|
||||
LegoBuildingInfo* GetInfo(LegoEntity* p_entity);
|
||||
|
|
|
@ -28,7 +28,7 @@ class LegoPlantManager : public MxCore {
|
|||
|
||||
void Init();
|
||||
void LoadWorldInfo(MxS32 p_worldId);
|
||||
void FUN_100263a0(undefined4 p_und);
|
||||
void Reset(MxS32 p_worldId);
|
||||
MxResult Write(LegoStorage* p_storage);
|
||||
MxResult Read(LegoStorage* p_storage);
|
||||
MxBool SwitchColor(LegoEntity* p_entity);
|
||||
|
@ -49,14 +49,16 @@ class LegoPlantManager : public MxCore {
|
|||
|
||||
private:
|
||||
LegoEntity* CreatePlant(MxS32 p_index, LegoWorld* p_world, MxS32 p_worldId);
|
||||
void RemovePlant(MxS32 p_index, MxS32 p_worldId);
|
||||
void FUN_10026860(MxS32 p_index);
|
||||
|
||||
static char* g_customizeAnimFile;
|
||||
|
||||
MxS32 m_worldId; // 0x08
|
||||
undefined m_unk0x0c; // 0x0c
|
||||
undefined m_unk0x10[0x17]; // 0x10
|
||||
undefined m_unk0x24; // 0x24
|
||||
undefined4 m_unk0x28; // 0x28
|
||||
MxS32 m_worldId; // 0x08
|
||||
undefined m_unk0x0c; // 0x0c
|
||||
undefined* m_unk0x10[5]; // 0x10
|
||||
MxS8 m_unk0x24; // 0x24
|
||||
undefined4 m_unk0x28; // 0x28
|
||||
};
|
||||
|
||||
#endif // LEGOPLANTMANAGER_H
|
||||
|
|
|
@ -304,7 +304,7 @@ void LegoBuildingManager::CreateBuilding(MxS32 p_index, LegoWorld* p_world)
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1002fb30
|
||||
void LegoBuildingManager::FUN_1002fb30()
|
||||
void LegoBuildingManager::Reset()
|
||||
{
|
||||
MxU32 i;
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
#include "legoplants.h"
|
||||
#include "legoworld.h"
|
||||
#include "misc.h"
|
||||
#include "misc/legostorage.h"
|
||||
#include "scripts.h"
|
||||
#include "sndanim_actions.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -18,6 +21,12 @@ const char* g_plantLodNames[4][5] = {
|
|||
{"palmwht", "palmblk", "palmyel", "palmred", "palm"}
|
||||
};
|
||||
|
||||
// GLOBAL: LEGO1 0x100f16b0
|
||||
float g_unk0x100f16b0[] = {0.1f, 0.7f, 0.5f, 0.9f};
|
||||
|
||||
// GLOBAL: LEGO1 0x100f16c0
|
||||
MxU8 g_unk0x100f16c0[] = {1, 2, 2, 3};
|
||||
|
||||
// GLOBAL: LEGO1 0x100f3188
|
||||
char* LegoPlantManager::g_customizeAnimFile = NULL;
|
||||
|
||||
|
@ -63,10 +72,24 @@ void LegoPlantManager::LoadWorldInfo(MxS32 p_worldId)
|
|||
m_unk0x0c = 0;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x100263a0
|
||||
void LegoPlantManager::FUN_100263a0(undefined4 p_und)
|
||||
// FUNCTION: LEGO1 0x100263a0
|
||||
void LegoPlantManager::Reset(MxS32 p_worldId)
|
||||
{
|
||||
// TODO
|
||||
MxU32 i;
|
||||
DeleteObjects(g_sndAnimScript, SndanimScript::c_AnimC1, SndanimScript::c_AnimBld18);
|
||||
|
||||
for (i = 0; i < m_unk0x24; i++) {
|
||||
delete m_unk0x10[i];
|
||||
}
|
||||
|
||||
m_unk0x24 = 0;
|
||||
|
||||
for (i = 0; i < sizeOfArray(g_plantInfo); i++) {
|
||||
RemovePlant(i, p_worldId);
|
||||
}
|
||||
|
||||
m_worldId = -1;
|
||||
m_unk0x0c = 0;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10026590
|
||||
|
@ -108,20 +131,106 @@ LegoEntity* LegoPlantManager::CreatePlant(MxS32 p_index, LegoWorld* p_world, MxS
|
|||
return entity;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10026720
|
||||
// FUNCTION: LEGO1 0x100266c0
|
||||
// FUNCTION: BETA10 0x100c5859
|
||||
void LegoPlantManager::RemovePlant(MxS32 p_index, MxS32 p_worldId)
|
||||
{
|
||||
if (p_index < sizeOfArray(g_plantInfo)) {
|
||||
MxU32 world = 1 << (MxU8) p_worldId;
|
||||
|
||||
if (g_plantInfo[p_index].m_worlds & world && g_plantInfo[p_index].m_entity != NULL) {
|
||||
CharacterManager()->ReleaseAutoROI(g_plantInfo[p_index].m_entity->GetROI());
|
||||
g_plantInfo[p_index].m_entity = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10026720
|
||||
// FUNCTION: BETA10 0x100c5918
|
||||
MxResult LegoPlantManager::Write(LegoStorage* p_storage)
|
||||
{
|
||||
// TODO
|
||||
return SUCCESS;
|
||||
MxResult result = FAILURE;
|
||||
|
||||
for (MxS32 i = 0; i < sizeOfArray(g_plantInfo); i++) {
|
||||
LegoPlantInfo* info = &g_plantInfo[i];
|
||||
|
||||
if (p_storage->Write(&info->m_variant, sizeof(info->m_variant)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
if (p_storage->Write(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
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) {
|
||||
goto done;
|
||||
}
|
||||
if (p_storage->Write(&info->m_color, sizeof(info->m_color)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
if (p_storage->Write(&info->m_initialUnk0x16, sizeof(info->m_initialUnk0x16)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
result = SUCCESS;
|
||||
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x100267b0
|
||||
// FUNCTION: LEGO1 0x100267b0
|
||||
// FUNCTION: BETA10 0x100c5a76
|
||||
MxResult LegoPlantManager::Read(LegoStorage* p_storage)
|
||||
{
|
||||
// TODO
|
||||
return SUCCESS;
|
||||
MxResult result = FAILURE;
|
||||
|
||||
for (MxS32 i = 0; i < sizeOfArray(g_plantInfo); i++) {
|
||||
LegoPlantInfo* info = &g_plantInfo[i];
|
||||
|
||||
if (p_storage->Read(&info->m_variant, sizeof(info->m_variant)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
if (p_storage->Read(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
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) {
|
||||
goto done;
|
||||
}
|
||||
if (p_storage->Read(&info->m_color, sizeof(info->m_color)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
if (p_storage->Read(&info->m_unk0x16, sizeof(info->m_unk0x16)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
info->m_initialUnk0x16 = info->m_unk0x16;
|
||||
FUN_10026860(i);
|
||||
}
|
||||
|
||||
result = SUCCESS;
|
||||
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10026860
|
||||
// FUNCTION: BETA10 0x100c5be0
|
||||
void LegoPlantManager::FUN_10026860(MxS32 p_index)
|
||||
{
|
||||
MxU8 variant = g_plantInfo[p_index].m_variant;
|
||||
|
||||
if (g_plantInfo[p_index].m_unk0x16 >= 0) {
|
||||
float value = g_unk0x100f16c0[variant] - g_plantInfo[p_index].m_unk0x16;
|
||||
g_plantInfo[p_index].m_position[1] = g_plantInfoInit[p_index].m_position[1] - value * g_unk0x100f16b0[variant];
|
||||
}
|
||||
else {
|
||||
g_plantInfo[p_index].m_position[1] = g_plantInfoInit[p_index].m_position[1];
|
||||
}
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10026920
|
||||
|
|
|
@ -178,8 +178,8 @@ void LegoWorld::Destroy(MxBool p_fromDestructor)
|
|||
}
|
||||
|
||||
if (m_worldId != -1 && m_set0xd0.empty()) {
|
||||
PlantManager()->FUN_100263a0(m_worldId);
|
||||
BuildingManager()->FUN_1002fb30();
|
||||
PlantManager()->Reset(m_worldId);
|
||||
BuildingManager()->Reset();
|
||||
}
|
||||
|
||||
if (m_entityList) {
|
||||
|
@ -715,8 +715,8 @@ void LegoWorld::Enable(MxBool p_enable)
|
|||
m_set0xd0.insert(this);
|
||||
|
||||
if (m_worldId != -1) {
|
||||
PlantManager()->FUN_100263a0(m_worldId);
|
||||
BuildingManager()->FUN_1002fb30();
|
||||
PlantManager()->Reset(m_worldId);
|
||||
BuildingManager()->Reset();
|
||||
}
|
||||
|
||||
MxPresenterListCursor controlPresenterCursor(&m_controlPresenters);
|
||||
|
|
Loading…
Reference in a new issue