metaforce/Runtime/World/CScriptCameraWaypoint.cpp

43 lines
1.6 KiB
C++
Raw Normal View History

#include "Runtime/World/CScriptCameraWaypoint.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/World/CActorParameters.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
2016-04-24 01:10:47 +00:00
2018-12-08 05:30:43 +00:00
namespace urde {
2016-04-24 01:10:47 +00:00
2017-11-13 06:19:18 +00:00
CScriptCameraWaypoint::CScriptCameraWaypoint(TUniqueId uid, std::string_view name, const CEntityInfo& info,
2017-11-24 08:23:28 +00:00
const zeus::CTransform& xf, bool active, float hfov, u32 w1)
2017-12-19 03:05:50 +00:00
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::NoStepLogic),
2016-04-24 01:10:47 +00:00
CActorParameters::None(), kInvalidUniqueId)
2017-11-24 08:23:28 +00:00
, xe8_hfov(hfov)
2018-12-08 05:30:43 +00:00
, xec_(w1) {}
2016-04-24 01:10:47 +00:00
2018-12-08 05:30:43 +00:00
void CScriptCameraWaypoint::Accept(IVisitor& visitor) { visitor.Visit(this); }
2017-01-15 03:07:01 +00:00
2018-12-08 05:30:43 +00:00
void CScriptCameraWaypoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CActor::AcceptScriptMsg(msg, uid, mgr);
2020-04-22 00:35:37 +00:00
if (GetActive() && msg == EScriptObjectMessage::Arrived)
2018-12-08 05:30:43 +00:00
SendScriptMsgs(EScriptObjectState::Arrived, mgr, EScriptObjectMessage::None);
}
2018-12-08 05:30:43 +00:00
TUniqueId CScriptCameraWaypoint::GetRandomNextWaypointId(CStateManager& mgr) const {
std::vector<TUniqueId> candidateIds;
for (const SConnection& conn : x20_conns) {
if (conn.x0_state == EScriptObjectState::Arrived && conn.x4_msg == EScriptObjectMessage::Next) {
TUniqueId uid = mgr.GetIdForScript(conn.x8_objId);
if (uid == kInvalidUniqueId)
continue;
candidateIds.push_back(uid);
2017-10-14 06:34:57 +00:00
}
2018-12-08 05:30:43 +00:00
}
2017-10-14 06:34:57 +00:00
2018-12-08 05:30:43 +00:00
if (candidateIds.empty())
return kInvalidUniqueId;
2017-10-14 06:34:57 +00:00
2018-12-08 05:30:43 +00:00
return candidateIds[mgr.GetActiveRandom()->Range(0, s32(candidateIds.size() - 1))];
2017-10-14 06:34:57 +00:00
}
2018-12-08 05:30:43 +00:00
} // namespace urde