2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 09:47:43 +00:00

New code style refactor

This commit is contained in:
Jack Andersen
2018-12-07 19:30:43 -10:00
parent 41ae32be31
commit 636c82a568
1451 changed files with 171430 additions and 203303 deletions

View File

@@ -4,8 +4,7 @@
#include "CStateManager.hpp"
#include "TCastTo.hpp"
namespace urde
{
namespace urde {
CScriptShadowProjector::CScriptShadowProjector(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, bool active, const zeus::CVector3f& offset,
@@ -18,80 +17,64 @@ CScriptShadowProjector::CScriptShadowProjector(TUniqueId uid, std::string_view n
, xf8_zOffsetAdjust(f2)
, xfc_opacity(opacity)
, x100_opacityRecip(opacity < 0.00001 ? 1.f : opacityQ / opacity)
, x10c_textureSize(textureSize)
{
x110_24_persistent = b2;
, x10c_textureSize(textureSize) {
x110_24_persistent = b2;
}
void CScriptShadowProjector::Accept(IVisitor& visitor)
{
visitor.Visit(this);
void CScriptShadowProjector::Accept(IVisitor& visitor) { visitor.Visit(this); }
void CScriptShadowProjector::Think(float dt, CStateManager& mgr) {
if (GetActive() && x110_25_shadowInvalidated) {
xfc_opacity = (x100_opacityRecip * xfc_opacity) - dt;
if (dt > 0.f)
return;
x108_projectedShadow.reset();
x110_25_shadowInvalidated = false;
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
}
}
void CScriptShadowProjector::Think(float dt, CStateManager& mgr)
{
if (GetActive() && x110_25_shadowInvalidated)
{
xfc_opacity = (x100_opacityRecip * xfc_opacity) - dt;
if (dt > 0.f)
return;
void CScriptShadowProjector::CreateProjectedShadow() {
if (!GetActive() || x104_target == kInvalidUniqueId || xfc_opacity <= 0.f)
x108_projectedShadow.reset();
else
x108_projectedShadow.reset(new CProjectedShadow(x10c_textureSize, x10c_textureSize, x110_24_persistent));
}
x108_projectedShadow.reset();
void CScriptShadowProjector::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CActor::AcceptScriptMsg(msg, uid, mgr);
if (msg == EScriptObjectMessage::Decrement) {
if (x110_24_persistent)
return;
x110_25_shadowInvalidated = false;
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
if (xfc_opacity <= 0.f)
return;
x110_25_shadowInvalidated = true;
} else if (msg == EScriptObjectMessage::InitializedInArea) {
for (const SConnection& conn : x20_conns) {
if (conn.x0_state != EScriptObjectState::Play)
continue;
const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId)));
if (!act)
continue;
const CModelData* mData = act->GetModelData();
if (!mData || (!mData->GetAnimationData() && !mData->GetNormalModel()))
continue;
x104_target = act->GetUniqueId();
}
}
void CScriptShadowProjector::CreateProjectedShadow()
{
if (!GetActive() || x104_target == kInvalidUniqueId || xfc_opacity <= 0.f)
x108_projectedShadow.reset();
if (x104_target == kInvalidUniqueId)
mgr.FreeScriptObject(GetUniqueId());
else
x108_projectedShadow.reset(new CProjectedShadow(x10c_textureSize, x10c_textureSize, x110_24_persistent));
CreateProjectedShadow();
} else if (msg == EScriptObjectMessage::Activate)
CreateProjectedShadow();
}
void CScriptShadowProjector::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
CActor::AcceptScriptMsg(msg, uid, mgr);
if (msg == EScriptObjectMessage::Decrement)
{
if (x110_24_persistent)
return;
if (xfc_opacity <= 0.f)
return;
x110_25_shadowInvalidated = true;
}
else if (msg == EScriptObjectMessage::InitializedInArea)
{
for (const SConnection& conn : x20_conns)
{
if (conn.x0_state != EScriptObjectState::Play)
continue;
const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId)));
if (!act)
continue;
const CModelData* mData = act->GetModelData();
if (!mData || (!mData->GetAnimationData() && !mData->GetNormalModel()))
continue;
x104_target = act->GetUniqueId();
}
if (x104_target == kInvalidUniqueId)
mgr.FreeScriptObject(GetUniqueId());
else
CreateProjectedShadow();
}
else if (msg == EScriptObjectMessage::Activate)
CreateProjectedShadow();
}
void CScriptShadowProjector::PreRender(CStateManager&, const zeus::CFrustum &)
{
}
}
void CScriptShadowProjector::PreRender(CStateManager&, const zeus::CFrustum&) {}
} // namespace urde