metaforce/Runtime/World/CFishCloudModifier.cpp

59 lines
2.3 KiB
C++
Raw Permalink Normal View History

#include "Runtime/World/CFishCloudModifier.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/World/CActorParameters.hpp"
#include "Runtime/World/CFishCloud.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
2018-05-07 00:52:35 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
2018-05-07 00:52:35 +00:00
CFishCloudModifier::CFishCloudModifier(TUniqueId uid, bool active, std::string_view name, const CEntityInfo& eInfo,
2019-04-03 04:32:31 +00:00
const zeus::CVector3f& pos, bool isRepulsor, bool swirl, float radius,
float priority)
2018-12-08 05:30:43 +00:00
: CActor(uid, active, name, eInfo, zeus::CTransform::Translate(pos), CModelData::CModelDataNull(),
{EMaterialTypes::NoStepLogic}, CActorParameters::None(), kInvalidUniqueId)
2019-04-03 04:32:31 +00:00
, xe8_radius(radius)
, xec_priority(priority)
, xf0_isRepulsor(isRepulsor)
, xf1_swirl(swirl) {}
2018-12-08 05:30:43 +00:00
void CFishCloudModifier::Accept(IVisitor& visitor) { visitor.Visit(this); }
void CFishCloudModifier::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CActor::AcceptScriptMsg(msg, uid, mgr);
if ((msg == EScriptObjectMessage::Activate || msg == EScriptObjectMessage::InitializedInArea) && GetActive())
AddSelf(mgr);
else if (msg == EScriptObjectMessage::Deactivate || msg == EScriptObjectMessage::Deleted)
RemoveSelf(mgr);
2018-05-07 00:52:35 +00:00
}
2018-12-08 05:30:43 +00:00
void CFishCloudModifier::AddSelf(CStateManager& mgr) {
for (const SConnection& conn : GetConnectionList()) {
if (conn.x0_state != EScriptObjectState::Modify || conn.x4_msg != EScriptObjectMessage::Follow)
continue;
2018-05-07 00:52:35 +00:00
2018-12-08 05:30:43 +00:00
if (TCastToPtr<CFishCloud> fishCloud = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId))) {
if (xf0_isRepulsor)
2019-04-03 04:32:31 +00:00
fishCloud->AddRepulsor(GetUniqueId(), xf1_swirl, xe8_radius, xec_priority);
2018-12-08 05:30:43 +00:00
else
2019-04-03 04:32:31 +00:00
fishCloud->AddAttractor(GetUniqueId(), xf1_swirl, xe8_radius, xec_priority);
2018-05-07 00:52:35 +00:00
}
2018-12-08 05:30:43 +00:00
}
2018-05-07 00:52:35 +00:00
}
2018-12-08 05:30:43 +00:00
void CFishCloudModifier::RemoveSelf(CStateManager& mgr) {
for (const SConnection& conn : GetConnectionList()) {
if (conn.x0_state != EScriptObjectState::Modify || conn.x4_msg != EScriptObjectMessage::Follow)
continue;
2018-05-07 00:52:35 +00:00
2018-12-08 05:30:43 +00:00
if (TCastToPtr<CFishCloud> fishCloud = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId))) {
if (xf0_isRepulsor)
fishCloud->RemoveRepulsor(GetUniqueId());
else
fishCloud->RemoveAttractor(GetUniqueId());
2018-05-07 00:52:35 +00:00
}
2018-12-08 05:30:43 +00:00
}
2018-05-07 00:52:35 +00:00
}
2021-04-10 08:42:06 +00:00
} // namespace metaforce