Merge pull request #78 from CNLouisLiu/faketime

add faketime
This commit is contained in:
Callow 2022-06-19 14:45:24 +03:00 committed by GitHub
commit f017b8d08b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 103 additions and 0 deletions

View File

@ -15,6 +15,7 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\user\cheat\world\FakeTime.h" />
<ClInclude Include="src\user\cheat\debugger.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
@ -131,6 +132,7 @@
<Font Include="res\Ruda-ExtraBold.ttf" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\user\cheat\world\FakeTime.cpp" />
<ClCompile Include="src\user\cheat\debugger.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">false</ExcludedFromBuild>

View File

@ -225,6 +225,9 @@
<ClInclude Include="src\user\cheat\world\AutoCook.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\user\cheat\world\FakeTime.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\user\cheat\visuals\ProfileChanger.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -426,6 +429,9 @@
<ClCompile Include="src\user\cheat\debugger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\user\cheat\world\FakeTime.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\user\cheat\visuals\ProfileChanger.cpp">
<Filter>Source Files</Filter>
</ClCompile>

View File

@ -319,6 +319,9 @@ DO_APP_FUNC(0x06552F50, Rect, RectTransform_get_rect, (RectTransform* __this, Me
DO_APP_FUNC(0x06677BD0, float, Canvas_get_scaleFactor, (/*Canvas**/void* __this, MethodInfo* method));
DO_APP_FUNC(0x00935700, void, LevelTimeManager_SetInternalTimeOfDay, (/*LevelTimeManager**/void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method));
// Singletons
DO_APP_FUNC(0x05189A90, void*, Singleton_GetInstance, (MethodInfo* method));
DO_APP_FUNC_METHODINFO(0x096EA3B0, Singleton_1_MoleMole_MapModule__get_Instance__MethodInfo);

View File

@ -26,6 +26,7 @@
#include <cheat/world/MobVacuum.h>
#include <cheat/world/AutoTreeFarm.h>
#include <cheat/world/AutoDestroy.h>
#include <cheat/world/FakeTime.h>
#include <cheat/teleport/ChestTeleport.h>
#include <cheat/teleport/MapTeleport.h>
@ -86,6 +87,7 @@ namespace cheat
FEAT_INST(ElementalSight),
FEAT_INST(KillAura),
FEAT_INST(MobVacuum),
FEAT_INST(FakeTime),
FEAT_INST(ChestTeleport),
FEAT_INST(OculiTeleport),

View File

@ -0,0 +1,67 @@
#include "pch-il2cpp.h"
#include "FakeTime.h"
#include <cheat/events.h>
namespace cheat::feature
{
//CNLouisLiu
void* LevelTimeManager = NULL;
FakeTime::FakeTime() : Feature(),
NF(f_Enabled, "FakeTime", "Enabled", false),
NF(f_TimeHour, "FakeTime", "TimeHour", 12),
NF(f_TimeMinute, "FakeTime", "TimeMinute", 0)
{
HookManager::install(app::LevelTimeManager_SetInternalTimeOfDay, LevelTimeManager_SetInternalTimeOfDay_Hook);
events::GameUpdateEvent += MY_METHOD_HANDLER(FakeTime::OnGameUpdate);
}
FakeTime& FakeTime::GetInstance()
{
static FakeTime instance;
return instance;
}
const FeatureGUIInfo& FakeTime::GetGUIInfo() const
{
static const FeatureGUIInfo info{ "FakeTime", "World", true };
return info;
}
void FakeTime::DrawMain()
{
ConfigWidget("Enabled", f_Enabled, "Keep game time the same");
ConfigWidget("TimeHour", f_TimeHour, 1, 0, 24);
ConfigWidget("TimeMinute", f_TimeMinute, 1, 0, 60);
}
bool FakeTime::NeedStatusDraw() const
{
return f_Enabled;
}
void FakeTime::DrawStatus()
{
ImGui::Text("FakeTime|%d:%d", f_TimeHour.value(), f_TimeMinute.value());
}
float FakeTime::ConversionTime() {
float time = float(f_TimeHour);
float timemin = f_TimeMinute / 60;
return time + timemin;
}
void FakeTime::OnGameUpdate()
{
if (LevelTimeManager != NULL && f_Enabled) {
auto& faketime = GetInstance();
CALL_ORIGIN(LevelTimeManager_SetInternalTimeOfDay_Hook, LevelTimeManager, faketime.ConversionTime(), false, false, (MethodInfo*)0);
}
}
void FakeTime::LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method) {
float Hours = inHours;
auto& faketime = GetInstance();
if (faketime.f_Enabled)
{
Hours = faketime.ConversionTime();
}
CALL_ORIGIN(LevelTimeManager_SetInternalTimeOfDay_Hook, __this, Hours, force, refreshEnviroTime, method);
}
}

View File

@ -0,0 +1,23 @@
#pragma once
namespace cheat::feature
{
class FakeTime : public Feature
{
public:
config::Field<config::Toggle<Hotkey>> f_Enabled;
config::Field<int> f_TimeHour;
config::Field<int> f_TimeMinute;
static FakeTime& GetInstance();
void OnGameUpdate();
const FeatureGUIInfo& GetGUIInfo() const override;
void DrawMain() override;
virtual bool NeedStatusDraw() const override;
void DrawStatus() override;
private:
static void LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method);
float ConversionTime();
FakeTime();
};
}