2024-07-07 08:10:46 -04:00
|
|
|
#include "legoracers.h"
|
2024-01-20 18:04:46 -05:00
|
|
|
|
2024-07-07 08:10:46 -04:00
|
|
|
#include "anim/legoanim.h"
|
2024-07-01 14:39:31 -04:00
|
|
|
#include "define.h"
|
2024-07-07 08:10:46 -04:00
|
|
|
#include "legocameracontroller.h"
|
2024-07-01 14:39:31 -04:00
|
|
|
#include "legorace.h"
|
|
|
|
#include "misc.h"
|
2024-03-22 21:30:58 -04:00
|
|
|
#include "mxmisc.h"
|
|
|
|
#include "mxnotificationmanager.h"
|
2024-07-01 14:39:31 -04:00
|
|
|
#include "mxutilities.h"
|
2024-03-22 21:30:58 -04:00
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
DECOMP_SIZE_ASSERT(EdgeReference, 0x08)
|
2024-03-22 21:30:58 -04:00
|
|
|
DECOMP_SIZE_ASSERT(LegoRaceCar, 0x200)
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// GLOBAL: LEGO1 0x100f0a20
|
|
|
|
EdgeReference LegoRaceCar::g_edgeReferences[] = {
|
|
|
|
{// STRING: LEGO1 0x100f0a10
|
|
|
|
"EDG03_772",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{// STRING: LEGO1 0x100f0a04
|
|
|
|
"EDG03_773",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{// STRING: LEGO1 0x100f09f8
|
|
|
|
"EDG03_774",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{// STRING: LEGO1 0x100f09ec
|
|
|
|
"EDG03_775",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{// STRING: LEGO1 0x100f09e0
|
|
|
|
"EDG03_776",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{// STRING: LEGO1 0x100f09d4
|
|
|
|
"EDG03_777",
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0a50
|
|
|
|
const EdgeReference* LegoRaceCar::g_pEdgeReferences = g_edgeReferences;
|
|
|
|
|
2024-03-22 21:30:58 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012950
|
|
|
|
LegoRaceCar::LegoRaceCar()
|
|
|
|
{
|
2024-07-07 08:10:46 -04:00
|
|
|
m_userState = 0;
|
2024-03-22 21:30:58 -04:00
|
|
|
m_unk0x70 = 0;
|
|
|
|
m_unk0x74 = 0;
|
|
|
|
m_unk0x5c.Clear();
|
|
|
|
m_unk0x58 = 0;
|
|
|
|
m_unk0x78 = 0;
|
|
|
|
m_unk0x7c = 0;
|
|
|
|
NotificationManager()->Register(this);
|
|
|
|
}
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012c80
|
2024-06-10 13:04:40 -04:00
|
|
|
LegoRaceCar::~LegoRaceCar()
|
|
|
|
{
|
2024-07-01 14:39:31 -04:00
|
|
|
NotificationManager()->Unregister(this);
|
2024-06-10 13:04:40 -04:00
|
|
|
}
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012d90
|
2024-06-10 13:04:40 -04:00
|
|
|
MxLong LegoRaceCar::Notify(MxParam& p_param)
|
|
|
|
{
|
2024-07-01 14:39:31 -04:00
|
|
|
return LegoRaceMap::Notify(p_param);
|
2024-06-10 13:04:40 -04:00
|
|
|
}
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012e60
|
2024-06-10 13:04:40 -04:00
|
|
|
void LegoRaceCar::SetWorldSpeed(MxFloat p_worldSpeed)
|
|
|
|
{
|
2024-07-01 14:39:31 -04:00
|
|
|
if (!m_userNavFlag) {
|
|
|
|
if (!LegoCarRaceActor::m_unk0x0c) {
|
|
|
|
m_maxLinearVel = p_worldSpeed;
|
|
|
|
}
|
|
|
|
LegoAnimActor::SetWorldSpeed(p_worldSpeed);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_worldSpeed = p_worldSpeed;
|
|
|
|
}
|
2024-06-10 13:04:40 -04:00
|
|
|
}
|
|
|
|
|
2024-03-22 21:30:58 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012ea0
|
2024-07-01 14:39:31 -04:00
|
|
|
void LegoRaceCar::SetMaxLinearVelocity(float p_maxLinearVelocity)
|
2024-03-22 21:30:58 -04:00
|
|
|
{
|
2024-07-01 14:39:31 -04:00
|
|
|
if (p_maxLinearVelocity < 0) {
|
2024-03-22 21:30:58 -04:00
|
|
|
LegoCarRaceActor::m_unk0x0c = 2;
|
2024-06-06 11:45:37 -04:00
|
|
|
m_maxLinearVel = 0;
|
2024-03-22 21:30:58 -04:00
|
|
|
SetWorldSpeed(0);
|
|
|
|
}
|
|
|
|
else {
|
2024-07-01 14:39:31 -04:00
|
|
|
m_maxLinearVel = p_maxLinearVelocity;
|
2024-03-22 21:30:58 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012ef0
|
|
|
|
void LegoRaceCar::ParseAction(char* p_extra)
|
2024-06-10 13:04:40 -04:00
|
|
|
{
|
2024-07-01 14:39:31 -04:00
|
|
|
char buffer[256];
|
|
|
|
|
|
|
|
LegoAnimActor::ParseAction(p_extra);
|
|
|
|
LegoRaceMap::ParseAction(p_extra);
|
|
|
|
LegoRace* currentWorld = (LegoRace*) CurrentWorld();
|
|
|
|
|
|
|
|
if (KeyValueStringParse(buffer, g_strCOMP, p_extra) && currentWorld) {
|
|
|
|
currentWorld->VTable0x7c(this, atoi(buffer));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_userNavFlag) {
|
|
|
|
for (MxU32 i = 0; i < m_animMaps.size(); i++) {
|
|
|
|
LegoAnimActorStruct* animMap = m_animMaps[i];
|
|
|
|
|
|
|
|
if (animMap->m_unk0x00 == -1.0f) {
|
|
|
|
m_unk0x70 = animMap;
|
|
|
|
}
|
|
|
|
else if (animMap->m_unk0x00 == -2.0f) {
|
|
|
|
m_unk0x74 = animMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// STRING: LEGO1 0x100f0bc4
|
|
|
|
const char* edge0344 = "EDG03_44";
|
|
|
|
m_unk0x78 = currentWorld->FindPathBoundary(edge0344);
|
|
|
|
// STRING: LEGO1 0x100f0bb8
|
|
|
|
const char* edge0354 = "EDG03_54";
|
|
|
|
m_unk0x7c = currentWorld->FindPathBoundary(edge0354);
|
|
|
|
|
|
|
|
for (MxS32 j = 0; j < sizeOfArray(g_edgeReferences); j++) {
|
|
|
|
g_edgeReferences[j].m_data = currentWorld->FindPathBoundary(g_edgeReferences[j].m_name);
|
|
|
|
}
|
|
|
|
}
|
2024-06-10 13:04:40 -04:00
|
|
|
}
|
|
|
|
|
2024-07-07 08:10:46 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012ff0
|
|
|
|
// FUNCTION: BETA10 0x100cb60e
|
|
|
|
void LegoRaceCar::FUN_10012ff0(float p_param)
|
2024-03-22 21:30:58 -04:00
|
|
|
{
|
2024-07-07 08:10:46 -04:00
|
|
|
LegoAnimActorStruct* a; // called `a` in BETA10
|
|
|
|
float deltaTime;
|
|
|
|
|
|
|
|
if (m_userState == 2) {
|
|
|
|
a = m_unk0x70;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// TODO: Possibly an enum?
|
|
|
|
const char legoracecarKick2 = 4; // original name: LEGORACECAR_KICK2
|
|
|
|
assert(m_userState == legoracecarKick2);
|
|
|
|
a = m_unk0x74;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(a && a->GetAnimTreePtr() && a->GetAnimTreePtr()->GetCamAnim());
|
|
|
|
|
|
|
|
if (a->GetAnimTreePtr()) {
|
|
|
|
deltaTime = p_param - m_unk0x58;
|
|
|
|
|
|
|
|
if (a->GetDuration() <= deltaTime || deltaTime < 0.0) {
|
|
|
|
if (m_userState == 2) {
|
|
|
|
LegoEdge** edges = m_unk0x78->GetEdges();
|
|
|
|
m_destEdge = (LegoUnknown100db7f4*) (edges[2]);
|
|
|
|
m_boundary = m_unk0x78;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LegoEdge** edges = m_unk0x78->GetEdges();
|
|
|
|
m_destEdge = (LegoUnknown100db7f4*) (edges[1]);
|
|
|
|
m_boundary = m_unk0x7c;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_userState = 0;
|
|
|
|
}
|
|
|
|
else if (a->GetAnimTreePtr()->GetCamAnim()) {
|
|
|
|
MxMatrix transformationMatrix;
|
|
|
|
|
|
|
|
LegoWorld* r = CurrentWorld(); // called `r` in BETA10
|
|
|
|
assert(r);
|
|
|
|
|
|
|
|
transformationMatrix.SetIdentity();
|
|
|
|
|
|
|
|
// Possible bug in the original code: The first argument is not initialized
|
|
|
|
a->GetAnimTreePtr()->GetCamAnim()->FUN_1009f490(deltaTime, transformationMatrix);
|
|
|
|
|
|
|
|
if (r->GetCamera()) {
|
|
|
|
r->GetCamera()->FUN_100123e0(transformationMatrix, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_roi->FUN_100a58f0(transformationMatrix);
|
|
|
|
}
|
|
|
|
}
|
2024-03-22 21:30:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x10013130
|
|
|
|
MxBool LegoRaceCar::FUN_10013130(float)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2024-06-10 13:04:40 -04:00
|
|
|
// STUB: LEGO1 0x100131f0
|
|
|
|
void LegoRaceCar::VTable0x70(float p_float)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2024-06-10 13:04:40 -04:00
|
|
|
// STUB: LEGO1 0x100133c0
|
|
|
|
MxResult LegoRaceCar::VTable0x94(LegoPathActor* p_actor, MxBool p_bool)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
|
|
|
// TODO
|
2024-06-10 13:04:40 -04:00
|
|
|
return 0;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-06-10 13:04:40 -04:00
|
|
|
// STUB: LEGO1 0x10013600
|
|
|
|
MxResult LegoRaceCar::VTable0x9c()
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
|
|
|
// TODO
|
2024-06-10 13:04:40 -04:00
|
|
|
return SUCCESS;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-06-10 13:04:40 -04:00
|
|
|
// STUB: LEGO1 0x10014500
|
2024-04-17 06:34:21 -04:00
|
|
|
MxU32 LegoRaceCar::VTable0x6c(
|
|
|
|
LegoPathBoundary* p_boundary,
|
|
|
|
Vector3& p_v1,
|
|
|
|
Vector3& p_v2,
|
|
|
|
float p_f1,
|
|
|
|
float p_f2,
|
|
|
|
Vector3& p_v3
|
|
|
|
)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
|
|
|
// TODO
|
2024-04-17 06:34:21 -04:00
|
|
|
return 0;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-06-10 13:04:40 -04:00
|
|
|
// STUB: LEGO1 0x10014560
|
2024-05-20 14:27:00 -04:00
|
|
|
void LegoRaceCar::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|