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 Simpler Meads v1.1.0
SimplerMeads.dll
Decompiled 2 days agousing System; using System.Collections; 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.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("SimplerMeads")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+ad87e688f235557c9dae575bf9d1bf84e94dff79")] [assembly: AssemblyProduct("SimplerMeads")] [assembly: AssemblyTitle("SimplerMeads")] [assembly: AssemblyVersion("1.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 SimplerMeads { internal sealed class MeadBase { public string Prefab; public string Name; public string Bottle; public int Yield; public Dictionary<string, int> Ingredients; public Recipe Live; public RequirementConfig[] ToRequirements() { return ((IEnumerable<KeyValuePair<string, int>>)Ingredients).Select((Func<KeyValuePair<string, int>, RequirementConfig>)((KeyValuePair<string, int> i) => new RequirementConfig { Item = i.Key, Amount = i.Value })).ToArray(); } } internal sealed class RecipeOverride { public int Yield { get; set; } = -1; public Dictionary<string, int> Ingredients { get; set; } } internal static class Recipes { internal const string FileName = "elric.SimplerMeads.recipes.yml"; internal const string VanillaBase = "MeadBaseTasty"; private static readonly MeadBase[] Defaults = new MeadBase[6] { new MeadBase { Prefab = "smr_base_kvasir", Name = "$smr_base_kvasir", Bottle = "smr_exp_buff", Yield = 4, Ingredients = new Dictionary<string, int> { { "Honey", 10 }, { "Thistle", 10 }, { "YmirRemains", 2 } } }, new MeadBase { Prefab = "smr_base_mimir", Name = "$smr_base_mimir", Bottle = "smr_no_skill_buff", Yield = 4, Ingredients = new Dictionary<string, int> { { "Honey", 10 }, { "WitheredBone", 10 }, { "Ectoplasm", 2 } } }, new MeadBase { Prefab = "smr_base_bifrost", Name = "$smr_base_bifrost", Bottle = "smr_teleport_anything", Yield = 4, Ingredients = new Dictionary<string, int> { { "Honey", 10 }, { "GreydwarfEye", 10 }, { "Thunderstone", 2 } } }, new MeadBase { Prefab = "smr_base_soft_tread", Name = "$smr_base_soft_tread", Bottle = "smr_silent", Yield = 4, Ingredients = new Dictionary<string, int> { { "Honey", 10 }, { "Feathers", 5 }, { "TrollHide", 2 } } }, new MeadBase { Prefab = "smr_base_hearthfire", Name = "$smr_base_hearthfire", Bottle = "smr_warm_buff", Yield = 4, Ingredients = new Dictionary<string, int> { { "Honey", 10 }, { "Coal", 10 }, { "TrophySurtling", 1 } } }, new MeadBase { Prefab = "smr_base_comforts", Name = "$smr_base_comforts", Bottle = "smr_rested_buff", Yield = 4, Ingredients = new Dictionary<string, int> { { "Honey", 10 }, { "Mushroom", 10 }, { "Thistle", 5 }, { "FishRaw", 2 } } } }; private static string Path => System.IO.Path.Combine(Paths.ConfigPath, "elric.SimplerMeads.recipes.yml"); internal static MeadBase[] Load(ManualLogSource log) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown MeadBase[] defaults = Defaults; try { if (!File.Exists(Path)) { File.WriteAllText(Path, Template()); log.LogInfo((object)"Wrote default recipes to elric.SimplerMeads.recipes.yml."); return defaults; } Dictionary<string, RecipeOverride> dictionary = ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).IgnoreUnmatchedProperties().Build() .Deserialize<Dictionary<string, RecipeOverride>>(File.ReadAllText(Path)); if (dictionary == null) { return defaults; } foreach (KeyValuePair<string, RecipeOverride> entry in dictionary) { MeadBase meadBase = defaults.FirstOrDefault((MeadBase r) => r.Prefab == entry.Key); if (meadBase == null) { log.LogWarning((object)("elric.SimplerMeads.recipes.yml names '" + entry.Key + "', which is not one of this mod's mead bases. Ignored.")); continue; } if (entry.Value?.Ingredients != null && entry.Value.Ingredients.Count > 0) { meadBase.Ingredients = entry.Value.Ingredients; } if (entry.Value != null && entry.Value.Yield > 0) { meadBase.Yield = entry.Value.Yield; } } return defaults; } catch (Exception ex) { log.LogError((object)("Could not read elric.SimplerMeads.recipes.yml, using the built-in recipes instead: " + ex.Message)); return Defaults; } } internal static void Report(MeadBase[] recipes, ManualLogSource log) { foreach (MeadBase meadBase in recipes) { foreach (string key in meadBase.Ingredients.Keys) { if ((Object)(object)ObjectDB.instance.GetItemPrefab(key) == (Object)null) { log.LogError((object)(meadBase.Prefab + ": the game has no item called '" + key + "', so that ingredient will be missing. Check the spelling in elric.SimplerMeads.recipes.yml.")); } } } } internal static string Serialise(MeadBase[] recipes) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown return ((BuilderSkeleton<SerializerBuilder>)new SerializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).Build().Serialize((object)recipes.ToDictionary((MeadBase r) => r.Prefab, (MeadBase r) => new RecipeOverride { Yield = r.Yield, Ingredients = r.Ingredients })); } internal static void ApplySynced(string yaml, MeadBase[] recipes, ManualLogSource log) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown Dictionary<string, RecipeOverride> dictionary; try { dictionary = ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).IgnoreUnmatchedProperties().Build() .Deserialize<Dictionary<string, RecipeOverride>>(yaml ?? string.Empty); } catch (Exception ex) { log.LogError((object)("Could not read the recipes the server sent: " + ex.Message)); return; } if (dictionary == null) { return; } int num = 0; foreach (KeyValuePair<string, RecipeOverride> entry in dictionary) { MeadBase meadBase = recipes.FirstOrDefault((MeadBase r) => r.Prefab == entry.Key); if (meadBase == null || entry.Value?.Ingredients == null) { continue; } List<Requirement> list = new List<Requirement>(); foreach (KeyValuePair<string, int> ingredient in entry.Value.Ingredients) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(ingredient.Key); ItemDrop val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { log.LogError((object)(entry.Key + ": the server asked for '" + ingredient.Key + "', which this game has no item for. Skipping that ingredient.")); continue; } list.Add(new Requirement { m_resItem = val, m_amount = ingredient.Value, m_amountPerLevel = 1, m_recover = true }); } if (list.Count == 0) { log.LogError((object)(entry.Key + ": nothing usable in the server's recipe, keeping ours.")); continue; } if ((Object)(object)meadBase.Live != (Object)null) { meadBase.Live.m_resources = list.ToArray(); } meadBase.Ingredients = entry.Value.Ingredients; num++; } if (num > 0) { log.LogInfo((object)$"Took {num} recipe(s) from the server."); } } private static string Template() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("# Simpler Meads - mead base recipes"); stringBuilder.AppendLine("#"); stringBuilder.AppendLine("# Everything below is commented out and shows the current defaults."); stringBuilder.AppendLine("# Uncomment a mead to take it over; anything left commented keeps"); stringBuilder.AppendLine("# following the mod, including any future balance changes."); stringBuilder.AppendLine("#"); stringBuilder.AppendLine("# Edit and restart the game. Overrides are per mead and per field, so"); stringBuilder.AppendLine("# you can change a yield without touching ingredients, and removing an"); stringBuilder.AppendLine("# entry restores its default."); stringBuilder.AppendLine("#"); stringBuilder.AppendLine("# ingredients: item prefab names, not display names. Honey, not Honey Jar."); stringBuilder.AppendLine("# An unknown name is dropped and reported in the log."); stringBuilder.AppendLine("# yield: how many meads one fermented base produces."); stringBuilder.AppendLine(); MeadBase[] defaults = Defaults; foreach (MeadBase meadBase in defaults) { stringBuilder.AppendLine("#" + meadBase.Prefab + ":"); stringBuilder.AppendLine($"# yield: {meadBase.Yield}"); stringBuilder.AppendLine("# ingredients:"); foreach (KeyValuePair<string, int> ingredient in meadBase.Ingredients) { stringBuilder.AppendLine($"# {ingredient.Key}: {ingredient.Value}"); } stringBuilder.AppendLine(); } return stringBuilder.ToString(); } } [BepInPlugin("elric.SimplerMeads", "Simpler Meads", "1.1.0")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class SimplerMeads : BaseUnityPlugin { private static class Effect { internal static readonly int Kvasir = StringExtensionMethods.GetStableHashCode("SMR_Exp_Buff"); internal static readonly int SoftTread = StringExtensionMethods.GetStableHashCode("SMR_Noise_Reduction"); internal static readonly int Mimir = StringExtensionMethods.GetStableHashCode("SMR_Soft_Death"); internal static readonly int Bifrost = StringExtensionMethods.GetStableHashCode("SMR_Teleport_Anything"); internal static readonly int Hearthfire = StringExtensionMethods.GetStableHashCode("SMR_Quick_Dry"); internal static readonly int Comforts = StringExtensionMethods.GetStableHashCode("SMR_Rested"); internal static readonly int Cooldown = StringExtensionMethods.GetStableHashCode("SMR_Potion_Cooldown"); internal static readonly int[] Utility = new int[4] { Kvasir, SoftTread, Mimir, Bifrost }; } [HarmonyPatch(typeof(Humanoid), "IsTeleportable", new Type[] { typeof(bool) })] private static class BifrostCarriesAnything { private static void Postfix(Humanoid __instance, ref bool __result) { if (!__result && ((Character)__instance).GetSEMan().HaveStatusEffect(Effect.Bifrost)) { __result = true; } } } [HarmonyPatch(typeof(Skills), "OnDeath")] private static class MimirKeepsWhatYouLearned { private static bool Prefix(Player ___m_player) { if (!((Object)(object)___m_player == (Object)null)) { return !((Character)___m_player).GetSEMan().HaveStatusEffect(Effect.Mimir); } return true; } } [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[] { typeof(StatusEffect), typeof(bool), typeof(int), typeof(float), typeof(short) })] private static class HearthfireRefusesWet { private static bool Prefix(SEMan __instance, StatusEffect statusEffect, ref StatusEffect __result, Character ___m_character) { //IL_0034: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)statusEffect == (Object)null) { return true; } int num = statusEffect.NameHash(); if (num == Effect.Comforts) { if ((Object)(object)___m_character != (Object)null) { statusEffect.m_startEffects.Create(((Component)___m_character).transform.position, ((Component)___m_character).transform.rotation, ((Component)___m_character).transform, 1f, -1, default(ZDOID)); } StatusEffect val = __instance.GetStatusEffect(SEMan.s_statusEffectRested) ?? __instance.AddStatusEffect(SEMan.s_statusEffectRested, true, 0, 0f, (short)(-1)); if ((Object)(object)val != (Object)null) { float num2 = val.m_ttl - val.GetRemaningTime(); val.m_ttl = num2 + comfortsSeconds; } __result = val; return false; } if (num == Effect.Hearthfire) { __instance.RemoveStatusEffect(SEMan.s_statusEffectWet, true); return true; } if (num == SEMan.s_statusEffectWet && __instance.HaveStatusEffect(Effect.Hearthfire)) { __result = null; return false; } return true; } } [HarmonyPatch(typeof(Player), "RaiseSkill")] private static class LogSkillGain { private static void Prefix(Player __instance, SkillType skill, float value) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (logGains && (int)skill != 0) { float num = 1f; ((Character)__instance).GetSEMan().ModifyRaiseSkill(skill, ref num); patchLog.LogInfo((object)($"skill {skill}: {value:0.###} x{num:0.##} " + $"= {value * num:0.###}")); } } } [HarmonyPatch(typeof(Character), "AddNoise")] private static class LogNoiseRange { private static void Postfix(Character __instance, float range) { if (logNoiseOn && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { bool flag = __instance.GetSEMan().HaveStatusEffect(Effect.SoftTread); patchLog.LogInfo((object)($"noise: made {range:0.#} -> carries " + $"{__instance.GetNoiseRange():0.#}" + (flag ? " (Soft Tread active)" : string.Empty))); } } } [HarmonyPatch(typeof(StatusEffect), "Stop")] private static class UtilityCooldown { private static void Postfix(StatusEffect __instance) { if (__instance.IsDone() && Array.IndexOf(Effect.Utility, __instance.NameHash()) >= 0) { Character character = __instance.m_character; if ((Object)(object)character != (Object)null) { character.GetSEMan().AddStatusEffect(Effect.Cooldown, true, 0, 0f, (short)(-1)); } } } } public const string PluginGUID = "elric.SimplerMeads"; public const string PluginName = "Simpler Meads"; public const string PluginVersion = "1.1.0"; private const string BundleName = "simpler_meads"; private AssetBundle assets; private static readonly string[] BottlePrefabs = new string[6] { "smr_exp_buff", "smr_no_skill_buff", "smr_teleport_anything", "smr_silent", "smr_warm_buff", "smr_rested_buff" }; private static readonly string[] StatsEffects = new string[2] { "SMR_Exp_Buff", "SMR_Noise_Reduction" }; private static readonly string[] PlainEffects = new string[4] { "SMR_Soft_Death", "SMR_Teleport_Anything", "SMR_Quick_Dry", "SMR_Potion_Cooldown" }; private static readonly List<CustomItem> rendered = new List<CustomItem>(); private static float comfortsSeconds = 600f; private static bool logGains; private static bool logNoiseOn; private static ManualLogSource patchLog; private MeadBase[] recipes = Array.Empty<MeadBase>(); private ConfigEntry<int> kvasirDuration; private ConfigEntry<float> kvasirMultiplier; private ConfigEntry<int> mimirDuration; private ConfigEntry<int> bifrostDuration; private ConfigEntry<int> softTreadDuration; private ConfigEntry<int> hearthfireDuration; private ConfigEntry<int> comfortsDuration; private ConfigEntry<int> cooldownDuration; private ConfigEntry<bool> logSkillGains; private ConfigEntry<bool> logNoise; private ConfigEntry<string> syncedRecipes; private void Awake() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) CreateConfig(); if (!LoadBundle()) { ((BaseUnityPlugin)this).Logger.LogError((object)"No asset bundle - Simpler Meads is loaded but inactive."); return; } AddStatusEffects(); AddMeads(); PrefabManager.OnVanillaPrefabsAvailable += AddMeadBases; PrefabManager.OnPrefabsRegistered += ApplyConfigValues; PrefabManager.OnPrefabsRegistered += RenderIcons; AddLocalizations(); patchLog = ((BaseUnityPlugin)this).Logger; new Harmony("elric.SimplerMeads").PatchAll(); } private void CreateConfig() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Expected O, but got Unknown //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Expected O, but got Unknown //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Expected O, but got Unknown kvasirDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Tonic of Kvasir", "Duration", 300, new ConfigDescription("How many seconds Tonic of Kvasir lasts.", (AcceptableValueBase)null, new object[1] { adminOnly() })); kvasirMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Tonic of Kvasir", "SkillGainBonus", 2f, new ConfigDescription("Extra skill experience, added to the normal rate. 2 means experience is gained three times as fast; 0 disables the bonus.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[1] { adminOnly() })); mimirDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Mead of Mimir", "Duration", 120, new ConfigDescription("How many seconds Mead of Mimir lasts.", (AcceptableValueBase)null, new object[1] { adminOnly() })); bifrostDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Bifrost Mead", "Duration", 120, new ConfigDescription("How many seconds Bifrost Mead lasts.", (AcceptableValueBase)null, new object[1] { adminOnly() })); softTreadDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Soft Tread Mead", "Duration", 300, new ConfigDescription("How many seconds Soft Tread Mead lasts.", (AcceptableValueBase)null, new object[1] { adminOnly() })); hearthfireDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Hearthfire Mead", "Duration", 180, new ConfigDescription("How many seconds Hearthfire Mead lasts.", (AcceptableValueBase)null, new object[1] { adminOnly() })); comfortsDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Comforts of Home", "Duration", 600, new ConfigDescription("How many seconds Comforts of Home lasts. This is a minimum, not an exact duration: the game raises it when you drink it somewhere comfortable.", (AcceptableValueBase)null, new object[1] { adminOnly() })); logSkillGains = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "LogSkillGains", false, new ConfigDescription("Write every skill gain to the log: which skill, how much, and the level before and after. Useful for checking Tonic of Kvasir is doing what it claims. Noisy - leave off unless you are measuring something.", (AcceptableValueBase)null, Array.Empty<object>())); syncedRecipes = ((BaseUnityPlugin)this).Config.Bind<string>("Recipes", "Definitions", string.Empty, new ConfigDescription("Set by the mod from your recipe file, and replaced by the server's when you connect to one running this mod. Edit the .yml, not this.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Browsable = false } })); logNoise = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "LogNoise", false, new ConfigDescription("Write every noise you make to the log: how loud the action was, and how far it actually carries after modifiers. Soft Tread should turn the second number into 0. Very noisy - leave off unless you are measuring something.", (AcceptableValueBase)null, Array.Empty<object>())); cooldownDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Utility Cooldown", "Duration", 120, new ConfigDescription("How many seconds before another utility mead can be drunk once one wears off.", (AcceptableValueBase)null, new object[1] { adminOnly() })); static ConfigurationManagerAttributes adminOnly() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true }; } } private bool LoadBundle() { try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string n) => n.EndsWith("simpler_meads", StringComparison.Ordinal)); if (text == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Bundle 'simpler_meads' is not embedded in the assembly."); return false; } using (Stream stream = executingAssembly.GetManifestResourceStream(text)) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); assets = AssetBundle.LoadFromMemory(memoryStream.ToArray()); } return (Object)(object)assets != (Object)null; } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Could not load the asset bundle: {arg}"); return false; } } private void AddStatusEffects() { string[] statsEffects = StatsEffects; foreach (string text in statsEffects) { Register((StatusEffect)(object)assets.LoadAsset<SE_Stats>(text), text); } statsEffects = PlainEffects; foreach (string text2 in statsEffects) { Register(assets.LoadAsset<StatusEffect>(text2), text2); } Register((StatusEffect)(object)assets.LoadAsset<SE_Rested>("SMR_Rested"), "SMR_Rested"); } private void Register(StatusEffect effect, string name) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if ((Object)(object)effect == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Status effect '" + name + "' missing from the bundle.")); } else { ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(effect, true)); } } private void AddMeads() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown string[] bottlePrefabs = BottlePrefabs; foreach (string text in bottlePrefabs) { GameObject val = assets.LoadAsset<GameObject>(text); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Mead prefab '" + text + "' missing from the bundle.")); continue; } CustomItem val2 = new CustomItem(val, true); ItemManager.Instance.AddItem(val2); rendered.Add(val2); } } private void AddMeadBases() { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= AddMeadBases; recipes = Recipes.Load(((BaseUnityPlugin)this).Logger); syncedRecipes.Value = Recipes.Serialise(recipes); SynchronizationManager.OnConfigurationSynchronized += TakeServerRecipes; ItemManager.OnItemsRegistered += ReportRecipeProblems; MeadBase[] array = recipes; foreach (MeadBase meadBase in array) { Sprite val = assets.LoadAsset<Sprite>(meadBase.Prefab); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Icon '" + meadBase.Prefab + "' missing from the bundle - is the PNG imported as a Sprite rather than a Texture?")); continue; } ItemConfig val2 = new ItemConfig { Name = meadBase.Name, Description = "$item_meadbase_description", Icon = val, CraftingStation = CraftingStations.MeadKetill, Requirements = meadBase.ToRequirements() }; CustomItem val3 = new CustomItem(meadBase.Prefab, "MeadBaseTasty", val2); if ((Object)(object)val3.ItemPrefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not clone 'MeadBaseTasty' into '" + meadBase.Prefab + "'.")); continue; } GameObject val4 = assets.LoadAsset<GameObject>(meadBase.Bottle); if ((Object)(object)val4 != (Object)null) { val3.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect = val4.GetComponent<ItemDrop>().m_itemData.m_shared.m_consumeStatusEffect; } ItemManager.Instance.AddItem(val3); CustomRecipe recipe = val3.Recipe; meadBase.Live = ((recipe != null) ? recipe.Recipe : null); ItemManager.Instance.AddItemConversion(new CustomItemConversion((ConversionConfig)new FermenterConversionConfig { FromItem = meadBase.Prefab, ToItem = meadBase.Bottle, ProducedItems = meadBase.Yield })); } } private void TakeServerRecipes(object sender, ConfigurationSynchronizationEventArgs e) { Recipes.ApplySynced(syncedRecipes.Value, recipes, ((BaseUnityPlugin)this).Logger); } private void ReportRecipeProblems() { ItemManager.OnItemsRegistered -= ReportRecipeProblems; Recipes.Report(recipes, ((BaseUnityPlugin)this).Logger); } private void ApplyConfigValues() { PrefabManager.OnPrefabsRegistered -= ApplyConfigValues; SE_Stats kvasir = Cache.GetPrefab<SE_Stats>("SMR_Exp_Buff"); Bind(kvasirDuration, delegate(int v) { ((StatusEffect)kvasir).m_ttl = v; }); Bind(kvasirMultiplier, delegate(float v) { kvasir.m_raiseSkillModifier = v; }); StatusEffect mimir = Cache.GetPrefab<StatusEffect>("SMR_Soft_Death"); Bind(mimirDuration, delegate(int v) { mimir.m_ttl = v; }); StatusEffect bifrost = Cache.GetPrefab<StatusEffect>("SMR_Teleport_Anything"); Bind(bifrostDuration, delegate(int v) { bifrost.m_ttl = v; }); SE_Stats softTread = Cache.GetPrefab<SE_Stats>("SMR_Noise_Reduction"); Bind(softTreadDuration, delegate(int v) { ((StatusEffect)softTread).m_ttl = v; }); StatusEffect hearthfire = Cache.GetPrefab<StatusEffect>("SMR_Quick_Dry"); Bind(hearthfireDuration, delegate(int v) { hearthfire.m_ttl = v; }); Bind(comfortsDuration, delegate(int v) { comfortsSeconds = v; }); Bind(logSkillGains, delegate(bool v) { logGains = v; }); Bind(logNoise, delegate(bool v) { logNoiseOn = v; }); SE_Rested prefab = Cache.GetPrefab<SE_Rested>("SMR_Rested"); if ((Object)(object)((StatusEffect)prefab).m_icon == (Object)null) { ObjectDB instance = ObjectDB.instance; StatusEffect val = ((instance != null) ? instance.GetStatusEffect(SEMan.s_statusEffectRested) : null); if ((Object)(object)val != (Object)null && (Object)(object)val.m_icon != (Object)null) { ((StatusEffect)prefab).m_icon = val.m_icon; } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not borrow vanilla's Rested icon; Comforts of Home will run but stay hidden in the HUD."); } } StatusEffect cooldown = Cache.GetPrefab<StatusEffect>("SMR_Potion_Cooldown"); Bind(cooldownDuration, delegate(int v) { cooldown.m_ttl = v; }); } private static void Bind<T>(ConfigEntry<T> entry, Action<T> apply) { apply(entry.Value); entry.SettingChanged += delegate { apply(entry.Value); }; } private void RenderIcons() { PrefabManager.OnPrefabsRegistered -= RenderIcons; foreach (CustomItem item in rendered) { ((MonoBehaviour)this).StartCoroutine(RenderItem(item)); } } private static IEnumerator RenderItem(CustomItem item) { yield return null; item.ItemDrop.m_itemData.m_shared.m_icons[0] = RenderManager.Instance.Render(new RenderRequest(item.ItemPrefab) { Width = 64, Height = 64, Rotation = RenderManager.IsometricRotation * Quaternion.Euler(0f, -90f, 0f) }); } private void AddLocalizations() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "smr_exp_buff", "Tonic of Kvasir" }, { "smr_exp_buff_description", "Kvasir's blood made the mead of wisdom. A mouthful sharpens the eye, and a day's work teaches what a season otherwise would." }, { "smr_exp_buff_effect", "Kvasir" }, { "smr_exp_effect_tooltip", "Skills improve faster." }, { "smr_no_skill_buff", "Mead of Mimir" }, { "smr_no_skill_buff_description", "Mimir's head kept its counsel long after his body was lost. Drink before a bad idea and what you have learned will outlast you." }, { "smr_softdeath_effect", "Mimir" }, { "smr_teleport_anything", "Bifrost Mead" }, { "smr_teleport_anything_description", "The burning bridge carries what it is given. Step through a portal with ore and metal still on your back." }, { "smr_teleport_anything_effect", "Bifrost" }, { "smr_teleport_anything_tooltip", "Portals accept every burden." }, { "smr_silent", "Soft Tread Mead" }, { "smr_silent_description", "Walk, mine and fell timber without a sound carrying. The quiet ones are rarely the ones found." }, { "smr_noise_reduction", "Soft Tread" }, { "smr_noise_reduction_effect_tooltip", "You make no noise moving, mining or chopping." }, { "smr_warm_buff", "Hearthfire Mead" }, { "smr_warm_buff_description", "Carries the warmth of a hearth out into the rain. Wet clothes dry on you as you walk." }, { "smr_fire_effect", "Hearthfire" }, { "smr_fire_tooltip", "You cannot become wet." }, { "smr_rested_buff", "Comforts of Home" }, { "smr_rested_buff_description", "A roof, a fire and a bed, bottled. Take the comforts of home wherever you go." }, { "smr_potion_cooldown_effect", "Potion Cooldown" }, { "smr_potion_cooldown_tooltip", "You cannot drink another utility mead yet." }, { "smr_base_kvasir", "Mead Base: Kvasir" }, { "smr_base_mimir", "Mead Base: Mimir" }, { "smr_base_bifrost", "Mead Base: Bifrost" }, { "smr_base_soft_tread", "Mead Base: Soft Tread" }, { "smr_base_hearthfire", "Mead Base: Hearthfire" }, { "smr_base_comforts", "Mead Base: Comforts of Home" } }); } } }