Merge pull request #600 from gawgua/glider-texture

Feature: Glider Texture Changer
This commit is contained in:
Taiga 2022-08-31 06:17:40 -06:00 committed by GitHub
commit 7d8d2f3324
2 changed files with 38 additions and 8 deletions

View File

@ -17,6 +17,7 @@ namespace cheat::feature
NF(f_HeadPath, "Head", "Visuals::TextureChanger", false),
NF(f_BodyPath, "Body", "Visuals::TextureChanger", false),
NF(f_DressPath, "Dress", "Visuals::TextureChanger", false),
NF(f_GliderPath, "Glider", "Visuals::TextureChanger", false),
toBeUpdate(), nextUpdate(0)
{
events::GameUpdateEvent += MY_METHOD_HANDLER(TextureChanger::OnGameUpdate);
@ -32,6 +33,7 @@ namespace cheat::feature
{
ConfigWidget(f_Enabled, "Texture Changer.");
ImGui::Text("Active Hero: %s", ActiveHero.c_str());
ImGui::Text("Active Glider: %s", ActiveGlider.c_str());
ConfigWidget(f_HeadPath, "Head Texture.\n" \
"Example path: C:\\Head.png");
@ -42,6 +44,9 @@ namespace cheat::feature
ConfigWidget(f_DressPath, "Dress Texture.\n" \
"Example path: C:\\Dress.png");
ConfigWidget(f_GliderPath, "Glider Texture.\n" \
"Example path: C:\\Glider.png");
if (ImGui::Button("Apply"))
ApplyTexture = true;
}
@ -74,7 +79,7 @@ namespace cheat::feature
if (ApplyTexture)
{
GameObject::AvatarRoot = app::GameObject_Find(string_to_il2cppi("/EntityRoot/AvatarRoot"), nullptr);
if (GameObject::AvatarRoot != nullptr)
{
auto Transform = app::GameObject_GetComponentByName(GameObject::AvatarRoot, string_to_il2cppi("Transform"), nullptr);
@ -95,24 +100,47 @@ namespace cheat::feature
auto TransformChildOffsetDummy = app::Transform_GetChild(reinterpret_cast<app::Transform*>(TransformOffsetDummy), 0, nullptr);
auto OffsetGameObject = app::Component_1_get_gameObject(reinterpret_cast<app::Component_1*>(TransformChildOffsetDummy), nullptr);
auto OffsetGameObjectName = app::Object_1_get_name(reinterpret_cast<app::Object_1*>(OffsetGameObject), nullptr);
auto GameObjectBody = app::GameObject_Find(string_to_il2cppi("/EntityRoot/AvatarRoot/" + il2cppi_to_string(GameObjectName) + "/OffsetDummy/" + il2cppi_to_string(OffsetGameObjectName) + "/Body"), nullptr);
auto SkinnedMeshRenderer = app::GameObject_GetComponentByName(reinterpret_cast<app::GameObject*>(GameObjectBody), string_to_il2cppi("SkinnedMeshRenderer"), nullptr);
auto Material = app::Renderer_GetMaterialArray(reinterpret_cast<app::Renderer*>(SkinnedMeshRenderer), nullptr);
//Specific to Avatar
auto AvatarBody = app::GameObject_Find(string_to_il2cppi("/EntityRoot/AvatarRoot/" + il2cppi_to_string(GameObjectName) + "/OffsetDummy/" + il2cppi_to_string(OffsetGameObjectName) + "/Body"), nullptr);
auto AvatarSkinnedMeshRenderer = app::GameObject_GetComponentByName(reinterpret_cast<app::GameObject*>(AvatarBody), string_to_il2cppi("SkinnedMeshRenderer"), nullptr);
auto AvatarMaterial = app::Renderer_GetMaterialArray(reinterpret_cast<app::Renderer*>(AvatarSkinnedMeshRenderer), nullptr);
//Specific to Glider
auto GliderRoot = app::GameObject_Find(string_to_il2cppi("/EntityRoot/AvatarRoot/" + il2cppi_to_string(GameObjectName) + "/OffsetDummy/" + il2cppi_to_string(OffsetGameObjectName) + "/Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Spine2/+FlycloakRootB CB A01"), nullptr);
auto TransformGliderRoot = app::GameObject_GetComponentByName(GliderRoot, string_to_il2cppi("Transform"), nullptr);
auto TransformGlider = app::Transform_GetChild(reinterpret_cast<app::Transform*>(TransformGliderRoot), 0, nullptr);
auto Glider = app::Component_1_get_gameObject(reinterpret_cast<app::Component_1*>(TransformGlider), nullptr);
auto GliderName = app::Object_1_get_name(reinterpret_cast<app::Object_1*>(Glider), nullptr);
ActiveGlider = il2cppi_to_string(GliderName);
auto TransformGliderModelRoot = app::Transform_GetChild(reinterpret_cast<app::Transform*>(TransformGlider), 1, nullptr);
auto TransformGliderModel = app::Transform_GetChild(reinterpret_cast<app::Transform*>(TransformGliderModelRoot), 0, nullptr);
auto GliderModel = app::Component_1_get_gameObject(reinterpret_cast<app::Component_1*>(TransformGliderModel), nullptr);
auto GliderSkinnedMeshRenderer = app::GameObject_GetComponentByName(reinterpret_cast<app::GameObject*>(GliderModel), string_to_il2cppi("SkinnedMeshRenderer"), nullptr);
auto GliderMaterial = app::Renderer_GetMaterialArray(reinterpret_cast<app::Renderer*>(GliderSkinnedMeshRenderer), nullptr);
// 0 - Hair, 1 - Body, 2 - Dress
if (f_HeadPath && CheckFile(f_HeadPath)) {
auto HeadTexture = app::NativeGallery_LoadImageAtPath(string_to_il2cppi(f_HeadPath), 100, false, false, false, nullptr);
app::Material_set_mainTexture(Material->vector[0], reinterpret_cast<app::Texture*>(HeadTexture), nullptr);
app::Material_set_mainTexture(AvatarMaterial->vector[0], reinterpret_cast<app::Texture*>(HeadTexture), nullptr);
}
if (f_BodyPath && CheckFile(f_BodyPath)) {
auto BodyTexture = app::NativeGallery_LoadImageAtPath(string_to_il2cppi(f_BodyPath), 100, false, false, false, nullptr);
app::Material_set_mainTexture(Material->vector[1], reinterpret_cast<app::Texture*>(BodyTexture), nullptr);
app::Material_set_mainTexture(AvatarMaterial->vector[1], reinterpret_cast<app::Texture*>(BodyTexture), nullptr);
}
if (f_DressPath && CheckFile(f_DressPath)) {
auto DressTexture = app::NativeGallery_LoadImageAtPath(string_to_il2cppi(f_DressPath), 100, false, false, false, nullptr);
if (Material->vector[2] != nullptr)
app::Material_set_mainTexture(Material->vector[2], reinterpret_cast<app::Texture*>(DressTexture), nullptr);
if (AvatarMaterial->vector[2] != nullptr)
app::Material_set_mainTexture(AvatarMaterial->vector[2], reinterpret_cast<app::Texture*>(DressTexture), nullptr);
}
//Glider
if (f_GliderPath && CheckFile(f_GliderPath))
{
auto GliderTexture = app::NativeGallery_LoadImageAtPath(string_to_il2cppi(f_GliderPath), 100, false, false, false, nullptr);
app::Material_set_mainTexture(GliderMaterial->vector[0], reinterpret_cast<app::Texture*>(GliderTexture), nullptr);
}
ApplyTexture = false;
}
}

View File

@ -12,7 +12,9 @@ namespace cheat::feature
config::Field<config::Toggle<std::string>> f_HeadPath;
config::Field<config::Toggle<std::string>> f_BodyPath;
config::Field<config::Toggle<std::string>> f_DressPath;
config::Field<config::Toggle<std::string>> f_GliderPath;
std::string ActiveHero = "NONE";
std::string ActiveGlider = "NONE";
bool ApplyTexture;
static TextureChanger& GetInstance();