mirror of https://github.com/AxioDL/metaforce.git
CScriptDock: Brace conditionals where applicable
This commit is contained in:
parent
49dd7a874b
commit
470d649604
|
@ -36,32 +36,33 @@ void CScriptDock::Think(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const IGameArea::Dock* gameDock = mgr.GetWorld()->GetArea(x260_area)->GetDock(x25c_dock);
|
const IGameArea::Dock* gameDock = mgr.GetWorld()->GetArea(x260_area)->GetDock(x25c_dock);
|
||||||
TAreaId connArea = gameDock->GetConnectedAreaId(gameDock->GetReferenceCount());
|
const TAreaId connArea = gameDock->GetConnectedAreaId(gameDock->GetReferenceCount());
|
||||||
if (connArea != kInvalidAreaId) {
|
if (connArea != kInvalidAreaId) {
|
||||||
bool connPostConstructed = mgr.GetWorld()->GetArea(connArea)->IsPostConstructed();
|
const bool connPostConstructed = mgr.GetWorld()->GetArea(connArea)->IsPostConstructed();
|
||||||
if (x268_26_areaPostConstructed != connPostConstructed) {
|
if (x268_26_areaPostConstructed != connPostConstructed) {
|
||||||
x268_26_areaPostConstructed = connPostConstructed;
|
x268_26_areaPostConstructed = connPostConstructed;
|
||||||
if (connPostConstructed)
|
if (connPostConstructed) {
|
||||||
CEntity::SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
CEntity::SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
||||||
else
|
} else {
|
||||||
CEntity::SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
CEntity::SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mgr.GetNextAreaId() != x260_area)
|
if (mgr.GetNextAreaId() != x260_area) {
|
||||||
x264_dockState = EDockState::Three;
|
x264_dockState = EDockState::Three;
|
||||||
else if (x264_dockState == EDockState::Three)
|
} else if (x264_dockState == EDockState::Three) {
|
||||||
x264_dockState = EDockState::Idle;
|
x264_dockState = EDockState::Idle;
|
||||||
else if (x264_dockState == EDockState::PlayerTouched)
|
} else if (x264_dockState == EDockState::PlayerTouched) {
|
||||||
x264_dockState = EDockState::EnterNextArea;
|
x264_dockState = EDockState::EnterNextArea;
|
||||||
else if (x264_dockState == EDockState::EnterNextArea) {
|
} else if (x264_dockState == EDockState::EnterNextArea) {
|
||||||
CPlayer& player = mgr.GetPlayer();
|
CPlayer& player = mgr.GetPlayer();
|
||||||
if (HasPointCrossedDock(mgr, player.GetTranslation())) {
|
if (HasPointCrossedDock(mgr, player.GetTranslation())) {
|
||||||
IGameArea::Dock* dock = mgr.GetWorld()->GetArea(mgr.GetNextAreaId())->GetDock(x25c_dock);
|
const IGameArea::Dock* dock = mgr.GetWorld()->GetArea(mgr.GetNextAreaId())->GetDock(x25c_dock);
|
||||||
TAreaId aid = dock->GetConnectedAreaId(dock->GetReferenceCount());
|
const TAreaId aid = dock->GetConnectedAreaId(dock->GetReferenceCount());
|
||||||
if (aid != kInvalidAreaId && mgr.GetWorld()->GetArea(aid)->GetActive()) {
|
if (aid != kInvalidAreaId && mgr.GetWorld()->GetArea(aid)->GetActive()) {
|
||||||
mgr.SetCurrentAreaId(aid);
|
mgr.SetCurrentAreaId(aid);
|
||||||
s32 otherDock = dock->GetOtherDockNumber(dock->GetReferenceCount());
|
const s32 otherDock = dock->GetOtherDockNumber(dock->GetReferenceCount());
|
||||||
|
|
||||||
if (CObjectList* objs = mgr.GetWorld()->GetArea(aid)->GetAreaObjects()) {
|
if (CObjectList* objs = mgr.GetWorld()->GetArea(aid)->GetAreaObjects()) {
|
||||||
for (CEntity* ent : *objs) {
|
for (CEntity* ent : *objs) {
|
||||||
|
@ -82,11 +83,13 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case EScriptObjectMessage::Registered: {
|
case EScriptObjectMessage::Registered: {
|
||||||
CGameArea* area = mgr.GetWorld()->GetArea(x260_area);
|
CGameArea* area = mgr.GetWorld()->GetArea(x260_area);
|
||||||
if (area->GetDockCount() < x25c_dock)
|
if (area->GetDockCount() < x25c_dock) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
IGameArea::Dock* dock = area->GetDock(x25c_dock);
|
IGameArea::Dock* dock = area->GetDock(x25c_dock);
|
||||||
if (!dock->IsReferenced())
|
if (!dock->IsReferenced()) {
|
||||||
dock->SetReferenceCount(x258_dockReferenceCount);
|
dock->SetReferenceCount(x258_dockReferenceCount);
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case EScriptObjectMessage::Deleted:
|
case EScriptObjectMessage::Deleted:
|
||||||
CleanUp();
|
CleanUp();
|
||||||
|
@ -96,32 +99,35 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
|
||||||
break;
|
break;
|
||||||
case EScriptObjectMessage::WorldInitialized: {
|
case EScriptObjectMessage::WorldInitialized: {
|
||||||
UpdateAreaActivateFlags(mgr);
|
UpdateAreaActivateFlags(mgr);
|
||||||
CMaterialList exclude = GetMaterialFilter().GetExcludeList();
|
const CMaterialList exclude = GetMaterialFilter().GetExcludeList();
|
||||||
CMaterialList include = GetMaterialFilter().GetIncludeList();
|
CMaterialList include = GetMaterialFilter().GetIncludeList();
|
||||||
include.Add(EMaterialTypes::AIBlock);
|
include.Add(EMaterialTypes::AIBlock);
|
||||||
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
|
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
|
||||||
} break;
|
} break;
|
||||||
case EScriptObjectMessage::SetToZero: {
|
case EScriptObjectMessage::SetToZero: {
|
||||||
if (mgr.GetNextAreaId() != x260_area)
|
if (mgr.GetNextAreaId() != x260_area) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetLoadConnected(mgr, false);
|
SetLoadConnected(mgr, false);
|
||||||
|
|
||||||
CGameArea* area = mgr.GetWorld()->GetArea(x260_area);
|
const CGameArea* area = mgr.GetWorld()->GetArea(x260_area);
|
||||||
IGameArea::Dock* dock = area->GetDock(x25c_dock);
|
const IGameArea::Dock* dock = area->GetDock(x25c_dock);
|
||||||
|
|
||||||
TAreaId aid = dock->GetConnectedAreaId(dock->GetReferenceCount());
|
const TAreaId aid = dock->GetConnectedAreaId(dock->GetReferenceCount());
|
||||||
|
|
||||||
CPlatformAndDoorList& lst = mgr.GetPlatformAndDoorObjectList();
|
CPlatformAndDoorList& lst = mgr.GetPlatformAndDoorObjectList();
|
||||||
for (CEntity* ent : lst) {
|
for (CEntity* ent : lst) {
|
||||||
TCastToPtr<CScriptDoor> door(ent);
|
const TCastToPtr<CScriptDoor> door(ent);
|
||||||
if (door && door->IsConnectedToArea(mgr, aid))
|
if (door && door->IsConnectedToArea(mgr, aid)) {
|
||||||
door->ForceClosed(mgr);
|
door->ForceClosed(mgr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case EScriptObjectMessage::SetToMax:
|
case EScriptObjectMessage::SetToMax:
|
||||||
if (mgr.GetNextAreaId() != x260_area)
|
if (mgr.GetNextAreaId() != x260_area) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetLoadConnected(mgr, true);
|
SetLoadConnected(mgr, true);
|
||||||
break;
|
break;
|
||||||
|
@ -131,13 +137,14 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
|
||||||
case EScriptObjectMessage::Decrement: {
|
case EScriptObjectMessage::Decrement: {
|
||||||
TAreaId aid = x260_area;
|
TAreaId aid = x260_area;
|
||||||
if (mgr.GetNextAreaId() == x260_area) {
|
if (mgr.GetNextAreaId() == x260_area) {
|
||||||
IGameArea::Dock* dock = mgr.GetWorld()->GetArea(x260_area)->GetDock(x25c_dock);
|
const IGameArea::Dock* dock = mgr.GetWorld()->GetArea(x260_area)->GetDock(x25c_dock);
|
||||||
aid = dock->GetConnectedAreaId(dock->GetReferenceCount());
|
aid = dock->GetConnectedAreaId(dock->GetReferenceCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aid >= 0 && aid < mgr.GetWorld()->GetNumAreas() && mgr.GetWorld()->GetArea(aid)->GetActive())
|
if (aid >= 0 && aid < mgr.GetWorld()->GetNumAreas() && mgr.GetWorld()->GetArea(aid)->GetActive()) {
|
||||||
CWorld::PropogateAreaChain(CGameArea::EOcclusionState(msg == EScriptObjectMessage::Increment),
|
CWorld::PropogateAreaChain(CGameArea::EOcclusionState(msg == EScriptObjectMessage::Increment),
|
||||||
mgr.GetWorld()->GetArea(aid), mgr.GetWorld());
|
mgr.GetWorld()->GetArea(aid), mgr.GetWorld());
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
CPhysicsActor::AcceptScriptMsg(msg, uid, mgr);
|
CPhysicsActor::AcceptScriptMsg(msg, uid, mgr);
|
||||||
|
@ -154,12 +161,14 @@ std::optional<zeus::CAABox> CScriptDock::GetTouchBounds() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptDock::Touch(CActor& act, CStateManager&) {
|
void CScriptDock::Touch(CActor& act, CStateManager&) {
|
||||||
if (x264_dockState == EDockState::Three)
|
if (x264_dockState == EDockState::Three) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TCastToPtr<CPlayer>(act))
|
if (TCastToConstPtr<CPlayer>(act)) {
|
||||||
x264_dockState = EDockState::PlayerTouched;
|
x264_dockState = EDockState::PlayerTouched;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
zeus::CPlane CScriptDock::GetPlane(const CStateManager& mgr) const {
|
zeus::CPlane CScriptDock::GetPlane(const CStateManager& mgr) const {
|
||||||
const IGameArea::Dock* dock = mgr.GetWorld()->GetAreaAlways(x260_area)->GetDock(x25c_dock);
|
const IGameArea::Dock* dock = mgr.GetWorld()->GetAreaAlways(x260_area)->GetDock(x25c_dock);
|
||||||
|
@ -176,11 +185,14 @@ s32 CScriptDock::GetDockReference(const CStateManager& mgr) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
TAreaId CScriptDock::GetCurrentConnectedAreaId(const CStateManager& mgr) const {
|
TAreaId CScriptDock::GetCurrentConnectedAreaId(const CStateManager& mgr) const {
|
||||||
if (x260_area >= mgr.GetWorld()->GetNumAreas())
|
if (x260_area >= mgr.GetWorld()->GetNumAreas()) {
|
||||||
return kInvalidAreaId;
|
return kInvalidAreaId;
|
||||||
|
}
|
||||||
|
|
||||||
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(x260_area);
|
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(x260_area);
|
||||||
if (x25c_dock >= area->GetDockCount())
|
if (x25c_dock >= area->GetDockCount()) {
|
||||||
return kInvalidAreaId;
|
return kInvalidAreaId;
|
||||||
|
}
|
||||||
|
|
||||||
const IGameArea::Dock* dock = area->GetDock(x25c_dock);
|
const IGameArea::Dock* dock = area->GetDock(x25c_dock);
|
||||||
return dock->GetConnectedAreaId(dock->GetReferenceCount());
|
return dock->GetConnectedAreaId(dock->GetReferenceCount());
|
||||||
|
@ -188,22 +200,23 @@ TAreaId CScriptDock::GetCurrentConnectedAreaId(const CStateManager& mgr) const {
|
||||||
|
|
||||||
void CScriptDock::UpdateAreaActivateFlags(CStateManager& mgr) {
|
void CScriptDock::UpdateAreaActivateFlags(CStateManager& mgr) {
|
||||||
CWorld* world = mgr.GetWorld();
|
CWorld* world = mgr.GetWorld();
|
||||||
if (x260_area >= world->GetNumAreas())
|
if (x260_area >= world->GetNumAreas()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CGameArea* area = world->GetArea(x260_area);
|
CGameArea* area = world->GetArea(x260_area);
|
||||||
|
|
||||||
if (x25c_dock >= area->GetDockCount())
|
if (x25c_dock >= area->GetDockCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IGameArea::Dock* dock = area->GetDock(x25c_dock);
|
const IGameArea::Dock* dock = area->GetDock(x25c_dock);
|
||||||
|
|
||||||
for (s32 i = 0; i < dock->GetDockRefs().size(); ++i) {
|
for (s32 i = 0; i < dock->GetDockRefs().size(); ++i) {
|
||||||
s32 dockRefCount = dock->GetReferenceCount();
|
const s32 dockRefCount = dock->GetReferenceCount();
|
||||||
TAreaId aid = dock->GetConnectedAreaId(i);
|
const TAreaId aid = dock->GetConnectedAreaId(i);
|
||||||
if (aid != kInvalidAreaId)
|
if (aid != kInvalidAreaId) {
|
||||||
world->GetArea(aid)->SetActive(i == dockRefCount);
|
world->GetArea(aid)->SetActive(i == dockRefCount);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mgr.SetCurrentAreaId(mgr.GetNextAreaId());
|
mgr.SetCurrentAreaId(mgr.GetNextAreaId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,9 +229,10 @@ void CScriptDock::AreaLoaded(CStateManager& mgr) { SetLoadConnected(mgr, x268_25
|
||||||
|
|
||||||
void CScriptDock::SetLoadConnected(CStateManager& mgr, bool loadOther) {
|
void CScriptDock::SetLoadConnected(CStateManager& mgr, bool loadOther) {
|
||||||
IGameArea::Dock* dock = mgr.GetWorld()->GetArea(x260_area)->GetDock(x25c_dock);
|
IGameArea::Dock* dock = mgr.GetWorld()->GetArea(x260_area)->GetDock(x25c_dock);
|
||||||
bool cur = dock->GetShouldLoadOther(dock->GetReferenceCount());
|
const bool cur = dock->GetShouldLoadOther(dock->GetReferenceCount());
|
||||||
if (cur == loadOther)
|
if (cur == loadOther) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dock->SetShouldLoadOther(dock->GetReferenceCount(), loadOther);
|
dock->SetShouldLoadOther(dock->GetReferenceCount(), loadOther);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue