Decompiled source of CheatingAllowed v1.0.2

plugins/A2.CheatingAllowed.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using HarmonyLib;
using Jotunn;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CheatingAllowed")]
[assembly: AssemblyDescription("Mod that prevents game from reading or setting any cheat flag.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CheatingAllowed")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("201be2fb-1f46-ccb3-ee2c-7099bc978573")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyVersion("1.0.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
internal static class PluginInfo
{
	public const string PluginGUID = "A2.CheatingAllowed";

	public const string PluginName = "CheatingAllowed";

	public const string PluginDescription = "Mod that prevents game from reading or setting any cheat flag.";

	public const string PluginSemanticVersion = "1.0.2";

	public const string PluginFullVersion = "1.0.2.0";
}
namespace A2.CheatingAllowed
{
	[BepInPlugin("A2.CheatingAllowed", "CheatingAllowed", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		private static readonly Harmony _harmony = new Harmony("A2.CheatingAllowed");

		private static bool _isPatched = false;

		public void Awake()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if ((int)SystemInfo.graphicsDeviceType != 4)
			{
				_isPatched = TryPatch();
			}
		}

		public void OnDestroy()
		{
			if (_isPatched)
			{
				TryUnpatch();
			}
		}

		private bool TryPatch()
		{
			try
			{
				_harmony.PatchAll();
				return true;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)ex);
				TryUnpatch();
				return false;
			}
		}

		private void TryUnpatch()
		{
			try
			{
				_harmony.UnpatchSelf();
			}
			catch (Exception ex)
			{
				Logger.LogError((object)ex);
			}
		}
	}
}
namespace A2.CheatingAllowed.Patches
{
	public static class AchievementsPatch
	{
		[HarmonyPatch(typeof(Achievements), "CanGetAchievements")]
		public static class CanGetAchievements
		{
			public static bool Prefix(ref bool __result, bool cheated)
			{
				__result = true;
				return false;
			}
		}

		[HarmonyPatch(typeof(Achievements), "IsCheatedAtAll")]
		public static class IsCheatedAtAll
		{
			public static bool Prefix(ref bool __result)
			{
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Achievements), "IsWorldCheated")]
		public static class IsWorldCheated
		{
			public static bool Prefix(ref bool __result)
			{
				__result = false;
				return false;
			}
		}
	}
	public static class CharacterDropPatch
	{
		[HarmonyPatch(typeof(CharacterDrop), "DropItems")]
		public static class DropItems
		{
			public static void Prefix(ref bool cheated)
			{
				cheated = false;
			}
		}
	}
	public static class CookingStationPatch
	{
		[HarmonyPatch(typeof(CookingStation), "SetSlot")]
		public static class SetSlot
		{
			private static void Prefix(ref bool cheated)
			{
				cheated = false;
			}
		}

		[HarmonyPatch(typeof(CookingStation), "GetSlot")]
		public static class GetSlot
		{
			private static void Postfix(ref bool cheated)
			{
				cheated = false;
			}
		}
	}
	public static class InventoryPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static class ItemCheated_ByResources
		{
			public static bool Prefix(ref bool __result)
			{
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static class ItemCheated_ByName
		{
			public static bool Prefix(ref bool __result)
			{
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Inventory), "CheatedDamagingItemEquipped")]
		public static class CheatedDamagingItemEquipped
		{
			public static bool Prefix(ref bool __result)
			{
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Inventory), "AnyCheatedItem")]
		public static class AnyCheatedItem
		{
			public static bool Prefix(ref bool __result)
			{
				__result = false;
				return false;
			}
		}
	}
	public static class ItemDropPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static class OnCreateNew_GameObject
		{
			private static void Prefix(ref bool cheated)
			{
				cheated = false;
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static class OnCreateNew_ItemDrop
		{
			private static void Prefix(ref bool cheated)
			{
				cheated = false;
			}
		}
	}
	public static class ZDOPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static class GetBool_ByHash
		{
			public static bool Prefix(ref bool __result, int hash, bool defaultValue)
			{
				if (hash == ZDOVars.s_cheated)
				{
					__result = false;
					return false;
				}
				if (hash == ZDOVars.s_cheatedQueued)
				{
					__result = false;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static class GetBool_ByHash_OutVar
		{
			public static void Postfix(int hash, ref bool value, ref bool __result)
			{
				if (hash == ZDOVars.s_cheated)
				{
					value = false;
				}
				if (hash == ZDOVars.s_cheatedQueued)
				{
					value = false;
				}
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static class SetBool_ByHash
		{
			public static void Prefix(int hash, ref bool value)
			{
				if (hash == ZDOVars.s_cheated || hash == ZDOVars.s_cheatedQueued)
				{
					value = false;
				}
			}
		}
	}
}
namespace A2.CheatingAllowed.Consts
{
	internal static class HarmonyConsts
	{
		public const bool HARMONY_PREFIX_RESULT_CONTINUE = true;

		public const bool HARMONY_PREFIX_RESULT_BREAK = false;
	}
}