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 EndingIndicators v0.2.0
EndingIndicators.dll
Decompiled 8 months agousing System; using System.ComponentModel; using System.Diagnostics; using System.IO; 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 UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EndingIndicators")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0+51b0f2f0e089021626eb366208effc8658089c1d")] [assembly: AssemblyProduct("EndingIndicators")] [assembly: AssemblyTitle("EndingIndicators")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.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.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] [Microsoft.CodeAnalysis.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; } } [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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace EndingIndicators { internal static class Config { public enum EndingDisplayOpts { [Description("OnlyCompleted")] OnlyCompleted, [Description("ShowAllIfAnyCompleted")] ShowAllIfAnyCompleted, [Description("ShowAll")] ShowAll } private static ConfigFile _config; private static ConfigEntry<EndingDisplayOpts> _endingDisplay; private static ConfigEntry<bool> _naturalOrder; public static EndingDisplayOpts EndingDisplay => _endingDisplay.Value; public static bool NaturalOrder => _naturalOrder.Value; public static void Setup(Plugin plugin) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if (_config != null) { return; } ConfigFile val = new ConfigFile(GetConfigFilePath(), false, ((BaseUnityPlugin)plugin).Info.Metadata); FieldInfo fieldInfo = ((object)plugin).GetType().BaseType?.GetField("<Config>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic); if ((object)fieldInfo != null) { fieldInfo.SetValue(plugin, val); } else { Log.Error("Patching of `Plugin.Config` failed. ConfigurationManager discovery will not work"); } _config = val; _endingDisplay = _config.Bind<EndingDisplayOpts>("Options", "EndingDisplay", EndingDisplayOpts.OnlyCompleted, "How the indicators should be displayed.\nEndings that are not yet completed, will be shown in a more transparent color\nif `ShowAllIfAnyCompleted` or `ShowAll` are used."); _naturalOrder = _config.Bind<bool>("Options", "NaturalOrder", false, "Reverse the order of the endings to match their natural order of unlocking."); Log.Debug("Config parsed successfully"); _config.SettingChanged += delegate(object _, SettingChangedEventArgs args) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 UIManager instance = UIManager.instance; if ((int)instance.uiState == 1 && (int)instance.menuState == 5) { SaveSlotButton[] array = Object.FindObjectsByType<SaveSlotButton>((FindObjectsSortMode)0); foreach (SaveSlotButton val2 in array) { val2.saveSlotCompletionIcons.SetCompletionIconState(val2.saveStats); } Log.Debug(args.ChangedSetting.Definition.Key + " setting changed. Live UI reload applied"); } }; } private static string GetConfigFilePath() { Platform current = Platform.Current; Platform obj = ((current is DesktopPlatform) ? current : null); object obj2; if (obj == null) { obj2 = null; } else { DesktopOnlineSubsystem onlineSubsystem = ((DesktopPlatform)obj).onlineSubsystem; obj2 = ((onlineSubsystem != null) ? onlineSubsystem.UserId : null); } string text = (string)obj2; string text2 = (string.IsNullOrEmpty(text) ? "default" : text); string text3 = Path.Combine(Application.persistentDataPath, text2, "plugins", "unavailable.ending-indicators", "config.dat"); Log.Debug("Config file located at: " + text3); return text3; } } internal static class Log { public static void Debug(string message) { Debug.Log((object)("[unavailable.ending-indicators] " + message)); } public static void Error(string message) { Debug.LogError((object)("[unavailable.ending-indicators] " + message)); } } [BepInPlugin("unavailable.ending-indicators", "EndingIndicators", "0.2.0")] public class Plugin : BaseUnityPlugin { internal static Plugin _instance; private static Harmony _harmony; public const string Id = "unavailable.ending-indicators"; public static string Name => "EndingIndicators"; public static string Version => "0.2.0"; private void Awake() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown Log.Debug("Mod loaded"); _instance = this; _harmony = new Harmony("unavailable.ending-indicators"); _harmony.PatchAll(typeof(Patches)); } } internal class Patches { [HarmonyPatch(typeof(UIManager), "Awake")] private static void Prefix() { Config.Setup(Plugin._instance); } [HarmonyPatch(typeof(SaveSlotCompletionIcons), "SetCompletionIconState")] private static void Postfix(SaveSlotCompletionIcons __instance, SaveStats SaveStats) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) CompletionState completedEndings = SaveStats.CompletedEndings; bool flag = false; foreach (CompletionIcon completionIcon in __instance.completionIcons) { bool flag2 = (int)completionIcon.state != 0 && ((Enum)completedEndings).HasFlag((Enum)(object)completionIcon.state); flag = flag || flag2; if (Config.EndingDisplay == Config.EndingDisplayOpts.OnlyCompleted) { completionIcon.icon.gameObject.SetActive(flag2); } else { Config.EndingDisplayOpts endingDisplay = Config.EndingDisplay; if ((uint)(endingDisplay - 1) > 1u) { throw new InvalidOperationException("Someone forgot to add more branches :)"); } completionIcon.icon.gameObject.SetActive(true); if (!flag2) { Image component = completionIcon.icon.GetComponent<Image>(); Color color = ((Graphic)component).color; color.a = 0.25f; ((Graphic)component).color = color; } } if (Config.NaturalOrder) { completionIcon.icon.transform.SetAsFirstSibling(); } else { completionIcon.icon.transform.SetAsLastSibling(); } } if (__instance.completionIcons.Count > 0) { ((Component)__instance.completionIcons[0].icon.transform.parent).gameObject.SetActive(Config.EndingDisplay == Config.EndingDisplayOpts.ShowAll || flag); } } } }