Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of AchievementPins v1.0.2
AchievementPins.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using IL.RoR2.UI.LogBook; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using On.RoR2.Achievements; using On.RoR2.UI; using On.RoR2.UI.LogBook; using RoR2; using RoR2.Achievements; using RoR2.Achievements.Artifacts; using RoR2.Achievements.Croco; using RoR2.UI; using RoR2.UI.LogBook; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AchievementPins")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+79cbeb90485d5189411d71a1b9230d5192ffc0ae")] [assembly: AssemblyProduct("AchievementPins")] [assembly: AssemblyTitle("AchievementPins")] [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 AchievementPins { [BepInPlugin("prodzpod.AchievementPins", "AchievementPins", "1.0.0")] public class Main : BaseUnityPlugin { public class AchievementClass : ObjectiveTracker { public bool _invopen = false; public AchievementDef def; public AchievementClass() { def = pins[pinIndex]; base.baseToken = pins[pinIndex].nameToken; pinIndex++; trackers.Add(this); _invopen = !invopen; } public override string GenerateString() { return Language.GetString(invopen ? def.descriptionToken : def.nameToken); } public override bool IsDirty() { if (invopen != _invopen) { _invopen = invopen; return true; } return false; } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_OnEnable <>9__18_0; public static hook_OnDisable <>9__18_1; public static hook_InitializeChallenge <>9__18_2; public static Func<Instruction, bool> <>9__18_11; public static Func<Instruction, bool> <>9__18_12; public static Manipulator <>9__18_3; public static Action<CharacterMaster, List<ObjectiveSourceDescriptor>> <>9__18_4; public static hook_OnInstall <>9__18_5; public static hook_OnInstall <>9__18_6; public static hook_OnUninstall <>9__18_7; public static hook_Grant <>9__18_8; public static Func<AchievementDef, bool> <>9__18_13; public static Func<AchievementDef, bool> <>9__18_14; public static Action<Run> <>9__18_9; public static Predicate<AchievementDef> <>9__18_15; public static Action<Run> <>9__18_10; public static Func<AchievementDef, bool> <>9__19_0; public static Func<NetworkUser, bool> <>9__20_0; public static Func<NetworkUser, bool> <>9__20_1; public static Predicate<AchievementDef> <>9__21_0; internal void <Awake>b__18_0(orig_OnEnable orig, ScoreboardController self) { orig.Invoke(self); invopen = true; } internal void <Awake>b__18_1(orig_OnDisable orig, ScoreboardController self) { orig.Invoke(self); invopen = false; } internal void <Awake>b__18_2(orig_InitializeChallenge orig, GameObject obj, Entry entry, EntryStatus status, UserProfile profile) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown orig.Invoke(obj, entry, status, profile); if ((int)status != 3) { return; } HGButton component = obj.GetComponent<HGButton>(); if ((int)status == 3) { ((MPButton)component).disableGamepadClick = false; ((MPButton)component).disablePointerClick = false; if (pins.Contains((AchievementDef)entry.extraData)) { ((Component)((Component)component).transform.Find("BGImage").Find("HasBeenUnlocked")).gameObject.SetActive(true); ((Behaviour)((Component)((Component)component).transform.Find("BGImage").Find("HasBeenUnlocked")).GetComponent<Image>()).enabled = false; } ((UnityEvent)((Button)component).onClick).AddListener(new UnityAction(ToggleAchievement(component, (AchievementDef)entry.extraData).Invoke)); } } internal void <Awake>b__18_3(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.GotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 13), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 4) }); int index = val.Index; val.Index = index + 1; val.Remove(); val.Emit(OpCodes.Ldc_I4_3); } internal bool <Awake>b__18_11(Instruction x) { return ILPatternMatchingExt.MatchLdloc(x, 13); } internal bool <Awake>b__18_12(Instruction x) { return ILPatternMatchingExt.MatchLdcI4(x, 4); } internal void <Awake>b__18_4(CharacterMaster master, List<ObjectiveSourceDescriptor> list) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) pinIndex = 0; trackers.Clear(); foreach (GameObject pinObject in pinObjects) { list.Add(new ObjectiveSourceDescriptor { source = (Object)(object)pinObject, master = master, objectiveType = typeof(AchievementClass) }); } } internal void <Awake>b__18_5(orig_OnInstall orig, UserAchievementManager self, LocalUser user) { Log.LogDebug((object)"Adding Achievements..."); defToClass.Clear(); orig.Invoke(self, user); Log.LogDebug((object)("Achievements: " + defToClass.Count)); } internal void <Awake>b__18_6(orig_OnInstall orig, BaseAchievement self) { orig.Invoke(self); defToClass.Add(self.achievementDef, self); } internal void <Awake>b__18_7(orig_OnUninstall orig, BaseAchievement self) { orig.Invoke(self); RemovePin(self.achievementDef); } internal void <Awake>b__18_8(orig_Grant orig, BaseAchievement self) { orig.Invoke(self); RemovePin(self.achievementDef); } internal void <Awake>b__18_9(Run run) { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown pins = pins.Where((AchievementDef x) => defToClass.ContainsKey(x) && BetterBodyCheck(defToClass[x])).ToList(); tempPins.Clear(); Log.LogDebug((object)"Fetching Random Pins"); for (int i = pins.Count; i < RandomPins.Value; i++) { AchievementDef[] array = (from x in defToClass.Keys.Except(pins) where BetterBodyCheck(defToClass[x]) && TrialCheck(x) select x).ToArray(); if (array.Length == 0) { break; } AchievementDef item = RoR2Application.rng.NextElementUniform<AchievementDef>(array); pins.Add(item); tempPins.Add(item); } foreach (GameObject pinObject in pinObjects) { Object.Destroy((Object)(object)pinObject); } pinObjects.Clear(); foreach (AchievementDef pin in pins) { GameObject val = new GameObject("Achievement Pin Holder"); pinObjects.Add(val); val.transform.parent = ((Component)Run.instance).transform; } } internal bool <Awake>b__18_13(AchievementDef x) { return defToClass.ContainsKey(x) && BetterBodyCheck(defToClass[x]); } internal bool <Awake>b__18_14(AchievementDef x) { return BetterBodyCheck(defToClass[x]) && TrialCheck(x); } internal void <Awake>b__18_10(Run _) { pins.RemoveAll((AchievementDef x) => tempPins.Contains(x)); } internal bool <Awake>b__18_15(AchievementDef x) { return tempPins.Contains(x); } internal bool <RemovePin>b__19_0(AchievementDef x) { return BetterBodyCheck(defToClass[x]) && TrialCheck(x); } internal bool <BetterBodyCheck>b__20_0(NetworkUser x) { return ((NetworkBehaviour)x).isLocalPlayer; } internal bool <BetterBodyCheck>b__20_1(NetworkUser x) { return ((NetworkBehaviour)x).isLocalPlayer; } internal bool <TrialCheck>b__21_0(AchievementDef x) { return defToClass[x] is BaseObtainArtifactAchievement; } } public const string PluginGUID = "prodzpod.AchievementPins"; public const string PluginAuthor = "prodzpod"; public const string PluginName = "AchievementPins"; public const string PluginVersion = "1.0.0"; public static ManualLogSource Log; public static PluginInfo pluginInfo; public static ConfigFile Config; public static ConfigEntry<bool> ShowOnTab; public static ConfigEntry<bool> RemoveOnComplete; public static ConfigEntry<int> RandomPins; public static ConfigEntry<bool> RegenPins; public static List<AchievementDef> pins = new List<AchievementDef>(); public static int pinIndex = 0; public static List<AchievementClass> trackers = new List<AchievementClass>(); public static Dictionary<AchievementDef, BaseAchievement> defToClass = new Dictionary<AchievementDef, BaseAchievement>(); public static List<GameObject> pinObjects = new List<GameObject>(); public static List<AchievementDef> tempPins = new List<AchievementDef>(); public static bool invopen = false; public void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown pluginInfo = ((BaseUnityPlugin)this).Info; Log = ((BaseUnityPlugin)this).Logger; Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "prodzpod.AchievementPins.cfg"), true); ShowOnTab = Config.Bind<bool>("General", "Hide Without Inventory Key", false, "Hide pinlist until tab is pressed."); RemoveOnComplete = Config.Bind<bool>("General", "Remove on Complete", false, "Remove pin when it's completed."); RandomPins = Config.Bind<int>("General", "Pin Random Achievements", 0, "Every run will have random pins up to that amount. Manual pins overrides it."); RegenPins = Config.Bind<bool>("General", "Regenerate Pins", false, "Automatically adds a new pin upon clearing one."); object obj2 = <>c.<>9__18_0; if (obj2 == null) { hook_OnEnable val = delegate(orig_OnEnable orig, ScoreboardController self) { orig.Invoke(self); invopen = true; }; <>c.<>9__18_0 = val; obj2 = (object)val; } ScoreboardController.OnEnable += (hook_OnEnable)obj2; object obj3 = <>c.<>9__18_1; if (obj3 == null) { hook_OnDisable val2 = delegate(orig_OnDisable orig, ScoreboardController self) { orig.Invoke(self); invopen = false; }; <>c.<>9__18_1 = val2; obj3 = (object)val2; } ScoreboardController.OnDisable += (hook_OnDisable)obj3; object obj4 = <>c.<>9__18_2; if (obj4 == null) { hook_InitializeChallenge val3 = delegate(orig_InitializeChallenge orig, GameObject obj, Entry entry, EntryStatus status, UserProfile profile) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown orig.Invoke(obj, entry, status, profile); if ((int)status == 3) { HGButton component = obj.GetComponent<HGButton>(); if ((int)status == 3) { ((MPButton)component).disableGamepadClick = false; ((MPButton)component).disablePointerClick = false; if (pins.Contains((AchievementDef)entry.extraData)) { ((Component)((Component)component).transform.Find("BGImage").Find("HasBeenUnlocked")).gameObject.SetActive(true); ((Behaviour)((Component)((Component)component).transform.Find("BGImage").Find("HasBeenUnlocked")).GetComponent<Image>()).enabled = false; } ((UnityEvent)((Button)component).onClick).AddListener(new UnityAction(ToggleAchievement(component, (AchievementDef)entry.extraData).Invoke)); } } }; <>c.<>9__18_2 = val3; obj4 = (object)val3; } CategoryDef.InitializeChallenge += (hook_InitializeChallenge)obj4; object obj5 = <>c.<>9__18_3; if (obj5 == null) { Manipulator val4 = delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) ILCursor val10 = new ILCursor(il); val10.GotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 13), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 4) }); int index = val10.Index; val10.Index = index + 1; val10.Remove(); val10.Emit(OpCodes.Ldc_I4_3); }; <>c.<>9__18_3 = val4; obj5 = (object)val4; } LogBookController.BuildEntriesPage += (Manipulator)obj5; ObjectivePanelController.collectObjectiveSources += delegate(CharacterMaster master, List<ObjectiveSourceDescriptor> list) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) pinIndex = 0; trackers.Clear(); foreach (GameObject pinObject in pinObjects) { list.Add(new ObjectiveSourceDescriptor { source = (Object)(object)pinObject, master = master, objectiveType = typeof(AchievementClass) }); } }; object obj6 = <>c.<>9__18_5; if (obj6 == null) { hook_OnInstall val5 = delegate(orig_OnInstall orig, UserAchievementManager self, LocalUser user) { Log.LogDebug((object)"Adding Achievements..."); defToClass.Clear(); orig.Invoke(self, user); Log.LogDebug((object)("Achievements: " + defToClass.Count)); }; <>c.<>9__18_5 = val5; obj6 = (object)val5; } UserAchievementManager.OnInstall += (hook_OnInstall)obj6; object obj7 = <>c.<>9__18_6; if (obj7 == null) { hook_OnInstall val6 = delegate(orig_OnInstall orig, BaseAchievement self) { orig.Invoke(self); defToClass.Add(self.achievementDef, self); }; <>c.<>9__18_6 = val6; obj7 = (object)val6; } BaseAchievement.OnInstall += (hook_OnInstall)obj7; object obj8 = <>c.<>9__18_7; if (obj8 == null) { hook_OnUninstall val7 = delegate(orig_OnUninstall orig, BaseAchievement self) { orig.Invoke(self); RemovePin(self.achievementDef); }; <>c.<>9__18_7 = val7; obj8 = (object)val7; } BaseAchievement.OnUninstall += (hook_OnUninstall)obj8; object obj9 = <>c.<>9__18_8; if (obj9 == null) { hook_Grant val8 = delegate(orig_Grant orig, BaseAchievement self) { orig.Invoke(self); RemovePin(self.achievementDef); }; <>c.<>9__18_8 = val8; obj9 = (object)val8; } BaseAchievement.Grant += (hook_Grant)obj9; Run.onRunStartGlobal += delegate { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown pins = pins.Where((AchievementDef x) => defToClass.ContainsKey(x) && BetterBodyCheck(defToClass[x])).ToList(); tempPins.Clear(); Log.LogDebug((object)"Fetching Random Pins"); for (int i = pins.Count; i < RandomPins.Value; i++) { AchievementDef[] array = (from x in defToClass.Keys.Except(pins) where BetterBodyCheck(defToClass[x]) && TrialCheck(x) select x).ToArray(); if (array.Length == 0) { break; } AchievementDef item = RoR2Application.rng.NextElementUniform<AchievementDef>(array); pins.Add(item); tempPins.Add(item); } foreach (GameObject pinObject2 in pinObjects) { Object.Destroy((Object)(object)pinObject2); } pinObjects.Clear(); foreach (AchievementDef pin in pins) { GameObject val9 = new GameObject("Achievement Pin Holder"); pinObjects.Add(val9); val9.transform.parent = ((Component)Run.instance).transform; } }; Run.onRunDestroyGlobal += delegate { pins.RemoveAll((AchievementDef x) => tempPins.Contains(x)); }; } public static void RemovePin(AchievementDef def) { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown int num = pins.IndexOf(def); if (num == -1) { return; } pins.RemoveAt(num); tempPins.Remove(def); Object.Destroy((Object)(object)pinObjects[num]); pinObjects.RemoveAt(num); if (RegenPins.Value) { AchievementDef[] array = (from x in defToClass.Keys.Except(pins) where BetterBodyCheck(defToClass[x]) && TrialCheck(x) select x).ToArray(); if (array.Length != 0) { AchievementDef item = RoR2Application.rng.NextElementUniform<AchievementDef>(array); pins.Add(item); tempPins.Add(item); GameObject val = new GameObject("Achievement Pin Holder"); pinObjects.Add(val); val.transform.parent = ((Component)Run.instance).transform; } } } public static bool BetterBodyCheck(BaseAchievement bc) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Invalid comparison between Unknown and I4 //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (bc is CrocoTotalInfectionsMilestoneAchievement || bc is CrocoKillWeakEnemiesMilestoneAchievement) { return ((Object)NetworkUser.readOnlyInstancesList.First((NetworkUser x) => ((NetworkBehaviour)x).isLocalPlayer).master.bodyPrefab).name == "CrocoBody"; } return (int)bc.LookUpRequiredBodyIndex() == -1 || BodyCatalog.GetBodyName(bc.LookUpRequiredBodyIndex()) == ((Object)NetworkUser.readOnlyInstancesList.First((NetworkUser x) => ((NetworkBehaviour)x).isLocalPlayer).master.bodyPrefab).name; } public static bool TrialCheck(AchievementDef x) { if (!pins.Exists((AchievementDef x) => defToClass[x] is BaseObtainArtifactAchievement)) { return true; } return !(defToClass[x] is BaseObtainArtifactAchievement); } public static Action ToggleAchievement(HGButton self, AchievementDef def) { return delegate { if (pins.Contains(def)) { UnpinAchievement(self, def); } else { PinAchievement(self, def); } }; } public static void PinAchievement(HGButton self, AchievementDef def) { pins.Add(def); ((Component)((Component)self).transform.Find("BGImage").Find("HasBeenUnlocked")).gameObject.SetActive(true); ((Behaviour)((Component)((Component)self).transform.Find("BGImage").Find("HasBeenUnlocked")).GetComponent<Image>()).enabled = false; Util.PlaySound("Play_UI_skill_unlock", ((Component)RoR2Application.instance).gameObject); } public static void UnpinAchievement(HGButton self, AchievementDef def) { pins.Remove(def); ((Component)((Component)self).transform.Find("BGImage").Find("HasBeenUnlocked")).gameObject.SetActive(false); Util.PlaySound("Play_UI_achievementUnlock", ((Component)RoR2Application.instance).gameObject); } } }