using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Repo_Library;
using TrainerMod;
using TrainerMod.Cheats;
using TrainerMod.UI;
using TrainerMod.Utils;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(TrainerMain), "Repo Trainer Mod", "1.0.0", "thrasher", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TrainerMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Repo Trainer Mod - MelonLoader")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TrainerMod")]
[assembly: AssemblyTitle("TrainerMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TrainerMod
{
public class TrainerMain : MelonMod
{
public static TrainerMain Instance;
public static Library RepoLib;
private Menu _menu;
public bool ShowMenu = true;
private InputAction _toggleAction;
public List<BaseCheat> Cheats { get; private set; } = new List<BaseCheat>();
public override void OnInitializeMelon()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
RepoLib = new Library();
((MelonBase)RepoLib).OnInitializeMelon();
_menu = new Menu();
Cheats.Add(new GodMode());
Cheats.Add(new InfiniteAmmo());
Cheats.Add(new InfiniteEnergy());
Cheats.Add(new StableValue());
Cheats.Add(new MoneyHack());
Cheats.Add(new EnemyFreeze());
Cheats.Add(new ItemDurability());
_toggleAction = new InputAction("TrainerToggle", (InputActionType)1, (string)null, (string)null, (string)null, (string)null);
InputActionSetupExtensions.AddBinding(_toggleAction, "<Keyboard>/insert", (string)null, (string)null, (string)null);
InputActionSetupExtensions.AddBinding(_toggleAction, "<Keyboard>/delete", (string)null, (string)null, (string)null);
_toggleAction.Enable();
((MelonBase)this).LoggerInstance.Msg("Trainer Mod loaded successfully!");
}
public override void OnUpdate()
{
bool flag = false;
if (_toggleAction != null && _toggleAction.WasPressedThisFrame())
{
flag = true;
((MelonBase)this).LoggerInstance.Msg("Menu Toggle: InputAction");
}
if (!flag)
{
try
{
if (Input.GetKeyDown((KeyCode)277) || Input.GetKeyDown((KeyCode)127))
{
flag = true;
((MelonBase)this).LoggerInstance.Msg("Menu Toggle: Legacy");
}
}
catch
{
}
}
if (flag)
{
ShowMenu = !ShowMenu;
((MelonBase)this).LoggerInstance.Msg($"Menu Toggled. State: {ShowMenu}");
if (ShowMenu)
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
}
else
{
Cursor.lockState = (CursorLockMode)1;
Cursor.visible = false;
}
}
foreach (BaseCheat cheat in Cheats)
{
if (cheat.Enabled)
{
cheat.Update();
}
}
}
public override void OnGUI()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
if (ShowMenu)
{
if ((int)Cursor.lockState != 0)
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
}
_menu?.Draw(Cheats);
}
foreach (BaseCheat cheat in Cheats)
{
if (cheat.Enabled)
{
cheat.OnGUI();
}
}
}
public override void OnSceneWasInitialized(int buildIndex, string sceneName)
{
Library repoLib = RepoLib;
if (repoLib != null)
{
((MelonMod)repoLib).OnSceneWasInitialized(buildIndex, sceneName);
}
}
public override void OnDeinitializeMelon()
{
InputAction toggleAction = _toggleAction;
if (toggleAction != null)
{
toggleAction.Dispose();
}
}
}
}
namespace TrainerMod.Utils
{
public static class ReflectionCache
{
private static FieldInfo _healthField;
private static FieldInfo _maxHealthField;
private static FieldInfo _godModeField;
private static void InitHealthFields()
{
if (_healthField == null)
{
_healthField = typeof(PlayerHealth).GetField("health", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
if (_maxHealthField == null)
{
_maxHealthField = typeof(PlayerHealth).GetField("maxHealth", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
}
public static int GetHealth(PlayerHealth ph)
{
InitHealthFields();
if (_healthField == null)
{
return 0;
}
return (int)_healthField.GetValue(ph);
}
public static void SetHealth(PlayerHealth ph, int value)
{
InitHealthFields();
if (_healthField != null)
{
_healthField.SetValue(ph, value);
}
}
public static int GetMaxHealth(PlayerHealth ph)
{
InitHealthFields();
if (_maxHealthField == null)
{
return 100;
}
return (int)_maxHealthField.GetValue(ph);
}
public static bool GetGodMode(PlayerHealth ph)
{
if (_godModeField == null)
{
_godModeField = typeof(PlayerHealth).GetField("godMode", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
if (_godModeField == null)
{
return false;
}
return (bool)_godModeField.GetValue(ph);
}
public static void SetGodMode(PlayerHealth ph, bool value)
{
if (_godModeField == null)
{
_godModeField = typeof(PlayerHealth).GetField("godMode", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
if (_godModeField != null)
{
_godModeField.SetValue(ph, value);
}
}
}
public static class Visuals
{
private static Texture2D _whiteTexture;
public static Texture2D WhiteTexture
{
get
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_whiteTexture == (Object)null)
{
_whiteTexture = new Texture2D(1, 1);
_whiteTexture.SetPixel(0, 0, Color.white);
_whiteTexture.Apply();
}
return _whiteTexture;
}
}
public static void DrawBox(Vector2 position, Vector2 size, Color color, float thickness = 2f)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
Color color2 = GUI.color;
GUI.color = color;
GUI.Box(new Rect(position.x, position.y, size.x, size.y), GUIContent.none);
GUI.color = color2;
}
public static void DrawString(Vector2 pos, string text, Color color, bool center = true)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
GUIContent val = new GUIContent(text);
Vector2 val2 = GUI.skin.label.CalcSize(val);
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(pos.x, pos.y, val2.x, val2.y);
if (center)
{
((Rect)(ref val3)).x = ((Rect)(ref val3)).x - val2.x / 2f;
}
Color contentColor = GUI.contentColor;
GUI.contentColor = color;
GUI.Label(val3, val);
GUI.contentColor = contentColor;
}
public static void DrawLine(Vector2 start, Vector2 end, Color color, float width = 1f)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
Color color2 = GUI.color;
GUI.color = color;
Vector2 val = end - start;
float num = 57.29578f * Mathf.Atan2(val.y, val.x);
if (num < 0f)
{
num += 360f;
}
GUIUtility.RotateAroundPivot(0f - num, start);
GUI.DrawTexture(new Rect(start.x, start.y, ((Vector2)(ref val)).magnitude, width), (Texture)(object)WhiteTexture);
GUIUtility.RotateAroundPivot(num, start);
GUI.color = color2;
}
}
}
namespace TrainerMod.UI
{
public class Menu
{
private Rect _windowRect = new Rect(50f, 50f, 400f, 450f);
private CheatCategory _selectedCategory = CheatCategory.Player;
public void Draw(List<BaseCheat> cheats)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.9f);
GUI.contentColor = Color.white;
_windowRect = GUI.Window(1024, _windowRect, (WindowFunction)delegate(int id)
{
WindowContent(id, cheats);
}, "<b>REPO Trainer</b>");
}
private void WindowContent(int id, List<BaseCheat> cheats)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
GUILayout.Space(10f);
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
foreach (CheatCategory value in Enum.GetValues(typeof(CheatCategory)))
{
GUI.color = ((_selectedCategory == value) ? Color.cyan : Color.gray);
if (GUILayout.Button(value.ToString(), Array.Empty<GUILayoutOption>()))
{
_selectedCategory = value;
}
}
GUILayout.EndHorizontal();
GUI.color = Color.white;
GUILayout.Space(10f);
GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
List<BaseCheat> list = cheats.Where((BaseCheat c) => c.Category == _selectedCategory).ToList();
if (list.Count > 0)
{
foreach (BaseCheat item in list)
{
Color color = GUI.color;
GUI.color = (item.Enabled ? Color.green : Color.white);
if (GUILayout.Button(item.Name, Array.Empty<GUILayoutOption>()))
{
item.Toggle();
}
if (item.Enabled)
{
item.OnGuiMenu();
}
GUI.color = color;
}
}
else
{
GUILayout.Label("No cheats in this category.", Array.Empty<GUILayoutOption>());
}
GUILayout.EndVertical();
GUILayout.Space(10f);
GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
GUILayout.Label("<b>Player Info</b>", Array.Empty<GUILayoutOption>());
if ((Object)(object)PlayerAvatar.instance != (Object)null)
{
PlayerHealth component = ((Component)PlayerAvatar.instance).GetComponent<PlayerHealth>();
if ((Object)(object)component != (Object)null)
{
int health = ReflectionCache.GetHealth(component);
int maxHealth = ReflectionCache.GetMaxHealth(component);
bool godMode = ReflectionCache.GetGodMode(component);
GUILayout.Label($"Health: {health} / {maxHealth}", Array.Empty<GUILayoutOption>());
GUILayout.Label("GodMode: " + (godMode ? "Active" : "Inactive"), Array.Empty<GUILayoutOption>());
}
}
else
{
GUILayout.Label("Player Not Found", Array.Empty<GUILayoutOption>());
}
GUILayout.EndVertical();
GUI.DragWindow();
}
}
}
namespace TrainerMod.Cheats
{
public enum CheatCategory
{
Visuals,
Player,
World,
Misc
}
public abstract class BaseCheat
{
public bool Enabled { get; set; }
public string Name { get; protected set; }
public CheatCategory Category { get; protected set; } = CheatCategory.Misc;
public abstract void Update();
public abstract void OnGUI();
public virtual void OnGuiMenu()
{
}
public void Toggle()
{
Enabled = !Enabled;
OnToggle();
}
protected virtual void OnToggle()
{
}
}
public class EnemyFreeze : BaseCheat
{
public EnemyFreeze()
{
base.Name = "Enemy Freeze";
base.Category = CheatCategory.World;
}
public override void Update()
{
if (base.Enabled)
{
UpdateFreezeState(freeze: true);
}
}
protected override void OnToggle()
{
if (!base.Enabled)
{
UpdateFreezeState(freeze: false);
}
}
private void UpdateFreezeState(bool freeze)
{
if (TrainerMain.RepoLib == null || !TrainerMain.RepoLib.IsInGame())
{
return;
}
GameObject[] enemies = TrainerMain.RepoLib.GetEnemies();
if (enemies == null)
{
return;
}
GameObject[] array = enemies;
foreach (GameObject val in array)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
Transform val2 = val.transform.Find("Enable");
if (!((Object)(object)val2 != (Object)null))
{
continue;
}
Transform val3 = val2.Find("Controller");
if ((Object)(object)val3 != (Object)null)
{
bool flag = !freeze;
if (((Component)val3).gameObject.activeSelf != flag)
{
((Component)val3).gameObject.SetActive(flag);
}
}
}
}
public override void OnGUI()
{
}
}
public class GodMode : BaseCheat
{
private PlayerHealth _cachedHealth;
public GodMode()
{
base.Name = "God Mode";
base.Category = CheatCategory.Player;
}
public override void Update()
{
if ((Object)(object)PlayerAvatar.instance == (Object)null)
{
return;
}
if ((Object)(object)_cachedHealth == (Object)null || (Object)(object)((Component)_cachedHealth).gameObject != (Object)(object)((Component)PlayerAvatar.instance).gameObject)
{
_cachedHealth = ((Component)PlayerAvatar.instance).GetComponent<PlayerHealth>();
}
if ((Object)(object)_cachedHealth != (Object)null)
{
if (!ReflectionCache.GetGodMode(_cachedHealth))
{
ReflectionCache.SetGodMode(_cachedHealth, value: true);
}
int health = ReflectionCache.GetHealth(_cachedHealth);
int maxHealth = ReflectionCache.GetMaxHealth(_cachedHealth);
if (health < maxHealth)
{
ReflectionCache.SetHealth(_cachedHealth, maxHealth);
}
}
}
public override void OnGUI()
{
}
protected override void OnToggle()
{
if (!base.Enabled && (Object)(object)_cachedHealth != (Object)null)
{
ReflectionCache.SetGodMode(_cachedHealth, value: false);
}
}
}
public class InfiniteAmmo : BaseCheat
{
private bool _wasEnabled;
private FieldInfo _debugInfiniteBatteryField;
private float _timer;
public InfiniteAmmo()
{
base.Name = "Infinite Battery";
base.Category = CheatCategory.Player;
_debugInfiniteBatteryField = typeof(RoundDirector).GetField("debugInfiniteBattery", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
public override void Update()
{
if ((Object)(object)RoundDirector.instance == (Object)null || _debugInfiniteBatteryField == null)
{
return;
}
bool flag = (bool)_debugInfiniteBatteryField.GetValue(RoundDirector.instance);
if (base.Enabled && !flag)
{
_debugInfiniteBatteryField.SetValue(RoundDirector.instance, true);
MelonLogger.Msg("Infinite Battery: Enabled");
}
else if (!base.Enabled && _wasEnabled && flag)
{
_debugInfiniteBatteryField.SetValue(RoundDirector.instance, false);
MelonLogger.Msg("Infinite Battery: Disabled");
}
_wasEnabled = base.Enabled;
if (!base.Enabled)
{
return;
}
_timer += Time.deltaTime;
if (!(_timer >= 0.5f))
{
return;
}
_timer = 0f;
ItemBattery[] array = Object.FindObjectsOfType<ItemBattery>();
foreach (ItemBattery val in array)
{
if ((Object)(object)val != (Object)null && val.batteryLife < 100f)
{
val.batteryLife = 100f;
}
}
}
public override void OnGUI()
{
}
}
public class InfiniteEnergy : BaseCheat
{
public InfiniteEnergy()
{
base.Name = "Infinite Energy";
base.Category = CheatCategory.Player;
}
public override void Update()
{
if ((Object)(object)PlayerController.instance != (Object)null)
{
PlayerController.instance.EnergyCurrent = PlayerController.instance.EnergyStart;
}
}
public override void OnGUI()
{
}
}
public class ItemDurability : BaseCheat
{
private bool _infiniteDurability;
private float _cacheTimer;
private List<PhysGrabObject> _cachedObjects = new List<PhysGrabObject>();
public ItemDurability()
{
base.Name = "Item Durability";
base.Category = CheatCategory.World;
}
public override void OnGUI()
{
}
public override void OnGuiMenu()
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Space(20f);
_infiniteDurability = GUILayout.Toggle(_infiniteDurability, "Infinite Durability", Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
}
public override void Update()
{
if (!_infiniteDurability)
{
return;
}
_cacheTimer -= Time.deltaTime;
if (_cacheTimer <= 0f)
{
_cacheTimer = 1f;
_cachedObjects.Clear();
_cachedObjects.AddRange(Object.FindObjectsOfType<PhysGrabObject>());
}
for (int num = _cachedObjects.Count - 1; num >= 0; num--)
{
PhysGrabObject val = _cachedObjects[num];
if ((Object)(object)val == (Object)null)
{
_cachedObjects.RemoveAt(num);
}
else
{
val.OverrideIndestructible(2f);
}
}
}
}
public class MoneyHack : BaseCheat
{
public MoneyHack()
{
base.Name = "Money Hack (1M)";
base.Category = CheatCategory.World;
}
public override void Update()
{
if (TrainerMain.RepoLib != null && TrainerMain.RepoLib.IsInGame())
{
TrainerMain.RepoLib.SetCurrency(1000000);
}
}
public override void OnGUI()
{
}
}
public class StableValue : BaseCheat
{
private float _timer;
public StableValue()
{
base.Name = "Stable Value (No Damage)";
base.Category = CheatCategory.World;
}
public override void Update()
{
_timer += Time.deltaTime;
if (!(_timer >= 1f))
{
return;
}
_timer = 0f;
ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>();
foreach (ValuableObject val in array)
{
if ((Object)(object)val != (Object)null && val.dollarValueCurrent < val.dollarValueOriginal)
{
val.dollarValueCurrent = val.dollarValueOriginal;
}
}
}
public override void OnGUI()
{
}
}
public class SuperSpeed : BaseCheat
{
private float _originalSpeed = -1f;
public SuperSpeed()
{
base.Name = "Super Speed";
base.Category = CheatCategory.Player;
}
public override void Update()
{
if (TrainerMain.RepoLib == null || !TrainerMain.RepoLib.IsInGame())
{
return;
}
PlayerController playerController = TrainerMain.RepoLib.GetPlayerController();
if ((Object)(object)playerController != (Object)null)
{
if (_originalSpeed == -1f)
{
_originalSpeed = TrainerMain.RepoLib.GetSprintSpeed(playerController);
}
TrainerMain.RepoLib.SetSprintSpeed(playerController, 20f);
TrainerMain.RepoLib.SetMovementSpeed(playerController, 10f);
}
}
protected override void OnToggle()
{
if (!base.Enabled && TrainerMain.RepoLib != null && _originalSpeed != -1f)
{
PlayerController playerController = TrainerMain.RepoLib.GetPlayerController();
if ((Object)(object)playerController != (Object)null)
{
TrainerMain.RepoLib.SetSprintSpeed(playerController, _originalSpeed);
TrainerMain.RepoLib.SetMovementSpeed(playerController, _originalSpeed * 0.6f);
}
_originalSpeed = -1f;
}
}
public override void OnGUI()
{
}
}
}