2022-05-26 03:59:23 +03:00
|
|
|
#include "pch-il2cpp.h"
|
|
|
|
#include "AutoCook.h"
|
|
|
|
|
|
|
|
#include <helpers.h>
|
|
|
|
#include <cheat/events.h>
|
|
|
|
|
|
|
|
namespace cheat::feature
|
|
|
|
{
|
2022-06-12 06:21:18 +03:00
|
|
|
namespace GameObject {
|
|
|
|
app::GameObject* Profirency = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Components {
|
|
|
|
app::Component_1* Profirency = nullptr;
|
|
|
|
}
|
|
|
|
|
2022-08-07 17:19:19 +03:00
|
|
|
static std::map<std::string, int> qualities{ {"Suspicious", 1}, {"Normal", 2}, {"Delicious", 3} };
|
2022-08-07 17:04:50 +03:00
|
|
|
|
|
|
|
static void PlayerModule_RequestPlayerCook(app::MoleMole_PlayerModule* __this, uint32_t recipeId, uint32_t avatarId, uint32_t qteQuality, uint32_t count, MethodInfo* method);
|
2022-05-29 22:51:08 +03:00
|
|
|
static void PlayerModule_OnPlayerCookRsp(app::MoleMole_PlayerModule* __this, app::PlayerCookRsp* rsp, MethodInfo* method);
|
2022-05-26 03:59:23 +03:00
|
|
|
static void CookingQtePageContext_UpdateProficiency(app::CookingQtePageContext* __this, MethodInfo* method);
|
|
|
|
|
|
|
|
AutoCook::AutoCook() : Feature(),
|
2022-06-12 06:21:18 +03:00
|
|
|
NF(f_Enabled, "Standart Cooking", "AutoCook", false),
|
|
|
|
NF(f_FastProficiency, "Fast Proficiency", "AutoCook", false),
|
|
|
|
NF(f_CountField, "Count Item", "AutoCook", 1),
|
2022-08-07 17:04:50 +03:00
|
|
|
NF(f_QualityField, "Quality", "AutoCook", "Normal")
|
2022-05-26 03:59:23 +03:00
|
|
|
{
|
2022-05-29 22:51:08 +03:00
|
|
|
HookManager::install(app::MoleMole_PlayerModule_RequestPlayerCook, PlayerModule_RequestPlayerCook);
|
2022-06-12 06:21:18 +03:00
|
|
|
HookManager::install(app::MoleMole_PlayerModule_OnPlayerCookRsp, PlayerModule_OnPlayerCookRsp);
|
2022-05-29 22:51:08 +03:00
|
|
|
HookManager::install(app::MoleMole_CookingQtePageContext_UpdateProficiency, CookingQtePageContext_UpdateProficiency);
|
2022-05-26 03:59:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const FeatureGUIInfo& AutoCook::GetGUIInfo() const
|
|
|
|
{
|
|
|
|
static const FeatureGUIInfo info{ "AutoCook", "World", true };
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AutoCook::DrawMain()
|
|
|
|
{
|
2022-06-12 06:21:18 +03:00
|
|
|
ConfigWidget(f_Enabled, "Fast Cooking if the recipe has fast cooking open. \n" \
|
2022-08-07 17:04:50 +03:00
|
|
|
"If fast cooking is closed, you in addition need to turn on Fast Proficiency.");
|
2022-06-12 06:21:18 +03:00
|
|
|
ConfigWidget(f_FastProficiency, "Quickly prepare an unstudied recipe to the maximum possible.");
|
|
|
|
ConfigWidget("Count Item", f_CountField, 1, 1, 100,
|
2022-05-26 03:59:23 +03:00
|
|
|
"How much to cook at a time.\n" \
|
2022-06-12 06:21:18 +03:00
|
|
|
"(For standard mode only.)");
|
2022-08-07 17:04:50 +03:00
|
|
|
if (ImGui::BeginCombo("Cooking Quality", f_QualityField.value().c_str()))
|
|
|
|
{
|
|
|
|
for (auto& [qualityName, quality] : qualities)
|
|
|
|
{
|
|
|
|
bool is_selected = (f_QualityField.value().c_str() == qualityName);
|
|
|
|
if (ImGui::Selectable(qualityName.c_str(), is_selected))
|
|
|
|
f_QualityField.value() = qualityName;
|
|
|
|
|
|
|
|
if (is_selected)
|
|
|
|
ImGui::SetItemDefaultFocus();
|
|
|
|
}
|
|
|
|
ImGui::EndCombo();
|
|
|
|
}
|
2022-05-26 03:59:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AutoCook::NeedStatusDraw() const
|
|
|
|
{
|
|
|
|
return f_Enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AutoCook::DrawStatus()
|
|
|
|
{
|
2022-08-07 17:04:50 +03:00
|
|
|
if (f_FastProficiency)
|
|
|
|
ImGui::Text("Auto Cooking [Proficiency]");
|
|
|
|
else
|
|
|
|
ImGui::Text("Auto Cooking [Standart, %s]", f_QualityField.value().c_str());
|
2022-05-26 03:59:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
AutoCook& AutoCook::GetInstance()
|
|
|
|
{
|
|
|
|
static AutoCook instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Auto Cooking | RyujinZX#6666
|
|
|
|
|
2022-06-12 06:21:18 +03:00
|
|
|
std::vector<std::string> split(std::string& s, char delimeter)
|
|
|
|
{
|
|
|
|
std::stringstream ss(s);
|
|
|
|
std::string item;
|
|
|
|
std::vector<std::string> tokens;
|
|
|
|
while (std::getline(ss, item, delimeter))
|
|
|
|
{
|
|
|
|
tokens.push_back(item);
|
|
|
|
}
|
|
|
|
return tokens;
|
|
|
|
}
|
|
|
|
|
2022-05-29 22:51:08 +03:00
|
|
|
static void PlayerModule_RequestPlayerCook(app::MoleMole_PlayerModule* __this, uint32_t recipeId, uint32_t avatarId, uint32_t qteQuality, uint32_t count, MethodInfo* method)
|
2022-05-26 03:59:23 +03:00
|
|
|
{
|
|
|
|
AutoCook& autoCook = AutoCook::GetInstance();
|
2022-06-12 06:21:18 +03:00
|
|
|
if (autoCook.f_Enabled || autoCook.f_FastProficiency)
|
2022-05-26 03:59:23 +03:00
|
|
|
{
|
2022-06-12 06:21:18 +03:00
|
|
|
autoCook.CookFoodMaxNum = app::MoleMole_Config_CookRecipeExcelConfig_CheckCookFoodMaxNum(recipeId, nullptr);
|
|
|
|
|
2022-08-07 17:04:50 +03:00
|
|
|
// To prevent possible crashes
|
|
|
|
if (!qualities.count(autoCook.f_QualityField.value()))
|
|
|
|
autoCook.f_QualityField.value() = "Normal";
|
|
|
|
|
|
|
|
qteQuality = qualities.find(autoCook.f_QualityField.value())->second;
|
|
|
|
|
|
|
|
if (!autoCook.f_FastProficiency && autoCook.f_Enabled) {
|
2022-06-12 06:21:18 +03:00
|
|
|
count = autoCook.f_CountField;
|
|
|
|
if (autoCook.f_CountField > autoCook.CookFoodMaxNum)
|
|
|
|
count = autoCook.CookFoodMaxNum;
|
|
|
|
|
|
|
|
return CALL_ORIGIN(PlayerModule_RequestPlayerCook, __this, recipeId, avatarId, qteQuality, count, method);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (autoCook.f_Enabled && autoCook.f_FastProficiency) {
|
|
|
|
count = 1;
|
|
|
|
|
|
|
|
GameObject::Profirency = app::GameObject_Find(string_to_il2cppi("/Canvas/Pages/CookingPage/GrpCooking/GrpTab/GrpItemTips/CookingItemTip/Viewport/ItemTips_Cooking(Clone)/Content/GrpProficiency/Level/"), nullptr);
|
|
|
|
auto RectTransform = app::GameObject_GetComponentByName(GameObject::Profirency, string_to_il2cppi("RectTransform"), nullptr);
|
|
|
|
auto TransformChild = app::Transform_GetChild(reinterpret_cast<app::Transform*>(RectTransform), 0, nullptr);
|
|
|
|
auto TextComponent = app::Component_1_GetComponent_1(reinterpret_cast<app::Component_1*>(TransformChild), string_to_il2cppi("Text"), nullptr);
|
2022-08-07 17:04:50 +03:00
|
|
|
|
2022-06-12 06:21:18 +03:00
|
|
|
if (TextComponent != nullptr) {
|
|
|
|
auto Text_str = app::Text_get_text(reinterpret_cast<app::Text*>(TextComponent), nullptr);
|
|
|
|
auto ProficiencyStr = il2cppi_to_string(Text_str).erase(0, il2cppi_to_string(Text_str).find_first_of(" ."));
|
|
|
|
std::vector<std::string> FinalProficiency = split(ProficiencyStr, '/');
|
|
|
|
autoCook.CookCount = atoi(FinalProficiency[1].c_str()) - atoi(FinalProficiency[0].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (autoCook.CookCount == 0)
|
|
|
|
autoCook.CookCount = 1;
|
|
|
|
|
|
|
|
if (autoCook.CookCount > autoCook.CookFoodMaxNum)
|
|
|
|
autoCook.CookCount = autoCook.CookFoodMaxNum;
|
|
|
|
|
|
|
|
for (int i = 1; i <= autoCook.CookCount; i++) {
|
|
|
|
CALL_ORIGIN(PlayerModule_RequestPlayerCook, __this, recipeId, avatarId, qteQuality, count, method);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return CALL_ORIGIN(PlayerModule_RequestPlayerCook, __this, recipeId, avatarId, qteQuality, count, method);
|
2022-05-26 03:59:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-12 06:21:18 +03:00
|
|
|
static void PlayerModule_OnPlayerCookRsp(app::MoleMole_PlayerModule* __this, app::PlayerCookRsp* rsp, MethodInfo* method) {
|
2022-05-26 03:59:23 +03:00
|
|
|
AutoCook& autoCook = AutoCook::GetInstance();
|
2022-06-12 06:21:18 +03:00
|
|
|
if (autoCook.f_Enabled || autoCook.f_FastProficiency)
|
2022-05-26 03:59:23 +03:00
|
|
|
{
|
2022-08-07 17:04:50 +03:00
|
|
|
// To prevent possible crashes
|
|
|
|
if (!qualities.count(autoCook.f_QualityField.value()))
|
|
|
|
autoCook.f_QualityField.value() = "Normal";
|
|
|
|
|
|
|
|
rsp->fields.qteQuality_ = qualities.find(autoCook.f_QualityField.value())->second;
|
2022-06-12 06:21:18 +03:00
|
|
|
rsp->fields.cookCount_ = autoCook.f_CountField;
|
|
|
|
if (autoCook.f_FastProficiency)
|
|
|
|
rsp->fields.cookCount_ = 1;
|
|
|
|
// if (rsp->fields.recipeData_ != nullptr)
|
|
|
|
// rsp->fields.recipeData_->fields.proficiency_ = autoCook.CookCount;
|
2022-05-26 03:59:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return CALL_ORIGIN(PlayerModule_OnPlayerCookRsp, __this, rsp, method);
|
|
|
|
}
|
2022-08-07 17:04:50 +03:00
|
|
|
|
2022-05-26 03:59:23 +03:00
|
|
|
static void CookingQtePageContext_UpdateProficiency(app::CookingQtePageContext* __this, MethodInfo* method) {
|
|
|
|
AutoCook& autoCook = AutoCook::GetInstance();
|
2022-06-12 06:21:18 +03:00
|
|
|
if (autoCook.f_Enabled || autoCook.f_FastProficiency)
|
2022-05-26 03:59:23 +03:00
|
|
|
{
|
|
|
|
__this->fields._pageMono->fields._qteTime = 0;
|
|
|
|
__this->fields._pageMono->fields._autoQteTime = 0;
|
2022-06-12 06:21:18 +03:00
|
|
|
app::CookingQtePageContext_CloseItemGotPanel(__this, nullptr); // Auto Close Panel
|
2022-05-26 03:59:23 +03:00
|
|
|
}
|
|
|
|
return CALL_ORIGIN(CookingQtePageContext_UpdateProficiency, __this, method);
|
|
|
|
}
|
|
|
|
}
|