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 WishUtil v0.2.0
WishUtil.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using DanielSteginkUtils.ExternalFiles; using GlobalSettings; using HarmonyLib; using Microsoft.CodeAnalysis; using TeamCherry.Localization; using TeamCherry.SharedUtils; using UnityEngine; using WishUtil.Test; [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("WishUtil")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("This is a library for adding custom Wishes to Hollow Knight: Silksong.")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0+07f8b982115726b1e428e94ab20e49e418c6d0f8")] [assembly: AssemblyProduct("WishUtil")] [assembly: AssemblyTitle("WishUtil")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/danielstegink/Silksong.WishUtil")] [assembly: NeutralResourcesLanguage("EN")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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")] [Microsoft.CodeAnalysis.Embedded] 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")] [Microsoft.CodeAnalysis.Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace WishUtil { public abstract class CustomQuest : FullQuestBase { public abstract bool GiveAtStart { get; } public override bool IsHidden => false; public abstract string GetDescription(); public CustomQuest(string name, LocalisedString displayName, LocalisedString location) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0042: Expected O, but got Unknown //IL_0043: 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) //IL_004f: Expected O, but got Unknown //IL_0054: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0066: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) ((Object)this).name = name; ((BasicQuestBase)this).displayName = displayName; ((BasicQuestBase)this).location = location; base.inventoryDescription = new LocalisedString("Mods.io.github.danielstegink.wishutil", "QUEST_DESC"); OverrideFloat val = new OverrideFloat(); ((OverrideValue<float>)val).IsEnabled = false; base.overrideFontSize = val; OverrideFloat val2 = new OverrideFloat(); ((OverrideValue<float>)val2).IsEnabled = false; base.overrideParagraphSpacing = val2; OverrideFloat val3 = new OverrideFloat(); ((OverrideValue<float>)val3).IsEnabled = false; base.overrideParagraphSpacingShort = val3; base.targets = (QuestTarget[])(object)new QuestTarget[0]; base.customPickupDisplay = new UIMsgDisplay { Name = UI.QuestContinuePopup, Icon = ((BasicQuestBase)this).QuestType.Icon, IconScale = 1f, RepresentingObject = (Object)(object)this }; } public void Accept() { ((FullQuestBase)this).BeginQuest((Action)delegate { }, true); } public void Update() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!((FullQuestBase)this).Completion.IsCompleted) { CollectableUIMsg.Spawn((ICollectableUIMsgItem)(object)base.customPickupDisplay, Color.white, (CollectableUIMsg)null, false); } } public void Complete() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_002c: Unknown result type (might be due to invalid IL or missing references) if (!((FullQuestBase)this).Completion.IsCompleted) { Completion data = ((SerializableNamedList<Completion, NamedCompletion>)(object)PlayerData.instance.QuestCompletionData).GetData(((Object)this).name); ((Completion)(ref data)).SetCompleted(); ((FullQuestBase)this).Completion = data; ((FullQuestBase)this).ShowQuestCompleted((Action)delegate { }); } } } public enum QuestTypeEnum { Wayfarer, Gather, Hunt, GrandHunt, Donate, Delivery, Learn, Sprint, Witness, Steel } public static class GetQuestType { internal static Dictionary<QuestTypeEnum, QuestType> types = new Dictionary<QuestTypeEnum, QuestType>(); private static Dictionary<QuestTypeEnum, Color> typeColors = new Dictionary<QuestTypeEnum, Color> { { QuestTypeEnum.Wayfarer, new Color(0.925f, 0.792f, 0.478f) }, { QuestTypeEnum.Gather, new Color(0.559f, 0.926f, 0.724f) }, { QuestTypeEnum.Hunt, new Color(0.925f, 0.514f, 0.478f) }, { QuestTypeEnum.GrandHunt, new Color(0.925f, 0.514f, 0.478f) }, { QuestTypeEnum.Donate, new Color(0.915f, 0.662f, 0.522f) }, { QuestTypeEnum.Delivery, new Color(0.783f, 0.471f, 0.321f) }, { QuestTypeEnum.Learn, new Color(0.962f, 0.595f, 0.76f) }, { QuestTypeEnum.Sprint, new Color(0.358f, 0.59f, 0.783f) }, { QuestTypeEnum.Witness, new Color(1f, 0.6f, 0.278f) }, { QuestTypeEnum.Steel, new Color(0.75f, 0.75f, 0.75f) } }; public static QuestType GetType(QuestTypeEnum questType) { return types[questType]; } public static QuestType BuildCustomType(LocalisedString questTypeName, Sprite icon, Color? textColor, Sprite? iconGlow, Sprite? iconLarge, Sprite? iconLargeGlow) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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) if ((Object)(object)iconGlow == (Object)null) { iconGlow = icon; } if ((Object)(object)iconLarge == (Object)null) { iconLarge = icon; } if ((Object)(object)iconLargeGlow == (Object)null) { iconLargeGlow = icon; } if (!textColor.HasValue) { textColor = Color.white; } return QuestType.Create(questTypeName, icon, textColor.Value, iconLarge, iconLargeGlow, iconGlow); } internal static void BuildQuestTypes() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) QuestTypeEnum[] array = (QuestTypeEnum[])Enum.GetValues(typeof(QuestTypeEnum)); for (int i = 0; i < array.Length; i++) { QuestTypeEnum key = array[i]; string text = key.ToString(); LocalisedString val = new LocalisedString("Mods.io.github.danielstegink.wishutil", "TYPE_NAME_" + text); Assembly executingAssembly = Assembly.GetExecutingAssembly(); Sprite localSprite = GetSprite.GetLocalSprite("WishUtil.Resources." + text + ".Icon.png", executingAssembly, false); Sprite localSprite2 = GetSprite.GetLocalSprite("WishUtil.Resources." + text + ".Glow.png", executingAssembly, false); Sprite localSprite3 = GetSprite.GetLocalSprite("WishUtil.Resources." + text + ".Large.png", executingAssembly, false); Sprite localSprite4 = GetSprite.GetLocalSprite("WishUtil.Resources." + text + ".Large_Glow.png", executingAssembly, false); Color val2 = typeColors[key]; QuestType value = QuestType.Create(val, localSprite, val2, localSprite3, localSprite4, localSprite2); types.Add(key, value); } } } public static class QuestData { internal static Dictionary<string, CustomQuest> quests = new Dictionary<string, CustomQuest>(); public static void AddQuest<T>(T quest) where T : CustomQuest { quests.Add(((Object)quest).name, quest); } public static CustomQuest GetQuest(string name) { return quests[name]; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("io.github.danielstegink.wishutil", "WishUtil", "0.2.0")] public class WishUtil : BaseUnityPlugin { internal static WishUtil instance; public const string Id = "io.github.danielstegink.wishutil"; public static string Name => "WishUtil"; public static string Version => "0.2.0"; private void Awake() { instance = this; Log("Plugin " + Name + " (io.github.danielstegink.wishutil) has loaded!"); } private void Start() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("io.github.danielstegink.wishutil").PatchAll(); GetQuestType.BuildQuestTypes(); Log("Quest Type templates constructed"); if (TestData.testMode) { TestData.deliveryTest = new DeliveryTest(); QuestData.AddQuest(TestData.deliveryTest); TestData.donateTest = new DonateTest(); QuestData.AddQuest(TestData.donateTest); TestData.gatherTest = new GatherTest(); QuestData.AddQuest(TestData.gatherTest); TestData.grandHuntTest = new GrandHuntTest(); QuestData.AddQuest(TestData.grandHuntTest); TestData.huntTest = new HuntTest(); QuestData.AddQuest(TestData.huntTest); TestData.learnTest = new LearnTest(); QuestData.AddQuest(TestData.learnTest); TestData.sprintTest = new SprintTest(); QuestData.AddQuest(TestData.sprintTest); TestData.steelTest = new SteelTest(); QuestData.AddQuest(TestData.steelTest); TestData.wayfarerTest = new WayfarerTest(); QuestData.AddQuest(TestData.wayfarerTest); TestData.witnessTest = new WitnessTest(); QuestData.AddQuest(TestData.witnessTest); } } internal void Log(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } } } namespace WishUtil.Test { internal class DeliveryTest : TestQuest { public override bool GiveAtStart => false; public override QuestType QuestType => GetQuestType.GetType(QuestTypeEnum.Delivery); public DeliveryTest() : base("DeliveryTest") { } } internal class DonateTest : TestQuest { public override bool GiveAtStart => true; public override QuestType QuestType => GetQuestType.GetType(QuestTypeEnum.Donate); public DonateTest() : base("DonateTest") { } } [HarmonyPatch(typeof(EnemyJournalManager), "RecordKillToJournalData")] public static class EnemyJournalManager_RecordKillToJournalData { [HarmonyPostfix] public static void Postfix() { if (!TestData.testMode) { return; } TestData.killCount++; TestData.deliveryTest.Update(); TestData.donateTest.Update(); TestData.gatherTest.Update(); TestData.grandHuntTest.Update(); TestData.huntTest.Update(); TestData.learnTest.Update(); TestData.sprintTest.Update(); TestData.steelTest.Update(); TestData.wayfarerTest.Update(); TestData.witnessTest.Update(); if (TestData.killCount > 2) { if (!((BasicQuestBase)TestData.deliveryTest).IsAccepted) { TestData.deliveryTest.Accept(); } else { TestData.deliveryTest.Update(); } } if (TestData.killCount > 4) { TestData.deliveryTest.Complete(); } if (TestData.killCount > 5) { TestData.donateTest.Complete(); } if (TestData.killCount > 6) { TestData.gatherTest.Complete(); } if (TestData.killCount > 7) { TestData.grandHuntTest.Complete(); } if (TestData.killCount > 8) { TestData.huntTest.Complete(); } if (TestData.killCount > 9) { TestData.learnTest.Complete(); } if (TestData.killCount > 10) { TestData.sprintTest.Complete(); } if (TestData.killCount > 11) { TestData.steelTest.Complete(); } if (TestData.killCount > 12) { TestData.wayfarerTest.Complete(); } if (TestData.killCount > 13) { TestData.witnessTest.Complete(); } } } internal class GatherTest : TestQuest { public override bool GiveAtStart => true; public override QuestType QuestType => GetQuestType.GetType(QuestTypeEnum.Gather); public GatherTest() : base("GatherTest") { } } internal class GrandHuntTest : TestQuest { public override bool GiveAtStart => true; public override QuestType QuestType => GetQuestType.GetType(QuestTypeEnum.GrandHunt); public GrandHuntTest() : base("GrandHuntTest") { } } internal class HuntTest : TestQuest { public override bool GiveAtStart => true; public override QuestType QuestType => GetQuestType.GetType(QuestTypeEnum.Hunt); public HuntTest() : base("HuntTest") { } } internal class LearnTest : TestQuest { public override bool GiveAtStart => true; public override QuestType QuestType => GetQuestType.GetType(QuestTypeEnum.Learn); public LearnTest() : base("LearnTest") { } } internal class SprintTest : TestQuest { public override bool GiveAtStart => true; public override QuestType QuestType => GetQuestType.GetType(QuestTypeEnum.Sprint); public SprintTest() : base("SprintTest") { } } internal class SteelTest : TestQuest { public override bool GiveAtStart => true; public override QuestType QuestType => GetQuestType.GetType(QuestTypeEnum.Steel); public SteelTest() : base("SteelTest") { } } internal static class TestData { internal static bool testMode; internal static DeliveryTest deliveryTest; internal static DonateTest donateTest; internal static GatherTest gatherTest; internal static GrandHuntTest grandHuntTest; internal static HuntTest huntTest; internal static LearnTest learnTest; internal static SprintTest sprintTest; internal static SteelTest steelTest; internal static WayfarerTest wayfarerTest; internal static WitnessTest witnessTest; internal static int killCount; } internal abstract class TestQuest : CustomQuest { internal TestQuest(string questName) : base(questName, new LocalisedString("Mods.io.github.danielstegink.wishutil", "QUEST_NAME"), new LocalisedString("Mods.io.github.danielstegink.wishutil", "QUEST_LOC")) { }//IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) public override string GetDescription() { return ((Object)this).name; } } internal class WayfarerTest : TestQuest { public override bool GiveAtStart => true; public override QuestType QuestType => GetQuestType.GetType(QuestTypeEnum.Wayfarer); public WayfarerTest() : base("WayfarerTest") { } } internal class WitnessTest : TestQuest { public override bool GiveAtStart => true; public override QuestType QuestType => GetQuestType.GetType(QuestTypeEnum.Witness); public WitnessTest() : base("WitnessTest") { } } } namespace WishUtil.HarmonyPatches { [HarmonyPatch(typeof(HeroController), "Start")] public static class HeroController_Start { [HarmonyPostfix] public static void Postfix(HeroController __instance) { //IL_00db: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) List<string> validNames = ((SerializableNamedList<Completion, NamedCompletion>)(object)PlayerData.instance.QuestCompletionData).GetValidNames((Func<Completion, bool>)null); foreach (CustomQuest value in QuestData.quests.Values) { if (!validNames.Contains(((Object)value).name)) { Completion val = default(Completion); val.HasBeenSeen = value.GiveAtStart; val.IsAccepted = value.GiveAtStart; val.IsCompleted = false; val.WasEverCompleted = false; val.CompletedCount = 0; Completion val2 = val; ((SerializableNamedList<Completion, NamedCompletion>)(object)PlayerData.instance.QuestCompletionData).SetData(((Object)value).name, val2); ((FullQuestBase)value).Completion = val2; WishUtil.instance.Log($"{((Object)value).name} added to QuestCompletionData (Accepted: {val2.IsAccepted}, Completed: {val2.IsCompleted})"); } else { Completion data = ((SerializableNamedList<Completion, NamedCompletion>)(object)PlayerData.instance.QuestCompletionData).GetData(((Object)value).name); WishUtil.instance.Log($"QuestCompletionData found for {((Object)value).name} (Accepted: {data.IsAccepted}, Completed: {data.IsCompleted})"); } } } } [HarmonyPatch(typeof(Language), "Get", new Type[] { typeof(string), typeof(string) })] public static class Language_Get { [HarmonyPostfix] public static void Postfix(ref string key, ref string sheetTitle, ref string __result) { foreach (CustomQuest value in QuestData.quests.Values) { if (sheetTitle.Equals(((FullQuestBase)value).inventoryDescription.Sheet) && key.Equals(((FullQuestBase)value).inventoryDescription.Key)) { __result = value.GetDescription(); } } } } [HarmonyPatch(typeof(QuestManager), "Awake")] public static class QuestManager_Awake { [HarmonyPostfix] public static void Postfix(QuestManager __instance) { foreach (CustomQuest value in QuestData.quests.Values) { ((NamedScriptableObjectList<BasicQuestBase>)(object)__instance.masterList).Add((BasicQuestBase)(object)value); WishUtil.instance.Log(((Object)value).name + " added to QuestManager"); } } } }