2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-05-13 21:11:21 +00:00
metaforce/Runtime/World/CScriptCameraHintTrigger.cpp
Lioncash 221cc5c6b8 RuntimeCommonB: Normalize cpp file includes
Like the prior changes normalizing the inclusions within headers, this
tackles the cpp files of the RuntimeCommonB target, making these source
files consistent with their headers.
2019-12-22 18:12:04 -05:00

60 lines
2.2 KiB
C++

#include "Runtime/World/CScriptCameraHintTrigger.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/World/CActorParameters.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
namespace urde {
CScriptCameraHintTrigger::CScriptCameraHintTrigger(TUniqueId uid, bool active, std::string_view name,
const CEntityInfo& info, const zeus::CVector3f& scale,
const zeus::CTransform& xf, bool deactivateOnEnter,
bool deactivateOnExit)
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Trigger),
CActorParameters::None(), kInvalidUniqueId)
, xe8_obb(xf, scale)
, x124_scale(scale) {
x130_24_deactivateOnEnter = deactivateOnEnter;
x130_25_deactivateOnExit = deactivateOnExit;
}
void CScriptCameraHintTrigger::Accept(IVisitor& visitor) { visitor.Visit(this); }
void CScriptCameraHintTrigger::Think(float dt, CStateManager& mgr) {
if (!GetActive())
return;
if (x130_26_playerInside && !x130_27_playerWasInside) {
x130_27_playerWasInside = true;
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
if (x130_24_deactivateOnEnter)
mgr.SendScriptMsg(this, kInvalidUniqueId, EScriptObjectMessage::Deactivate);
}
if (!x130_26_playerInside && x130_27_playerWasInside) {
x130_27_playerWasInside = false;
SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::None);
if (x130_25_deactivateOnExit)
mgr.SendScriptMsg(this, kInvalidUniqueId, EScriptObjectMessage::Deactivate);
}
if (x130_26_playerInside)
SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::None);
x130_26_playerInside = false;
}
void CScriptCameraHintTrigger::Touch(CActor& other, CStateManager& mgr) {
if (TCastToPtr<CPlayer>(other)) {
if (auto tb = other.GetTouchBounds())
x130_26_playerInside = xe8_obb.OBBIntersectsBox(zeus::COBBox::FromAABox(*tb, {}));
}
}
std::optional<zeus::CAABox> CScriptCameraHintTrigger::GetTouchBounds() const {
return {xe8_obb.calculateAABox()};
}
} // namespace urde