CElitePirate: Make IsArmClawCollider internally linked

We can fully collapse this into a helper function and simplify the
parameters on it.
This commit is contained in:
Lioncash 2020-05-14 22:09:56 -04:00
parent d9540c31ce
commit 7d3b43712d
2 changed files with 18 additions and 20 deletions

View File

@ -42,7 +42,22 @@ constexpr std::array<SSphereJointInfo, 7> skSphereJointList{{
{"L_Ball", 0.8f}, {"L_Ball", 0.8f},
{"R_Ball", 0.8f}, {"R_Ball", 0.8f},
}}; }};
} // namespace
// The following used to be member functions, but are made internal as
// they alter no internal state.
// Used to be a member function with a pointer and size in GM8Ev0
bool IsArmClawCollider(std::string_view name, std::string_view locator, const std::array<SJointInfo, 3>& info) {
if (name == locator) {
return true;
}
return std::any_of(info.cbegin(), info.cend(), [&name](const auto& entry) { return entry.from == name; });
}
bool IsArmClawCollider(TUniqueId uid, const rstl::reserved_vector<TUniqueId, 7>& vec) {
return std::find(vec.cbegin(), vec.cend(), uid) != vec.cend();
}
} // Anonymous namespace
CElitePirateData::CElitePirateData(CInputStream& in, u32 propCount) CElitePirateData::CElitePirateData(CInputStream& in, u32 propCount)
: x0_tauntInterval(in.readFloatBig()) : x0_tauntInterval(in.readFloatBig())
@ -787,10 +802,6 @@ void CElitePirate::SetShotAt(bool val, CStateManager& mgr) {
} }
} }
bool CElitePirate::IsArmClawCollider(TUniqueId uid, const rstl::reserved_vector<TUniqueId, 7>& vec) const {
return std::find(vec.begin(), vec.end(), uid) != vec.end();
}
void CElitePirate::AddCollisionList(const SJointInfo* joints, size_t count, void CElitePirate::AddCollisionList(const SJointInfo* joints, size_t count,
std::vector<CJointCollisionDescription>& outJoints) const { std::vector<CJointCollisionDescription>& outJoints) const {
const CAnimData* animData = GetModelData()->GetAnimationData(); const CAnimData* animData = GetModelData()->GetAnimationData();
@ -858,11 +869,9 @@ void CElitePirate::SetupCollisionActorInfo(CStateManager& mgr) {
if (TCastToPtr<CCollisionActor> act = mgr.ObjectById(uid)) { if (TCastToPtr<CCollisionActor> act = mgr.ObjectById(uid)) {
if (colDesc.GetName() == "Head_1"sv) { if (colDesc.GetName() == "Head_1"sv) {
x770_collisionHeadId = uid; x770_collisionHeadId = uid;
} else if (IsArmClawCollider(colDesc.GetName(), "R_Palm_LCTR"sv, skRightArmJointList.data(), } else if (IsArmClawCollider(colDesc.GetName(), "R_Palm_LCTR"sv, skRightArmJointList)) {
skRightArmJointList.size())) {
x774_collisionRJointIds.push_back(uid); x774_collisionRJointIds.push_back(uid);
} else if (IsArmClawCollider(colDesc.GetName(), "L_Palm_LCTR"sv, skLeftArmJointList.data(), } else if (IsArmClawCollider(colDesc.GetName(), "L_Palm_LCTR"sv, skLeftArmJointList)) {
skLeftArmJointList.size())) {
x788_collisionLJointIds.push_back(uid); x788_collisionLJointIds.push_back(uid);
} }
if (uid != x770_collisionHeadId) { if (uid != x770_collisionHeadId) {
@ -882,14 +891,6 @@ void CElitePirate::SetupCollisionActorInfo(CStateManager& mgr) {
x5d4_collisionActorMgr->AddMaterial(mgr, {EMaterialTypes::AIJoint, EMaterialTypes::CameraPassthrough}); x5d4_collisionActorMgr->AddMaterial(mgr, {EMaterialTypes::AIJoint, EMaterialTypes::CameraPassthrough});
} }
bool CElitePirate::IsArmClawCollider(std::string_view name, std::string_view locator, const SJointInfo* info,
size_t infoCount) const {
if (name == locator) {
return true;
}
return std::any_of(info, info + infoCount, [&name](const auto& entry) { return entry.from == name; });
}
void CElitePirate::CreateGrenadeLauncher(CStateManager& mgr, TUniqueId uid) { void CElitePirate::CreateGrenadeLauncher(CStateManager& mgr, TUniqueId uid) {
const CAnimationParameters& params = x5d8_data.GetLauncherAnimParams(); const CAnimationParameters& params = x5d8_data.GetLauncherAnimParams();
if (!params.GetACSFile().IsValid()) { if (!params.GetACSFile().IsValid()) {

View File

@ -220,15 +220,12 @@ protected:
const CCollisionActorManager& GetCollisionActorManager() const { return *x5d4_collisionActorMgr; } const CCollisionActorManager& GetCollisionActorManager() const { return *x5d4_collisionActorMgr; }
private: private:
bool IsArmClawCollider(TUniqueId uid, const rstl::reserved_vector<TUniqueId, 7>& vec) const;
void AddSphereCollisionList(const SSphereJointInfo* joints, size_t count, void AddSphereCollisionList(const SSphereJointInfo* joints, size_t count,
std::vector<CJointCollisionDescription>& outJoints) const; std::vector<CJointCollisionDescription>& outJoints) const;
void AddCollisionList(const SJointInfo* joints, size_t count, void AddCollisionList(const SJointInfo* joints, size_t count,
std::vector<CJointCollisionDescription>& outJoints) const; std::vector<CJointCollisionDescription>& outJoints) const;
void SetupCollisionManager(CStateManager& mgr); void SetupCollisionManager(CStateManager& mgr);
void SetupCollisionActorInfo(CStateManager& mgr); void SetupCollisionActorInfo(CStateManager& mgr);
bool IsArmClawCollider(std::string_view name, std::string_view locator, const SJointInfo* info,
size_t infoCount) const;
void ApplyDamageToHead(CStateManager& mgr, TUniqueId uid); void ApplyDamageToHead(CStateManager& mgr, TUniqueId uid);
void CreateEnergyAbsorb(CStateManager& mgr, const zeus::CTransform& xf); void CreateEnergyAbsorb(CStateManager& mgr, const zeus::CTransform& xf);
bool CanKnockBack(const CDamageInfo& info) const; bool CanKnockBack(const CDamageInfo& info) const;