2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CScriptCameraHintTrigger.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2016-12-13 02:56:43 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-12-13 02:56:43 +00:00
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CScriptCameraHintTrigger::CScriptCameraHintTrigger(TUniqueId uid, bool active, std::string_view name,
|
2016-12-19 18:27:58 +00:00
|
|
|
const CEntityInfo& info, const zeus::CVector3f& scale,
|
2019-06-15 00:39:20 +00:00
|
|
|
const zeus::CTransform& xf, bool deactivateOnEnter,
|
|
|
|
bool deactivateOnExit)
|
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_obb(xf, scale)
|
2020-04-11 05:50:10 +00:00
|
|
|
, x124_scale(scale)
|
|
|
|
, x130_24_deactivateOnEnter(deactivateOnEnter)
|
2020-04-20 04:57:50 +00:00
|
|
|
, x130_25_deactivateOnExit(deactivateOnExit) {}
|
2017-01-15 03:07:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptCameraHintTrigger::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2017-01-15 03:07:01 +00:00
|
|
|
|
2019-06-15 00:39:20 +00:00
|
|
|
void CScriptCameraHintTrigger::Think(float dt, CStateManager& mgr) {
|
2020-05-07 11:45:05 +00:00
|
|
|
if (!GetActive()) {
|
2019-06-15 00:39:20 +00:00
|
|
|
return;
|
2020-05-07 11:45:05 +00:00
|
|
|
}
|
2019-06-15 00:39:20 +00:00
|
|
|
|
|
|
|
if (x130_26_playerInside && !x130_27_playerWasInside) {
|
|
|
|
x130_27_playerWasInside = true;
|
|
|
|
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
|
2020-05-07 11:45:05 +00:00
|
|
|
if (x130_24_deactivateOnEnter) {
|
2019-06-15 00:39:20 +00:00
|
|
|
mgr.SendScriptMsg(this, kInvalidUniqueId, EScriptObjectMessage::Deactivate);
|
2020-05-07 11:45:05 +00:00
|
|
|
}
|
2019-06-15 00:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!x130_26_playerInside && x130_27_playerWasInside) {
|
|
|
|
x130_27_playerWasInside = false;
|
|
|
|
SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::None);
|
2020-05-07 11:45:05 +00:00
|
|
|
if (x130_25_deactivateOnExit) {
|
2019-06-15 00:39:20 +00:00
|
|
|
mgr.SendScriptMsg(this, kInvalidUniqueId, EScriptObjectMessage::Deactivate);
|
2020-05-07 11:45:05 +00:00
|
|
|
}
|
2019-06-15 00:39:20 +00:00
|
|
|
}
|
|
|
|
|
2020-05-07 11:45:05 +00:00
|
|
|
if (x130_26_playerInside) {
|
2019-06-15 00:39:20 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::None);
|
2020-05-07 11:45:05 +00:00
|
|
|
}
|
2019-06-15 00:39:20 +00:00
|
|
|
|
|
|
|
x130_26_playerInside = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CScriptCameraHintTrigger::Touch(CActor& other, CStateManager& mgr) {
|
2020-05-07 11:45:05 +00:00
|
|
|
if (TCastToConstPtr<CPlayer>(other)) {
|
|
|
|
if (const auto tb = other.GetTouchBounds()) {
|
2019-06-15 00:39:20 +00:00
|
|
|
x130_26_playerInside = xe8_obb.OBBIntersectsBox(zeus::COBBox::FromAABox(*tb, {}));
|
2020-05-07 11:45:05 +00:00
|
|
|
}
|
2019-06-15 00:39:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-07 19:29:18 +00:00
|
|
|
std::optional<zeus::CAABox> CScriptCameraHintTrigger::GetTouchBounds() const { return {xe8_obb.calculateAABox()}; }
|
2019-06-15 00:39:20 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|