2017-03-18 05:12:27 +00:00
|
|
|
#include "CScriptCameraShaker.hpp"
|
|
|
|
#include "TCastTo.hpp"
|
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "CWorld.hpp"
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2017-03-18 05:12:27 +00:00
|
|
|
|
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) {}
|
2017-03-18 05:12:27 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptCameraShaker::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2017-03-18 05:12:27 +00:00
|
|
|
|
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));
|
2017-03-18 05:12:27 +00:00
|
|
|
}
|
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);
|
2017-03-18 05:12:27 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|