#define DEBUG
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks.Data;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("AchievementManager")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AchievementManager")]
[assembly: AssemblyTitle("AchievementManager")]
[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 AchievementManager
{
[BepInPlugin("com.maxgamertyper1.achievementmanager", "AchievementManager", "1.0.0")]
public class AchievementManager : BaseUnityPlugin
{
internal static ConfigFile config;
internal static ConfigEntry<bool> AchievementDecision;
private void Log(string message)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)message);
}
private void Awake()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
config = ((BaseUnityPlugin)this).Config;
AchievementDecision = config.Bind<bool>("Decision", "Achievement Decision", true, "Whether to give or remove all achievements (true is give, false is remove)");
Log("Plugin AchievementManager is loaded!");
Harmony harmony = new Harmony("com.maxgamertyper1.{name}");
Patch(harmony, typeof(MainMenu), "Awake", AchievementDecision.Value ? "GiveAchievements" : "RemoveAchievements", prefix: true, transpiler: false);
}
private void OnDestroy()
{
Log("Bye Bye From AchievementManager");
}
private void Patch(Harmony harmony, Type OriginalClass, string OriginalMethod, string PatchMethod, bool prefix, bool transpiler)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.Method(OriginalClass, OriginalMethod, (Type[])null, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(AchievementManager), PatchMethod, (Type[])null, (Type[])null);
if (prefix)
{
harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
else if (transpiler)
{
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null);
}
else
{
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
Log("Patched " + OriginalMethod + " in " + OriginalClass.ToString());
}
public static void RemoveAchievements()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
foreach (AchievementEnum value in Enum.GetValues(typeof(AchievementEnum)))
{
AchievementEnum val = value;
Debug.Print(((object)(AchievementEnum)(ref val)).ToString() + " removed");
((Achievement)(ref AchievementHandler.achievements[val])).Clear();
}
}
public static void GiveAchievements()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
foreach (AchievementEnum value in Enum.GetValues(typeof(AchievementEnum)))
{
AchievementEnum val = value;
Debug.Print(((object)(AchievementEnum)(ref val)).ToString() + " given");
((Achievement)(ref AchievementHandler.achievements[val])).Trigger(true);
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "AchievementManager";
public const string PLUGIN_NAME = "AchievementManager";
public const string PLUGIN_VERSION = "1.0.0";
}
}