diff options
author | Leo <leomauv@gmail.com> | 2020-04-07 13:37:10 +0200 |
---|---|---|
committer | Leo <leomauv@gmail.com> | 2020-04-07 13:37:10 +0200 |
commit | 5843b580f7abe5ee09211470c75a69b2f2a959bc (patch) | |
tree | 0bb992151a86b3f004c9068e8e9fc94277dd374a | |
parent | 5b7e11032b3e3870c3f5919e0d65927e95bbb31b (diff) |
ESP Refact
-rw-r--r-- | ESP.cpp | 103 | ||||
-rw-r--r-- | ESP.h | 8 |
2 files changed, 67 insertions, 44 deletions
@@ -3,7 +3,7 @@ #include "Sdk.h" #include "Renderer.h" #include "Engine.h" - +#include <map> #include <math.h> uint32_t ESP::colors_hex[8] = { 0xff0000ff, 0xffff0000,0xff00ff00,0xffffff00,0xff00ffff,0xffff00ff,0xffffffff,0xffffb400 }; @@ -220,59 +220,74 @@ void ESP::OnNeutralUnit(Unit* unit) return; } - if (strcmp(unitName.c_str(), "FISHS") == 0 || strcmp(unitName.c_str(), "FISHX") == 0 || - strcmp(unitName.c_str(), "FISH1") == 0 || strcmp(unitName.c_str(), "FISH2") == 0 || - strcmp(unitName.c_str(), "FISH3") == 0 || strcmp(unitName.c_str(), "FISH4") == 0 || - strcmp(unitName.c_str(), "turtles") == 0) - { - Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff); - Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); - } + typedef void (ESP::* fPtr)(Vector2&, std::string&); + typedef std::map<std::vector<std::string>, fPtr> Actions; + Actions link; - if (strcmp(unitName.c_str(), "BOARX") == 0 || strcmp(unitName.c_str(), "RHINO") == 0 || - strcmp(unitName.c_str(), "BOAR") == 0 || strcmp(unitName.c_str(), "BOARJ") == 0 || - strcmp(unitName.c_str(), "WELEF") == 0) - { - Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ff00); - Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); - } + std::vector<std::string> valuesFish = { "FISHS", "FISHX","FISH1","FISH2","FISH3","FISH4","turtles" }; + std::vector<std::string> valuesHeavyFood = { "BOARX", "RHINO","BOAR","BOARJ","WELEF" }; + std::vector<std::string> valuesLighthuntable = { "DEERX", "IBEX","ZEBRA","OSTRICH" }; + std::vector<std::string> valuesLightFood = { "SHEEPG", "GOOSE","PIG", "LLAMAG", "Cow Black", "Cow Brown", "Cow Black and White", "BUFFALO", "TURKYG", "GOAT" }; + std::vector<std::string> valuesDangerousAnimal = { "WOLFX", "KOMODO","GJAGR", "SLEOPA", "BEAR", "CROCO", "LION", "TIGER" }; + std::vector<std::string> valuesRelic = { "RELIC" }; - if (strcmp(unitName.c_str(), "DEERX") == 0 || strcmp(unitName.c_str(), "IBEX") == 0 || - strcmp(unitName.c_str(), "ZEBRA") == 0 || strcmp(unitName.c_str(), "OSTRICH") == 0) - { - Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ffff); - Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); - } + void (ESP:: * RenderStyleAction)(Vector2&, std::string&); - if (strcmp(unitName.c_str(), "SHEEPG") == 0 || strcmp(unitName.c_str(), "GOOSE") == 0 || - strcmp(unitName.c_str(), "PIG") == 0 || strcmp(unitName.c_str(), "LLAMAG") == 0 || - strcmp(unitName.c_str(), "Cow Black") == 0 || strcmp(unitName.c_str(), "Cow Brown") == 0 || - strcmp(unitName.c_str(), "Cow Black and White") == 0 || strcmp(unitName.c_str(), "BUFFALO") == 0 || - strcmp(unitName.c_str(), "TURKYG") == 0 || strcmp(unitName.c_str(), "Cow Black") == 0 || - strcmp(unitName.c_str(), "GOAT") == 0) - { - Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff); - Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); - } + link.emplace(valuesFish, &ESP::RenderStyleFish); + link.emplace(valuesHeavyFood, &ESP::RenderStyleHeavyFood); + link.emplace(valuesLighthuntable, &ESP::RenderStyleLighHuntable); + link.emplace(valuesLightFood, &ESP::RenderStyleLightFood); + link.emplace(valuesDangerousAnimal, &ESP::RenderStyleDangerousAnimal); + link.emplace(valuesRelic, &ESP::RenderStyleRelic); - if (strcmp(unitName.c_str(), "WOLFX") == 0 || strcmp(unitName.c_str(), "KOMODO") == 0 || - strcmp(unitName.c_str(), "GJAGR") == 0 || strcmp(unitName.c_str(), "SLEOPA") == 0 || - strcmp(unitName.c_str(), "BEAR") == 0 || strcmp(unitName.c_str(), "CROCO") == 0 || - strcmp(unitName.c_str(), "LION") == 0 || strcmp(unitName.c_str(), "TIGER") == 0) + for (std::pair<std::vector<std::string>, fPtr> element : link) { - Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x40ff0000); - Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); + if (std::find(element.first.begin(), element.first.end(), unitName) != element.first.end()) + { + RenderStyleAction = element.second; + } } - - if (strcmp(unitName.c_str(), "RELIC") == 0) - { - Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 50, 0x40ffffff); - Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); - } + (this->*RenderStyleAction)(screenPos, unitName); } } +void ESP::RenderStyleRelic(Vector2& screenPos, std::string& unitName) +{ + Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 50, 0x40ffffff); + Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); +} + +void ESP::RenderStyleDangerousAnimal(Vector2& screenPos, std::string& unitName) +{ + Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x40ff0000); + Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); +} + +void ESP::RenderStyleLighHuntable(Vector2& screenPos, std::string& unitName) +{ + Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ffff); + Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); +} + +void ESP::RenderStyleHeavyFood(Vector2& screenPos, std::string& unitName) +{ + Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ff00); + Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); +} + +void ESP::RenderStyleLightFood(Vector2& screenPos, std::string& unitName) +{ + Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff); + Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); +} + +void ESP::RenderStyleFish(Vector2& screenPos, std::string& unitName) +{ + Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff); + Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); +} + void ESP::OnMenuMainWindow() { ImGui::Separator(); @@ -1,5 +1,6 @@ #pragma once #include "Feature.h" +#include <string> struct Vector2; struct Vector3; @@ -30,4 +31,11 @@ class ESP : public Feature void DrawBox(Vector3 position, Vector2 edgeSize, int32_t color); void DrawCircle(Unit* unit, int radius, int32_t color, int smoothness , int thickness, bool drawName); + + void RenderStyleRelic(Vector2& screenPos, std::string& unitName); + void RenderStyleDangerousAnimal(Vector2& screenPos, std::string& unitName); + void RenderStyleLighHuntable(Vector2& screenPos, std::string& unitName); + void RenderStyleHeavyFood(Vector2& screenPos, std::string& unitName); + void RenderStyleLightFood(Vector2& screenPos, std::string& unitName); + void RenderStyleFish(Vector2& screenPos, std::string& unitName); };
\ No newline at end of file |