Decompiled source of Unlockify v1.0.2

plugins/Unlockify/Unlockify.dll

Decompiled 3 months ago
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.Logging;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.Stats;
using RoR2;
using RoR2.Stats;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Unlockify")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6b1bf61fe0919364ab098a8e0aa27f208335b65c")]
[assembly: AssemblyProduct("Unlockify")]
[assembly: AssemblyTitle("Unlockify")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 Unlockify
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("Unlockify");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "Unlockify".Length + 1);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogDebug((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Debug_NoCallerPrefix(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("Nuxlar.Unlockify", "Unlockify", "1.0.2")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "Nuxlar.Unlockify";

		public const string PluginAuthor = "Nuxlar";

		public const string PluginName = "Unlockify";

		public const string PluginVersion = "1.0.2";

		internal static Main Instance { get; private set; }

		public static string PluginDirectory { get; private set; }

		public void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			Instance = this;
			Stopwatch stopwatch = Stopwatch.StartNew();
			Log.Init(((BaseUnityPlugin)this).Logger);
			Run.IsUnlockableUnlocked_UnlockableDef += new hook_IsUnlockableUnlocked_UnlockableDef(TrueifyRun);
			Run.IsUnlockableUnlocked_string += new hook_IsUnlockableUnlocked_string(TrueifyRun2);
			Run.DoesEveryoneHaveThisUnlockableUnlocked_UnlockableDef += new hook_DoesEveryoneHaveThisUnlockableUnlocked_UnlockableDef(TrueifyRunAll);
			Run.DoesEveryoneHaveThisUnlockableUnlocked_string += new hook_DoesEveryoneHaveThisUnlockableUnlocked_string(TrueifyRunAll2);
			UnlockableCatalog.GetUnlockableDef_string += new hook_GetUnlockableDef_string(PreventAchievement1);
			UnlockableCatalog.GetUnlockableDef_UnlockableIndex += new hook_GetUnlockableDef_UnlockableIndex(PreventAchievement2);
			UserProfile.HasUnlockable_UnlockableDef += new hook_HasUnlockable_UnlockableDef(TrueifyProfile);
			UserProfile.HasUnlockable_string += new hook_HasUnlockable_string(TrueifyProfile2);
			UserProfile.HasDiscoveredPickup += new hook_HasDiscoveredPickup(TrueifyPickup);
			UserProfile.HasSurvivorUnlocked += new hook_HasSurvivorUnlocked(TrueifySurvivor);
			UserProfile.HasAchievement += new hook_HasAchievement(TrueifyAchievement);
			UserProfile.CanSeeAchievement += new hook_CanSeeAchievement(TrueifyAchievement2);
			StatSheet.HasUnlockable += new hook_HasUnlockable(TrueifyStatSheet);
			PreGameController.AnyUserHasUnlockable += new hook_AnyUserHasUnlockable(TrueifyPreGameController);
			AchievementSystemSteam.AddAchievement += new hook_AddAchievement(DontGrantSteamAchievement);
			AchievementSystemEOS.AddAchievement += new hook_AddAchievement(DontGrantEGSAchievement);
			EclipseRun.GetLocalUserSurvivorCompletedEclipseLevel += new hook_GetLocalUserSurvivorCompletedEclipseLevel(GiveMaxEclipseLevel);
			EclipseRun.GetNetworkUserSurvivorCompletedEclipseLevel += new hook_GetNetworkUserSurvivorCompletedEclipseLevel(GiveMaxEclipseLevel2);
			stopwatch.Stop();
			Log.Info_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
		}

		private void DontGrantSteamAchievement(orig_AddAchievement orig, AchievementSystemSteam self, string achievementName)
		{
		}

		private void DontGrantEGSAchievement(orig_AddAchievement orig, AchievementSystemEOS self, string achievementName)
		{
		}

		private int GiveMaxEclipseLevel(orig_GetLocalUserSurvivorCompletedEclipseLevel orig, LocalUser localUser, SurvivorDef survivorDef)
		{
			return EclipseRun.maxEclipseLevel;
		}

		private int GiveMaxEclipseLevel2(orig_GetNetworkUserSurvivorCompletedEclipseLevel orig, NetworkUser networkUser, SurvivorDef survivorDef)
		{
			return EclipseRun.maxEclipseLevel;
		}

		private bool TrueifyStatSheet(orig_HasUnlockable orig, StatSheet self, UnlockableDef def)
		{
			return true;
		}

		private UnlockableDef PreventAchievement1(orig_GetUnlockableDef_string orig, string defName)
		{
			return null;
		}

		private UnlockableDef PreventAchievement2(orig_GetUnlockableDef_UnlockableIndex orig, UnlockableIndex idx)
		{
			return null;
		}

		private bool TrueifyRun(orig_IsUnlockableUnlocked_UnlockableDef orig, Run self, UnlockableDef unlockableDef)
		{
			if (NetworkServer.active)
			{
				return true;
			}
			Log.Warning("[Server] function 'Unlockify.TrueifyRun' called on client", "C:\\Users\\romym\\Desktop\\RoR2Mods\\Unlockify\\Unlockify\\Main.cs", "TrueifyRun", 98);
			return false;
		}

		private bool TrueifyRun2(orig_IsUnlockableUnlocked_string orig, Run self, string unlockableName)
		{
			if (NetworkServer.active)
			{
				return true;
			}
			Log.Warning("[Server] function 'Unlockify.TrueifyRun2' called on client", "C:\\Users\\romym\\Desktop\\RoR2Mods\\Unlockify\\Unlockify\\Main.cs", "TrueifyRun2", 106);
			return false;
		}

		private bool TrueifyPreGameController(orig_AnyUserHasUnlockable orig, UnlockableDef unlockableDef)
		{
			if (NetworkServer.active)
			{
				return true;
			}
			Log.Warning("[Server] function 'Unlockify.TrueifyPreGameController' called on client", "C:\\Users\\romym\\Desktop\\RoR2Mods\\Unlockify\\Unlockify\\Main.cs", "TrueifyPreGameController", 114);
			return false;
		}

		private bool TrueifyRunAll(orig_DoesEveryoneHaveThisUnlockableUnlocked_UnlockableDef orig, Run self, UnlockableDef unlockableDef)
		{
			if (NetworkServer.active)
			{
				return true;
			}
			Log.Warning("[Server] function 'Unlockify.Trueify' called on client", "C:\\Users\\romym\\Desktop\\RoR2Mods\\Unlockify\\Unlockify\\Main.cs", "TrueifyRunAll", 122);
			return false;
		}

		private bool TrueifyRunAll2(orig_DoesEveryoneHaveThisUnlockableUnlocked_string orig, Run self, string unlockableName)
		{
			if (NetworkServer.active)
			{
				return true;
			}
			Log.Warning("[Server] function 'Unlockify.Trueify' called on client", "C:\\Users\\romym\\Desktop\\RoR2Mods\\Unlockify\\Unlockify\\Main.cs", "TrueifyRunAll2", 130);
			return false;
		}

		private bool TrueifyProfile(orig_HasUnlockable_UnlockableDef orig, UserProfile self, UnlockableDef unlockableDef)
		{
			return true;
		}

		private bool TrueifyProfile2(orig_HasUnlockable_string orig, UserProfile self, string unlockableName)
		{
			return true;
		}

		private bool TrueifyAchievement(orig_HasAchievement orig, UserProfile self, string achievementName)
		{
			return true;
		}

		private bool TrueifyAchievement2(orig_CanSeeAchievement orig, UserProfile self, string achievementName)
		{
			return true;
		}

		private bool TrueifySurvivor(orig_HasSurvivorUnlocked orig, UserProfile self, SurvivorIndex survivorIndex)
		{
			return true;
		}

		private bool TrueifyPickup(orig_HasDiscoveredPickup orig, UserProfile self, PickupIndex pickupIndex)
		{
			return true;
		}
	}
}