2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CScriptCameraPitchVolume.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/Camera/CCameraManager.hpp"
|
|
|
|
#include "Runtime/Camera/CFirstPersonCamera.hpp"
|
|
|
|
#include "Runtime/Particle/CGenDescription.hpp"
|
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
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,
|
2019-07-19 08:30:11 +00:00
|
|
|
const zeus::CTransform& xf, const zeus::CRelAngle& upPitch,
|
|
|
|
const zeus::CRelAngle& downPitch, 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)
|
2019-07-19 08:30:11 +00:00
|
|
|
, x124_upPitch(upPitch)
|
|
|
|
, x128_downPitch(downPitch)
|
2016-12-19 18:27:58 +00:00
|
|
|
, x12c_scale(scale * skScaleFactor)
|
2020-04-20 04:57:50 +00:00
|
|
|
, x138_maxInterpDistance(maxInterpDistance) {}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptCameraPitchVolume::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2017-01-15 03:07:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptCameraPitchVolume::Think(float, CStateManager& mgr) {
|
2020-05-07 11:43:33 +00:00
|
|
|
if (!GetActive()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-05-07 11:43:33 +00:00
|
|
|
}
|
2017-01-23 10:13:36 +00:00
|
|
|
|
2020-05-07 11:43:33 +00:00
|
|
|
if (x13c_24_entered && !x13c_25_occupied) {
|
2018-12-08 05:30:43 +00:00
|
|
|
Entered(mgr);
|
2020-05-07 11:43:33 +00:00
|
|
|
} else if (!x13c_24_entered && x13c_25_occupied) {
|
2018-12-08 05:30:43 +00:00
|
|
|
Exited(mgr);
|
2020-05-07 11:43:33 +00:00
|
|
|
}
|
2017-01-23 10:13:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x13c_24_entered = false;
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<zeus::CAABox> CScriptCameraPitchVolume::GetTouchBounds() const {
|
2019-02-24 07:15:54 +00:00
|
|
|
return {xe8_obbox.calculateAABox(zeus::CTransform())};
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptCameraPitchVolume::Touch(CActor& act, CStateManager& mgr) {
|
2020-05-07 11:43:33 +00:00
|
|
|
const TCastToConstPtr<CPlayer> pl(act);
|
|
|
|
if (!pl) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-05-07 11:43:33 +00:00
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2020-05-07 11:43:33 +00:00
|
|
|
const auto plBox = pl->GetTouchBounds();
|
|
|
|
if (!plBox) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-05-07 11:43:33 +00:00
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x13c_24_entered = xe8_obbox.AABoxIntersectsBox(plBox.value());
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
void CScriptCameraPitchVolume::Entered(metaforce::CStateManager& mgr) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x13c_25_occupied = true;
|
|
|
|
mgr.GetCameraManager()->GetFirstPersonCamera()->SetScriptPitchId(GetUniqueId());
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptCameraPitchVolume::Exited(CStateManager& mgr) {
|
|
|
|
x13c_25_occupied = false;
|
|
|
|
mgr.GetCameraManager()->GetFirstPersonCamera()->SetScriptPitchId(kInvalidUniqueId);
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|