2016-12-19 18:27:58 +00:00
|
|
|
#include "CScriptCameraPitchVolume.hpp"
|
|
|
|
#include "CActorParameters.hpp"
|
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "CPlayer.hpp"
|
|
|
|
#include "Camera/CCameraManager.hpp"
|
|
|
|
#include "Camera/CFirstPersonCamera.hpp"
|
2017-02-12 04:43:33 +00:00
|
|
|
#include "Particle/CGenDescription.hpp"
|
2017-01-15 03:07:01 +00:00
|
|
|
#include "TCastTo.hpp"
|
2016-12-19 18:27:58 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
2017-12-18 02:54:50 +00:00
|
|
|
const zeus::CVector3f CScriptCameraPitchVolume::skScaleFactor = zeus::CVector3f(0.5f);
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CScriptCameraPitchVolume::CScriptCameraPitchVolume(TUniqueId uid, bool active, std::string_view name,
|
2016-12-19 18:27:58 +00:00
|
|
|
const CEntityInfo& info, const zeus::CVector3f& scale,
|
|
|
|
const zeus::CTransform& xf, const zeus::CRelAngle& r1,
|
|
|
|
const zeus::CRelAngle& r2, float maxInterpDistance)
|
2016-12-29 21:38:59 +00:00
|
|
|
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Trigger),
|
2016-12-19 18:27:58 +00:00
|
|
|
CActorParameters::None(), kInvalidUniqueId)
|
|
|
|
, xe8_obbox(xf, scale * skScaleFactor)
|
2017-10-07 05:32:11 +00:00
|
|
|
, x124_upPitch(r1)
|
|
|
|
, x128_downPitch(r2)
|
2016-12-19 18:27:58 +00:00
|
|
|
, x12c_scale(scale * skScaleFactor)
|
|
|
|
, x138_maxInterpDistance(maxInterpDistance)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-15 03:07:01 +00:00
|
|
|
void CScriptCameraPitchVolume::Accept(IVisitor& visitor)
|
|
|
|
{
|
|
|
|
visitor.Visit(this);
|
|
|
|
}
|
|
|
|
|
2017-01-23 10:13:36 +00:00
|
|
|
void CScriptCameraPitchVolume::Think(float, CStateManager& mgr)
|
2016-12-19 18:27:58 +00:00
|
|
|
{
|
2017-08-29 13:17:52 +00:00
|
|
|
if (!GetActive())
|
2016-12-19 18:27:58 +00:00
|
|
|
return;
|
2017-01-23 10:13:36 +00:00
|
|
|
|
|
|
|
if (x13c_24_entered && !x13c_25_occupied)
|
|
|
|
Entered(mgr);
|
|
|
|
else if (!x13c_24_entered && x13c_25_occupied)
|
|
|
|
Exited(mgr);
|
|
|
|
|
|
|
|
x13c_24_entered = false;
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
2018-04-30 03:12:41 +00:00
|
|
|
std::experimental::optional<zeus::CAABox> CScriptCameraPitchVolume::GetTouchBounds() const
|
2016-12-19 18:27:58 +00:00
|
|
|
{
|
|
|
|
return {xe8_obbox.calculateAABox(zeus::CTransform::Identity())};
|
|
|
|
}
|
|
|
|
|
|
|
|
void CScriptCameraPitchVolume::Touch(CActor& act, CStateManager& mgr)
|
|
|
|
{
|
2017-01-15 03:59:37 +00:00
|
|
|
TCastToPtr<CPlayer> pl(act);
|
2016-12-19 18:27:58 +00:00
|
|
|
if (!pl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto plBox = pl->GetTouchBounds();
|
|
|
|
if (!plBox)
|
|
|
|
return;
|
|
|
|
|
2017-01-23 10:13:36 +00:00
|
|
|
x13c_24_entered = xe8_obbox.AABoxIntersectsBox(plBox.value());
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CScriptCameraPitchVolume::Entered(urde::CStateManager& mgr)
|
|
|
|
{
|
|
|
|
x13c_25_occupied = true;
|
|
|
|
mgr.GetCameraManager()->GetFirstPersonCamera()->SetScriptPitchId(GetUniqueId());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CScriptCameraPitchVolume::Exited(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
x13c_25_occupied = false;
|
|
|
|
mgr.GetCameraManager()->GetFirstPersonCamera()->SetScriptPitchId(kInvalidUniqueId);
|
|
|
|
}
|
|
|
|
}
|