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 PonyPlushies v1.0.1
PonyPlushies.dll
Decompiled 15 hours 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 Dawn; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using Microsoft.CodeAnalysis; using PonyPlushies.NetcodePatcher; using Unity.Netcode; using UnityEngine; [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("PonyPlushies")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Pony plushies as scrap in Lethal Company")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+69a70b54164d918310283752474236025a3b18bb")] [assembly: AssemblyProduct("PonyPlushies")] [assembly: AssemblyTitle("PonyPlushies")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 PonyPlushies { public class MysteryBoxItem : GiftBoxItem { public bool IsShopItem = false; private bool opened = false; private float despawnTimer = 0f; public override void InitializeAfterPositioning() { if ((bool)AccessTools.Field(typeof(GiftBoxItem), "loadedItemFromSave").GetValue(this) || !((NetworkBehaviour)this).IsServer) { return; } Random random = new Random(); PonyType[] array = (from pony in PonyTypes.All where (Object)(object)pony.Item != (Object)null where Plugin.BoundConfig.PonyConfigs[pony.Id].MysteryBoxEnabled.Value where Plugin.BoundConfig.PonyConfigs[pony.Id].MysteryBoxWeight.Value > 0 select pony).ToArray(); if (array.Length == 0) { Plugin.logger.LogWarning((object)"Mystery Box has 0 ponies to choose from, nothing will be in it"); AccessTools.Field(typeof(GiftBoxItem), "objectInPresentItem").SetValue(this, null); AccessTools.Field(typeof(GiftBoxItem), "objectInPresent").SetValue(this, null); AccessTools.Field(typeof(GiftBoxItem), "objectInPresentValue").SetValue(this, 0); return; } List<int> list = new List<int>(); PonyType[] array2 = array; foreach (PonyType ponyType in array2) { list.Add(Plugin.BoundConfig.PonyConfigs[ponyType.Id].MysteryBoxWeight.Value); } int randomWeightedIndexList = RoundManager.Instance.GetRandomWeightedIndexList(list, random); Item item = array[randomWeightedIndexList].Item; GameObject spawnPrefab = item.spawnPrefab; int num2 = 0; if (IsShopItem) { Terminal val = Object.FindObjectOfType<Terminal>(); int num3 = Array.IndexOf(val.buyableItemsList, PluginItems.MysteryBoxStoreItem); float num4 = (float)val.itemSalesPercentages[num3] / 100f; int value = Plugin.BoundConfig.MysteryBoxStorePrice.Value; float value2 = Plugin.BoundConfig.MysteryBoxSellbackMultiplier.Value; num2 = (int)((float)value * value2 * num4); } else { num2 = (int)((float)random.Next(item.minValue, item.maxValue) * RoundManager.Instance.scrapValueMultiplier); } AccessTools.Field(typeof(GiftBoxItem), "objectInPresentItem").SetValue(this, item); AccessTools.Field(typeof(GiftBoxItem), "objectInPresent").SetValue(this, spawnPrefab); AccessTools.Field(typeof(GiftBoxItem), "objectInPresentValue").SetValue(this, num2); } public override void ItemActivate(bool used, bool buttonDown = true) { if (((NetworkBehaviour)this).IsServer) { ((GiftBoxItem)this).ItemActivate(used, buttonDown); opened = true; } } public override void Update() { ((GrabbableObject)this).Update(); if (((NetworkBehaviour)this).IsServer) { if (opened) { despawnTimer += Time.deltaTime; } if (despawnTimer > 1f) { ((GrabbableObject)this).DiscardItem(); ((NetworkBehaviour)this).NetworkObject.Despawn(true); opened = false; } } } protected override void __initializeVariables() { ((GiftBoxItem)this).__initializeVariables(); } protected override void __initializeRpcs() { ((GiftBoxItem)this).__initializeRpcs(); } protected internal override string __getTypeName() { return "MysteryBoxItem"; } } [HarmonyPatch] public class NetworkManagerPatch { [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "Start")] public static void Start_PostfixPatch() { foreach (GameObject item in Plugin.PrefabsToRegsiter) { if ((Object)(object)item == (Object)null) { Plugin.logger.LogError((object)"Attempted to register null prefab"); } else { NetworkManager.Singleton.AddNetworkPrefab(item); } } } } [BepInPlugin("horse.paperbark.PonyPlushies", "PonyPlushies", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string modGUID = "horse.paperbark.PonyPlushies"; public const string modName = "PonyPlushies"; public const string modVersion = "1.0.1"; private static Harmony harmony = new Harmony("horse.paperbark.PonyPlushies"); internal static ManualLogSource logger = Logger.CreateLogSource("PonyPlushies"); public static AssetBundle ModAssets; public static readonly string AssetLocation = "assets/LethalCompany/Mods/plugins/PonyPlushies"; public static List<GameObject> PrefabsToRegsiter = new List<GameObject>(); internal static PluginConfig BoundConfig { get; private set; } = null; private void Awake() { BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config); PrepareNetcode(); LoadModAssets(); ApplyPatches(); PluginItems.Init(); logger.LogInfo((object)"Pony Plushies 1.0.1 is loaded! /)"); } private void LoadModAssets() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ModAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "ponyplushies")); if ((Object)(object)ModAssets == (Object)null) { logger.LogError((object)"Failed to load mod asset bundle"); } } private void ApplyPatches() { harmony.PatchAll(); } private void PrepareNetcode() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } } public class PluginConfig { public Dictionary<string, PonyConfig> PonyConfigs; public ConfigEntry<bool> TwoHandedPonies; public ConfigEntry<bool> AllowDineSpawning; public ConfigEntry<bool> MysteryBoxSpawnEnabled; public ConfigEntry<int> MysteryBoxSpawnWeight; public ConfigEntry<bool> MysteryBoxStoreEnabled; public ConfigEntry<int> MysteryBoxStorePrice; public ConfigEntry<float> MysteryBoxSellbackMultiplier; public ConfigEntry<float> ToyStorePonyMultiplier; public ConfigEntry<float> ToyStoreMysteryBoxMultiplier; public PluginConfig(ConfigFile config) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_006b: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_0181: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown //IL_0242: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Expected O, but got Unknown //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Expected O, but got Unknown //IL_02b4: Expected O, but got Unknown //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Expected O, but got Unknown //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Expected O, but got Unknown //IL_0326: Expected O, but got Unknown //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Expected O, but got Unknown //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Expected O, but got Unknown //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Expected O, but got Unknown //IL_0398: Expected O, but got Unknown //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Expected O, but got Unknown PonyConfigs = new Dictionary<string, PonyConfig>(); config.SaveOnConfigSet = false; TwoHandedPonies = config.Bind<bool>("General", "TwoHandedPonies", true, "Whether some larger ponies (e.g. Celestia, Luna, Queen Chrysalis) are considered two-handed items"); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(TwoHandedPonies, new BoolCheckBoxOptions { Section = "General", Name = "Two Handed Ponies", Description = "Whether some larger ponies (e.g. Celestia, Luna, Queen Chrysalis) are considered two-handed items" })); AllowDineSpawning = config.Bind<bool>("General", "AllowDineSpawning", false, "Whether ponies can spawn on Dine. In vanilla, Dine is supposed to only spawn body parts as scrap. With this enabled, ponies will spawn frequently on Dine due to the limited loot pool on this moon."); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(AllowDineSpawning, new BoolCheckBoxOptions { Section = "General", Name = "Spawn Ponies on Dine", Description = "Whether ponies can spawn on Dine. In vanilla, Dine is supposed to only spawn body parts as scrap. With this enabled, ponies will spawn frequently on Dine due to the limited loot pool on this moon." })); MysteryBoxSpawnEnabled = config.Bind<bool>("MysteryBox", "MysteryBoxSpawnEnabled", true, "Whether Mystery Boxes containing a random pony can spawn as scrap on moons"); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(MysteryBoxSpawnEnabled, new BoolCheckBoxOptions { Section = "Mystery Box", Name = "Spawn as Scrap", Description = "Whether Mystery Boxes containing a random pony can spawn as scrap on moons" })); MysteryBoxSpawnWeight = config.Bind<int>("MysteryBox", "MysteryBoxSpawnWeight", 8, "The weighted chance for a Mystery Box to spawn"); ConfigEntry<int> mysteryBoxSpawnWeight = MysteryBoxSpawnWeight; IntInputFieldOptions val = new IntInputFieldOptions { Section = "Mystery Box", Name = "Spawn Weight", Description = "The weighted chance for a Mystery Box to spawn" }; ((BaseRangeOptions<int>)val).Min = 1; ((BaseRangeOptions<int>)val).Max = 1000; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(mysteryBoxSpawnWeight, val)); MysteryBoxStoreEnabled = config.Bind<bool>("MysteryBox", "MysteryBoxStoreEnabled", true, "Whether Mystery Boxes can be purchased via the terminal"); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(MysteryBoxStoreEnabled, new BoolCheckBoxOptions { Section = "Mystery Box", Name = "Purchase from Store", Description = "Whether Mystery Boxes can be purchased via the terminal" })); MysteryBoxStorePrice = config.Bind<int>("MysteryBox", "MysteryBoxStorePrice", 100, "The price to buy a Mystery Box from the terminal"); ConfigEntry<int> mysteryBoxStorePrice = MysteryBoxStorePrice; IntInputFieldOptions val2 = new IntInputFieldOptions { Section = "Mystery Box", Name = "Store Price", Description = "The cost to purchase a Mystery Box via the terminal" }; ((BaseRangeOptions<int>)val2).Min = 1; ((BaseRangeOptions<int>)val2).Max = 1000000; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(mysteryBoxStorePrice, val2)); MysteryBoxSellbackMultiplier = config.Bind<float>("MysteryBox", "MysteryBoxSellbackMultiplier", 0.5f, "The scrap value of ponies obtained from purchased Mystery Boxes as a percentage of its original value"); ConfigEntry<float> mysteryBoxSellbackMultiplier = MysteryBoxSellbackMultiplier; FloatSliderOptions val3 = new FloatSliderOptions { Section = "Mystery Box", Name = "Purchased Pony Value", Description = "The scrap value of ponies obtained from purchased Mystery Boxes as a percentage of the box's original value. A value of 1 means the pony will be the same price you paid to purchase the Mystery Box, and 0 means it will always have no value." }; ((BaseRangeOptions<float>)val3).Min = 0f; ((BaseRangeOptions<float>)val3).Max = 1f; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(mysteryBoxSellbackMultiplier, val3)); ToyStorePonyMultiplier = config.Bind<float>("Compat.WesleysMoons", "ToyStorePonyMultiplier", 3f, "Multiplies the chance for ponies to spawn in Toy Store interiors by this amount"); ConfigEntry<float> toyStorePonyMultiplier = ToyStorePonyMultiplier; FloatSliderOptions val4 = new FloatSliderOptions { Section = "Compat - Wesley's Moons", Name = "Toy Store Pony Multiplier", Description = "Multiplies the chance for ponies to spawn in Toy Store interiors by this amount" }; ((BaseRangeOptions<float>)val4).Min = 1f; ((BaseRangeOptions<float>)val4).Max = 20f; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(toyStorePonyMultiplier, val4)); ToyStoreMysteryBoxMultiplier = config.Bind<float>("Compat.WesleysMoons", "ToyStoreMysteryBoxMultiplier", 5f, "Multiplies the chance for Mystery Boxes to spawn in Toy Store interiors by this amount"); ConfigEntry<float> toyStoreMysteryBoxMultiplier = ToyStoreMysteryBoxMultiplier; FloatSliderOptions val5 = new FloatSliderOptions { Section = "Compat - Wesley's Moons", Name = "Toy Store Mystery Box Multiplier", Description = "Multiplies the chance for ponies to spawn in Toy Store interiors by this amount" }; ((BaseRangeOptions<float>)val5).Min = 1f; ((BaseRangeOptions<float>)val5).Max = 20f; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(toyStoreMysteryBoxMultiplier, val5)); InitPonyConfigs(config); ClearOrphanedEntries(config); config.Save(); config.SaveOnConfigSet = true; } private void InitPonyConfigs(ConfigFile config) { //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Expected O, but got Unknown //IL_0243: Expected O, but got Unknown //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Expected O, but got Unknown //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Expected O, but got Unknown //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_028e: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Expected O, but got Unknown //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Expected O, but got Unknown //IL_02d9: Expected O, but got Unknown //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Expected O, but got Unknown //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Expected O, but got Unknown //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Expected O, but got Unknown //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Expected O, but got Unknown //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Expected O, but got Unknown //IL_035b: Expected O, but got Unknown //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Expected O, but got Unknown //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Expected O, but got Unknown //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Expected O, but got Unknown //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Expected O, but got Unknown //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Expected O, but got Unknown //IL_03dd: Expected O, but got Unknown //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Expected O, but got Unknown PonyType[] all = PonyTypes.All; foreach (PonyType ponyType in all) { PonyConfig ponyConfig = new PonyConfig { SpawnEnabled = config.Bind<bool>("Pony." + ponyType.Id, "SpawnAsScrap", ponyType.Values.SpawnEnabled, "Whether this pony should randomly spawn as scrap"), SpawnWeight = config.Bind<int>("Pony." + ponyType.Id, "SpawnWeight", ponyType.Values.SpawnWeight, "The weighted chance for this pony to spawn"), MinValue = config.Bind<int>("Pony." + ponyType.Id, "MinValue", ponyType.Values.MinValue, "The minimum sell value this pony can have"), MaxValue = config.Bind<int>("Pony." + ponyType.Id, "MaxValue", ponyType.Values.MaxValue, "The maximum sell value this pony can have"), StoreEnabled = config.Bind<bool>("Pony." + ponyType.Id, "StoreEnabled", ponyType.Values.StoreEnabled, "Whether this pony is available to purchase via the terminal"), StorePrice = config.Bind<int>("Pony." + ponyType.Id, "StorePrice", ponyType.Values.StorePrice, "The cost to purchase this pony via the terminal"), MysteryBoxEnabled = config.Bind<bool>("Pony." + ponyType.Id, "MysteryBoxEnabled", ponyType.Values.MysteryBoxEnabled, "Whether this pony can randomly spawn inside a Mystery Box"), MysteryBoxWeight = config.Bind<int>("Pony." + ponyType.Id, "MysteryBoxWeight", ponyType.Values.MysteryBoxWeight, "The weighted chance of this pony spawning in a Mystery Box") }; PonyConfigs.Add(ponyType.Id, ponyConfig); string section = "Pony - " + ponyType.ReadableName; LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(ponyConfig.SpawnEnabled, new BoolCheckBoxOptions { Section = section, Name = "Spawn as Scrap", Description = "Whether this pony can spawn randomly as scrap on moons" })); ConfigEntry<int> spawnWeight = ponyConfig.SpawnWeight; IntInputFieldOptions val = new IntInputFieldOptions { Section = section, Name = "Spawn Chance", Description = "The weighted chance for this pony to spawn" }; ((BaseRangeOptions<int>)val).Min = 1; ((BaseRangeOptions<int>)val).Max = 1000; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(spawnWeight, val)); ConfigEntry<int> minValue = ponyConfig.MinValue; IntInputFieldOptions val2 = new IntInputFieldOptions { Section = section, Name = "Min. Value", Description = "The minimum sell value this pony can have" }; ((BaseRangeOptions<int>)val2).Min = 0; ((BaseRangeOptions<int>)val2).Max = 1000000; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(minValue, val2)); ConfigEntry<int> maxValue = ponyConfig.MaxValue; IntInputFieldOptions val3 = new IntInputFieldOptions { Section = section, Name = "Max. Value", Description = "The maximum sell value this pony can have" }; ((BaseRangeOptions<int>)val3).Min = 0; ((BaseRangeOptions<int>)val3).Max = 1000000; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(maxValue, val3)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(ponyConfig.StoreEnabled, new BoolCheckBoxOptions { Section = section, Name = "Purchase from Store", Description = "Whether this pony is available to purchase via the terminal" })); ConfigEntry<int> storePrice = ponyConfig.StorePrice; IntInputFieldOptions val4 = new IntInputFieldOptions { Section = section, Name = "Store Price", Description = "The cost to purchase this pony via the terminal" }; ((BaseRangeOptions<int>)val4).Min = 0; ((BaseRangeOptions<int>)val4).Max = 1000000; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(storePrice, val4)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(ponyConfig.MysteryBoxEnabled, new BoolCheckBoxOptions { Section = section, Name = "Spawn in Mystery Box", Description = "Whether this pony can randomly spawn inside a Mystery Box" })); ConfigEntry<int> mysteryBoxWeight = ponyConfig.MysteryBoxWeight; IntInputFieldOptions val5 = new IntInputFieldOptions { Section = section, Name = "Mystery Box Chance", Description = "The weighted chance of this pony spawning in a Mystery Box" }; ((BaseRangeOptions<int>)val5).Min = 1; ((BaseRangeOptions<int>)val5).Max = 1000000; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(mysteryBoxWeight, val5)); } } private static void ClearOrphanedEntries(ConfigFile cfg) { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg); dictionary.Clear(); } } public record PonyConfig { public ConfigEntry<bool> SpawnEnabled; public ConfigEntry<int> SpawnWeight; public ConfigEntry<int> MinValue; public ConfigEntry<int> MaxValue; public ConfigEntry<bool> StoreEnabled; public ConfigEntry<int> StorePrice; public ConfigEntry<bool> MysteryBoxEnabled; public ConfigEntry<int> MysteryBoxWeight; } public record PonyConfigValues { public bool SpawnEnabled; public int SpawnWeight; public int MinValue; public int MaxValue; public bool StoreEnabled; public int StorePrice; public bool MysteryBoxEnabled; public int MysteryBoxWeight; } public class PluginItems { public static Item MysteryBoxItem; public static Item MysteryBoxStoreItem; public static void Init() { PonyType[] all = PonyTypes.All; foreach (PonyType pony in all) { InitPony(pony); } MysteryBoxItem = Plugin.ModAssets.LoadAsset<Item>(Plugin.AssetLocation + "/Items/MysteryBox/MysteryBoxItem.asset"); GameObject val = Plugin.ModAssets.LoadAsset<GameObject>(Plugin.AssetLocation + "/Items/MysteryBox/MysteryBoxPrefab.prefab"); MysteryBoxItem.minValue = (int)((float)PonyTypes.DefaultValues.MinValue / 0.4f); MysteryBoxItem.maxValue = (int)((float)PonyTypes.DefaultValues.MaxValue / 0.4f); if ((Object)(object)val == (Object)null) { Plugin.logger.LogError((object)"Failed to load Mystery Box - prefab not found in asset bundle"); } Plugin.PrefabsToRegsiter.Add(val); DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("ponyplushies", "MysteryBox"), MysteryBoxItem, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder) { if (Plugin.BoundConfig.MysteryBoxSpawnEnabled.Value) { builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrap) { scrap.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weights) { weights.SetGlobalWeight((IContextualProvider<int?, DawnMoonInfo, SpawnWeightContext>)new MysteryBoxSpawnWeightProvider()); }); }); } }); MysteryBoxStoreItem = Plugin.ModAssets.LoadAsset<Item>(Plugin.AssetLocation + "/Items/MysteryBox/MysteryBoxStoreItem.asset"); GameObject val2 = Plugin.ModAssets.LoadAsset<GameObject>(Plugin.AssetLocation + "/Items/MysteryBox/MysteryBoxStorePrefab.prefab"); if ((Object)(object)val2 == (Object)null) { Plugin.logger.LogError((object)"Failed to load Mystery Box - prefab not found in asset bundle"); } Plugin.PrefabsToRegsiter.Add(val2); DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("ponyplushies", "MysteryBoxStore"), MysteryBoxStoreItem, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder) { if (Plugin.BoundConfig.MysteryBoxStoreEnabled.Value) { builder.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shop) { shop.OverrideCost(Plugin.BoundConfig.MysteryBoxStorePrice.Value); }); } }); } private static void InitPony(PonyType pony) { Plugin.logger.LogDebug((object)("Initialising pony " + pony.Id)); Item val = Plugin.ModAssets.LoadAsset<Item>(Plugin.AssetLocation + "/Ponies/" + pony.Id + "/" + pony.Id + "Item.asset"); GameObject val2 = Plugin.ModAssets.LoadAsset<GameObject>(Plugin.AssetLocation + "/Ponies/" + pony.Id + "/" + pony.Id + "Prefab.prefab"); PonyConfig config = Plugin.BoundConfig.PonyConfigs[pony.Id]; if ((Object)(object)val == (Object)null) { Plugin.logger.LogError((object)("Failed to load pony " + pony.Id + " - asset not found in bundle")); return; } if ((Object)(object)val2 == (Object)null) { Plugin.logger.LogError((object)("Failed to load pony " + pony.Id + " - prefab not found in bundle")); return; } if (config == null) { Plugin.logger.LogError((object)("Failed to load pony " + pony.Id + " - config values not found")); return; } Plugin.PrefabsToRegsiter.Add(val2); val.minValue = (int)Math.Round((double)config.MinValue.Value / 0.4); val.maxValue = (int)Math.Round((double)config.MaxValue.Value / 0.4); if (!Plugin.BoundConfig.TwoHandedPonies.Value && val.twoHanded) { val.twoHanded = false; } pony.Item = val; DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("ponyplushies", pony.Id), val, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder) { if (config.SpawnEnabled.Value) { builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrap) { scrap.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weights) { weights.SetGlobalWeight((IContextualProvider<int?, DawnMoonInfo, SpawnWeightContext>)new PonySpawnWeightProvider(pony)); }); }); } if (config.StoreEnabled.Value) { builder.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shop) { shop.OverrideCost(config.StorePrice.Value); }); } }); } } public class PonySpawnWeightProvider : IContextualProvider<int?, DawnMoonInfo, SpawnWeightContext> { private PonyType pony; public PonySpawnWeightProvider(PonyType pony) { this.pony = pony; } public int? Provide(DawnMoonInfo info, SpawnWeightContext ctx) { int num = Plugin.BoundConfig.PonyConfigs[pony.Id].SpawnWeight.Value; if (!Plugin.BoundConfig.AllowDineSpawning.Value && ((SpawnWeightContext)(ref ctx)).Moon != null && ((object)((DawnBaseInfo<DawnMoonInfo>)(object)((SpawnWeightContext)(ref ctx)).Moon).Key).ToString() == "lethal_company:dine") { return 0; } if (((SpawnWeightContext)(ref ctx)).Dungeon != null && ((object)((DawnBaseInfo<DawnDungeonInfo>)(object)((SpawnWeightContext)(ref ctx)).Dungeon).Key).ToString() == "toy_store:toystoreflow") { num = (int)((float)num * Plugin.BoundConfig.ToyStorePonyMultiplier.Value); } return num; } } public class MysteryBoxSpawnWeightProvider : IContextualProvider<int?, DawnMoonInfo, SpawnWeightContext> { public int? Provide(DawnMoonInfo info, SpawnWeightContext ctx) { int num = Plugin.BoundConfig.MysteryBoxSpawnWeight.Value; if (!Plugin.BoundConfig.AllowDineSpawning.Value && ((SpawnWeightContext)(ref ctx)).Moon != null && ((object)((DawnBaseInfo<DawnMoonInfo>)(object)((SpawnWeightContext)(ref ctx)).Moon).Key).ToString() == "lethal_company:dine") { return 0; } if (((SpawnWeightContext)(ref ctx)).Dungeon != null && ((object)((DawnBaseInfo<DawnDungeonInfo>)(object)((SpawnWeightContext)(ref ctx)).Dungeon).Key).ToString() == "toy_store:toystoreflow") { num = (int)((float)num * Plugin.BoundConfig.ToyStoreMysteryBoxMultiplier.Value); } return num; } } public record PonyType { public string Id; public string ReadableName; public PonyConfigValues Values; public Item Item; } public class PonyTypes { public static readonly PonyConfigValues DefaultValues = new PonyConfigValues { SpawnEnabled = true, SpawnWeight = 3, MinValue = 40, MaxValue = 80, StoreEnabled = false, StorePrice = 80, MysteryBoxEnabled = true, MysteryBoxWeight = 10 }; public static readonly PonyConfigValues CommonValues = new PonyConfigValues { SpawnEnabled = DefaultValues.SpawnEnabled, SpawnWeight = 6, MinValue = DefaultValues.MinValue, MaxValue = DefaultValues.MaxValue, StoreEnabled = DefaultValues.StoreEnabled, StorePrice = DefaultValues.StorePrice, MysteryBoxEnabled = DefaultValues.MysteryBoxEnabled, MysteryBoxWeight = 30 }; public static readonly PonyConfigValues ExpensiveValues = new PonyConfigValues { SpawnEnabled = DefaultValues.SpawnEnabled, SpawnWeight = DefaultValues.SpawnWeight, MinValue = 100, MaxValue = 160, StoreEnabled = DefaultValues.StoreEnabled, StorePrice = DefaultValues.StorePrice, MysteryBoxEnabled = DefaultValues.MysteryBoxEnabled, MysteryBoxWeight = DefaultValues.MysteryBoxWeight }; public static readonly PonyType[] All = new PonyType[47] { new PonyType { Id = "AppleBloom", ReadableName = "Apple Bloom", Values = DefaultValues }, new PonyType { Id = "Applejack", ReadableName = "Applejack", Values = CommonValues }, new PonyType { Id = "AutumnBlaze", ReadableName = "Autumn Blaze", Values = DefaultValues }, new PonyType { Id = "BabsSeed", ReadableName = "Babs Seed", Values = DefaultValues }, new PonyType { Id = "BerryPunch", ReadableName = "Berry Punch", Values = DefaultValues }, new PonyType { Id = "BigMac", ReadableName = "Big Mac", Values = DefaultValues }, new PonyType { Id = "BonBon", ReadableName = "Bon Bon", Values = DefaultValues }, new PonyType { Id = "Braeburn", ReadableName = "Braeburn", Values = DefaultValues }, new PonyType { Id = "Cadance", ReadableName = "Princess Cadance", Values = ExpensiveValues }, new PonyType { Id = "Celestia", ReadableName = "Princess Celestia", Values = ExpensiveValues }, new PonyType { Id = "CheeseSandwich", ReadableName = "Cheese Sandwich", Values = DefaultValues }, new PonyType { Id = "Chrysalis", ReadableName = "Queen Chrysalis", Values = ExpensiveValues }, new PonyType { Id = "Daybreaker", ReadableName = "Daybreaker", Values = ExpensiveValues }, new PonyType { Id = "Derpy", ReadableName = "Derpy", Values = DefaultValues }, new PonyType { Id = "Discord", ReadableName = "Discord", Values = ExpensiveValues }, new PonyType { Id = "DrHooves", ReadableName = "Dr. Hooves", Values = DefaultValues }, new PonyType { Id = "Fizzy", ReadableName = "Fizzy", Values = DefaultValues }, new PonyType { Id = "Fluttershy", ReadableName = "Fluttershy", Values = CommonValues }, new PonyType { Id = "GrannySmith", ReadableName = "Granny Smith", Values = DefaultValues }, new PonyType { Id = "Kerfuffle", ReadableName = "Kerfuffle", Values = DefaultValues }, new PonyType { Id = "KingSombra", ReadableName = "King Sombra", Values = ExpensiveValues }, new PonyType { Id = "Littlepip", ReadableName = "Littlepip", Values = DefaultValues }, new PonyType { Id = "Luna", ReadableName = "Princess Luna", Values = ExpensiveValues }, new PonyType { Id = "Lyra", ReadableName = "Lyra", Values = DefaultValues }, new PonyType { Id = "MaudPie", ReadableName = "Maud Pie", Values = DefaultValues }, new PonyType { Id = "Minuette", ReadableName = "Minuette", Values = DefaultValues }, new PonyType { Id = "MoonDancer", ReadableName = "Moon Dancer", Values = DefaultValues }, new PonyType { Id = "NightmareMoon", ReadableName = "Nightmare Moon", Values = ExpensiveValues }, new PonyType { Id = "Octavia", ReadableName = "Octavia", Values = DefaultValues }, new PonyType { Id = "PinkiePie", ReadableName = "Pinkie Pie", Values = CommonValues }, new PonyType { Id = "PunkRarity", ReadableName = "Punk Rarity", Values = DefaultValues }, new PonyType { Id = "RainbowDash", ReadableName = "Rainbow Dash", Values = CommonValues }, new PonyType { Id = "Rarity", ReadableName = "Rarity", Values = CommonValues }, new PonyType { Id = "Scootaloo", ReadableName = "Scootaloo", Values = DefaultValues }, new PonyType { Id = "ShiningArmor", ReadableName = "Shining Armor", Values = DefaultValues }, new PonyType { Id = "Snowdrop", ReadableName = "Snowdrop", Values = DefaultValues }, new PonyType { Id = "Spike", ReadableName = "Spike", Values = new PonyConfigValues { SpawnEnabled = true, SpawnWeight = DefaultValues.SpawnWeight, MinValue = 20, MaxValue = 50, StoreEnabled = DefaultValues.StoreEnabled, StorePrice = DefaultValues.StorePrice, MysteryBoxEnabled = DefaultValues.MysteryBoxEnabled, MysteryBoxWeight = DefaultValues.MysteryBoxWeight } }, new PonyType { Id = "StarlightGlimmer", ReadableName = "Starlight Glimmer", Values = DefaultValues }, new PonyType { Id = "StoneyPony", ReadableName = "Stoney Pony", Values = DefaultValues }, new PonyType { Id = "Sunburst", ReadableName = "Sunburst", Values = DefaultValues }, new PonyType { Id = "SunsetShimmer", ReadableName = "Sunset Shimmer", Values = DefaultValues }, new PonyType { Id = "SweetieBelle", ReadableName = "Sweetie Belle", Values = DefaultValues }, new PonyType { Id = "TempestShadow", ReadableName = "Tempest Shadow", Values = DefaultValues }, new PonyType { Id = "Trixie", ReadableName = "Trixie", Values = DefaultValues }, new PonyType { Id = "TwilightSparkle", ReadableName = "Twilight Sparkle", Values = CommonValues }, new PonyType { Id = "VinylScratch", ReadableName = "Vinyl Scratch", Values = DefaultValues }, new PonyType { Id = "Zecora", ReadableName = "Zecora", Values = DefaultValues } }; } public static class PluginInfo { public const string PLUGIN_GUID = "PonyPlushies"; public const string PLUGIN_NAME = "PonyPlushies"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace PonyPlushies.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }