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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CheatManager.Patches.Common;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CheatManager")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds ability to allow cheats without blocking any kind of progression or stat saving, while still disabling leaderboard submissions.")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+4253ea8ae50ede495293f9682fb1f616766b45a9")]
[assembly: AssemblyProduct("CheatManager")]
[assembly: AssemblyTitle("CheatManager")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 CheatManager
{
public static class Manager
{
private static readonly HashSet<string> CheatingMods = new HashSet<string>();
private static readonly HashSet<string> DisableLeaderboardMods = new HashSet<string>();
public static bool HasCheatedMods => CheatingMods.Any();
public static bool AllowCheats => Plugin.AllowCheats.Value;
public static bool IsLeaderboardBlocked => Plugin.AllowCheats.Value || Plugin.DisableLeaderboard.Value || HasCheatedMods || DisableLeaderboardMods.Any();
public static void SetCheated(string pluginId)
{
CheatingMods.Add(pluginId);
Plugin.Logger.LogInfo((object)("[" + pluginId + "] Enabled cheat check for mod"));
}
public static void UnsetCheated(string pluginId)
{
CheatingMods.Remove(pluginId);
Plugin.Logger.LogInfo((object)("[" + pluginId + "] Disabled cheat check for mod"));
}
public static void BlockLeaderboard(string pluginId)
{
DisableLeaderboardMods.Add(pluginId);
Plugin.Logger.LogInfo((object)("[" + pluginId + "] Blocked leaderboard for mod"));
}
public static void UnblockLeaderboard(string pluginId)
{
DisableLeaderboardMods.Remove(pluginId);
Plugin.Logger.LogInfo((object)("[" + pluginId + "] Unblocked leaderboard for mod"));
}
}
[BepInPlugin("com.dotlake.CheatManager", "CheatManager", "0.1.1")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Logger;
public static ConfigEntry<bool> AllowCheats { get; private set; }
public static ConfigEntry<bool> DisableLeaderboard { get; private set; }
public void Awake()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
LoadConfig();
Harmony val = new Harmony("dotlake.CheatManager");
val.PatchAll();
Logger.LogInfo((object)"CheatManager v0.1.1 loaded");
}
private void LoadConfig()
{
AllowCheats = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Allow Cheats", false, "Allow cheats without blocking achievements or unlocks.");
DisableLeaderboard = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable Leaderboard", false, "Enable or disable leaderboard functionality regardless of having cheats allowed. Leaderboard is always disabled if \"Allow Cheats\" is on.");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.dotlake.CheatManager";
public const string PLUGIN_NAME = "CheatManager";
public const string PLUGIN_VERSION = "0.1.1";
}
}
namespace CheatManager.Patches
{
[HarmonyPatch(typeof(CommandConsole))]
public static class CommandConsolePatches
{
[HarmonyPatch("Awake")]
[HarmonyPatch("EnableCheatsCommand")]
[HarmonyPatch("ExecuteCommand", new Type[]
{
typeof(string),
typeof(bool),
typeof(bool)
})]
[HarmonyPostfix]
public static void AllowCheatsPostfix()
{
CheatsPatch.PatchCheatChecks();
}
}
[HarmonyPatch(typeof(CL_SaveManager))]
public static class SaveManagerPatches
{
[HarmonyPatch("LoadSession")]
[HarmonyPostfix]
public static void LoadSessionPostfix()
{
CheatsPatch.PatchCheatChecks();
}
}
[HarmonyPatch(typeof(SteamManager))]
public static class SteamManagerPatches
{
[HarmonyPatch("UploadGamemodeResults")]
[HarmonyPrefix]
public static bool BlockLeaderboardPrefix()
{
if (Manager.IsLeaderboardBlocked)
{
Plugin.Logger.LogInfo((object)"Leaderboards blocked due to cheat mods being installed or cheat manager configuration");
return false;
}
return true;
}
}
}
namespace CheatManager.Patches.Common
{
public static class CheatsPatch
{
public static void PatchCheatChecks()
{
if (Manager.AllowCheats)
{
CommandConsole.cheatsEnabled = true;
CommandConsole.hasCheated = false;
}
else if (Manager.HasCheatedMods)
{
CommandConsole.hasCheated = true;
}
}
}
}