metaforce/Runtime/MP1/CFaceplateDecoration.cpp

45 lines
1.2 KiB
C++
Raw Normal View History

2017-02-12 03:17:18 +00:00
#include "CFaceplateDecoration.hpp"
#include "CStateManager.hpp"
#include "World/CPlayer.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
2017-02-12 04:43:33 +00:00
#include "Particle/CGenDescription.hpp"
2017-02-12 03:17:18 +00:00
2018-12-08 05:30:43 +00:00
namespace urde::MP1 {
2017-02-12 03:17:18 +00:00
CFaceplateDecoration::CFaceplateDecoration(CStateManager& stateMgr) {}
2018-12-08 05:30:43 +00:00
void CFaceplateDecoration::Update(float dt, CStateManager& stateMgr) {
CAssetId txtrId = stateMgr.GetPlayer().GetVisorSteam().GetTextureId();
if (!txtrId.IsValid()) {
if (xc_ready) {
x4_tex.Unlock();
x0_id = txtrId;
if (m_texFilter)
m_texFilter = std::experimental::nullopt;
2017-02-12 03:17:18 +00:00
}
2018-12-08 05:30:43 +00:00
}
2017-02-12 03:17:18 +00:00
2018-12-08 05:30:43 +00:00
if (x0_id != txtrId && txtrId.IsValid()) {
if (m_texFilter)
m_texFilter = std::experimental::nullopt;
x0_id = txtrId;
x4_tex = g_SimplePool->GetObj(SObjectTag{FOURCC('TXTR'), txtrId});
xc_ready = true;
x4_tex.Lock();
}
2017-02-12 03:17:18 +00:00
2018-12-08 05:30:43 +00:00
if (!m_texFilter && x4_tex.IsLoaded())
m_texFilter.emplace(EFilterType::Blend, x4_tex);
2017-02-12 03:17:18 +00:00
}
2018-12-08 05:30:43 +00:00
void CFaceplateDecoration::Draw(CStateManager& stateMgr) {
if (xc_ready && m_texFilter) {
zeus::CColor color = zeus::CColor::skWhite;
color.a() = stateMgr.GetPlayer().GetVisorSteam().GetAlpha();
m_texFilter->draw(color, 1.f);
}
2017-02-12 03:17:18 +00:00
}
2018-12-08 05:30:43 +00:00
} // namespace urde::MP1