mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-05 19:15:52 +00:00
CArtifactDoll: Make use of std::array where applicable
This commit is contained in:
parent
26b24d604a
commit
7a8edc8d5e
@ -1,6 +1,7 @@
|
|||||||
#include "Runtime/MP1/CArtifactDoll.hpp"
|
#include "Runtime/MP1/CArtifactDoll.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "Runtime/CSimplePool.hpp"
|
#include "Runtime/CSimplePool.hpp"
|
||||||
@ -14,7 +15,7 @@
|
|||||||
|
|
||||||
namespace urde::MP1 {
|
namespace urde::MP1 {
|
||||||
namespace {
|
namespace {
|
||||||
constexpr const char* ArtifactPieceModels[] = {
|
constexpr std::array ArtifactPieceModels{
|
||||||
"CMDL_Piece1", // Truth
|
"CMDL_Piece1", // Truth
|
||||||
"CMDL_Piece2", // Strength
|
"CMDL_Piece2", // Strength
|
||||||
"CMDL_Piece3", // Elder
|
"CMDL_Piece3", // Elder
|
||||||
@ -29,7 +30,7 @@ constexpr const char* ArtifactPieceModels[] = {
|
|||||||
"CMDL_Piece12" // Newborn
|
"CMDL_Piece12" // Newborn
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr CAssetId ArtifactHeadScans[] = {
|
constexpr std::array<CAssetId, 12> ArtifactHeadScans{
|
||||||
0x32C9DDCE, // Truth
|
0x32C9DDCE, // Truth
|
||||||
0xB45DAF60, // Strength
|
0xB45DAF60, // Strength
|
||||||
0x7F017CC5, // Elder
|
0x7F017CC5, // Elder
|
||||||
@ -52,29 +53,35 @@ CArtifactDoll::CArtifactDoll() {
|
|||||||
x10_lights.resize(2, CLight::BuildDirectional(zeus::skForward, zeus::skWhite));
|
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);
|
x20_actorLights = std::make_unique<CActorLights>(8, zeus::skZero3f, 4, 4, false, false, false, 0.1f);
|
||||||
x28_24_loaded = false;
|
x28_24_loaded = false;
|
||||||
x0_models.reserve(12);
|
x0_models.reserve(ArtifactPieceModels.size());
|
||||||
for (int i = 0; i < 12; ++i)
|
for (const char* const model : ArtifactPieceModels) {
|
||||||
x0_models.push_back(g_SimplePool->GetObj(ArtifactPieceModels[i]));
|
x0_models.emplace_back(g_SimplePool->GetObj(model));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CArtifactDoll::GetArtifactHeadScanIndex(CAssetId scanId) {
|
int CArtifactDoll::GetArtifactHeadScanIndex(CAssetId scanId) {
|
||||||
for (int i = 0; i < 12; ++i)
|
for (size_t i = 0; i < ArtifactHeadScans.size(); ++i) {
|
||||||
if (ArtifactHeadScans[i] == scanId)
|
if (ArtifactHeadScans[i] == scanId) {
|
||||||
return i;
|
return int(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAssetId CArtifactDoll::GetArtifactHeadScanFromItemType(CPlayerState::EItemType item) {
|
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 -1;
|
||||||
return ArtifactHeadScans[int(item) - 29];
|
}
|
||||||
|
|
||||||
|
return ArtifactHeadScans[size_t(item) - 29];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CArtifactDoll::UpdateArtifactHeadScan(const CStateManager& mgr, float delta) {
|
void CArtifactDoll::UpdateArtifactHeadScan(const CStateManager& mgr, float delta) {
|
||||||
CPlayerState& playerState = *mgr.GetPlayerState();
|
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))) {
|
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));
|
playerState.SetScanTime(id, std::min(playerState.GetScanTime(id) + delta, 1.f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,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;
|
float interp = (std::sin(CGraphics::GetSecondsMod900() * 2.f * M_PIF) + 1.f) * 0.5f;
|
||||||
color = zeus::CColor::lerp(zeus::skWhite, color, interp);
|
color = zeus::CColor::lerp(zeus::skWhite, color, interp);
|
||||||
color.a() *= zeus::clamp(0.f, 1.25f - interp, 1.f);
|
color.a() *= zeus::clamp(0.f, 1.25f - interp, 1.f);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user