Decompiled source of AchievementEnabler v1.0.0

AchievementEnabler.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("AchievementEnabler")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AchievementEnabler")]
[assembly: AssemblyTitle("AchievementEnabler")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 AchievementEnabler
{
	[BepInPlugin("vsp.AchievementEnabler", "Achievement Enabler", "1.0.0")]
	public class AchievementEnabler : BaseUnityPlugin
	{
		private void Awake()
		{
			Harmony.CreateAndPatchAll(typeof(AchievementEnabler).Assembly, (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Achievement Enabler loaded: mods no longer block achievements (real cheats still do)");
		}
	}
	[HarmonyPatch(typeof(Achievements), "CanGetAchievements")]
	internal static class Achievements_CanGetAchievements_Patch
	{
		private static void Postfix(ref bool __result, bool cheated)
		{
			try
			{
				if (!(__result || cheated) && (Game.instance == null || !Game.instance.GetPlayerProfile().m_usedCheats))
				{
					Player localPlayer = Player.m_localPlayer;
					if ((localPlayer == null || !((Humanoid)localPlayer).GetInventory().AnyCheatedItem()) && !Achievements.IsWorldCheated())
					{
						__result = true;
					}
				}
			}
			catch (Exception)
			{
			}
		}
	}
}