2017-03-18 05:12:27 +00:00
|
|
|
#include "CScriptCameraShaker.hpp"
|
|
|
|
#include "TCastTo.hpp"
|
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "CWorld.hpp"
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CScriptCameraShaker::CScriptCameraShaker(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
2017-03-18 05:12:27 +00:00
|
|
|
bool active, const CCameraShakeData& shakeData)
|
|
|
|
: CEntity(uid, info, active, name), x34_shakeData(shakeData)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void CScriptCameraShaker::Accept(IVisitor& visitor)
|
|
|
|
{
|
|
|
|
visitor.Visit(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2017-03-31 19:51:40 +00:00
|
|
|
CGameArea::EOcclusionState occState = CGameArea::EOcclusionState::Occluded;
|
2017-03-18 05:12:27 +00:00
|
|
|
if (area->IsPostConstructed())
|
|
|
|
occState = area->GetPostConstructed()->x10dc_occlusionState;
|
2017-03-31 19:51:40 +00:00
|
|
|
if (occState == CGameArea::EOcclusionState::Visible)
|
2017-03-18 05:12:27 +00:00
|
|
|
x34_shakeData.SetShakerId(stateMgr.GetCameraManager()->AddCameraShaker(x34_shakeData, false));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Deactivate:
|
|
|
|
{
|
|
|
|
if (GetActive())
|
|
|
|
stateMgr.GetCameraManager()->RemoveCameraShaker(x34_shakeData.GetShakerId());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|