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 XytreeMegingjordProgression v0.1.0
BepInEx/MegingjordProgression/MegingjordProgression.dll
Decompiled 2 days agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; 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("MegingjordProgression")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MegingjordProgression")] [assembly: AssemblyTitle("MegingjordProgression")] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } namespace MegingjordProgression { internal static class BalanceDefaults { public const int Tier1Capacity = 150; public const int Tier2Capacity = 200; public const int Tier3Capacity = 250; public const int Tier4Capacity = 300; public const float Tier2OreBonus = 10f; public const float Tier3OreBonus = 15f; public const float Tier4OreBonus = 20f; public const float Tier3CreatureDropBonus = 5f; public const float Tier4CreatureDropBonus = 10f; public const bool BonusBossDrops = false; public const bool BonusRareDrops = false; } [BepInPlugin("xytree.megingjordprogression", "Xytree's Megingjord Progression", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private ConfigEntry<bool> EnableFreeMegingjord = null; private ConfigEntry<bool> EnableFreeHaulerBelts = null; private ConfigEntry<string> CraftingDifficulty = null; private void Awake() { EnableFreeMegingjord = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableFreeMegingjord", false, "Adds a free Forge recipe for the vanilla Megingjord."); EnableFreeHaulerBelts = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableFreeHaulerBelts", false, "Makes all Hauler belt recipes free for testing."); CraftingDifficulty = ((BaseUnityPlugin)this).Config.Bind<string>("Crafting", "CraftingDifficulty", "Normal", "Crafting difficulty: Easy, Normal, or Hard."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Megingjord Progression: starting."); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Crafting difficulty: " + CraftingDifficulty.Value)); PrefabManager.OnVanillaPrefabsAvailable += RegisterBelts; } private int GetMetalCost() { string text = CraftingDifficulty.Value.ToLowerInvariant(); string text2 = text; if (!(text2 == "easy")) { if (text2 == "hard") { return 40; } return 20; } return 10; } private int GetHideCost() { string text = CraftingDifficulty.Value.ToLowerInvariant(); string text2 = text; if (!(text2 == "easy")) { if (text2 == "hard") { return 20; } return 10; } return 5; } private Sprite LoadIcon(string fileName) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) string text = "MegingjordProgression.Assets." + fileName; using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text); if (stream == null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not find embedded icon: " + text)); return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, array)) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not load PNG icon: " + fileName)); return null; } ((Object)val).name = fileName; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)val2).name = fileName; return val2; } private void RegisterBelts() { try { GameObject prefab = PrefabManager.Instance.GetPrefab("BeltStrength"); if ((Object)(object)prefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find vanilla Megingjord."); return; } int metalCost = GetMetalCost(); int hideCost = GetHideCost(); RegisterHauler("MP_HaulerBelt", "Hauler Belt", 250f, 0.05f, "BeltStrength", "An upgraded belt for carrying heavy loads.", "Iron", metalCost, "DeerHide", hideCost, "HaulerBelt.png"); RegisterHauler("MP_HaulerBeltT2", "Hauler Belt Tier 2", 350f, 0.05f, "MP_HaulerBelt", "A stronger belt for carrying heavy loads.", "Silver", metalCost, "WolfPelt", hideCost, "HaulerBeltTier2.png"); RegisterHauler("MP_HaulerBeltT3", "Hauler Belt Tier 3", 450f, 0.1f, "MP_HaulerBeltT2", "A powerful belt for carrying heavy loads.", "BlackMetal", metalCost, "LoxPelt", hideCost, "HaulerBeltTier3.png"); RegisterHauler("MP_HaulerBeltT4", "Hauler Belt Tier 4", 600f, 0.1f, "MP_HaulerBeltT3", "The ultimate belt for carrying heavy loads.", "FlametalNew", metalCost, "AskHide", hideCost, "HaulerBeltTier4.png"); if (EnableFreeMegingjord.Value) { RegisterFreeMegingjordRecipe(); } else { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Free Megingjord debug recipe disabled."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Belt registration error: " + ex)); } finally { PrefabManager.OnVanillaPrefabsAvailable -= RegisterBelts; } } private void RegisterHauler(string prefabName, string displayName, float carryBonus, float speedBonus, string previousBelt, string description, string metal, int metalAmount, string hide, int hideAmount, string iconFile) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateClonedPrefab(prefabName, "BeltStrength"); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)(displayName + ": failed to clone belt.")); return; } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)(displayName + ": ItemDrop missing.")); return; } Sprite val2 = LoadIcon(iconFile); if ((Object)(object)val2 != (Object)null) { component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 }; } SE_Stats val3 = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val3).name = prefabName + "_Effect"; ((StatusEffect)val3).m_name = displayName; ((StatusEffect)val3).m_tooltip = description; val3.m_addMaxCarryWeight = carryBonus; val3.m_speedModifier = speedBonus; if (!ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val3, false))) { ((BaseUnityPlugin)this).Logger.LogError((object)(displayName + ": status effect registration failed.")); return; } component.m_itemData.m_shared.m_name = displayName; component.m_itemData.m_shared.m_description = description; component.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)val3; if (!ItemManager.Instance.AddItem(new CustomItem(val, false))) { ((BaseUnityPlugin)this).Logger.LogError((object)(displayName + ": item registration failed.")); return; } ((BaseUnityPlugin)this).Logger.LogInfo((object)(displayName + " registered successfully.")); RegisterRecipe(prefabName, displayName, previousBelt, metal, metalAmount, hide, hideAmount); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)(displayName + " registration error: " + ex)); } } private void RegisterRecipe(string prefabName, string displayName, string previousBelt, string metal, int metalAmount, string hide, int hideAmount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown RecipeConfig val = new RecipeConfig(); val.Name = "Recipe_" + prefabName; val.Item = prefabName; val.Amount = 1; val.CraftingStation = "forge"; val.MinStationLevel = 1; if (!EnableFreeHaulerBelts.Value) { val.AddRequirement(previousBelt, 1, 0); val.AddRequirement(metal, metalAmount, 0); val.AddRequirement(hide, hideAmount, 0); } if (ItemManager.Instance.AddRecipe(new CustomRecipe(val))) { ((BaseUnityPlugin)this).Logger.LogInfo((object)(displayName + " Forge recipe registered. " + (EnableFreeHaulerBelts.Value ? "FREE DEBUG RECIPE." : ("Metal cost: " + metalAmount + ", hide cost: " + hideAmount + ".")))); } else { ((BaseUnityPlugin)this).Logger.LogError((object)(displayName + ": recipe registration failed.")); } } private void RegisterFreeMegingjordRecipe() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown RecipeConfig val = new RecipeConfig(); val.Name = "Recipe_MP_FreeMegingjord"; val.Item = "BeltStrength"; val.Amount = 1; val.CraftingStation = "forge"; val.MinStationLevel = 1; if (ItemManager.Instance.AddRecipe(new CustomRecipe(val))) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Free Megingjord debug recipe registered."); } else { ((BaseUnityPlugin)this).Logger.LogError((object)"Free Megingjord debug recipe registration failed."); } } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterBelts; } } }