Implement/match LegoPathStruct (#944)

* Implement/match LegoPathStruct

* Rename some nums

* Consistent naming

* Naming

* relax regex

* Name some functions

* Improve naming

* Rename
This commit is contained in:
Christian Semmler
2024-05-21 15:03:50 -04:00
committed by GitHub
parent bc91fd2189
commit 8fee73c525
18 changed files with 225 additions and 40 deletions

View File

@@ -535,7 +535,7 @@ void IslePathActor::SpawnPlayer(LegoGameState::Area p_area, MxBool p_und, MxU8 p
}
if (camAnim) {
PlayCamAnim(this, 0, g_spawnLocations[i].m_location, TRUE);
PlayCamAnim(this, FALSE, g_spawnLocations[i].m_location, TRUE);
}
}

View File

@@ -1153,7 +1153,7 @@ MxResult LegoAnimationManager::FUN_10060dc0(
// FUNCTION: LEGO1 0x10060eb0
// FUNCTION: BETA10 0x1004206c
void LegoAnimationManager::CameraTriggerFire(IslePathActor* p_actor, undefined4, MxU32 p_location, MxBool p_bool)
void LegoAnimationManager::CameraTriggerFire(LegoPathActor* p_actor, undefined4, MxU32 p_location, MxBool p_bool)
{
if (Lego()->m_unk0x13c && m_enableCamAnims && !m_animRunning) {
LegoLocation* location = LegoNavController::GetLocation(p_location);

View File

@@ -344,7 +344,7 @@ void ConvertHSVToRGB(float p_h, float p_s, float p_v, float* p_rOut, float* p_bO
// FUNCTION: LEGO1 0x1003ecc0
// FUNCTION: BETA10 0x100d4b38
void PlayCamAnim(IslePathActor* p_actor, undefined4 p_unused, MxU32 p_location, MxBool p_bool)
void PlayCamAnim(LegoPathActor* p_actor, MxBool p_unused, MxU32 p_location, MxBool p_bool)
{
LegoWorld* world = CurrentWorld();
MxLong result = 0;

View File

@@ -61,19 +61,19 @@ void LegoPathBoundary::FUN_100575b0(Vector3& p_point1, Vector3& p_point2, LegoPa
if (dot2 > dot1) {
for (MxS32 i = 0; i < m_unk0x48; i++) {
LegoPathStruct* s = m_unk0x4c[i].m_unk0x00;
LegoPathStruct* s = m_unk0x4c[i].m_pathStruct;
if (m_unk0x4c[i].m_unk0x08 >= dot1 && m_unk0x4c[i].m_unk0x08 < dot2) {
s->VTable0x04(p_actor, 1, m_unk0x4c[i].m_unk0x04);
s->HandleTrigger(p_actor, TRUE, m_unk0x4c[i].m_data);
}
}
}
else if (dot2 < dot1) {
for (MxS32 i = 0; i < m_unk0x48; i++) {
LegoPathStruct* s = m_unk0x4c[i].m_unk0x00;
LegoPathStruct* s = m_unk0x4c[i].m_pathStruct;
if (m_unk0x4c[i].m_unk0x08 >= dot2 && m_unk0x4c[i].m_unk0x08 < dot1) {
s->VTable0x04(p_actor, 0, m_unk0x4c[i].m_unk0x04);
s->HandleTrigger(p_actor, FALSE, m_unk0x4c[i].m_data);
}
}
}

View File

@@ -528,7 +528,7 @@ MxResult LegoPathController::ReadStructs(LegoStorage* p_storage)
m_structs[i].m_name[length] = '\0';
}
if (p_storage->Read(&m_structs[i].m_unk0x08, sizeof(m_structs[i].m_unk0x08)) != SUCCESS) {
if (p_storage->Read(&m_structs[i].m_flags, sizeof(m_structs[i].m_flags)) != SUCCESS) {
return FAILURE;
}
}
@@ -678,17 +678,16 @@ MxResult LegoPathController::ReadBoundaries(LegoStorage* p_storage)
if (boundary.m_unk0x48 > 0) {
boundary.m_unk0x50 = new Mx3DPointFloat;
boundary.m_unk0x4c = new LegoWEGEdge::Path[boundary.m_unk0x48];
boundary.m_unk0x4c = new LegoWEGEdge::PathWithTrigger[boundary.m_unk0x48];
for (j = 0; j < boundary.m_unk0x48; j++) {
if (p_storage->Read(&s, sizeof(s)) != SUCCESS) {
return FAILURE;
}
boundary.m_unk0x4c[j].m_unk0x00 = &m_structs[s];
boundary.m_unk0x4c[j].m_pathStruct = &m_structs[s];
if (p_storage->Read(&boundary.m_unk0x4c[j].m_unk0x04, sizeof(boundary.m_unk0x4c[j].m_unk0x04)) !=
SUCCESS) {
if (p_storage->Read(&boundary.m_unk0x4c[j].m_data, sizeof(boundary.m_unk0x4c[j].m_data)) != SUCCESS) {
return FAILURE;
}

View File

@@ -1,11 +1,168 @@
#include "legopathstruct.h"
#include "isle.h"
#include "jukebox_actions.h"
#include "jukeboxstate.h"
#include "legohideanimpresenter.h"
#include "legopathactor.h"
#include "legoutils.h"
#include "misc.h"
#include "mxbackgroundaudiomanager.h"
#include "mxmisc.h"
#include "mxnotificationmanager.h"
#include "mxtype19notificationparam.h"
#include "scripts.h"
DECOMP_SIZE_ASSERT(LegoPathStructBase, 0x0c)
DECOMP_SIZE_ASSERT(LegoPathStruct, 0x14)
// STUB: LEGO1 0x1001b700
// FUNCTION: BETA10 0x100c26c5
void LegoPathStruct::VTable0x04(LegoPathActor*, undefined4, undefined4)
// Flags used in isle.cpp
extern MxU32 g_unk0x100f1198;
// GLOBAL: LEGO1 0x100f119c
MxBool g_unk0x100f119c = FALSE;
// FUNCTION: LEGO1 0x1001b700
void LegoPathStruct::HandleTrigger(LegoPathActor* p_actor, MxBool p_direction, MxU32 p_data)
{
// TODO
if (!HandleTrigger(p_actor, p_direction, p_data, FALSE) && g_unk0x100f119c) {
HandleTrigger(p_actor, p_direction, p_data, TRUE);
}
}
// FUNCTION: LEGO1 0x1001b740
// FUNCTION: BETA10 0x100c26c5
MxBool LegoPathStruct::HandleTrigger(LegoPathActor* p_actor, MxBool p_direction, MxU32 p_data, MxBool p_bool)
{
MxBool triggered = FALSE;
MxBool bool2 = p_bool ? !p_direction : p_direction;
MxU32 flags = bool2 ? c_bit5 : c_bit6;
flags |= p_actor->GetCameraFlag() ? c_bit1 : (c_bit2 | c_bit3 | c_bit4);
if ((m_flags & flags & (c_bit5 | c_bit6 | c_bit7)) && (m_flags & flags & (c_bit1 | c_bit2 | c_bit3 | c_bit4))) {
triggered = TRUE;
switch (m_name[2]) {
case c_camAnim:
if (g_unk0x100f1198 & Isle::c_bit6) {
PlayCamAnim(p_actor, bool2, p_data, TRUE);
}
break;
case c_d: {
p_actor->VTable0x58(p_data);
MxType19NotificationParam param(c_notificationType19, p_actor, m_name[2], p_data);
p_actor->Notify(param);
LegoWorld* world = CurrentWorld();
if (world != NULL) {
NotificationManager()->Send(world, param);
}
break;
}
case c_e:
FUN_1001bc40(m_name, p_data, !(p_bool == FALSE));
break;
case c_g:
break;
case c_h: {
LegoHideAnimPresenter* presenter = m_world->GetHideAnimPresenter();
if (presenter != NULL) {
presenter->FUN_1006db40(p_data * 100);
}
break;
}
case c_music:
if (g_unk0x100f1198 & Isle::c_bit7) {
PlayMusic(p_direction, p_data);
}
break;
case c_s: {
LegoWorld* world = CurrentWorld();
if (world != NULL) {
MxType19NotificationParam param(c_notificationType19, p_actor, m_name[2], p_data);
if (world->Notify(param) != 0) {
break;
}
}
FUN_1001bc40(m_name, p_data, p_bool == FALSE);
break;
}
case c_w: {
LegoWorld* world = CurrentWorld();
if (world != NULL) {
MxType19NotificationParam param(c_notificationType19, p_actor, m_name[2], p_data);
NotificationManager()->Send(world, param);
}
break;
}
}
}
return triggered;
}
// FUNCTION: LEGO1 0x1001bc40
// FUNCTION: BETA10 0x100c2a6c
void LegoPathStruct::FUN_1001bc40(const char* p_name, MxU32 p_data, MxBool p_bool)
{
MxDSAction action;
action.SetObjectId(p_data);
action.SetAtomId(m_atomId);
if (p_bool) {
action.SetUnknown24(-1);
Start(&action);
}
else {
action.SetUnknown24(-2);
DeleteObject(action);
}
}
// FUNCTION: LEGO1 0x1001bd10
// FUNCTION: BETA10 0x100c2b4a
void LegoPathStruct::PlayMusic(MxBool p_direction, MxU32 p_data)
{
JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState");
if (state != NULL && state->m_active) {
return;
}
JukeboxScript::Script music[] = {
JukeboxScript::c_ResidentalArea_Music,
JukeboxScript::c_BeachBlvd_Music,
JukeboxScript::c_Cave_Music,
JukeboxScript::c_CentralRoads_Music,
JukeboxScript::c_Jail_Music,
JukeboxScript::c_Hospital_Music,
JukeboxScript::c_InformationCenter_Music,
JukeboxScript::c_PoliceStation_Music,
JukeboxScript::c_Park_Music,
JukeboxScript::c_CentralNorthRoad_Music,
JukeboxScript::c_GarageArea_Music,
JukeboxScript::c_RaceTrackRoad_Music,
JukeboxScript::c_Beach_Music,
JukeboxScript::c_Quiet_Audio
};
MxS16 triggersReff[24][2] = {{11, 10}, {6, 10}, {3, 1}, {4, 1}, {1, 4}, {1, 4}, {13, 2}, {13, 2},
{13, 2}, {4, 10}, {11, 9}, {9, 7}, {8, 7}, {8, 5}, {5, 2}, {2, 4},
{4, 2}, {4, 5}, {11, 4}, {12, 10}, {10, 12}, {10, 12}, {14, 2}, {14, 2}};
MxDSAction action;
action.SetAtomId(*g_jukeboxScript);
action.SetUnknown24(-1);
if (p_data <= sizeOfArray(triggersReff)) {
action.SetObjectId(music[triggersReff[p_data - 1][p_direction == FALSE] - 1]);
}
if (action.GetObjectId() != -1) {
BackgroundAudioManager()->PlayMusic(action, 5, 4);
}
}

View File

@@ -38,7 +38,7 @@
DECOMP_SIZE_ASSERT(Isle, 0x140)
// GLOBAL: LEGO1 0x100f1198
undefined4 g_unk0x100f1198 = 0x7f;
MxU32 g_unk0x100f1198 = 0x7f;
// FUNCTION: LEGO1 0x10030820
Isle::Isle()