...
 
Commits (10)
......@@ -102,13 +102,14 @@ void CParticleGenInfoGeneric::SetGlobalTranslation(const zeus::CVector3f& trans,
void CParticleGenInfoGeneric::SetGlobalScale(const zeus::CVector3f& scale) { x84_system->SetGlobalScale(scale); }
void CParticleGenInfoGeneric::SetParticleEmission(bool emission, CStateManager& stateMgr) {
x84_system->SetParticleEmission(emission);
void CParticleGenInfoGeneric::SetParticleEmission(bool isActive, CStateManager& stateMgr) {
x84_system->SetParticleEmission(isActive);
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
if (gl)
gl->SetActive(emission);
if (gl) {
gl->SetActive(isActive);
}
}
bool CParticleGenInfoGeneric::IsSystemDeletable() const { return x84_system->IsSystemDeletable(); }
......
......@@ -44,7 +44,7 @@ public:
virtual void SetGlobalOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) = 0;
virtual void SetGlobalTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) = 0;
virtual void SetGlobalScale(const zeus::CVector3f& scale) = 0;
virtual void SetParticleEmission(bool, CStateManager& stateMgr) = 0;
virtual void SetParticleEmission(bool isActive, CStateManager& stateMgr) = 0;
virtual bool IsSystemDeletable() const = 0;
virtual std::optional<zeus::CAABox> GetBounds() const = 0;
virtual bool HasActiveParticles() const = 0;
......@@ -54,12 +54,12 @@ public:
virtual void DeleteLight(CStateManager& stateMgr) = 0;
virtual void SetModulationColor(const zeus::CColor& color) = 0;
void SetFlags(s32 f) { x2c_flags = f; }
void SetFlags(s32 flags) { x2c_flags = flags; }
s32 GetFlags() const { return x2c_flags; }
void SetIsGrabInitialData(bool g) { x40_grabInitialData = g; }
void SetIsGrabInitialData(bool grabInitialData) { x40_grabInitialData = grabInitialData; }
bool GetIsGrabInitialData() const { return x40_grabInitialData; }
bool GetIsActive() const { return x24_active; }
void SetIsActive(bool a) { x24_active = a; }
void SetIsActive(bool isActive) { x24_active = isActive; }
void OffsetTime(float dt) { x20_curTime += dt; }
const zeus::CVector3f& GetCurOffset() const { return x74_offset; }
void SetCurOffset(const zeus::CVector3f& offset) { x74_offset = offset; }
......@@ -67,12 +67,12 @@ public:
void SetCurTransform(const zeus::CTransform& xf) { x44_transform = xf; }
const zeus::CVector3f& GetCurScale() const { return x30_particleScale; }
void SetCurScale(const zeus::CVector3f& scale) { x30_particleScale = scale; }
void SetInactiveStartTime(float s) { xc_seconds = s; }
void SetInactiveStartTime(float seconds) { xc_seconds = seconds; }
float GetInactiveStartTime() const { return xc_seconds; }
void MarkFinishTime() { x3c_finishTime = x20_curTime; }
float GetFinishTime() const { return x3c_finishTime; }
float GetCurrentTime() const { return x20_curTime; }
void SetCurrentTime(float t) { x20_curTime = t; }
void SetCurrentTime(float time) { x20_curTime = time; }
EParticleGenType GetType() const { return x80_type; }
CParticleData::EParentedMode GetParentedMode() const { return x28_parentMode; }
......@@ -86,7 +86,7 @@ class CParticleGenInfoGeneric : public CParticleGenInfo {
public:
CParticleGenInfoGeneric(const SObjectTag& part, const std::weak_ptr<CParticleGen>& system, int frames,
std::string_view boneName, const zeus::CVector3f& scale,
CParticleData::EParentedMode parentMode, int flags, CStateManager& stateMgr, TAreaId,
CParticleData::EParentedMode parentMode, int flags, CStateManager& stateMgr, TAreaId areaId,
int lightId, EParticleGenType state);
void AddToRenderer() override;
......@@ -97,7 +97,7 @@ public:
void SetGlobalOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) override;
void SetGlobalTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) override;
void SetGlobalScale(const zeus::CVector3f& scale) override;
void SetParticleEmission(bool, CStateManager& stateMgr) override;
void SetParticleEmission(bool isActive, CStateManager& stateMgr) override;
bool IsSystemDeletable() const override;
std::optional<zeus::CAABox> GetBounds() const override;
bool HasActiveParticles() const override;
......
......@@ -58,10 +58,7 @@ struct CModelFlags {
x4_color == other.x4_color;
}
bool operator!=(const CModelFlags& other) const {
return x0_blendMode != other.x0_blendMode || x1_matSetIdx != other.x1_matSetIdx || x2_flags != other.x2_flags ||
x4_color != other.x4_color;
}
bool operator!=(const CModelFlags& other) const { return !operator==(other); }
};
/* urde addition: doesn't require hacky stashing of
......
#include "CArtifactDoll.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
#include "CStateManager.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "Runtime/MP1/CArtifactDoll.hpp"
namespace urde::MP1 {
#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"
static const char* ArtifactPieceModels[] = {
#include <zeus/CColor.hpp>
#include <zeus/CTransform.hpp>
namespace urde::MP1 {
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())
return false;
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;
......