metaforce/Runtime/World/CScriptAiJumpPoint.cpp

50 lines
1.7 KiB
C++
Raw Normal View History

#include "CScriptAiJumpPoint.hpp"
#include "CActorParameters.hpp"
#include "CStateManager.hpp"
#include "CScriptWaypoint.hpp"
2017-01-15 03:07:01 +00:00
#include "TCastTo.hpp"
2018-12-08 05:30:43 +00:00
namespace urde {
2017-11-13 06:19:18 +00:00
CScriptAiJumpPoint::CScriptAiJumpPoint(TUniqueId uid, std::string_view name, const CEntityInfo& info,
zeus::CTransform& xf, bool active, float f1)
2017-12-19 03:05:50 +00:00
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::NoStepLogic),
CActorParameters::None(), kInvalidUniqueId)
2018-12-13 07:39:16 +00:00
, xe8_apex(f1)
2018-12-08 05:30:43 +00:00
, xec_touchBounds(xf.origin, xf.origin) {}
2018-12-08 05:30:43 +00:00
void CScriptAiJumpPoint::Accept(IVisitor& visitor) { visitor.Visit(this); }
2017-01-15 03:07:01 +00:00
2018-12-08 05:30:43 +00:00
void CScriptAiJumpPoint::Think(float dt, CStateManager&) {
if (x110_timeRemaining <= 0)
return;
2018-12-08 05:30:43 +00:00
x110_timeRemaining -= dt;
}
2018-12-08 05:30:43 +00:00
void CScriptAiJumpPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CStateManager& mgr) {
CActor::AcceptScriptMsg(msg, other, mgr);
if (msg != EScriptObjectMessage::InitializedInArea)
return;
for (SConnection& conn : x20_conns) {
if (conn.x0_state != EScriptObjectState::Arrived || conn.x4_msg != EScriptObjectMessage::Next)
continue;
const CScriptWaypoint* wpnt =
static_cast<const CScriptWaypoint*>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId)));
if (wpnt) {
x10c_currentWaypoint = wpnt->GetUniqueId();
x10e_nextWaypoint = wpnt->NextWaypoint(mgr);
}
2018-12-08 05:30:43 +00:00
}
}
2019-01-29 08:28:35 +00:00
rstl::optional<zeus::CAABox> CScriptAiJumpPoint::GetTouchBounds() const { return xec_touchBounds; }
2018-12-08 05:30:43 +00:00
bool CScriptAiJumpPoint::GetInUse(TUniqueId uid) const {
2018-12-13 07:39:16 +00:00
return x108_24 || x110_timeRemaining > 0.f || x10a_occupant != kInvalidUniqueId || uid != kInvalidUniqueId ||
uid != x10a_occupant;
}
2018-12-08 05:30:43 +00:00
} // namespace urde