Files
DevourClient/DevourClient/Features/ClientRuntime.cs
manafeng 5f73135eaa version 4.8
new revive function
god mode
instant interaction
custom shortcut keys
2026-01-15 21:53:32 +11:00

168 lines
5.4 KiB
C#

using System;
using DevourClient.Helpers;
using UnityEngine;
namespace DevourClient.Features
{
internal static class ClientRuntime
{
internal static void Tick()
{
if (Settings.Settings.menuToggleKey != KeyCode.None && Input.GetKeyDown(Settings.Settings.menuToggleKey))
{
try
{
Il2Cpp.GameUI gameUI = UnityEngine.Object.FindObjectOfType<Il2Cpp.GameUI>();
if (Settings.Settings.menu_enable)
{
gameUI.HideMouseCursor();
}
else
{
gameUI.ShowMouseCursor();
}
}
catch { }
Settings.Settings.menu_enable = !Settings.Settings.menu_enable;
}
if (Player.IsInGame())
{
if (ClientMain.flashlight_toggle && !ClientMain.fullbright)
{
Hacks.Misc.BigFlashlight(false);
}
else if (!ClientMain.flashlight_toggle && !ClientMain.fullbright)
{
Hacks.Misc.BigFlashlight(true);
}
if (ClientMain.fullbright && !ClientMain.flashlight_toggle)
{
Hacks.Misc.Fullbright(false);
}
else if (!ClientMain.fullbright && !ClientMain.flashlight_toggle)
{
Hacks.Misc.Fullbright(true);
}
if (ClientMain._IsAutoRespawn && Helpers.Player.IsPlayerCrawling())
{
Hacks.Misc.AutoRespawn();
}
if (ClientMain.crosshair && !ClientMain.in_game_cache)
{
ClientMain.in_game_cache = true;
}
}
else
{
if (ClientMain.crosshair && ClientMain.in_game_cache)
{
ClientMain.in_game_cache = false;
}
}
if (ClientMain.spoofLevel)
{
Hacks.Misc.SetRank((int)ClientMain.spoofLevelValue);
}
if (Input.GetKeyDown(Settings.Settings.flyKey))
{
ClientMain.fly = !ClientMain.fly;
}
RadialMenuManager.Enabled = true;
RadialMenuManager.HandleUpdate();
if (Player.IsInGameOrLobby())
{
if (ClientMain.fly && !ClientMain.need_fly_reset)
{
Il2Cpp.NolanBehaviour nb = Player.GetPlayer();
if (nb)
{
Collider coll = nb.GetComponentInChildren<Collider>();
if (coll)
{
coll.enabled = false;
ClientMain.need_fly_reset = true;
}
}
}
else if (!ClientMain.fly && ClientMain.need_fly_reset)
{
Il2Cpp.NolanBehaviour nb = Player.GetPlayer();
if (nb)
{
Collider coll = nb.GetComponentInChildren<Collider>();
if (coll)
{
coll.enabled = true;
ClientMain.need_fly_reset = false;
}
}
}
if (ClientMain.fly)
{
Hacks.Misc.Fly(ClientMain.fly_speed);
}
Hacks.Misc.InstantInteractTick(ClientMain.InstantInteractionEnabled);
}
if (Helpers.Map.GetActiveScene() == "Menu")
{
Hacks.Misc.WalkInLobby(ClientMain._walkInLobby);
}
if (ClientMain.fastMove)
{
try
{
if (Helpers.Entities.LocalPlayer_.p_GameObject != null)
{
var locomotion = Helpers.Entities.LocalPlayer_.p_GameObject
.GetComponent<Il2CppOpsive.UltimateCharacterController.Character.UltimateCharacterLocomotion>();
if (locomotion != null)
{
locomotion.TimeScale = ClientMain._PlayerSpeedMultiplier;
}
}
}
catch
{
return;
}
}
ClientMain.frameCount++;
if (ClientMain.frameCount % ClientMain.GC_GEN0_INTERVAL == 0)
{
GC.Collect(0, GCCollectionMode.Optimized);
}
if (ClientMain.frameCount % ClientMain.GC_FULL_INTERVAL == 0)
{
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
ClientMain.frameCount = 0;
}
if (ClientMain.frameCount - ClientMain.lastMemoryLog >= ClientMain.MEMORY_LOG_INTERVAL)
{
long memoryUsed = GC.GetTotalMemory(false);
MelonLoader.MelonLogger.Msg($"[Memory Monitor] Current managed memory: {memoryUsed / 1024 / 1024} MB | Frame: {ClientMain.frameCount}");
ClientMain.lastMemoryLog = ClientMain.frameCount;
}
}
}
}