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) {
CActor::AcceptScriptMsg(msg, uid, mgr);
if (msg == EScriptObjectMessage::WorldInitialized) {
if (msg == EScriptObjectMessage::InitializedInArea) {
for (const SConnection& con : x20_conns)
if (con.x0_state == EScriptObjectState::Retreat) {
xfc_retreating = mgr.GetIdForScript(con.x8_objId);

View File

@ -29,11 +29,11 @@ void CScriptShadowProjector::Think(float dt, CStateManager& mgr) {
return;
}
xfc_opacity = (x100_opacityRecip * xfc_opacity) - dt;
if (dt > 0.f) {
xfc_opacity = -(x100_opacityRecip * dt - xfc_opacity);
if (xfc_opacity > 0.f) {
return;
}
xfc_opacity = 0.f;
x108_projectedShadow.reset();
x110_25_shadowInvalidated = false;
@ -50,41 +50,44 @@ void CScriptShadowProjector::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) {
switch (msg) {
case 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;
if (act) {
const CModelData* mData = act->GetModelData();
if (mData && (mData->GetAnimationData() || mData->HasNormalModel())) {
x104_target = act->GetUniqueId();
break;
}
}
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();
break;
}
} else if (msg == EScriptObjectMessage::Activate) {
[[fallthrough]];
case EScriptObjectMessage::Deactivate:
case EScriptObjectMessage::Activate:
CreateProjectedShadow();
break;
case EScriptObjectMessage::Decrement:
if (!GetActive()) {
return;
}
if (xfc_opacity > 0.f) {
x110_25_shadowInvalidated = true;
}
break;
default:
break;
}
}