Fixed other indexes not turning off if they share the same name

This commit is contained in:
Joaquin 2022-09-02 12:15:57 -06:00
parent 0757418450
commit 12f99edcc3

View File

@ -146,14 +146,23 @@ namespace cheat::feature
// Set Monster's collider // Set Monster's collider
// Taiga#5555: There might be an in-game function for this already I'm just not sure which one // Taiga#5555: There might be an in-game function for this already I'm just not sure which one
void SetMonsterCollider(game::Entity* entity, bool v) void SetMonsterCollider(bool v)
{ {
auto objName = entity->name(); auto monsterRoot = app::GameObject_Find(string_to_il2cppi("/EntityRoot/MonsterRoot"), nullptr);
auto name = objName.substr(0, objName.find_first_of(" ")); if (monsterRoot != nullptr)
// path example: "EntityRoot/MonsterRoot/Monster_Fungus_Raptor_01(Clone)/Collider" {
auto collider = app::GameObject_Find(string_to_il2cppi("/EntityRoot/MonsterRoot/" + name + "/Collider"), nullptr); auto transform = app::GameObject_GetComponentByName(monsterRoot, string_to_il2cppi("Transform"), nullptr);
if (collider != nullptr) auto monsterCount = app::Transform_get_childCount(reinterpret_cast<app::Transform*>(transform), nullptr);
app::GameObject_SetActive(collider, v, nullptr); for (int i = 0; i <= monsterCount - 1; i++)
{
auto monsters = app::Transform_GetChild(reinterpret_cast<app::Transform*>(transform), i, nullptr);
auto monsterGameObject = app::Component_1_get_gameObject(reinterpret_cast<app::Component_1*>(monsters), nullptr);
auto monsterTransform = app::GameObject_GetComponentByName(monsterGameObject, string_to_il2cppi("Transform"), nullptr);
auto transformChild = app::Transform_GetChild(reinterpret_cast<app::Transform*>(monsterTransform), 1, nullptr);
auto colliderGameObject = app::Component_1_get_gameObject(reinterpret_cast<app::Component_1*>(transformChild), nullptr);
app::GameObject_SetActive(colliderGameObject, v, nullptr);
}
}
} }
// Mob vacuum update function. // Mob vacuum update function.
@ -183,7 +192,7 @@ namespace cheat::feature
if (!IsEntityForVac(entity)) if (!IsEntityForVac(entity))
continue; continue;
SetMonsterCollider(entity, !f_SetCollider); SetMonsterCollider(!f_SetCollider);
if (f_Instantly) if (f_Instantly)
{ {
@ -227,7 +236,7 @@ namespace cheat::feature
if (!IsEntityForVac(entity)) if (!IsEntityForVac(entity))
return; return;
SetMonsterCollider(entity, !f_SetCollider); SetMonsterCollider(!f_SetCollider);
app::Vector3 targetPos = CalcMobVacTargetPos(); app::Vector3 targetPos = CalcMobVacTargetPos();
app::Vector3 entityPos = entity->relativePosition(); app::Vector3 entityPos = entity->relativePosition();