From 12f23ba3409acbaf855bc4bcb7aa9b7b30b7f34c Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 16 Aug 2016 12:49:19 -1000 Subject: [PATCH] Several CWorldTransManager imps --- DataSpec/DNACommon/CMakeLists.txt | 3 +- DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp | 30 ++ DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp | 123 ++++++++ DataSpec/DNAMP1/CMakeLists.txt | 3 +- DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp | 2 +- DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp | 135 +++++++++ Runtime/CGameState.hpp | 4 +- Runtime/CPlayerState.hpp | 2 + Runtime/Character/CAnimPlaybackParms.hpp | 10 +- Runtime/Character/CCharacterFactory.hpp | 2 + Runtime/GameGlobalObjects.cpp | 1 + Runtime/GameGlobalObjects.hpp | 2 + Runtime/GuiSys/CGuiTextSupport.cpp | 2 +- Runtime/GuiSys/CGuiTextSupport.hpp | 9 +- Runtime/MP1/CMFGame.cpp | 4 +- Runtime/World/CWorldTransManager.cpp | 265 +++++++++++++++++- Runtime/World/CWorldTransManager.hpp | 107 +++---- 17 files changed, 634 insertions(+), 70 deletions(-) create mode 100644 DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp create mode 100644 DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp diff --git a/DataSpec/DNACommon/CMakeLists.txt b/DataSpec/DNACommon/CMakeLists.txt index 68d206994..47c5b2a4b 100644 --- a/DataSpec/DNACommon/CMakeLists.txt +++ b/DataSpec/DNACommon/CMakeLists.txt @@ -36,4 +36,5 @@ add_library(DNACommon Tweaks/ITweakPlayer.hpp Tweaks/ITweakPlayerControl.hpp Tweaks/ITweakPlayerGun.hpp - Tweaks/ITweakGunRes.hpp) + Tweaks/ITweakGunRes.hpp + Tweaks/ITweakPlayerRes.hpp) diff --git a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp index ce4535d82..dd4c23cf9 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp @@ -8,6 +8,15 @@ namespace DataSpec struct ITweakGunRes : BigYAML { + enum class EBeamId + { + Power, + Ice, + Plasma, + Wave, + Phazon + }; + virtual const std::string& GetGunMotion() const=0; virtual const std::string& GetGrappleArm() const=0; virtual const std::string& GetRightHand() const=0; @@ -58,6 +67,27 @@ struct ITweakGunRes : BigYAML virtual const std::string& GetGrappleHitParticle() const=0; virtual const std::string& GetGrappleMuzzleParticle() const=0; virtual const std::string& GetGrappleSwooshParticle() const=0; + + const std::string& GetBeamModel(EBeamId beam) const + { + int b = int(beam); + if (b < 0 || b > 4) + b = 0; + switch (EBeamId(b)) + { + case EBeamId::Power: + default: + return GetPowerBeam(); + case EBeamId::Ice: + return GetIceBeam(); + case EBeamId::Plasma: + return GetPlasmaBeam(); + case EBeamId::Wave: + return GetWaveBeam(); + case EBeamId::Phazon: + return GetPhazonBeam(); + } + } }; } diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp new file mode 100644 index 000000000..b6e076a59 --- /dev/null +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp @@ -0,0 +1,123 @@ +#ifndef __DNACOMMON_ITWEAKPLAYERRES_HPP__ +#define __DNACOMMON_ITWEAKPLAYERRES_HPP__ + +#include "../DNACommon.hpp" + +namespace DataSpec +{ + +struct ITweakPlayerRes : BigYAML +{ + enum class EBeamId + { + Power, + Ice, + Plasma, + Wave, + Phazon + }; + + virtual const std::string& GetSaveStationIcon() const=0; + virtual const std::string& GetMissileStationIcon() const=0; + virtual const std::string& GetElevatorIcon() const=0; + + virtual const std::string& GetMinesBreakFirstTopIcon() const=0; + virtual const std::string& GetMinesBreakFirstBottomIcon() const=0; + virtual const std::string& GetMinesBreakSecondTopIcon() const=0; + virtual const std::string& GetMinesBreakSecondBottomIcon() const=0; + + virtual const std::string& GetLStickN() const=0; + virtual const std::string& GetLStickU() const=0; + virtual const std::string& GetLStickUL() const=0; + virtual const std::string& GetLStickL() const=0; + virtual const std::string& GetLStickDL() const=0; + virtual const std::string& GetLStickD() const=0; + virtual const std::string& GetLStickDR() const=0; + virtual const std::string& GetLStickR() const=0; + virtual const std::string& GetLStickUR() const=0; + + virtual const std::string& GetCStickN() const=0; + virtual const std::string& GetCStickU() const=0; + virtual const std::string& GetCStickUL() const=0; + virtual const std::string& GetCStickL() const=0; + virtual const std::string& GetCStickDL() const=0; + virtual const std::string& GetCStickD() const=0; + virtual const std::string& GetCStickDR() const=0; + virtual const std::string& GetCStickR() const=0; + virtual const std::string& GetCStickUR() const=0; + + virtual const std::string& GetLTriggerOut() const=0; + virtual const std::string& GetLTriggerIn() const=0; + virtual const std::string& GetRTriggerOut() const=0; + virtual const std::string& GetRTriggerIn() const=0; + + virtual const std::string& GetStartButtonOut() const=0; + virtual const std::string& GetStartButtonIn() const=0; + virtual const std::string& GetAButtonOut() const=0; + virtual const std::string& GetAButtonIn() const=0; + virtual const std::string& GetBButtonOut() const=0; + virtual const std::string& GetBButtonIn() const=0; + virtual const std::string& GetXButtonOut() const=0; + virtual const std::string& GetXButtonIn() const=0; + virtual const std::string& GetYButtonOut() const=0; + virtual const std::string& GetYButtonIn() const=0; + + virtual const std::string& GetBallTransitionsANCS() const=0; + virtual const std::string& GetBallTransitionsPowerBeamModel() const=0; + virtual const std::string& GetBallTransitionsIceBeamModel() const=0; + virtual const std::string& GetBallTransitionsWaveBeamModel() const=0; + virtual const std::string& GetBallTransitionsPlasmaBeamModel() const=0; + virtual const std::string& GetBallTransitionsPhazonBeamModel() const=0; + + virtual const std::string& GetPowerBeamCineModel() const=0; + virtual const std::string& GetIceBeamCineModel() const=0; + virtual const std::string& GetWaveBeamCineModel() const=0; + virtual const std::string& GetPlasmaBeamCineModel() const=0; + virtual const std::string& GetPhazonBeamCineModel() const=0; + + const std::string& GetBeamBallTransitionModel(EBeamId beam) const + { + int b = int(beam); + if (b < 0 || b > 4) + b = 0; + switch (EBeamId(b)) + { + case EBeamId::Power: + default: + return GetBallTransitionsPowerBeamModel(); + case EBeamId::Ice: + return GetBallTransitionsIceBeamModel(); + case EBeamId::Plasma: + return GetBallTransitionsPlasmaBeamModel(); + case EBeamId::Wave: + return GetBallTransitionsWaveBeamModel(); + case EBeamId::Phazon: + return GetBallTransitionsPhazonBeamModel(); + } + } + + const std::string& GetBeamCineModel(EBeamId beam) const + { + int b = int(beam); + if (b < 0 || b > 4) + b = 0; + switch (EBeamId(b)) + { + case EBeamId::Power: + default: + return GetPowerBeamCineModel(); + case EBeamId::Ice: + return GetIceBeamCineModel(); + case EBeamId::Plasma: + return GetPlasmaBeamCineModel(); + case EBeamId::Wave: + return GetWaveBeamCineModel(); + case EBeamId::Phazon: + return GetPhazonBeamCineModel(); + } + } +}; + +} + +#endif // __DNACOMMON_ITWEAKPLAYERRES_HPP__ diff --git a/DataSpec/DNAMP1/CMakeLists.txt b/DataSpec/DNAMP1/CMakeLists.txt index 3b55beaa3..da87902b3 100644 --- a/DataSpec/DNAMP1/CMakeLists.txt +++ b/DataSpec/DNAMP1/CMakeLists.txt @@ -21,7 +21,8 @@ make_dnalist(liblist Tweaks/CTweakPlayer Tweaks/CTweakPlayerControl Tweaks/CTweakPlayerGun - Tweaks/CTweakGunRes) + Tweaks/CTweakGunRes + Tweaks/CTweakPlayerRes) add_library(DNAMP1 DNAMP1.hpp DNAMP1.cpp diff --git a/DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp b/DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp index c6f31b596..b20de0fad 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp @@ -8,7 +8,7 @@ namespace DataSpec namespace DNAMP1 { -struct CTweakPlayerGun : ITweakGunRes +struct CTweakGunRes : ITweakGunRes { DECL_YAML diff --git a/DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp b/DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp new file mode 100644 index 000000000..5ade36405 --- /dev/null +++ b/DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp @@ -0,0 +1,135 @@ +#ifndef _DNAMP1_CTWEAKPLAYERRES_HPP_ +#define _DNAMP1_CTWEAKPLAYERRES_HPP_ + +#include "../../DNACommon/Tweaks/ITweakPlayerRes.hpp" + +namespace DataSpec +{ +namespace DNAMP1 +{ + +struct CTweakPlayerRes : ITweakPlayerRes +{ + DECL_YAML + + String<-1> m_saveStationIcon; + String<-1> m_missileStationIcon; + String<-1> m_elevatorIcon; + + String<-1> m_minesBreakFirstTopIcon; + String<-1> m_minesBreakFirstBottomIcon; + String<-1> m_minesBreakSecondTopIcon; + String<-1> m_minesBreakSecondBottomIcon; + + String<-1> m_lStickN; + String<-1> m_lStickU; + String<-1> m_lStickUL; + String<-1> m_lStickL; + String<-1> m_lStickDL; + String<-1> m_lStickD; + String<-1> m_lStickDR; + String<-1> m_lStickR; + String<-1> m_lStickUR; + + String<-1> m_cStickN; + String<-1> m_cStickU; + String<-1> m_cStickUL; + String<-1> m_cStickL; + String<-1> m_cStickDL; + String<-1> m_cStickD; + String<-1> m_cStickDR; + String<-1> m_cStickR; + String<-1> m_cStickUR; + + String<-1> m_lTriggerOut; + String<-1> m_lTriggerIn; + String<-1> m_rTriggerOut; + String<-1> m_rTriggerIn; + + String<-1> m_startButtonOut; + String<-1> m_startButtonIn; + String<-1> m_aButtonOut; + String<-1> m_aButtonIn; + String<-1> m_bButtonOut; + String<-1> m_bButtonIn; + String<-1> m_xButtonOut; + String<-1> m_xButtonIn; + String<-1> m_yButtonOut; + String<-1> m_yButtonIn; + + String<-1> m_ballTransitionsANCS; + String<-1> m_ballTransitionsPower; + String<-1> m_ballTransitionsIce; + String<-1> m_ballTransitionsWave; + String<-1> m_ballTransitionsPlasma; + String<-1> m_ballTransitionsPhazon; + + String<-1> m_cinePower; + String<-1> m_cineIce; + String<-1> m_cineWave; + String<-1> m_cinePlasma; + String<-1> m_cinePhazon; + + const std::string& GetSaveStationIcon() const { return m_saveStationIcon; } + const std::string& GetMissileStationIcon() const { return m_missileStationIcon; } + const std::string& GetElevatorIcon() const { return m_elevatorIcon; } + + const std::string& GetMinesBreakFirstTopIcon() const { return m_minesBreakFirstTopIcon; } + const std::string& GetMinesBreakFirstBottomIcon() const { return m_minesBreakFirstBottomIcon; } + const std::string& GetMinesBreakSecondTopIcon() const { return m_minesBreakSecondTopIcon; } + const std::string& GetMinesBreakSecondBottomIcon() const { return m_minesBreakSecondBottomIcon; } + + const std::string& GetLStickN() const { return m_lStickN; } + const std::string& GetLStickU() const { return m_lStickU; } + const std::string& GetLStickUL() const { return m_lStickUL; } + const std::string& GetLStickL() const { return m_lStickL; } + const std::string& GetLStickDL() const { return m_lStickDL; } + const std::string& GetLStickD() const { return m_lStickD; } + const std::string& GetLStickDR() const { return m_lStickDR; } + const std::string& GetLStickR() const { return m_lStickR; } + const std::string& GetLStickUR() const { return m_lStickUR; } + + const std::string& GetCStickN() const { return m_cStickN; } + const std::string& GetCStickU() const { return m_cStickU; } + const std::string& GetCStickUL() const { return m_cStickUL; } + const std::string& GetCStickL() const { return m_cStickL; } + const std::string& GetCStickDL() const { return m_cStickDL; } + const std::string& GetCStickD() const { return m_cStickD; } + const std::string& GetCStickDR() const { return m_cStickDR; } + const std::string& GetCStickR() const { return m_cStickR; } + const std::string& GetCStickUR() const { return m_cStickUR; } + + const std::string& GetLTriggerOut() const { return m_lTriggerOut; } + const std::string& GetLTriggerIn() const { return m_lTriggerIn; } + const std::string& GetRTriggerOut() const { return m_rTriggerOut; } + const std::string& GetRTriggerIn() const { return m_rTriggerIn; } + + const std::string& GetStartButtonOut() const { return m_startButtonOut; } + const std::string& GetStartButtonIn() const { return m_startButtonIn; } + const std::string& GetAButtonOut() const { return m_aButtonOut; } + const std::string& GetAButtonIn() const { return m_aButtonIn; } + const std::string& GetBButtonOut() const { return m_bButtonOut; } + const std::string& GetBButtonIn() const { return m_bButtonIn; } + const std::string& GetXButtonOut() const { return m_xButtonOut; } + const std::string& GetXButtonIn() const { return m_xButtonIn; } + const std::string& GetYButtonOut() const { return m_yButtonOut; } + const std::string& GetYButtonIn() const { return m_yButtonIn; } + + const std::string& GetBallTransitionsANCS() const { return m_ballTransitionsANCS; } + const std::string& GetBallTransitionsPowerBeamModel() const { return m_ballTransitionsPower; } + const std::string& GetBallTransitionsIceBeamModel() const { return m_ballTransitionsIce; } + const std::string& GetBallTransitionsWaveBeamModel() const { return m_ballTransitionsWave; } + const std::string& GetBallTransitionsPlasmaBeamModel() const { return m_ballTransitionsPlasma; } + const std::string& GetBallTransitionsPhazonBeamModel() const { return m_ballTransitionsPhazon; } + + const std::string& GetPowerBeamCineModel() const { return m_cinePower; } + const std::string& GetIceBeamCineModel() const { return m_cineIce; } + const std::string& GetWaveBeamCineModel() const { return m_cineWave; } + const std::string& GetPlasmaBeamCineModel() const { return m_cinePlasma; } + const std::string& GetPhazonBeamCineModel() const { return m_cinePhazon; } +}; + +} +} + +#endif // _DNAMP1_CTWEAKPLAYERRES_HPP_ diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index 974b21402..9a15f203b 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -47,8 +47,8 @@ public: CGameState(); CGameState(CBitStreamReader& stream); void SetCurrentWorldId(unsigned int id, const std::string& name); - std::shared_ptr PlayerState() {return x98_playerState;} - std::shared_ptr WorldTransitionManager() {return x9c_transManager;} + std::shared_ptr GetPlayerState() {return x98_playerState;} + std::shared_ptr GetWorldTransitionManager() {return x9c_transManager;} void SetTotalPlayTime(float time); CWorldState& StateForWorld(ResId mlvlId); CWorldState& CurrentWorldState() { return StateForWorld(x84_mlvlId); } diff --git a/Runtime/CPlayerState.hpp b/Runtime/CPlayerState.hpp index c23a23e13..4825ad5b8 100644 --- a/Runtime/CPlayerState.hpp +++ b/Runtime/CPlayerState.hpp @@ -13,6 +13,7 @@ namespace urde class CPlayerState { + friend class CWorldTransManager; public: enum class EItemType : u32 { @@ -134,6 +135,7 @@ public: void SetFusion(bool val) { x0_26_fusion = val; } bool GetFusion() const { return x0_26_fusion; } EPlayerSuit GetCurrentSuit() const; + EBeamId GetCurrentBeam() const { return x8_currentBeam; } bool CanVisorSeeFog(const CStateManager& stateMgr) const; EPlayerVisor GetActiveVisor(const CStateManager& stateMgr) const; void UpdateStaticInterference(CStateManager& stateMgr, const float& dt); diff --git a/Runtime/Character/CAnimPlaybackParms.hpp b/Runtime/Character/CAnimPlaybackParms.hpp index eb0bb42a6..ad80f3f50 100644 --- a/Runtime/Character/CAnimPlaybackParms.hpp +++ b/Runtime/Character/CAnimPlaybackParms.hpp @@ -7,10 +7,10 @@ namespace urde { class CAnimPlaybackParms { - s32 x0_; + s32 x0_defaultAnim; s32 x4_; - float x8_; - bool xc_; + float x8_scale; + bool xc_loop; s32 x10_ = 0; s32 x14_ = 0; bool x18_ = false; @@ -18,8 +18,8 @@ class CAnimPlaybackParms s32 x20_ = 0; s32 x24_ = 0; public: - CAnimPlaybackParms(s32 a, s32 b, float c, bool d) - : x0_(a), x4_(b), x8_(c), xc_(d) + CAnimPlaybackParms(s32 defaultAnim, s32 b, float scale, bool loop) + : x0_defaultAnim(defaultAnim), x4_(b), x8_scale(scale), xc_loop(loop) {} }; } diff --git a/Runtime/Character/CCharacterFactory.hpp b/Runtime/Character/CCharacterFactory.hpp index 32abbc407..807398771 100644 --- a/Runtime/Character/CCharacterFactory.hpp +++ b/Runtime/Character/CCharacterFactory.hpp @@ -66,6 +66,8 @@ public: const TLockedToken& factory, int defaultAnim) const; ResId GetEventResourceIdForAnimResourceId(ResId animId) const; + + const CCharacterInfo& GetCharInfo(int charIdx) const { return x4_charInfoDB[charIdx]; } }; } diff --git a/Runtime/GameGlobalObjects.cpp b/Runtime/GameGlobalObjects.cpp index 8222f163b..5263eff46 100644 --- a/Runtime/GameGlobalObjects.cpp +++ b/Runtime/GameGlobalObjects.cpp @@ -21,5 +21,6 @@ DataSpec::ITweakPlayer* g_tweakPlayer = nullptr; DataSpec::ITweakPlayerControl* g_tweakPlayerControl = nullptr; DataSpec::ITweakPlayerGun* g_tweakPlayerGun = nullptr; DataSpec::ITweakGunRes* g_tweakGunRes = nullptr; +DataSpec::ITweakPlayerRes* g_tweakPlayerRes = nullptr; } diff --git a/Runtime/GameGlobalObjects.hpp b/Runtime/GameGlobalObjects.hpp index b6f9de81b..3c8284b9a 100644 --- a/Runtime/GameGlobalObjects.hpp +++ b/Runtime/GameGlobalObjects.hpp @@ -5,6 +5,7 @@ #include "../DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp" #include "../DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp" #include "../DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp" +#include "../DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp" #include "AutoMapper/ITweakAutoMapper.hpp" #include "GuiSys/ITweakGui.hpp" @@ -29,6 +30,7 @@ extern DataSpec::ITweakPlayer* g_tweakPlayer; extern DataSpec::ITweakPlayerControl* g_tweakPlayerControl; extern DataSpec::ITweakPlayerGun* g_tweakPlayerGun; extern DataSpec::ITweakGunRes* g_tweakGunRes; +extern DataSpec::ITweakPlayerRes* g_tweakPlayerRes; extern ITweakAutoMapper* g_tweakAutoMapper; extern ITweakGui* g_tweakGui; diff --git a/Runtime/GuiSys/CGuiTextSupport.cpp b/Runtime/GuiSys/CGuiTextSupport.cpp index b61919c82..f5918ab53 100644 --- a/Runtime/GuiSys/CGuiTextSupport.cpp +++ b/Runtime/GuiSys/CGuiTextSupport.cpp @@ -106,7 +106,7 @@ void CGuiTextSupport::CheckAndRebuildTextRenderBuffer() g_TextExecuteBuf->Clear(); g_TextExecuteBuf->x18_textState.x48_enableWordWrap = x14_props.x0_wordWrap; - g_TextExecuteBuf->BeginBlock(0, 0, x34_extentX, x38_extentY, ETextDirection(x14_props.x1_vertical), + g_TextExecuteBuf->BeginBlock(0, 0, x34_extentX, x38_extentY, x14_props.xc_direction, x14_props.x4_justification, x14_props.x8_vertJustification); g_TextExecuteBuf->AddColor(EColorType::Main, x24_fontColor); g_TextExecuteBuf->AddColor(EColorType::Outline, x28_outlineColor); diff --git a/Runtime/GuiSys/CGuiTextSupport.hpp b/Runtime/GuiSys/CGuiTextSupport.hpp index 7410a0f34..f47f36954 100644 --- a/Runtime/GuiSys/CGuiTextSupport.hpp +++ b/Runtime/GuiSys/CGuiTextSupport.hpp @@ -61,14 +61,15 @@ class CGuiTextProperties { friend class CGuiTextSupport; bool x0_wordWrap; - bool x1_vertical; + bool x1_multiline; EJustification x4_justification; EVerticalJustification x8_vertJustification; ETextDirection xc_direction; public: - CGuiTextProperties(bool wordWrap, bool vertical, EJustification justification, - EVerticalJustification vertJustification, ETextDirection dir) - : x0_wordWrap(wordWrap), x1_vertical(vertical), x4_justification(justification), + CGuiTextProperties(bool wordWrap, bool multiline, EJustification justification, + EVerticalJustification vertJustification, + ETextDirection dir=ETextDirection::Horizontal) + : x0_wordWrap(wordWrap), x1_multiline(multiline), x4_justification(justification), x8_vertJustification(vertJustification), xc_direction(dir) {} }; diff --git a/Runtime/MP1/CMFGame.cpp b/Runtime/MP1/CMFGame.cpp index 0914ec3f7..740463ebc 100644 --- a/Runtime/MP1/CMFGame.cpp +++ b/Runtime/MP1/CMFGame.cpp @@ -29,7 +29,7 @@ CMFGameLoader::CMFGameLoader() CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) { - std::shared_ptr wtMgr = g_GameState->WorldTransitionManager(); + std::shared_ptr wtMgr = g_GameState->GetWorldTransitionManager(); switch (msg.GetType()) { @@ -44,7 +44,7 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg, void CMFGameLoader::Draw() const { - g_GameState->WorldTransitionManager()->Draw(); + g_GameState->GetWorldTransitionManager()->Draw(); } } diff --git a/Runtime/World/CWorldTransManager.cpp b/Runtime/World/CWorldTransManager.cpp index eb567cca7..cb9607620 100644 --- a/Runtime/World/CWorldTransManager.cpp +++ b/Runtime/World/CWorldTransManager.cpp @@ -2,10 +2,148 @@ #include "GuiSys/CGuiTextSupport.hpp" #include "CSimplePool.hpp" #include "GameGlobalObjects.hpp" +#include "CGameState.hpp" +#include "Character/CAnimPlaybackParms.hpp" +#include "Character/CAssetFactory.hpp" +#include "Character/CCharacterFactory.hpp" +#include "Character/IAnimReader.hpp" namespace urde { +int CWorldTransManager::GetSuitCharSet() +{ + CPlayerState& state = *g_GameState->GetPlayerState(); + if (state.GetFusion()) + { + switch (state.x20_currentSuit) + { + case CPlayerState::EPlayerSuit::Power: + return 4; + case CPlayerState::EPlayerSuit::Gravity: + return 6; + case CPlayerState::EPlayerSuit::Varia: + return 7; + case CPlayerState::EPlayerSuit::Phazon: + return 8; + default: break; + } + } + return int(state.x20_currentSuit); +} + +CWorldTransManager::SModelDatas::SModelDatas(const CAnimRes& samusRes) +: x0_samusRes(samusRes) +{ + x1a0_lights.reserve(8); +} + +void CWorldTransManager::UpdateLights(float dt) +{ + if (!x4_modelData) + return; + + x4_modelData->x1a0_lights.clear(); + zeus::CVector3f lightPos(0.f, 10.f, 0.f); + CLight spot = CLight::BuildSpot(lightPos, zeus::kBackVec, zeus::CColor::skWhite, 90.f); + spot.SetAttenuation(1.f, 0.f, 0.f); + + CLight s1 = spot; + s1.SetPosition(lightPos + zeus::CVector3f{0.f, 0.f, 2.f * x18_bgOffset - x1c_bgHeight}); + + float z = 1.f; + float delta = x1c_bgHeight - x18_bgOffset; + if (!x44_26_goingUp && delta < 2.f) + z = delta * 0.5f; + else if (x44_26_goingUp && x18_bgOffset < 2.f) + z = x18_bgOffset * 0.5f; + + if (z < 1.f) + { + CLight s2 = spot; + float pos = x44_26_goingUp ? x1c_bgHeight : -x1c_bgHeight; + s2.SetPosition(lightPos + zeus::CVector3f{0.f, 0.f, pos}); + s2.SetColor(zeus::CColor::lerp(zeus::CColor::skBlack, zeus::CColor::skWhite, 1.f - z)); + x4_modelData->x1a0_lights.push_back(std::move(s2)); + s1.SetColor(zeus::CColor::lerp(zeus::CColor::skBlack, zeus::CColor::skWhite, z)); + } + + x4_modelData->x1a0_lights.push_back(std::move(s1)); +} + +void CWorldTransManager::UpdateDisabled(float) +{ + if (x0_curTime <= 2.f) + return; + x44_24_dissolveComplete = true; +} + +void CWorldTransManager::UpdateEnabled(float dt) +{ + if (x4_modelData && !x4_modelData->x1c_samusModelData.IsNull()) + { + if (x44_25_stopSoon && !x4_modelData->x1dc_dissolveStarted && x0_curTime > 2.f) + { + x4_modelData->x1dc_dissolveStarted = true; + x4_modelData->x1d0_dissolveStartTime = x0_curTime; + x4_modelData->x1d4_relativeDissolveStartTime = 4.f + x0_curTime - 2.f; + x4_modelData->x1d8_relativeDissolveEndTime = 5.f + x0_curTime - 2.f; + } + + if (x0_curTime > x4_modelData->x1d8_relativeDissolveEndTime && x4_modelData->x1dc_dissolveStarted) + x44_24_dissolveComplete = true; + + x4_modelData->x1c_samusModelData.AdvanceAnimationIgnoreParticles(dt, x20_random, true); + x4_modelData->x170_gunXf = x4_modelData->x1c_samusModelData.GetScaledLocatorTransform("GUN_LCTR"); + + x4_modelData->x1c4_randTimeout -= dt; + + if (x4_modelData->x1c4_randTimeout <= 0.f) + { + x4_modelData->x1c4_randTimeout = x20_random.Range(0.016666668f, 0.1f); + zeus::CVector2f randVec(x20_random.Range(-0.025f, 0.025f), x20_random.Range(-0.075f, 0.075f)); + x4_modelData->x1bc_shakeDelta = (randVec - x4_modelData->x1b4_shakeResult) / x4_modelData->x1c4_randTimeout; + x4_modelData->x1cc_blurDelta = (x20_random.Range(-2.f, 4.f) - x4_modelData->x1c8_blurResult) / x4_modelData->x1c4_randTimeout; + } + + x4_modelData->x1b4_shakeResult += x4_modelData->x1bc_shakeDelta * dt; + x4_modelData->x1c8_blurResult += dt * x4_modelData->x1cc_blurDelta; + } + + float delta = dt * 50.f; + if (x44_26_goingUp) + delta = -delta; + + x18_bgOffset += delta; + if (x18_bgOffset > x1c_bgHeight) + x18_bgOffset -= x1c_bgHeight; + if (x18_bgOffset < 0.f) + x18_bgOffset += x1c_bgHeight; + + UpdateLights(dt); +} + +void CWorldTransManager::UpdateText(float) +{ +} + +void CWorldTransManager::Update(float dt) +{ + x0_curTime += dt; + switch (x30_type) + { + case ETransType::Disabled: + UpdateDisabled(dt); + break; + case ETransType::Enabled: + UpdateEnabled(dt); + break; + case ETransType::Text: + UpdateText(dt); + break; + } +} + void CWorldTransManager::DrawEnabled() const { } @@ -14,12 +152,108 @@ void CWorldTransManager::DrawDisabled() const { } -void CWorldTransManager::StartTextTransition(ResId fontId, ResId stringId, bool b1, bool b2, - float chFadeTime, float chFadeRate, float f3) +void CWorldTransManager::Draw() const +{ + if (x30_type == ETransType::Disabled) + DrawDisabled(); + else if (x30_type == ETransType::Enabled) + DrawEnabled(); + else if (x30_type == ETransType::Text) + DrawText(); +} + +void CWorldTransManager::TouchModels() +{ + if (!x4_modelData) + return; + + if (x4_modelData->x14c_beamModel.IsLoaded() && + x4_modelData->x14c_beamModel.GetObj()) + { + x4_modelData->x68_beamModelData = CStaticRes(x4_modelData->x14c_beamModel.GetObjectTag()->id, + x4_modelData->x0_samusRes.GetScale()); + } + + if (x4_modelData->x158_suitModel.IsLoaded() && + x4_modelData->x158_suitModel.GetObj() && + x4_modelData->x164_suitSkin.IsLoaded() && + x4_modelData->x164_suitSkin.GetObj()) + { + CAnimRes animRes(x4_modelData->x0_samusRes.GetId(), GetSuitCharSet(), + x4_modelData->x0_samusRes.GetScale(), x4_modelData->x0_samusRes.GetDefaultAnim(), + true); + x4_modelData->x1c_samusModelData = animRes; + + CAnimPlaybackParms aData(animRes.GetDefaultAnim(), -1, 1.f, true); + x4_modelData->x1c_samusModelData.AnimationData()->SetAnimation(aData, false); + } + + if (x4_modelData->x1c_samusModelData.IsNull()) + x4_modelData->x1c_samusModelData.Touch(CModelData::EWhichModel::Normal, 0); + + if (x4_modelData->xb4_platformModelData.IsNull()) + x4_modelData->xb4_platformModelData.Touch(CModelData::EWhichModel::Normal, 0); + + if (x4_modelData->x100_bgModelData.IsNull()) + x4_modelData->x100_bgModelData.Touch(CModelData::EWhichModel::Normal, 0); + + if (x4_modelData->x68_beamModelData.IsNull()) + x4_modelData->x68_beamModelData.Touch(CModelData::EWhichModel::Normal, 0); +} + +void CWorldTransManager::EnableTransition(const CAnimRes& samusRes, + ResId platRes, const zeus::CVector3f& platScale, + ResId bgRes, const zeus::CVector3f& bgScale, bool goingUp) +{ + x44_25_stopSoon = false; + x44_26_goingUp = goingUp; + x30_type = ETransType::Enabled; + x4_modelData.reset(new SModelDatas(samusRes)); + + x8_textData.reset(); + x20_random.SetSeed(99); + + x4_modelData->x1c_samusModelData = CModelData(samusRes); + + CAnimPlaybackParms aData(samusRes.GetDefaultAnim(), -1, 1.f, true); + x4_modelData->x1c_samusModelData.AnimationData()->SetAnimation(aData, false); + + const std::string& modelName = g_tweakPlayerRes->GetBeamCineModel( + DataSpec::ITweakPlayerRes::EBeamId(g_GameState->GetPlayerState()->GetCurrentBeam())); + + x4_modelData->x14c_beamModel = g_SimplePool->GetObj(modelName.c_str()); + + TToken fac = g_CharFactoryBuilder->GetFactory(samusRes); + const CCharacterInfo& info = fac.GetObj()->GetCharInfo(GetSuitCharSet()); + x4_modelData->x158_suitModel = g_SimplePool->GetObj(SObjectTag{FOURCC('CMDL'), info.GetModelId()}); + x4_modelData->x164_suitSkin = g_SimplePool->GetObj(SObjectTag{FOURCC('CSKR'), info.GetSkinRulesId()}); + + if (platRes != -1) + { + x4_modelData->xb4_platformModelData = CStaticRes(platRes, platScale); + x4_modelData->xb4_platformModelData.Touch(CModelData::EWhichModel::Normal, 0); + } + + if (bgRes != -1) + { + x4_modelData->x100_bgModelData = CStaticRes(bgRes, bgScale); + x4_modelData->x100_bgModelData.Touch(CModelData::EWhichModel::Normal, 0); + zeus::CAABox bounds = x4_modelData->x100_bgModelData.GetBounds(); + x1c_bgHeight = (bounds.max.z - bounds.min.z) * bgScale.z; + } + else + x1c_bgHeight = 0.f; + + StartTransition(); + TouchModels(); +} + +void CWorldTransManager::EnableTransition(ResId fontId, ResId stringId, bool b1, bool b2, + float chFadeTime, float chFadeRate, float f3) { x40_ = b1; x38_ = f3; - x44_25_ = false; + x44_25_stopSoon = false; x30_type = ETransType::Text; x4_modelData.reset(); @@ -37,4 +271,29 @@ void CWorldTransManager::StartTextTransition(ResId fontId, ResId stringId, bool StartTransition(); } +void CWorldTransManager::DisableTransition() +{ + x4_modelData.reset(); + x8_textData.reset(); + x44_26_goingUp = false; +} + +void CWorldTransManager::StartTransition() +{ + x0_curTime = 0.f; + x18_bgOffset = 0.f; + x44_24_dissolveComplete = false; + x44_28_ = true; +} + +void CWorldTransManager::EndTransition() +{ + DisableTransition(); +} + +void CWorldTransManager::DrawText() const +{ + +} + } diff --git a/Runtime/World/CWorldTransManager.hpp b/Runtime/World/CWorldTransManager.hpp index 2ee4f8d07..a7881c08c 100644 --- a/Runtime/World/CWorldTransManager.hpp +++ b/Runtime/World/CWorldTransManager.hpp @@ -5,6 +5,7 @@ #include "CRandom16.hpp" #include "Character/CModelData.hpp" #include "GuiSys/CGuiTextSupport.hpp" +#include "Graphics/CLight.hpp" namespace urde { @@ -16,90 +17,96 @@ class CWorldTransManager public: enum class ETransType { - Blank, - LiftScene, + Disabled, + Enabled, Text }; - struct CWorldTransModelData + struct SModelDatas { - CModelData x1c_; - CModelData x68_; - CModelData xb4_; - CModelData x100_; - CToken x14c_; - CToken x158_; - CToken x164_; - std::vector x1a0_; - std::unique_ptr x1b0_; + CAnimRes x0_samusRes; + CModelData x1c_samusModelData; + CModelData x68_beamModelData; + CModelData xb4_platformModelData; + CModelData x100_bgModelData; + TLockedToken x14c_beamModel; + TLockedToken x158_suitModel; + TLockedToken x164_suitSkin; + zeus::CTransform x170_gunXf; + std::vector x1a0_lights; + //std::unique_ptr x1b0_dissolveTextureBuffer; + zeus::CVector2f x1b4_shakeResult; + zeus::CVector2f x1bc_shakeDelta; + float x1c4_randTimeout = 0.f; + float x1c8_blurResult = 0.f; + float x1cc_blurDelta = 0.f; + float x1d0_dissolveStartTime = 99999.f; + float x1d4_relativeDissolveStartTime = 99999.f; + float x1d8_relativeDissolveEndTime = 99999.f; + bool x1dc_dissolveStarted = false; + + SModelDatas(const CAnimRes& samusRes); }; private: - float x0_ = 0.f; - std::unique_ptr x4_modelData; + float x0_curTime = 0.f; + std::unique_ptr x4_modelData; std::unique_ptr x8_textData; TLockedToken xc_strTable; u8 x14_ = 0; - float x18_; - CRandom16 x20_ = CRandom16(99); + float x18_bgOffset; + float x1c_bgHeight; + CRandom16 x20_random = CRandom16(99); u16 x24_ = 1189; u32 x28_ = 0; u8 x2c_ = 127; u8 x2d_ = 64; - ETransType x30_type = ETransType::Blank; + ETransType x30_type = ETransType::Disabled; float x38_ = 0.f; bool x40_; union { struct { - bool x44_24_ : 1; - bool x44_25_ : 1; - bool x44_26_ : 1; + bool x44_24_dissolveComplete : 1; + bool x44_25_stopSoon : 1; + bool x44_26_goingUp : 1; bool x44_27_ : 1; bool x44_28_ : 1; }; u8 dummy = 0; }; + + static int GetSuitCharSet(); + public: - CWorldTransManager() : x44_24_(true) {} + CWorldTransManager() : x44_24_dissolveComplete(true) {} void DrawFirstPass() const {} void DrawSecondPass() const {} void DrawAllModels() const {} - void UpdateLights(float) {} - void UpdateEnabled(float) {} - void UpdateDisabled(float) {} - void Update(float) {} + void UpdateLights(float dt); + void UpdateEnabled(float); + void UpdateDisabled(float); + void UpdateText(float); + void Update(float); void DrawEnabled() const; void DrawDisabled() const; - void sub_80209280() const {} - void Draw() const - { - if (x30_type == ETransType::Blank) - DrawDisabled(); - else if (x30_type == ETransType::LiftScene) - DrawEnabled(); - else if (x30_type == ETransType::Text) - sub_80209280(); - } + void DrawText() const; + void Draw() const; - void StartTransition() - { - x0_ = 0.f; - x18_ = 0.f; - x44_24_ = false; - x44_28_ = true; - } + void EnableTransition(const CAnimRes& samusRes, + ResId platRes, const zeus::CVector3f& platScale, + ResId bgRes, const zeus::CVector3f& bgScale, bool goingUp); + void EnableTransition(ResId fontId, ResId stringId, bool b1, bool b2, + float chFadeTime, float chFadeRate, float f3); - void StartTextTransition(ResId fontId, ResId stringId, bool, bool, float, float, float); - - void EndTransition() {} - void PleaseStopSoon() {} - bool IsTransitionEnabled() const { return false; } - void DisableTransition() {} - void TouchModels() {} - void EnableTransition() {} + void StartTransition(); + void EndTransition(); + void PleaseStopSoon() { x44_25_stopSoon = true; } + bool IsTransitionEnabled() const { return x30_type != ETransType::Disabled; } + void DisableTransition(); + void TouchModels(); }; }