metaforce/Runtime/World/CScriptDistanceFog.cpp

75 lines
2.5 KiB
C++
Raw Permalink Normal View History

#include "Runtime/World/CScriptDistanceFog.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/World/CWorld.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
2016-08-08 20:55:58 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
2018-12-08 05:30:43 +00:00
CScriptDistanceFog::CScriptDistanceFog(TUniqueId uid, std::string_view name, const CEntityInfo& info, ERglFogMode mode,
const zeus::CColor& color, const zeus::CVector2f& range, float colorDelta,
const zeus::CVector2f& rangeDelta, bool expl, bool active, float thermalTarget,
float thermalSpeed, float xrayTarget, float xraySpeed)
: CEntity(uid, info, active, name)
, x34_mode(mode)
, x38_color(color)
, x3c_range(range)
, x44_colorDelta(colorDelta)
, x48_rangeDelta(rangeDelta)
, x50_thermalTarget(thermalTarget)
, x54_thermalSpeed(thermalSpeed)
, x58_xrayTarget(xrayTarget)
, x5c_xraySpeed(xraySpeed)
, x60_explicit(expl)
2016-08-08 20:55:58 +00:00
{
if (zeus::close_enough(rangeDelta, zeus::skZero2f) && zeus::close_enough(colorDelta, 0.f)) {
2018-12-08 05:30:43 +00:00
x61_nonZero = false;
} else {
2018-12-08 05:30:43 +00:00
x61_nonZero = true;
}
2016-08-09 03:58:19 +00:00
}
2018-12-08 05:30:43 +00:00
void CScriptDistanceFog::Accept(IVisitor& visitor) { visitor.Visit(this); }
2017-01-15 03:07:01 +00:00
2018-12-08 05:30:43 +00:00
void CScriptDistanceFog::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
2016-08-09 03:58:19 +00:00
if (x4_areaId == kInvalidAreaId || !GetActive()) {
2018-12-08 05:30:43 +00:00
return;
}
2016-08-09 03:58:19 +00:00
2018-12-08 05:30:43 +00:00
if (msg == EScriptObjectMessage::InitializedInArea) {
if (!x60_explicit) {
2018-12-08 05:30:43 +00:00
return;
}
CGameArea::CAreaFog* fog = stateMgr.GetWorld()->GetArea(x4_areaId)->GetAreaFog();
if (x34_mode == ERglFogMode::None) {
2018-12-08 05:30:43 +00:00
fog->DisableFog();
} else {
2018-12-08 05:30:43 +00:00
fog->SetFogExplicit(x34_mode, x38_color, x3c_range);
}
2018-12-08 05:30:43 +00:00
} else if (msg == EScriptObjectMessage::Action) {
if (x61_nonZero) {
CGameArea::CAreaFog* fog = stateMgr.GetWorld()->GetArea(x4_areaId)->GetAreaFog();
if (x34_mode == ERglFogMode::None) {
fog->RollFogOut(x48_rangeDelta.x(), x44_colorDelta, x38_color);
} else {
fog->FadeFog(x34_mode, x38_color, x3c_range, x44_colorDelta, x48_rangeDelta);
}
}
2016-08-09 03:58:19 +00:00
CWorld* world = stateMgr.GetWorld();
CGameArea* area = world->GetArea(x4_areaId);
if (!zeus::close_enough(x54_thermalSpeed, 0.f)) {
area->SetThermalSpeedAndTarget(x54_thermalSpeed, x50_thermalTarget);
}
2016-08-09 03:58:19 +00:00
if (!zeus::close_enough(x5c_xraySpeed, 0.f)) {
2018-12-08 05:30:43 +00:00
area->SetXRaySpeedAndTarget(x5c_xraySpeed, x58_xrayTarget);
2016-08-09 03:58:19 +00:00
}
2018-12-08 05:30:43 +00:00
}
2016-08-08 20:55:58 +00:00
}
2021-04-10 08:42:06 +00:00
} // namespace metaforce