Rename CWorldLayerState to CScriptLayerManager (this is it's actual name)

This commit is contained in:
Phillip Stephens 2021-06-03 23:08:05 -07:00
parent 99d363d5df
commit 144af8cc15
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
13 changed files with 74 additions and 61 deletions

View File

@ -23,7 +23,7 @@ union BitsToDouble {
double doub;
};
CWorldLayerState::CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& saveWorld) {
CScriptLayerManager::CScriptLayerManager(CBitStreamReader& reader, const CSaveWorld& saveWorld) {
const u32 bitCount = reader.ReadEncoded(10);
x10_saveLayers.reserve(bitCount);
@ -37,7 +37,7 @@ CWorldLayerState::CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& s
}
}
void CWorldLayerState::PutTo(CBitStreamWriter& writer) const {
void CScriptLayerManager::PutTo(CBitStreamWriter& writer) const {
u32 totalLayerCount = 0;
for (size_t i = 0; i < x0_areaLayers.size(); ++i) {
totalLayerCount += GetAreaLayerCount(s32(i)) - 1;
@ -53,7 +53,7 @@ void CWorldLayerState::PutTo(CBitStreamWriter& writer) const {
}
}
void CWorldLayerState::InitializeWorldLayers(const std::vector<CWorldLayers::Area>& layers) {
void CScriptLayerManager::InitializeWorldLayers(const std::vector<CWorldLayers::Area>& layers) {
if (!x0_areaLayers.empty()) {
return;
}
@ -75,24 +75,24 @@ void CWorldLayerState::InitializeWorldLayers(const std::vector<CWorldLayers::Are
}
CWorldState::CWorldState(CAssetId id) : x0_mlvlId(id), x4_areaId(0) {
x8_relayTracker = std::make_shared<CScriptMailbox>();
x8_mailbox = std::make_shared<CScriptMailbox>();
xc_mapWorldInfo = std::make_shared<CMapWorldInfo>();
x10_desiredAreaAssetId = {};
x14_layerState = std::make_shared<CWorldLayerState>();
x14_layerState = std::make_shared<CScriptLayerManager>();
}
CWorldState::CWorldState(CBitStreamReader& reader, CAssetId mlvlId, const CSaveWorld& saveWorld) : x0_mlvlId(mlvlId) {
x4_areaId = TAreaId(reader.ReadEncoded(32));
x10_desiredAreaAssetId = u32(reader.ReadEncoded(32));
x8_relayTracker = std::make_shared<CScriptMailbox>(reader, saveWorld);
x8_mailbox = std::make_shared<CScriptMailbox>(reader, saveWorld);
xc_mapWorldInfo = std::make_shared<CMapWorldInfo>(reader, saveWorld, mlvlId);
x14_layerState = std::make_shared<CWorldLayerState>(reader, saveWorld);
x14_layerState = std::make_shared<CScriptLayerManager>(reader, saveWorld);
}
void CWorldState::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const {
writer.WriteEncoded(x4_areaId, 32);
writer.WriteEncoded(u32(x10_desiredAreaAssetId.Value()), 32);
x8_relayTracker->PutTo(writer, savw);
x8_mailbox->PutTo(writer, savw);
xc_mapWorldInfo->PutTo(writer, savw, x0_mlvlId);
x14_layerState->PutTo(writer);
}

View File

@ -17,14 +17,14 @@
namespace metaforce {
class CSaveWorldMemory;
class CWorldLayerState {
class CScriptLayerManager {
friend class CSaveWorldIntermediate;
std::vector<CWorldLayers::Area> x0_areaLayers;
DataSpec::WordBitmap x10_saveLayers;
public:
CWorldLayerState() = default;
CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& saveWorld);
CScriptLayerManager() = default;
CScriptLayerManager(CBitStreamReader& reader, const CSaveWorld& saveWorld);
bool IsLayerActive(int areaIdx, int layerIdx) const { return ((x0_areaLayers[areaIdx].m_layerBits >> layerIdx) & 1); }
@ -46,10 +46,10 @@ public:
class CWorldState {
CAssetId x0_mlvlId;
TAreaId x4_areaId = kInvalidAreaId;
std::shared_ptr<CScriptMailbox> x8_relayTracker;
std::shared_ptr<CScriptMailbox> x8_mailbox;
std::shared_ptr<CMapWorldInfo> xc_mapWorldInfo;
CAssetId x10_desiredAreaAssetId;
std::shared_ptr<CWorldLayerState> x14_layerState;
std::shared_ptr<CScriptLayerManager> x14_layerState;
public:
explicit CWorldState(CAssetId id);
@ -59,9 +59,9 @@ public:
TAreaId GetCurrentAreaId() const { return x4_areaId; }
CAssetId GetDesiredAreaAssetId() const { return x10_desiredAreaAssetId; }
void SetDesiredAreaAssetId(CAssetId id) { x10_desiredAreaAssetId = id; }
const std::shared_ptr<CScriptMailbox>& RelayTracker() const { return x8_relayTracker; }
const std::shared_ptr<CScriptMailbox>& Mailbox() const { return x8_mailbox; }
const std::shared_ptr<CMapWorldInfo>& MapWorldInfo() const { return xc_mapWorldInfo; }
const std::shared_ptr<CWorldLayerState>& GetLayerState() const { return x14_layerState; }
const std::shared_ptr<CScriptLayerManager>& GetLayerState() const { return x14_layerState; }
void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const;
};

View File

@ -1,17 +0,0 @@
#pragma once
#include "Runtime/CIOWin.hpp"
#include "Runtime/Graphics/CMoviePlayer.hpp"
namespace metaforce {
class CPlayMovieBase : public CIOWin {
CMoviePlayer x18_moviePlayer;
public:
CPlayMovieBase(const char* iowName, const char* path) : CIOWin(iowName), x18_moviePlayer(path, 0.0, false, false) {}
EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override { return EMessageReturn::Normal; }
void Draw() override {}
};
} // namespace metaforce

View File

@ -62,12 +62,12 @@ hecl::CVar* debugToolDrawPlatformCollision = nullptr;
hecl::CVar* sm_logScripting = nullptr;
} // namespace
logvisor::Module LogModule("metaforce::CStateManager");
CStateManager::CStateManager(const std::weak_ptr<CScriptMailbox>& relayTracker,
CStateManager::CStateManager(const std::weak_ptr<CScriptMailbox>& mailbox,
const std::weak_ptr<CMapWorldInfo>& mwInfo, const std::weak_ptr<CPlayerState>& playerState,
const std::weak_ptr<CWorldTransManager>& wtMgr,
const std::weak_ptr<CWorldLayerState>& layerState)
const std::weak_ptr<CScriptLayerManager>& layerState)
: x8b8_playerState(playerState)
, x8bc_relayTracker(relayTracker)
, x8bc_mailbox(mailbox)
, x8c0_mapWorldInfo(mwInfo)
, x8c4_worldTransManager(wtMgr)
, x8c8_worldLayerState(layerState) {
@ -2677,7 +2677,7 @@ void CStateManager::PrepareAreaUnload(TAreaId aid) {
}
void CStateManager::AreaLoaded(TAreaId aid) {
x8bc_relayTracker->SendMsgs(aid, *this);
x8bc_mailbox->SendMsgs(aid, *this);
x880_envFxManager->AreaLoaded();
}

View File

@ -52,7 +52,7 @@ class CRumbleManager;
class CSortedListManager;
class CTexture;
class CWorld;
class CWorldLayerState;
class CScriptLayerManager;
class CWorldTransManager;
struct CFinalInput;
@ -140,10 +140,10 @@ private:
std::map<TEditorId, SScriptObjectStream> x8a4_loadedScriptObjects;
std::shared_ptr<CPlayerState> x8b8_playerState;
std::shared_ptr<CScriptMailbox> x8bc_relayTracker;
std::shared_ptr<CScriptMailbox> x8bc_mailbox;
std::shared_ptr<CMapWorldInfo> x8c0_mapWorldInfo;
std::shared_ptr<CWorldTransManager> x8c4_worldTransManager;
std::shared_ptr<CWorldLayerState> x8c8_worldLayerState;
std::shared_ptr<CScriptLayerManager> x8c8_worldLayerState;
TAreaId x8cc_nextAreaId = 0;
TAreaId x8d0_prevAreaId = kInvalidAreaId;
@ -222,7 +222,7 @@ private:
public:
CStateManager(const std::weak_ptr<CScriptMailbox>&, const std::weak_ptr<CMapWorldInfo>&,
const std::weak_ptr<CPlayerState>&, const std::weak_ptr<CWorldTransManager>&,
const std::weak_ptr<CWorldLayerState>&);
const std::weak_ptr<CScriptLayerManager>&);
~CStateManager();
u32 GetInputFrameIdx() const { return x8d4_inputFrameIdx; }
@ -396,16 +396,16 @@ public:
const CEnvFxManager* GetEnvFxManager() const { return x880_envFxManager; }
CWorld* GetWorld() { return x850_world.get(); }
const CWorld* GetWorld() const { return x850_world.get(); }
CScriptMailbox* GetRelayTracker() { return x8bc_relayTracker.get(); }
const CScriptMailbox* GetRelayTracker() const { return x8bc_relayTracker.get(); }
CScriptMailbox* GetMailbox() { return x8bc_mailbox.get(); }
const CScriptMailbox* GetRelayTracker() const { return x8bc_mailbox.get(); }
CCameraManager* GetCameraManager() const { return x870_cameraManager; }
CFluidPlaneManager* GetFluidPlaneManager() const { return x87c_fluidPlaneManager; }
CActorModelParticles* GetActorModelParticles() const { return x884_actorModelParticles; }
const std::shared_ptr<CMapWorldInfo>& MapWorldInfo() const { return x8c0_mapWorldInfo; }
const std::shared_ptr<CWorldTransManager>& WorldTransManager() const { return x8c4_worldTransManager; }
const std::shared_ptr<CWorldLayerState>& WorldLayerState() const { return x8c8_worldLayerState; }
std::shared_ptr<CWorldLayerState>& WorldLayerState() { return x8c8_worldLayerState; }
const std::shared_ptr<CScriptLayerManager>& WorldLayerState() const { return x8c8_worldLayerState; }
std::shared_ptr<CScriptLayerManager>& WorldLayerState() { return x8c8_worldLayerState; }
CPlayer& GetPlayer() const { return *x84c_player; }
CPlayer* Player() const { return x84c_player.get(); }

View File

@ -65,7 +65,6 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) {
CGuiWidget::EGuiModelDrawFlags::Alpha),
zeus::CVector2i(0, 0));
x30_text.back().first->SetText(x18_creditsTable->GetString(i));
x30_text.back().first->SetOutlineColor(g_tweakGui->GetCreditsTextBorderColor());
}
// auto tmp = std::make_pair(std::make_unique<CGuiTextSupport>(
@ -103,7 +102,7 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) {
scaleY += (bounds.second.y - bounds.first.y);
}
x4c_ = float(scaleY + g_Viewport.xc_height); // * 0.5f;
x4c_ = float(scaleY + g_Viewport.xc_height - 896); // * 0.5f;
const float divVal = std::max(g_tweakGui->x310_, g_tweakGui->x30c_);
x50_ = x4c_ / (g_tweakGui->x308_ - divVal);
x14_ = 1;
@ -159,13 +158,13 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) {
}
x48_ = std::min(x4c_, (dt * x50_) + x48_);
if (x48_ >= x4c_ || x5c_24_) {
if (x48_ == x4c_ || x5c_24_) {
x5c_24_ = true;
x54_ = std::max(0.f, x54_ - dt);
const float alpha = x54_ / g_tweakGui->x30c_;
for (const auto& [text, offset] : x30_text) {
zeus::CColor col = zeus::skWhite;
col.a() = alpha;
col.a() *= alpha;
text->SetGeometryColor(col);
}
if (x54_ <= 0.f) {

View File

@ -329,7 +329,7 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg,
if (!x14_stateMgr) {
CWorldTransManager::WaitForModelsAndTextures();
CWorldState& wldState = g_GameState->CurrentWorldState();
x14_stateMgr = std::make_shared<CStateManager>(wldState.RelayTracker(), wldState.MapWorldInfo(),
x14_stateMgr = std::make_shared<CStateManager>(wldState.Mailbox(), wldState.MapWorldInfo(),
g_GameState->GetPlayerState(), wtMgr, wldState.GetLayerState());
}

View File

@ -2,14 +2,35 @@
namespace metaforce::MP1 {
const char* kMovies[] = {"Video/wingame.thp", "Video/wingame_best.thp", "Video/wingame_best.thp",
const char* kMovies[] = {"Video/wingame.thp", "Video/wingame_good.thp", "Video/wingame_best.thp",
"Video/losegame.thp", "Video/05_tallonText.thp", "Video/AfterCredits.thp",
"Video/SpecialEnding.thp", "Video/creditBG.thp"};
bool CPlayMovie::IsResultsScreen(EWhichMovie which) { return int(which) <= 2; }
CPlayMovie::CPlayMovie(EWhichMovie which) : CPlayMovieBase("CPlayMovie", kMovies[int(which)]), x18_which(which) {
(void)x18_which;
CPlayMovie::CPlayMovie(EWhichMovie which) : CIOWin("CPlayMovie"), x18_which(which) {}
CIOWin::EMessageReturn CPlayMovie::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) {
return EMessageReturn::RemoveIOWinAndExit;
}
void CPlayMovie::Draw() {
if (x14_ != 3) {
return;
}
DrawVideo();
if (x78_27_) {
x40_quitScreen->Draw();
} else if (x78_26_resultsScreen) {
DrawText();
}
}
void CPlayMovie::DrawVideo() {
}
void CPlayMovie::DrawText() {
}
} // namespace metaforce::MP1

View File

@ -1,25 +1,30 @@
#pragma once
#include "Runtime/CPlayMovieBase.hpp"
#include "Runtime/CIOWin.hpp"
#include "Runtime/Graphics/CMoviePlayer.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/MP1/CQuitGameScreen.hpp"
namespace metaforce::MP1 {
class CPlayMovie : public CPlayMovieBase {
class CPlayMovie : public CIOWin {
public:
enum class EWhichMovie {
WinGameBad,
WinGameGood,
WinGameBest,
LoseGame,
TalonTest,
TalonText,
AfterCredits,
SpecialEnding,
CreditBG
};
private:
s32 x14_ = 0;
EWhichMovie x18_which;
std::unique_ptr<CMoviePlayer> x38_moviePlayer;
std::unique_ptr<CQuitGameScreen> x40_quitScreen;
bool x78_24_ : 1 = false;
bool x78_25_ : 1 = false;
bool x78_26_resultsScreen : 1 = false;
@ -27,8 +32,13 @@ private:
static bool IsResultsScreen(EWhichMovie which);
void DrawVideo();
void DrawText();
public:
explicit CPlayMovie(EWhichMovie which);
EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override;
void Draw() override;
bool GetIsContinueDraw() const override { return false; }
};
} // namespace metaforce::MP1

View File

@ -27,14 +27,14 @@ CIOWin::EMessageReturn CStateSetterFlow::OnMessage(const CArchitectureMessage& m
g_GameState->SetCurrentWorldId(worldId);
CWorldState& ws = g_GameState->StateForWorld(worldId);
CWorldLayerState& layers = *ws.GetLayerState();
CScriptLayerManager& layers = *ws.GetLayerState();
if (m->m_warpAreaId < layers.GetAreaCount()) {
ws.SetAreaId(m->m_warpAreaId);
if (m->m_warpLayerBits) {
for (u32 i = 0; i < layers.GetAreaLayerCount(m->m_warpAreaId); ++i)
layers.SetLayerActive(m->m_warpAreaId, i, ((m->m_warpLayerBits >> i) & 1) != 0);
}
CScriptMailbox& relays = *ws.RelayTracker();
CScriptMailbox& relays = *ws.Mailbox();
for (const auto& r : m->m_warpMemoryRelays)
relays.AddMsg(r);
}

View File

@ -894,7 +894,7 @@ void CGameArea::Validate(CStateManager& mgr) {
}
void CGameArea::LoadScriptObjects(CStateManager& mgr) {
CWorldLayerState& layerState = *mgr.WorldLayerState();
CScriptLayerManager& layerState = *mgr.WorldLayerState();
u32 layerCount = layerState.GetAreaLayerCount(x4_selfIdx);
std::vector<TEditorId> objIds;
for (u32 i = 0; i < layerCount; ++i) {

View File

@ -22,10 +22,10 @@ void CScriptMemoryRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId obj
}
if (msg == EScriptObjectMessage::Deactivate) {
stateMgr.GetRelayTracker()->RemoveMsg(xc_editorId);
stateMgr.GetMailbox()->RemoveMsg(xc_editorId);
return;
} else if (msg == EScriptObjectMessage::Activate) {
stateMgr.GetRelayTracker()->AddMsg(xc_editorId);
stateMgr.GetMailbox()->AddMsg(xc_editorId);
if (!x34_25_skipSendActive) {
SendScriptMsgs(EScriptObjectState::Active, stateMgr, EScriptObjectMessage::None);
}

View File

@ -345,7 +345,7 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
if (msg == EScriptObjectMessage::Decrement || msg == EScriptObjectMessage::Increment) {
if (x1bc_areaSaveId != -1 && x1c0_layerIdx != -1) {
TAreaId aId = mgr.GetWorld()->GetAreaIdForSaveId(x1bc_areaSaveId);
std::shared_ptr<CWorldLayerState> worldLayerState;
std::shared_ptr<CScriptLayerManager> worldLayerState;
if (aId != kInvalidAreaId) {
worldLayerState = mgr.WorldLayerState();
} else {