2019-12-22 12:04:07 -08:00
|
|
|
#include "Runtime/World/CScriptAiJumpPoint.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
|
|
|
#include "Runtime/World/CScriptWaypoint.hpp"
|
|
|
|
|
2019-09-21 06:07:13 -07:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2016-10-01 12:00:16 -07:00
|
|
|
|
2021-04-10 01:42:06 -07:00
|
|
|
namespace metaforce {
|
2017-11-12 22:19:18 -08:00
|
|
|
CScriptAiJumpPoint::CScriptAiJumpPoint(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
2019-07-19 01:30:11 -07:00
|
|
|
zeus::CTransform& xf, bool active, float apex)
|
2017-12-18 19:05:50 -08:00
|
|
|
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::NoStepLogic),
|
2016-12-19 10:27:58 -08:00
|
|
|
CActorParameters::None(), kInvalidUniqueId)
|
2019-07-19 01:30:11 -07:00
|
|
|
, xe8_apex(apex)
|
2020-04-19 21:57:50 -07:00
|
|
|
, xec_touchBounds(xf.origin, xf.origin) {}
|
2016-10-01 12:00:16 -07:00
|
|
|
|
2018-12-07 21:30:43 -08:00
|
|
|
void CScriptAiJumpPoint::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2017-01-14 19:07:01 -08:00
|
|
|
|
2018-12-07 21:30:43 -08:00
|
|
|
void CScriptAiJumpPoint::Think(float dt, CStateManager&) {
|
2020-05-07 05:01:35 -07:00
|
|
|
if (x110_timeRemaining <= 0) {
|
2018-12-07 21:30:43 -08:00
|
|
|
return;
|
2020-05-07 05:01:35 -07:00
|
|
|
}
|
2016-10-01 12:00:16 -07:00
|
|
|
|
2018-12-07 21:30:43 -08:00
|
|
|
x110_timeRemaining -= dt;
|
2016-10-01 12:00:16 -07:00
|
|
|
}
|
|
|
|
|
2018-12-07 21:30:43 -08:00
|
|
|
void CScriptAiJumpPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CStateManager& mgr) {
|
|
|
|
CActor::AcceptScriptMsg(msg, other, mgr);
|
|
|
|
|
2020-05-07 05:01:35 -07:00
|
|
|
if (msg != EScriptObjectMessage::InitializedInArea) {
|
2018-12-07 21:30:43 -08:00
|
|
|
return;
|
2020-05-07 05:01:35 -07:00
|
|
|
}
|
2018-12-07 21:30:43 -08:00
|
|
|
|
2020-05-20 11:32:20 -07:00
|
|
|
for (const SConnection& conn : x20_conns) {
|
2020-05-07 05:01:35 -07:00
|
|
|
if (conn.x0_state != EScriptObjectState::Arrived || conn.x4_msg != EScriptObjectMessage::Next) {
|
2018-12-07 21:30:43 -08:00
|
|
|
continue;
|
2020-05-07 05:01:35 -07:00
|
|
|
}
|
2018-12-07 21:30:43 -08:00
|
|
|
|
2020-05-07 05:01:35 -07:00
|
|
|
const auto* wpnt = static_cast<const CScriptWaypoint*>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId)));
|
2018-12-07 21:30:43 -08:00
|
|
|
if (wpnt) {
|
|
|
|
x10c_currentWaypoint = wpnt->GetUniqueId();
|
|
|
|
x10e_nextWaypoint = wpnt->NextWaypoint(mgr);
|
2016-10-01 12:00:16 -07:00
|
|
|
}
|
2018-12-07 21:30:43 -08:00
|
|
|
}
|
2016-10-01 12:00:16 -07:00
|
|
|
}
|
|
|
|
|
2019-06-11 19:05:17 -07:00
|
|
|
std::optional<zeus::CAABox> CScriptAiJumpPoint::GetTouchBounds() const { return xec_touchBounds; }
|
2016-10-01 12:00:16 -07:00
|
|
|
|
2018-12-07 21:30:43 -08:00
|
|
|
bool CScriptAiJumpPoint::GetInUse(TUniqueId uid) const {
|
2020-04-29 00:03:14 -07:00
|
|
|
return x108_24_inUse || x110_timeRemaining > 0.f ||
|
|
|
|
(x10a_occupant != kInvalidUniqueId && uid != kInvalidUniqueId && x10a_occupant != uid);
|
2016-10-01 12:00:16 -07:00
|
|
|
}
|
2021-04-10 01:42:06 -07:00
|
|
|
} // namespace metaforce
|