metaforce/Runtime/World/CScriptAiJumpPoint.cpp

66 lines
1.9 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"
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)
2016-12-29 21:38:59 +00:00
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Unknown),
CActorParameters::None(), kInvalidUniqueId)
, xe8_(f1)
{
xec_.emplace(xf.origin, xf.origin);
}
2017-01-15 03:07:01 +00:00
void CScriptAiJumpPoint::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptAiJumpPoint::Think(float dt, CStateManager&)
{
if (x110_timeRemaining <= 0)
return;
x110_timeRemaining -= dt;
}
void CScriptAiJumpPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CStateManager& mgr)
{
AcceptScriptMsg(msg, other, mgr);
2017-03-24 05:30:16 +00:00
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();
const CScriptWaypoint* nextWpnt = wpnt->NextWaypoint(mgr);
if (nextWpnt)
x10e_nextWaypoint = nextWpnt->GetUniqueId();
}
}
}
rstl::optional_object<zeus::CAABox> CScriptAiJumpPoint::GetTouchBounds() const { return xec_; }
bool CScriptAiJumpPoint::GetInUse(TUniqueId uid) const
{
if (x108_24 || x110_timeRemaining > 0.f || x10a_occupant != kInvalidUniqueId || uid != kInvalidUniqueId ||
uid != x10a_occupant)
return true;
return false;
}
}