mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #113 from lioncash/artifact
CArtifactDoll: Minor changes
This commit is contained in:
commit
5865552d7f
|
@ -1,12 +1,21 @@
|
|||
#include "CArtifactDoll.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "CSimplePool.hpp"
|
||||
#include "CStateManager.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/MP1/CArtifactDoll.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CTransform.hpp>
|
||||
|
||||
namespace urde::MP1 {
|
||||
|
||||
static const char* ArtifactPieceModels[] = {
|
||||
namespace {
|
||||
constexpr std::array ArtifactPieceModels{
|
||||
"CMDL_Piece1", // Truth
|
||||
"CMDL_Piece2", // Strength
|
||||
"CMDL_Piece3", // Elder
|
||||
|
@ -21,7 +30,7 @@ static const char* ArtifactPieceModels[] = {
|
|||
"CMDL_Piece12" // Newborn
|
||||
};
|
||||
|
||||
static const CAssetId ArtifactHeadScans[] = {
|
||||
constexpr std::array<CAssetId, 12> ArtifactHeadScans{
|
||||
0x32C9DDCE, // Truth
|
||||
0xB45DAF60, // Strength
|
||||
0x7F017CC5, // Elder
|
||||
|
@ -36,36 +45,43 @@ static const CAssetId ArtifactHeadScans[] = {
|
|||
0xB6763C91 // Newborn
|
||||
};
|
||||
|
||||
static const zeus::CColor ArtifactPreColor = {0.4f, 0.68f, 0.88f, 0.8f};
|
||||
static const zeus::CColor ArtifactPostColor = {1.f, 0.63f, 0.02f, 1.f};
|
||||
constexpr zeus::CColor ArtifactPreColor{0.4f, 0.68f, 0.88f, 0.8f};
|
||||
constexpr zeus::CColor ArtifactPostColor{1.f, 0.63f, 0.02f, 1.f};
|
||||
} // Anonymous namespace
|
||||
|
||||
CArtifactDoll::CArtifactDoll() {
|
||||
x10_lights.resize(2, CLight::BuildDirectional(zeus::skForward, zeus::skWhite));
|
||||
x20_actorLights = std::make_unique<CActorLights>(8, zeus::skZero3f, 4, 4, false, false, false, 0.1f);
|
||||
x28_24_loaded = false;
|
||||
x0_models.reserve(12);
|
||||
for (int i = 0; i < 12; ++i)
|
||||
x0_models.push_back(g_SimplePool->GetObj(ArtifactPieceModels[i]));
|
||||
x0_models.reserve(ArtifactPieceModels.size());
|
||||
for (const char* const model : ArtifactPieceModels) {
|
||||
x0_models.emplace_back(g_SimplePool->GetObj(model));
|
||||
}
|
||||
}
|
||||
|
||||
int CArtifactDoll::GetArtifactHeadScanIndex(CAssetId scanId) {
|
||||
for (int i = 0; i < 12; ++i)
|
||||
if (ArtifactHeadScans[i] == scanId)
|
||||
return i;
|
||||
for (size_t i = 0; i < ArtifactHeadScans.size(); ++i) {
|
||||
if (ArtifactHeadScans[i] == scanId) {
|
||||
return int(i);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
CAssetId CArtifactDoll::GetArtifactHeadScanFromItemType(CPlayerState::EItemType item) {
|
||||
if (item < CPlayerState::EItemType::Truth || item > CPlayerState::EItemType::Newborn)
|
||||
if (item < CPlayerState::EItemType::Truth || item > CPlayerState::EItemType::Newborn) {
|
||||
return -1;
|
||||
return ArtifactHeadScans[int(item) - 29];
|
||||
}
|
||||
|
||||
return ArtifactHeadScans[size_t(item) - 29];
|
||||
}
|
||||
|
||||
void CArtifactDoll::UpdateArtifactHeadScan(const CStateManager& mgr, float delta) {
|
||||
CPlayerState& playerState = *mgr.GetPlayerState();
|
||||
for (int i = 0; i < 12; ++i) {
|
||||
for (size_t i = 0; i < ArtifactHeadScans.size(); ++i) {
|
||||
if (mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType(i + 29))) {
|
||||
CAssetId id = ArtifactHeadScans[i];
|
||||
const CAssetId id = ArtifactHeadScans[i];
|
||||
playerState.SetScanTime(id, std::min(playerState.GetScanTime(id) + delta, 1.f));
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +119,7 @@ void CArtifactDoll::Draw(float alpha, const CStateManager& mgr, bool inArtifactC
|
|||
}
|
||||
}
|
||||
|
||||
if (inArtifactCategory && i == selectedArtifact) {
|
||||
if (inArtifactCategory && i == size_t(selectedArtifact)) {
|
||||
float interp = (std::sin(CGraphics::GetSecondsMod900() * 2.f * M_PIF) + 1.f) * 0.5f;
|
||||
color = zeus::CColor::lerp(zeus::skWhite, color, interp);
|
||||
color.a() *= zeus::clamp(0.f, 1.25f - interp, 1.f);
|
||||
|
@ -148,12 +164,15 @@ void CArtifactDoll::Touch() {
|
|||
}
|
||||
|
||||
bool CArtifactDoll::CheckLoadComplete() {
|
||||
if (IsLoaded())
|
||||
if (IsLoaded()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (TLockedToken<CModel>& model : x0_models)
|
||||
if (!model.IsLoaded())
|
||||
const bool allLoaded =
|
||||
std::all_of(x0_models.cbegin(), x0_models.cend(), [](const auto& model) { return model.IsLoaded(); });
|
||||
if (!allLoaded) {
|
||||
return false;
|
||||
}
|
||||
|
||||
x28_24_loaded = true;
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue