2023-06-29 04:10:08 -04:00
|
|
|
#include "legoworld.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2024-02-02 12:18:46 -05:00
|
|
|
#include "legoanimationmanager.h"
|
2024-01-26 16:00:02 -05:00
|
|
|
#include "legoanimpresenter.h"
|
2024-01-27 11:48:50 -05:00
|
|
|
#include "legobuildingmanager.h"
|
2024-01-13 15:00:11 -05:00
|
|
|
#include "legocontrolmanager.h"
|
2024-02-02 12:18:46 -05:00
|
|
|
#include "legogamestate.h"
|
2023-10-23 07:16:21 -04:00
|
|
|
#include "legoinputmanager.h"
|
2024-01-27 11:48:50 -05:00
|
|
|
#include "legolocomotionanimpresenter.h"
|
2024-02-02 12:18:46 -05:00
|
|
|
#include "legonavcontroller.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "legoomni.h"
|
2024-01-27 11:48:50 -05:00
|
|
|
#include "legoplantmanager.h"
|
|
|
|
#include "legosoundmanager.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "legoutils.h"
|
2024-01-13 15:00:11 -05:00
|
|
|
#include "legovideomanager.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "misc.h"
|
2023-10-25 16:51:59 -04:00
|
|
|
#include "mxactionnotificationparam.h"
|
2024-01-27 10:10:09 -05:00
|
|
|
#include "mxcontrolpresenter.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "mxmisc.h"
|
2023-12-29 13:04:18 -05:00
|
|
|
#include "mxnotificationmanager.h"
|
2023-10-25 16:51:59 -04:00
|
|
|
#include "mxnotificationparam.h"
|
2023-10-23 07:16:21 -04:00
|
|
|
#include "mxticklemanager.h"
|
|
|
|
|
2024-01-15 15:59:57 -05:00
|
|
|
DECOMP_SIZE_ASSERT(LegoWorld, 0xf8)
|
|
|
|
DECOMP_SIZE_ASSERT(LegoEntityList, 0x18)
|
|
|
|
DECOMP_SIZE_ASSERT(LegoEntityListCursor, 0x10)
|
2024-01-26 17:52:03 -05:00
|
|
|
DECOMP_SIZE_ASSERT(LegoCacheSoundList, 0x18)
|
|
|
|
DECOMP_SIZE_ASSERT(LegoCacheSoundListCursor, 0x10)
|
2023-10-23 07:16:21 -04:00
|
|
|
|
2024-01-22 10:18:46 -05:00
|
|
|
// FUNCTION: LEGO1 0x1001ca40
|
2023-12-20 20:09:05 -05:00
|
|
|
LegoWorld::LegoWorld() : m_list0x68(TRUE)
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2024-01-27 15:18:35 -05:00
|
|
|
m_startupTicks = e_four;
|
2024-01-22 10:18:46 -05:00
|
|
|
m_cameraController = NULL;
|
|
|
|
m_entityList = NULL;
|
2024-01-26 17:52:03 -05:00
|
|
|
m_cacheSoundList = NULL;
|
2024-01-27 11:48:50 -05:00
|
|
|
m_destroyed = FALSE;
|
2024-01-26 17:52:03 -05:00
|
|
|
m_hideAnimPresenter = NULL;
|
2024-01-22 10:18:46 -05:00
|
|
|
m_worldStarted = FALSE;
|
|
|
|
|
2023-12-29 13:04:18 -05:00
|
|
|
NotificationManager()->Register(this);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1001d670
|
2023-11-21 03:44:45 -05:00
|
|
|
MxBool LegoWorld::VTable0x5c()
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1001d680
|
2023-11-21 03:44:45 -05:00
|
|
|
MxBool LegoWorld::VTable0x64()
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-01-27 11:48:50 -05:00
|
|
|
// FUNCTION: LEGO1 0x1001dfa0
|
2023-06-29 04:10:08 -04:00
|
|
|
LegoWorld::~LegoWorld()
|
|
|
|
{
|
2024-01-27 11:48:50 -05:00
|
|
|
Destroy(TRUE);
|
|
|
|
|
|
|
|
TickleManager()->UnregisterClient(this);
|
|
|
|
NotificationManager()->Unregister(this);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2023-10-23 07:16:21 -04:00
|
|
|
|
2024-01-15 15:44:04 -05:00
|
|
|
// FUNCTION: LEGO1 0x1001e0b0
|
2024-01-13 15:00:11 -05:00
|
|
|
MxResult LegoWorld::Create(MxDSAction& p_dsAction)
|
2023-10-23 07:16:21 -04:00
|
|
|
{
|
2024-01-13 15:00:11 -05:00
|
|
|
MxEntity::Create(p_dsAction);
|
|
|
|
|
2024-01-15 15:44:04 -05:00
|
|
|
m_entityList = new LegoEntityList(TRUE);
|
2024-01-13 15:00:11 -05:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!m_entityList) {
|
2024-01-15 15:44:04 -05:00
|
|
|
return FAILURE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-13 15:00:11 -05:00
|
|
|
|
2024-01-26 17:52:03 -05:00
|
|
|
m_cacheSoundList = new LegoCacheSoundList(TRUE);
|
2024-01-15 15:44:04 -05:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!m_cacheSoundList) {
|
2024-01-15 15:44:04 -05:00
|
|
|
return FAILURE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-15 15:44:04 -05:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!VTable0x54()) {
|
2024-01-15 15:44:04 -05:00
|
|
|
return FAILURE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-13 15:00:11 -05:00
|
|
|
|
2024-01-17 11:53:53 -05:00
|
|
|
if (p_dsAction.GetFlags() & MxDSAction::c_enabled) {
|
2024-02-02 12:18:46 -05:00
|
|
|
if (CurrentWorld()) {
|
2024-02-16 20:10:42 -05:00
|
|
|
CurrentWorld()->Enable(FALSE);
|
2024-01-15 15:44:04 -05:00
|
|
|
}
|
2024-01-13 15:00:11 -05:00
|
|
|
|
2024-01-15 15:44:04 -05:00
|
|
|
SetCurrentWorld(this);
|
2024-01-26 16:00:02 -05:00
|
|
|
ControlManager()->FUN_10028df0(&m_controlPresenters);
|
2024-01-13 15:00:11 -05:00
|
|
|
}
|
2024-01-15 15:44:04 -05:00
|
|
|
|
|
|
|
SetIsWorldActive(TRUE);
|
2024-02-16 20:10:42 -05:00
|
|
|
m_scriptIndex = -1;
|
2024-01-15 15:44:04 -05:00
|
|
|
|
|
|
|
return SUCCESS;
|
2023-10-23 07:16:21 -04:00
|
|
|
}
|
|
|
|
|
2024-01-27 11:48:50 -05:00
|
|
|
// FUNCTION: LEGO1 0x1001e9d0
|
2024-01-18 20:24:15 -05:00
|
|
|
void LegoWorld::Destroy(MxBool p_fromDestructor)
|
|
|
|
{
|
2024-01-27 11:48:50 -05:00
|
|
|
m_destroyed = TRUE;
|
|
|
|
|
2024-02-02 12:18:46 -05:00
|
|
|
if (CurrentWorld() == this) {
|
2024-01-27 11:48:50 -05:00
|
|
|
ControlManager()->FUN_10028df0(NULL);
|
|
|
|
SetCurrentWorld(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_list0x68.DeleteAll();
|
|
|
|
|
|
|
|
if (m_cameraController) {
|
|
|
|
delete m_cameraController;
|
|
|
|
m_cameraController = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MxPresenterListCursor animPresenterCursor(&m_animPresenters);
|
|
|
|
MxPresenter* presenter;
|
|
|
|
|
|
|
|
while (animPresenterCursor.First(presenter)) {
|
|
|
|
animPresenterCursor.Detach();
|
|
|
|
|
|
|
|
MxDSAction* action = presenter->GetAction();
|
|
|
|
if (action) {
|
|
|
|
if (presenter->IsA("LegoLocomotionAnimPresenter")) {
|
|
|
|
LegoLocomotionAnimPresenter* animPresenter = (LegoLocomotionAnimPresenter*) presenter;
|
|
|
|
|
|
|
|
animPresenter->DecrementUnknown0xd4();
|
|
|
|
if (animPresenter->GetUnknown0xd4() == 0) {
|
|
|
|
FUN_100b7220(action, MxDSAction::c_world, FALSE);
|
|
|
|
presenter->EndAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FUN_100b7220(action, MxDSAction::c_world, FALSE);
|
|
|
|
presenter->EndAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!m_set0xa8.empty()) {
|
|
|
|
MxCoreSet::iterator it = m_set0xa8.begin();
|
|
|
|
MxCore* object = *it;
|
|
|
|
m_set0xa8.erase(it);
|
|
|
|
|
|
|
|
if (object->IsA("MxPresenter")) {
|
|
|
|
MxPresenter* presenter = (MxPresenter*) object;
|
|
|
|
MxDSAction* action = presenter->GetAction();
|
|
|
|
|
|
|
|
if (action) {
|
|
|
|
FUN_100b7220(action, MxDSAction::c_world, FALSE);
|
|
|
|
presenter->EndAction();
|
|
|
|
}
|
|
|
|
}
|
2024-02-01 15:42:10 -05:00
|
|
|
else {
|
2024-01-27 11:48:50 -05:00
|
|
|
delete object;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 11:48:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
MxPresenterListCursor controlPresenterCursor(&m_controlPresenters);
|
|
|
|
|
|
|
|
while (controlPresenterCursor.First(presenter)) {
|
|
|
|
controlPresenterCursor.Detach();
|
|
|
|
|
|
|
|
MxDSAction* action = presenter->GetAction();
|
|
|
|
if (action) {
|
|
|
|
FUN_100b7220(action, MxDSAction::c_world, FALSE);
|
|
|
|
presenter->EndAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-16 20:10:42 -05:00
|
|
|
if (m_scriptIndex != -1 && m_set0xd0.empty()) {
|
|
|
|
PlantManager()->FUN_100263a0(m_scriptIndex);
|
2024-01-27 11:48:50 -05:00
|
|
|
BuildingManager()->FUN_1002fb30();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_entityList) {
|
|
|
|
LegoEntityListCursor cursor(m_entityList);
|
|
|
|
LegoEntity* entity;
|
|
|
|
|
|
|
|
while (cursor.First(entity)) {
|
|
|
|
cursor.Detach();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!(entity->GetFlags() & LegoEntity::c_bit2)) {
|
2024-01-27 11:48:50 -05:00
|
|
|
delete entity;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 11:48:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
delete m_entityList;
|
|
|
|
m_entityList = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_cacheSoundList) {
|
|
|
|
LegoCacheSoundListCursor cursor(m_cacheSoundList);
|
|
|
|
LegoCacheSound* sound;
|
|
|
|
|
|
|
|
while (cursor.First(sound)) {
|
|
|
|
cursor.Detach();
|
|
|
|
SoundManager()->GetUnknown0x40()->FUN_1003dc40(&sound);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete m_cacheSoundList;
|
|
|
|
m_cacheSoundList = NULL;
|
|
|
|
}
|
|
|
|
|
2024-03-04 12:26:36 -05:00
|
|
|
while (!m_roiList.empty()) {
|
|
|
|
LegoROI* roi = m_roiList.front();
|
|
|
|
m_roiList.pop_front();
|
2024-01-27 11:48:50 -05:00
|
|
|
delete roi;
|
|
|
|
}
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!p_fromDestructor) {
|
2024-01-27 11:48:50 -05:00
|
|
|
LegoEntity::Destroy(FALSE);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-18 20:24:15 -05:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1001f5e0
|
2023-10-25 16:51:59 -04:00
|
|
|
MxLong LegoWorld::Notify(MxParam& p_param)
|
|
|
|
{
|
|
|
|
MxLong ret = 0;
|
|
|
|
switch (((MxNotificationParam&) p_param).GetNotification()) {
|
|
|
|
case c_notificationEndAction: {
|
|
|
|
MxPresenter* presenter = (MxPresenter*) ((MxEndActionNotificationParam&) p_param).GetSender();
|
2024-01-26 16:00:02 -05:00
|
|
|
Remove(presenter);
|
2023-10-25 16:51:59 -04:00
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case c_notificationNewPresenter:
|
|
|
|
TickleManager()->RegisterClient(this, 100);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-01-13 15:00:11 -05:00
|
|
|
// FUNCTION: LEGO1 0x1001f630
|
|
|
|
LegoCameraController* LegoWorld::VTable0x54()
|
2023-10-23 07:16:21 -04:00
|
|
|
{
|
2024-01-13 15:00:11 -05:00
|
|
|
MxBool success = FALSE;
|
|
|
|
|
|
|
|
if (!VideoManager()) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (!(m_cameraController = new LegoCameraController())) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (m_cameraController->Create() != SUCCESS) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_cameraController->OnViewSize(
|
|
|
|
VideoManager()->GetVideoParam().GetRect().GetWidth(),
|
|
|
|
VideoManager()->GetVideoParam().GetRect().GetHeight()
|
|
|
|
);
|
|
|
|
|
|
|
|
success = TRUE;
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (!success) {
|
|
|
|
if (m_cameraController) {
|
|
|
|
delete m_cameraController;
|
|
|
|
m_cameraController = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_cameraController;
|
2023-10-23 07:16:21 -04:00
|
|
|
}
|
|
|
|
|
2024-02-04 12:33:37 -05:00
|
|
|
// FUNCTION: LEGO1 0x1001fc80
|
2023-12-14 11:50:29 -05:00
|
|
|
void LegoWorld::FUN_1001fc80(IslePathActor* p_actor)
|
|
|
|
{
|
2024-02-04 12:33:37 -05:00
|
|
|
LegoPathControllerListCursor cursor(&m_list0x68);
|
|
|
|
LegoPathController* controller;
|
|
|
|
|
|
|
|
while (cursor.Next(controller)) {
|
|
|
|
if (!controller->FUN_10046770(p_actor)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-12-14 11:50:29 -05:00
|
|
|
}
|
|
|
|
|
2024-02-04 12:33:37 -05:00
|
|
|
// FUNCTION: LEGO1 0x10020120
|
|
|
|
MxResult LegoWorld::GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value)
|
2023-12-16 13:14:01 -05:00
|
|
|
{
|
2024-02-04 12:33:37 -05:00
|
|
|
LegoPathControllerListCursor cursor(&m_list0x68);
|
|
|
|
LegoPathController* controller;
|
|
|
|
|
|
|
|
cursor.Next(controller);
|
|
|
|
|
|
|
|
if (!controller) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return controller->FUN_10046b30(p_path, p_value);
|
2023-12-16 13:14:01 -05:00
|
|
|
}
|
|
|
|
|
2024-01-26 17:52:03 -05:00
|
|
|
// FUNCTION: LEGO1 0x10020220
|
2024-01-26 16:00:02 -05:00
|
|
|
void LegoWorld::Add(MxCore* p_object)
|
2023-10-23 07:16:21 -04:00
|
|
|
{
|
2024-01-26 17:52:03 -05:00
|
|
|
if (p_object && !p_object->IsA("LegoWorld") && !p_object->IsA("LegoWorldPresenter")) {
|
|
|
|
if (p_object->IsA("LegoAnimPresenter")) {
|
|
|
|
LegoAnimPresenter* animPresenter = (LegoAnimPresenter*) p_object;
|
|
|
|
|
|
|
|
if (!strcmpi(animPresenter->GetAction()->GetObjectName(), "ConfigAnimation")) {
|
|
|
|
FUN_1003e050(animPresenter);
|
2024-02-18 12:43:42 -05:00
|
|
|
animPresenter->GetAction()->SetDuration(animPresenter->GetAnimation()->GetDuration());
|
2024-01-26 17:52:03 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_object->IsA("MxControlPresenter")) {
|
|
|
|
MxPresenterListCursor cursor(&m_controlPresenters);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (cursor.Find((MxPresenter*) p_object)) {
|
2024-01-26 17:52:03 -05:00
|
|
|
return;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 17:52:03 -05:00
|
|
|
|
|
|
|
m_controlPresenters.Append((MxPresenter*) p_object);
|
|
|
|
}
|
|
|
|
else if (p_object->IsA("MxEntity")) {
|
|
|
|
LegoEntityListCursor cursor(m_entityList);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (cursor.Find((LegoEntity*) p_object)) {
|
2024-01-26 17:52:03 -05:00
|
|
|
return;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 17:52:03 -05:00
|
|
|
|
|
|
|
m_entityList->Append((LegoEntity*) p_object);
|
|
|
|
}
|
|
|
|
else if (p_object->IsA("LegoLocomotionAnimPresenter") || p_object->IsA("LegoHideAnimPresenter") || p_object->IsA("LegoLoopingAnimPresenter")) {
|
|
|
|
MxPresenterListCursor cursor(&m_animPresenters);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (cursor.Find((MxPresenter*) p_object)) {
|
2024-01-26 17:52:03 -05:00
|
|
|
return;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 17:52:03 -05:00
|
|
|
|
|
|
|
((MxPresenter*) p_object)->SendToCompositePresenter(Lego());
|
|
|
|
m_animPresenters.Append(((MxPresenter*) p_object));
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (p_object->IsA("LegoHideAnimPresenter")) {
|
2024-01-26 17:52:03 -05:00
|
|
|
m_hideAnimPresenter = (LegoHideAnimPresenter*) p_object;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 17:52:03 -05:00
|
|
|
}
|
|
|
|
else if (p_object->IsA("LegoCacheSound")) {
|
|
|
|
LegoCacheSoundListCursor cursor(m_cacheSoundList);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (cursor.Find((LegoCacheSound*) p_object)) {
|
2024-01-26 17:52:03 -05:00
|
|
|
return;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 17:52:03 -05:00
|
|
|
|
|
|
|
m_cacheSoundList->Append((LegoCacheSound*) p_object);
|
|
|
|
}
|
|
|
|
else {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_set0xa8.find(p_object) == m_set0xa8.end()) {
|
2024-01-26 17:52:03 -05:00
|
|
|
m_set0xa8.insert(p_object);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 17:52:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_set0xd0.empty() && p_object->IsA("MxPresenter")) {
|
|
|
|
if (((MxPresenter*) p_object)->IsEnabled()) {
|
|
|
|
((MxPresenter*) p_object)->Enable(FALSE);
|
|
|
|
m_set0xd0.insert(p_object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-23 07:16:21 -04:00
|
|
|
}
|
|
|
|
|
2024-01-27 10:10:09 -05:00
|
|
|
// FUNCTION: LEGO1 0x10020f10
|
2024-01-26 16:00:02 -05:00
|
|
|
void LegoWorld::Remove(MxCore* p_object)
|
2023-10-23 07:16:21 -04:00
|
|
|
{
|
2024-01-27 10:10:09 -05:00
|
|
|
if (p_object) {
|
|
|
|
MxCoreSet::iterator it;
|
|
|
|
|
|
|
|
if (p_object->IsA("MxControlPresenter")) {
|
|
|
|
MxPresenterListCursor cursor(&m_controlPresenters);
|
|
|
|
|
|
|
|
if (cursor.Find((MxControlPresenter*) p_object)) {
|
|
|
|
cursor.Detach();
|
|
|
|
((MxControlPresenter*) p_object)->GetAction()->SetOrigin(Lego());
|
|
|
|
((MxControlPresenter*) p_object)->VTable0x68(TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (p_object->IsA("LegoLocomotionAnimPresenter") || p_object->IsA("LegoHideAnimPresenter") || p_object->IsA("LegoLoopingAnimPresenter")) {
|
|
|
|
MxPresenterListCursor cursor(&m_animPresenters);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (cursor.Find((MxPresenter*) p_object)) {
|
2024-01-27 10:10:09 -05:00
|
|
|
cursor.Detach();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 10:10:09 -05:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (p_object->IsA("LegoHideAnimPresenter")) {
|
2024-01-27 10:10:09 -05:00
|
|
|
m_hideAnimPresenter = NULL;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 10:10:09 -05:00
|
|
|
}
|
|
|
|
else if (p_object->IsA("MxEntity")) {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (p_object->IsA("LegoPathActor")) {
|
2024-01-27 10:10:09 -05:00
|
|
|
FUN_1001fc80((IslePathActor*) p_object);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 10:10:09 -05:00
|
|
|
|
|
|
|
if (m_entityList) {
|
|
|
|
LegoEntityListCursor cursor(m_entityList);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (cursor.Find((LegoEntity*) p_object)) {
|
2024-01-27 10:10:09 -05:00
|
|
|
cursor.Detach();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 10:10:09 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (p_object->IsA("LegoCacheSound")) {
|
|
|
|
LegoCacheSoundListCursor cursor(m_cacheSoundList);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (cursor.Find((LegoCacheSound*) p_object)) {
|
2024-01-27 10:10:09 -05:00
|
|
|
cursor.Detach();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 10:10:09 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
it = m_set0xa8.find(p_object);
|
2024-02-01 15:42:10 -05:00
|
|
|
if (it != m_set0xa8.end()) {
|
2024-01-27 10:10:09 -05:00
|
|
|
m_set0xa8.erase(it);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 10:10:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
it = m_set0xd0.find(p_object);
|
2024-02-01 15:42:10 -05:00
|
|
|
if (it != m_set0xd0.end()) {
|
2024-01-27 10:10:09 -05:00
|
|
|
m_set0xd0.erase(it);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 10:10:09 -05:00
|
|
|
}
|
2023-10-23 07:16:21 -04:00
|
|
|
}
|
|
|
|
|
2024-01-26 16:00:02 -05:00
|
|
|
// FUNCTION: LEGO1 0x100213a0
|
|
|
|
MxCore* LegoWorld::Find(const char* p_class, const char* p_name)
|
2024-01-17 11:53:53 -05:00
|
|
|
{
|
2024-01-26 16:00:02 -05:00
|
|
|
if (!strcmp(p_class, "MxControlPresenter")) {
|
|
|
|
MxPresenterListCursor cursor(&m_controlPresenters);
|
|
|
|
MxPresenter* presenter;
|
|
|
|
|
|
|
|
while (cursor.Next(presenter)) {
|
|
|
|
MxDSAction* action = presenter->GetAction();
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!strcmp(action->GetObjectName(), p_name)) {
|
2024-01-26 16:00:02 -05:00
|
|
|
return presenter;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 16:00:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else if (!strcmp(p_class, "MxEntity")) {
|
|
|
|
LegoEntityListCursor cursor(m_entityList);
|
|
|
|
LegoEntity* entity;
|
|
|
|
|
|
|
|
while (cursor.Next(entity)) {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!p_name) {
|
2024-01-26 16:00:02 -05:00
|
|
|
return entity;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 16:00:02 -05:00
|
|
|
|
|
|
|
LegoROI* roi = entity->GetROI();
|
2024-02-16 19:34:30 -05:00
|
|
|
if (roi && !strcmpi(roi->GetName(), p_name)) {
|
2024-01-26 16:00:02 -05:00
|
|
|
return entity;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 16:00:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else if (!strcmp(p_class, "LegoAnimPresenter")) {
|
|
|
|
MxPresenterListCursor cursor(&m_animPresenters);
|
|
|
|
MxPresenter* presenter;
|
|
|
|
|
|
|
|
while (cursor.Next(presenter)) {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!strcmpi(((LegoAnimPresenter*) presenter)->GetActionObjectName(), p_name)) {
|
2024-01-26 16:00:02 -05:00
|
|
|
return presenter;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 16:00:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else {
|
2024-01-26 17:52:03 -05:00
|
|
|
for (MxCoreSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
|
2024-01-26 16:00:02 -05:00
|
|
|
if ((*it)->IsA(p_class) && (*it)->IsA("MxPresenter")) {
|
|
|
|
MxPresenter* presenter = (MxPresenter*) *it;
|
|
|
|
MxDSAction* action = presenter->GetAction();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!strcmp(action->GetObjectName(), p_name)) {
|
2024-01-26 16:00:02 -05:00
|
|
|
return *it;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 16:00:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2024-01-17 11:53:53 -05:00
|
|
|
}
|
|
|
|
|
2024-01-26 12:03:29 -05:00
|
|
|
// FUNCTION: LEGO1 0x10021790
|
2024-01-26 16:00:02 -05:00
|
|
|
MxCore* LegoWorld::Find(const MxAtomId& p_atom, MxS32 p_entityId)
|
2024-01-21 12:38:22 -05:00
|
|
|
{
|
2024-01-26 12:03:29 -05:00
|
|
|
LegoEntityListCursor entityCursor(m_entityList);
|
|
|
|
LegoEntity* entity;
|
|
|
|
|
|
|
|
while (entityCursor.Next(entity)) {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (entity->GetAtom() == p_atom && entity->GetEntityId() == p_entityId) {
|
2024-01-26 12:03:29 -05:00
|
|
|
return entity;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 12:03:29 -05:00
|
|
|
}
|
|
|
|
|
2024-01-26 16:00:02 -05:00
|
|
|
MxPresenterListCursor controlPresenterCursor(&m_controlPresenters);
|
2024-01-26 12:03:29 -05:00
|
|
|
MxPresenter* presenter;
|
|
|
|
|
2024-01-26 16:00:02 -05:00
|
|
|
while (controlPresenterCursor.Next(presenter)) {
|
2024-01-26 12:03:29 -05:00
|
|
|
MxDSAction* action = presenter->GetAction();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId) {
|
2024-01-26 12:03:29 -05:00
|
|
|
return presenter;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 12:03:29 -05:00
|
|
|
}
|
|
|
|
|
2024-01-26 16:00:02 -05:00
|
|
|
MxPresenterListCursor animPresenterCursor(&m_animPresenters);
|
2024-01-26 12:03:29 -05:00
|
|
|
|
2024-01-26 16:00:02 -05:00
|
|
|
while (animPresenterCursor.Next(presenter)) {
|
2024-01-26 12:03:29 -05:00
|
|
|
MxDSAction* action = presenter->GetAction();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (action && action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId) {
|
2024-01-26 12:03:29 -05:00
|
|
|
return presenter;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 12:03:29 -05:00
|
|
|
}
|
|
|
|
|
2024-01-26 17:52:03 -05:00
|
|
|
for (MxCoreSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
|
2024-01-26 12:03:29 -05:00
|
|
|
MxCore* core = *it;
|
|
|
|
|
|
|
|
if (core->IsA("MxPresenter")) {
|
|
|
|
MxPresenter* presenter = (MxPresenter*) *it;
|
|
|
|
MxDSAction* action = presenter->GetAction();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId) {
|
2024-01-26 12:03:29 -05:00
|
|
|
return *it;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-26 12:03:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-21 12:38:22 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2024-02-02 12:18:46 -05:00
|
|
|
// FUNCTION: LEGO1 0x10021a70
|
|
|
|
void LegoWorld::Enable(MxBool p_enable)
|
2023-10-23 07:16:21 -04:00
|
|
|
{
|
2024-02-02 12:18:46 -05:00
|
|
|
if (p_enable && !m_set0xd0.empty()) {
|
|
|
|
if (CurrentWorld() != this) {
|
|
|
|
if (CurrentWorld()) {
|
|
|
|
AnimationManager()->FUN_10061010(0);
|
|
|
|
CurrentWorld()->Enable(FALSE);
|
|
|
|
|
|
|
|
LegoEntityListCursor cursor(m_entityList);
|
|
|
|
LegoEntity* entity;
|
|
|
|
|
|
|
|
while (cursor.Next(entity)) {
|
|
|
|
if (entity->GetROI()) {
|
2024-03-05 13:35:28 -05:00
|
|
|
entity->GetROI()->SetEntity(entity);
|
2024-03-02 14:26:19 -05:00
|
|
|
GetViewManager()->Add(entity->GetROI());
|
2024-02-02 12:18:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!m_set0xd0.empty()) {
|
|
|
|
MxCoreSet::iterator it = m_set0xd0.begin();
|
|
|
|
|
|
|
|
if ((*it)->IsA("MxPresenter")) {
|
|
|
|
((MxPresenter*) *it)->Enable(TRUE);
|
|
|
|
}
|
|
|
|
else if ((*it)->IsA("LegoPathController")) {
|
|
|
|
((LegoPathController*) *it)->Enable(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_set0xd0.erase(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetCurrentWorld(this);
|
|
|
|
ControlManager()->FUN_10028df0(&m_controlPresenters);
|
|
|
|
InputManager()->SetCamera(m_cameraController);
|
|
|
|
|
|
|
|
if (m_cameraController) {
|
|
|
|
InputManager()->Register(m_cameraController->GetNavController());
|
|
|
|
Lego()->SetNavController(m_cameraController->GetNavController());
|
|
|
|
}
|
|
|
|
|
2024-02-16 20:10:42 -05:00
|
|
|
if (m_scriptIndex != -1) {
|
|
|
|
PlantManager()->FUN_10026360(m_scriptIndex);
|
2024-03-15 20:43:45 -04:00
|
|
|
AnimationManager()->LoadScriptInfo(m_scriptIndex);
|
2024-02-02 12:18:46 -05:00
|
|
|
BuildingManager()->FUN_1002fa00();
|
|
|
|
AnimationManager()->FUN_1005f0b0();
|
|
|
|
}
|
|
|
|
|
2024-02-27 15:04:17 -05:00
|
|
|
GameState()->ResetROI();
|
2024-02-02 12:18:46 -05:00
|
|
|
SetIsWorldActive(TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!p_enable && m_set0xd0.empty()) {
|
|
|
|
MxPresenter* presenter;
|
|
|
|
LegoPathController* controller;
|
2024-02-26 11:19:16 -05:00
|
|
|
IslePathActor* actor = CurrentActor();
|
2024-02-02 12:18:46 -05:00
|
|
|
|
2024-02-26 11:19:16 -05:00
|
|
|
if (actor) {
|
|
|
|
FUN_1001fc80(actor);
|
2024-02-02 12:18:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
AnimationManager()->FUN_1005ee80(FALSE);
|
|
|
|
m_set0xd0.insert(this);
|
|
|
|
|
2024-02-16 20:10:42 -05:00
|
|
|
if (m_scriptIndex != -1) {
|
|
|
|
PlantManager()->FUN_100263a0(m_scriptIndex);
|
2024-02-02 12:18:46 -05:00
|
|
|
BuildingManager()->FUN_1002fb30();
|
|
|
|
}
|
|
|
|
|
|
|
|
MxPresenterListCursor controlPresenterCursor(&m_controlPresenters);
|
|
|
|
|
|
|
|
while (controlPresenterCursor.Next(presenter)) {
|
|
|
|
if (presenter->IsEnabled()) {
|
|
|
|
m_set0xd0.insert(presenter);
|
|
|
|
presenter->Enable(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (MxCoreSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
|
|
|
|
if ((*it)->IsA("LegoActionControlPresenter") ||
|
|
|
|
((*it)->IsA("MxPresenter") && ((MxPresenter*) *it)->IsEnabled())) {
|
|
|
|
m_set0xd0.insert(*it);
|
|
|
|
((MxPresenter*) *it)->Enable(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CurrentWorld() && CurrentWorld() == this) {
|
|
|
|
ControlManager()->FUN_10028df0(NULL);
|
|
|
|
Lego()->SetCurrentWorld(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (InputManager()->GetCamera() == m_cameraController) {
|
|
|
|
InputManager()->ClearCamera();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_cameraController) {
|
|
|
|
InputManager()->UnRegister(m_cameraController->GetNavController());
|
|
|
|
|
|
|
|
if (NavController() == m_cameraController->GetNavController()) {
|
|
|
|
Lego()->SetNavController(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LegoPathControllerListCursor pathControllerCursor(&m_list0x68);
|
|
|
|
|
|
|
|
while (pathControllerCursor.Next(controller)) {
|
|
|
|
controller->Enable(FALSE);
|
|
|
|
m_set0xd0.insert(controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
GetViewManager()->RemoveAll(NULL);
|
|
|
|
}
|
2023-10-23 07:16:21 -04:00
|
|
|
}
|
|
|
|
|
2023-12-29 13:04:18 -05:00
|
|
|
// FUNCTION: LEGO1 0x10022080
|
2023-12-14 11:50:29 -05:00
|
|
|
MxResult LegoWorld::Tickle()
|
|
|
|
{
|
2024-01-12 17:27:07 -05:00
|
|
|
if (!m_worldStarted) {
|
2024-01-27 15:18:35 -05:00
|
|
|
switch (m_startupTicks) {
|
|
|
|
case e_start:
|
2024-01-12 17:27:07 -05:00
|
|
|
m_worldStarted = TRUE;
|
2023-12-29 13:04:18 -05:00
|
|
|
SetAppCursor(0);
|
2024-01-27 15:18:35 -05:00
|
|
|
ReadyWorld();
|
2023-12-29 13:04:18 -05:00
|
|
|
return TRUE;
|
2024-01-27 15:18:35 -05:00
|
|
|
case e_two:
|
2024-02-01 15:42:10 -05:00
|
|
|
if (PresentersPending()) {
|
2023-12-29 13:04:18 -05:00
|
|
|
break;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-29 13:04:18 -05:00
|
|
|
default:
|
2024-01-27 15:18:35 -05:00
|
|
|
m_startupTicks--;
|
2023-12-29 13:04:18 -05:00
|
|
|
}
|
|
|
|
}
|
2024-01-27 15:18:35 -05:00
|
|
|
|
2023-12-29 13:04:18 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2024-01-27 15:18:35 -05:00
|
|
|
// FUNCTION: LEGO1 0x100220e0
|
|
|
|
MxBool LegoWorld::PresentersPending()
|
2023-12-29 13:04:18 -05:00
|
|
|
{
|
2024-01-27 15:18:35 -05:00
|
|
|
MxPresenterListCursor controlPresenterCursor(&m_controlPresenters);
|
|
|
|
MxPresenter* presenter;
|
|
|
|
|
|
|
|
while (controlPresenterCursor.Next(presenter)) {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (presenter->IsEnabled() && !presenter->HasTickleStatePassed(MxPresenter::e_starting)) {
|
2024-01-27 15:18:35 -05:00
|
|
|
return TRUE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 15:18:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
MxPresenterListCursor animPresenterCursor(&m_animPresenters);
|
|
|
|
|
|
|
|
while (animPresenterCursor.Next(presenter)) {
|
|
|
|
if (presenter->IsEnabled()) {
|
|
|
|
if (presenter->IsA("LegoLocomotionAnimPresenter")) {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!presenter->HasTickleStatePassed(MxPresenter::e_ready)) {
|
2024-01-27 15:18:35 -05:00
|
|
|
return TRUE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 15:18:35 -05:00
|
|
|
}
|
|
|
|
else {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!presenter->HasTickleStatePassed(MxPresenter::e_starting)) {
|
2024-01-27 15:18:35 -05:00
|
|
|
return TRUE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 15:18:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (MxCoreSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
|
|
|
|
if ((*it)->IsA("MxPresenter")) {
|
|
|
|
presenter = (MxPresenter*) *it;
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (presenter->IsEnabled() && !presenter->HasTickleStatePassed(MxPresenter::e_starting)) {
|
2024-01-27 15:18:35 -05:00
|
|
|
return TRUE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-27 15:18:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2023-12-14 11:50:29 -05:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10022340
|
2024-01-27 15:18:35 -05:00
|
|
|
void LegoWorld::ReadyWorld()
|
2023-10-23 07:16:21 -04:00
|
|
|
{
|
2023-11-21 03:44:45 -05:00
|
|
|
TickleManager()->UnregisterClient(this);
|
2023-10-25 14:51:59 -04:00
|
|
|
}
|