#include "towtrack.h" #include "isle_actions.h" #include "legocontrolmanager.h" #include "legogamestate.h" #include "legonavcontroller.h" #include "legovariables.h" #include "legoworld.h" #include "misc.h" #include "mxmisc.h" #include "mxtimer.h" #include "mxvariabletable.h" DECOMP_SIZE_ASSERT(TowTrack, 0x180) DECOMP_SIZE_ASSERT(TowTrackMissionState, 0x28) // FUNCTION: LEGO1 0x1004c720 TowTrack::TowTrack() { m_unk0x168 = 0; m_unk0x16a = -1; m_state = NULL; m_unk0x16c = 0; m_unk0x170 = -1; m_unk0x16e = 0; m_unk0x174 = -1; m_maxLinearVel = 40.0; m_fuel = 1.0; } // FUNCTION: LEGO1 0x1004c970 TowTrack::~TowTrack() { ControlManager()->Unregister(this); } // FUNCTION: LEGO1 0x1004c9e0 // FUNCTION: BETA10 0x100f6bf1 MxResult TowTrack::Create(MxDSAction& p_dsAction) { MxResult result = IslePathActor::Create(p_dsAction); if (result == SUCCESS) { m_world = CurrentWorld(); if (m_world) { m_world->Add(this); } m_state = (TowTrackMissionState*) GameState()->GetState("TowTrackMissionState"); if (!m_state) { m_state = new TowTrackMissionState(); m_state->m_unk0x08 = 0; GameState()->RegisterState(m_state); } } VariableTable()->SetVariable(g_varTOWFUEL, "1.0"); m_fuel = 1.0; m_time = Timer()->GetTime(); return result; } // FUNCTION: LEGO1 0x1004cb10 void TowTrack::VTable0x70(float p_time) { IslePathActor::VTable0x70(p_time); if (UserActor() == this) { char buf[200]; float speed = abs(m_worldSpeed); float maxLinearVel = NavController()->GetMaxLinearVel(); sprintf(buf, "%g", speed / maxLinearVel); VariableTable()->SetVariable(g_varTOWSPEED, buf); m_fuel += (p_time - m_time) * -3.333333333e-06f; if (m_fuel < 0) { m_fuel = 0; } m_time = p_time; sprintf(buf, "%g", m_fuel); VariableTable()->SetVariable(g_varTOWFUEL, buf); if (p_time - m_state->m_unk0x0c > 100000.0f && m_state->m_unk0x08 == 1 && !m_state->m_unk0x10) { FUN_1004dcf0(IsleScript::c_Avo909In_PlayWav); m_state->m_unk0x10 = TRUE; } } } // FUNCTION: LEGO1 0x1004cc40 void TowTrack::CreateState() { m_state = (TowTrackMissionState*) GameState()->GetState("TowTrackMissionState"); if (m_state == NULL) { m_state = (TowTrackMissionState*) GameState()->CreateState("TowTrackMissionState"); } } // STUB: LEGO1 0x1004cc80 MxLong TowTrack::Notify(MxParam& p_param) { // TODO return 0; } // STUB: LEGO1 0x1004cd30 MxLong TowTrack::HandleEndAnim(LegoEndAnimNotificationParam& p_param) { // TODO return 0; } // STUB: LEGO1 0x1004d330 MxLong TowTrack::HandlePathStruct(LegoPathStructNotificationParam& p_param) { // TODO return 0; } // STUB: LEGO1 0x1004d690 MxLong TowTrack::HandleClick() { // TODO return 0; } // STUB: LEGO1 0x1004d8f0 void TowTrack::Exit() { // TODO } // STUB: LEGO1 0x1004d9e0 MxLong TowTrack::HandleControl(LegoControlManagerNotificationParam& p_param) { // TODO return 0; } // STUB: LEGO1 0x1004dab0 void TowTrack::FUN_1004dab0() { // TODO } // STUB: LEGO1 0x1004dad0 void TowTrack::FUN_1004dad0() { // TODO } // STUB: LEGO1 0x1004db10 void TowTrack::FUN_1004db10() { // TODO } // STUB: LEGO1 0x1004dbe0 void TowTrack::FUN_1004dbe0() { // TODO } // STUB: LEGO1 0x1004dcf0 void TowTrack::FUN_1004dcf0(IsleScript::Script) { // TODO } // FUNCTION: LEGO1 0x1004dd30 TowTrackMissionState::TowTrackMissionState() { m_unk0x12 = 0; m_unk0x14 = 0; m_unk0x16 = 0; m_unk0x08 = 0; m_unk0x18 = 0; m_unk0x0c = 0; m_unk0x1a = 0; m_unk0x10 = FALSE; m_score1 = 0; m_score2 = 0; m_score3 = 0; m_score4 = 0; m_score5 = 0; } // FUNCTION: LEGO1 0x1004dde0 MxResult TowTrackMissionState::Serialize(LegoFile* p_file) { LegoState::Serialize(p_file); if (p_file->IsReadMode()) { Read(p_file, &m_unk0x12); Read(p_file, &m_unk0x14); Read(p_file, &m_unk0x16); Read(p_file, &m_unk0x18); Read(p_file, &m_unk0x1a); Read(p_file, &m_score1); Read(p_file, &m_score2); Read(p_file, &m_score3); Read(p_file, &m_score4); Read(p_file, &m_score5); } else if (p_file->IsWriteMode()) { Write(p_file, m_unk0x12); Write(p_file, m_unk0x14); Write(p_file, m_unk0x16); Write(p_file, m_unk0x18); Write(p_file, m_unk0x1a); Write(p_file, m_score1); Write(p_file, m_score2); Write(p_file, m_score3); Write(p_file, m_score4); Write(p_file, m_score5); } return SUCCESS; }