Decomp fixes for CScriptShadowProjector

This commit is contained in:
Henrique Gemignani Passos Lima 2022-11-08 17:42:55 +02:00
parent 6ef1de8dda
commit e412adef33
No known key found for this signature in database
GPG Key ID: E224F951761145F8
2 changed files with 30 additions and 27 deletions

View File

@ -75,7 +75,7 @@ float CScriptCoverPoint::GetSinSqVerticalAngle() const { return xf0_sinVerticalA
void CScriptCoverPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { void CScriptCoverPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CActor::AcceptScriptMsg(msg, uid, mgr); CActor::AcceptScriptMsg(msg, uid, mgr);
if (msg == EScriptObjectMessage::WorldInitialized) { if (msg == EScriptObjectMessage::InitializedInArea) {
for (const SConnection& con : x20_conns) for (const SConnection& con : x20_conns)
if (con.x0_state == EScriptObjectState::Retreat) { if (con.x0_state == EScriptObjectState::Retreat) {
xfc_retreating = mgr.GetIdForScript(con.x8_objId); xfc_retreating = mgr.GetIdForScript(con.x8_objId);

View File

@ -29,11 +29,11 @@ void CScriptShadowProjector::Think(float dt, CStateManager& mgr) {
return; return;
} }
xfc_opacity = (x100_opacityRecip * xfc_opacity) - dt; xfc_opacity = -(x100_opacityRecip * dt - xfc_opacity);
if (dt > 0.f) { if (xfc_opacity > 0.f) {
return; return;
} }
xfc_opacity = 0.f;
x108_projectedShadow.reset(); x108_projectedShadow.reset();
x110_25_shadowInvalidated = false; x110_25_shadowInvalidated = false;
@ -50,41 +50,44 @@ void CScriptShadowProjector::CreateProjectedShadow() {
void CScriptShadowProjector::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { void CScriptShadowProjector::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CActor::AcceptScriptMsg(msg, uid, mgr); CActor::AcceptScriptMsg(msg, uid, mgr);
if (msg == EScriptObjectMessage::Decrement) {
if (x110_24_persistent) {
return;
}
if (xfc_opacity <= 0.f) { switch (msg) {
return; case EScriptObjectMessage::InitializedInArea:
}
x110_25_shadowInvalidated = true;
} else if (msg == EScriptObjectMessage::InitializedInArea) {
for (const SConnection& conn : x20_conns) { for (const SConnection& conn : x20_conns) {
if (conn.x0_state != EScriptObjectState::Play) { if (conn.x0_state != EScriptObjectState::Play) {
continue; continue;
} }
const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId))); const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId)));
if (!act) { if (act) {
continue;
}
const CModelData* mData = act->GetModelData(); const CModelData* mData = act->GetModelData();
if (!mData || (!mData->GetAnimationData() && !mData->GetNormalModel())) { if (mData && (mData->GetAnimationData() || mData->HasNormalModel())) {
continue;
}
x104_target = act->GetUniqueId(); x104_target = act->GetUniqueId();
break;
}
}
} }
if (x104_target == kInvalidUniqueId) { if (x104_target == kInvalidUniqueId) {
mgr.FreeScriptObject(GetUniqueId()); mgr.FreeScriptObject(GetUniqueId());
} else { break;
CreateProjectedShadow();
} }
} else if (msg == EScriptObjectMessage::Activate) { [[fallthrough]];
case EScriptObjectMessage::Deactivate:
case EScriptObjectMessage::Activate:
CreateProjectedShadow(); CreateProjectedShadow();
break;
case EScriptObjectMessage::Decrement:
if (!GetActive()) {
return;
}
if (xfc_opacity > 0.f) {
x110_25_shadowInvalidated = true;
}
break;
default:
break;
} }
} }