Decompiled source of YesIModButWantAchievementsAnyways v1.0.0

Plugins/VentureValheim.Achievements.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("VentureValheim.Achievements")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VentureValheim.Achievements")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("26C994A0-0C7D-4535-AA69-A8BA932C546D")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace VentureValheim.VVAchievements
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.orianaventure.mod.YesIModButWantAchievementsAnyways", "YesIModButWantAchievementsAnyways", "1.0.0")]
	public class AchievementsPlugin : BaseUnityPlugin
	{
		private const string ModName = "YesIModButWantAchievementsAnyways";

		private const string ModVersion = "1.0.0";

		private const string Author = "com.orianaventure.mod";

		private const string ModGUID = "com.orianaventure.mod.YesIModButWantAchievementsAnyways";

		private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.YesIModButWantAchievementsAnyways");

		public static readonly ManualLogSource AchievementsLogger = Logger.CreateLogSource("YesIModButWantAchievementsAnyways");

		public void Awake()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			HarmonyInstance.PatchAll(executingAssembly);
		}
	}
	public class VVAchievements
	{
		[HarmonyPatch(typeof(Achievements))]
		private static class AchievementsTranspiler
		{
			[HarmonyTranspiler]
			[HarmonyPatch("IsCheatedAtAll")]
			private static IEnumerable<CodeInstruction> IsCheatedAtAllTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Expected O, but got Unknown
				return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(Game), "isModded"), (string)null)
				}).ThrowIfInvalid("Could not patch Achievements.IsCheatedAtAll()!")
					.RemoveInstruction()
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(AchievementsTranspiler), "ReturnFalse", (Type[])null, (Type[])null))
					})
					.InstructionEnumeration();
			}

			private static bool ReturnFalse()
			{
				return false;
			}
		}

		[HarmonyPatch(typeof(Player), "Load")]
		public static class Patch_Player_Load
		{
			private static void Postfix(Player __instance)
			{
				//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)
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name.Equals("main"))
				{
					__instance.AddUniqueKeyValue("bypasscheatchecks", "0");
				}
			}
		}

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