metaforce/Runtime/World/CScriptCameraShaker.cpp

42 lines
1.5 KiB
C++
Raw Permalink Normal View History

#include "Runtime/World/CScriptCameraShaker.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/World/CWorld.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
2021-04-10 08:42:06 +00:00
namespace metaforce {
2018-12-08 05:30:43 +00:00
CScriptCameraShaker::CScriptCameraShaker(TUniqueId uid, std::string_view name, const CEntityInfo& info, bool active,
const CCameraShakeData& shakeData)
: CEntity(uid, info, active, name), x34_shakeData(shakeData) {}
2018-12-08 05:30:43 +00:00
void CScriptCameraShaker::Accept(IVisitor& visitor) { visitor.Visit(this); }
2018-12-08 05:30:43 +00:00
void CScriptCameraShaker::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {
switch (msg) {
case EScriptObjectMessage::Action: {
TAreaId aid = GetAreaIdAlways();
if (GetActive() && aid != kInvalidAreaId) {
const CGameArea* area = stateMgr.GetWorld()->GetAreaAlways(aid);
CGameArea::EOcclusionState occState = CGameArea::EOcclusionState::Occluded;
if (area->IsPostConstructed())
occState = area->GetPostConstructed()->x10dc_occlusionState;
if (occState == CGameArea::EOcclusionState::Visible)
x34_shakeData.SetShakerId(stateMgr.GetCameraManager()->AddCameraShaker(x34_shakeData, false));
}
2018-12-08 05:30:43 +00:00
break;
}
case EScriptObjectMessage::Deactivate: {
if (GetActive())
stateMgr.GetCameraManager()->RemoveCameraShaker(x34_shakeData.GetShakerId());
break;
}
default:
break;
}
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
}
2021-04-10 08:42:06 +00:00
} // namespace metaforce