using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Ravenwood Currency")] [assembly: AssemblyDescription("Ravenwood material-to-coin and coin exchange system for Valheim")] [assembly: AssemblyCompany("Ravenwood")] [assembly: AssemblyProduct("Ravenwood Currency")] [assembly: ComVisible(false)] [assembly: Guid("b581d77a-5c1c-48c7-9fa8-3a4748d9b802")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace RavenwoodCurrency; internal static class BossDropManager { private sealed class BossDropRule { internal string[] BossPrefabs { get; } internal string CoinPrefab { get; } internal ConfigEntry ChanceConfig { get; } internal int AmountMin { get; } internal int AmountMax { get; } internal ConfigEntry AmountMinConfig { get; } internal ConfigEntry AmountMaxConfig { get; } internal bool IsBossDrop { get; } internal BossDropRule(string[] bossPrefabs, string coinPrefab, ConfigEntry chance) { BossPrefabs = bossPrefabs; CoinPrefab = coinPrefab; ChanceConfig = chance; AmountMin = 1; AmountMax = 1; IsBossDrop = true; } internal BossDropRule(string[] bossPrefabs, string coinPrefab, ConfigEntry chance, int amountMin, int amountMax, bool isBossDrop) { BossPrefabs = bossPrefabs; CoinPrefab = coinPrefab; ChanceConfig = chance; AmountMin = amountMin; AmountMax = amountMax; IsBossDrop = isBossDrop; } internal BossDropRule(string[] bossPrefabs, string coinPrefab, ConfigEntry chance, ConfigEntry amountMin, ConfigEntry amountMax, bool isBossDrop) { BossPrefabs = bossPrefabs; CoinPrefab = coinPrefab; ChanceConfig = chance; AmountMinConfig = amountMin; AmountMaxConfig = amountMax; IsBossDrop = isBossDrop; } internal float GetChance() { return ChanceConfig.Value; } internal int GetAmountMin() { return (AmountMinConfig != null) ? AmountMinConfig.Value : AmountMin; } internal int GetAmountMax() { return (AmountMaxConfig != null) ? AmountMaxConfig.Value : AmountMax; } } internal static void ApplyToLoadedBossPrefabs() { if ((Object)(object)ZNetScene.instance == (Object)null) { return; } foreach (BossDropRule rule in GetRules()) { string[] bossPrefabs = rule.BossPrefabs; foreach (string text in bossPrefabs) { GameObject prefab = ZNetScene.instance.GetPrefab(text); CharacterDrop val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent() : null); if ((Object)(object)val != (Object)null) { Apply(val); } } } } internal static void Apply(CharacterDrop characterDrop) { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown if ((Object)(object)characterDrop == (Object)null) { return; } string characterName = NormalizeName(((Object)((Component)characterDrop).gameObject).name); foreach (BossDropRule rule in GetRules()) { bool flag = Array.Exists(rule.BossPrefabs, (string bossPrefab) => bossPrefab.Equals(characterName, StringComparison.OrdinalIgnoreCase)); bool flag2 = (rule.IsBossDrop ? CurrencyConfig.EnableBossDrops.Value : CurrencyConfig.EnableMonsterDrops.Value); float chance = rule.GetChance(); if (flag && flag2 && !(chance <= 0f)) { GameObject coinPrefab = CurrencyRegistrar.GetCoinPrefab(rule.CoinPrefab); if (!((Object)(object)coinPrefab == (Object)null) && !characterDrop.m_drops.Exists((Drop drop) => (Object)(object)drop.m_prefab != (Object)null && ((Object)drop.m_prefab).name == ((Object)coinPrefab).name)) { characterDrop.m_drops.Add(new Drop { m_prefab = coinPrefab, m_amountMin = rule.GetAmountMin(), m_amountMax = rule.GetAmountMax(), m_chance = Mathf.Clamp01(chance / 100f), m_onePerPlayer = false, m_levelMultiplier = false }); } } } } private static IEnumerable GetRules() { string deepNorthName = (string.IsNullOrWhiteSpace(CurrencyConfig.DeepNorthBossPrefab.Value) ? "DeepNorthBoss" : CurrencyConfig.DeepNorthBossPrefab.Value.Trim()); yield return new BossDropRule(new string[1] { "Eikthyr" }, "RWc_Lion", CurrencyConfig.EikthyrGoldChance); yield return new BossDropRule(new string[1] { "gd_king" }, "RWc_Lion", CurrencyConfig.ElderGoldChance); yield return new BossDropRule(new string[1] { "Bonemass" }, "RWc_Lion", CurrencyConfig.BonemassGoldChance); yield return new BossDropRule(new string[1] { "Dragon" }, "RWc_Lion", CurrencyConfig.ModerGoldChance); yield return new BossDropRule(new string[1] { "GoblinKing" }, "RWc_Lion", CurrencyConfig.YagluthGoldChance); yield return new BossDropRule(new string[1] { "SeekerQueen" }, "RWc_Lion", CurrencyConfig.QueenGoldChance); yield return new BossDropRule(new string[1] { "Fader" }, "RWc_Lion", CurrencyConfig.FaderGoldChance); yield return new BossDropRule(new string[1] { deepNorthName }, "RWc_Lion", CurrencyConfig.DeepNorthGoldChance); yield return new BossDropRule(new string[1] { "Dragon" }, "RWc_Raven", CurrencyConfig.ModerMithrilChance); yield return new BossDropRule(new string[1] { "Fader" }, "RWc_Raven", CurrencyConfig.FaderMithrilChance); yield return new BossDropRule(new string[1] { "Eikthyr" }, "RWc_Deer", CurrencyConfig.EikthyrCopperChance, CurrencyConfig.EikthyrCopperAmountMin, CurrencyConfig.EikthyrCopperAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "gd_king" }, "RWc_Deer", CurrencyConfig.ElderCopperChance, CurrencyConfig.ElderCopperAmountMin, CurrencyConfig.ElderCopperAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Bonemass" }, "RWc_Deer", CurrencyConfig.BonemassCopperChance, CurrencyConfig.BonemassCopperAmountMin, CurrencyConfig.BonemassCopperAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Dragon" }, "RWc_Deer", CurrencyConfig.ModerCopperChance, CurrencyConfig.ModerCopperAmountMin, CurrencyConfig.ModerCopperAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "GoblinKing" }, "RWc_Deer", CurrencyConfig.YagluthCopperChance, CurrencyConfig.YagluthCopperAmountMin, CurrencyConfig.YagluthCopperAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "SeekerQueen" }, "RWc_Deer", CurrencyConfig.QueenCopperChance, CurrencyConfig.QueenCopperAmountMin, CurrencyConfig.QueenCopperAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Fader" }, "RWc_Deer", CurrencyConfig.FaderCopperChance, CurrencyConfig.FaderCopperAmountMin, CurrencyConfig.FaderCopperAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { deepNorthName }, "RWc_Deer", CurrencyConfig.DeepNorthCopperChance, CurrencyConfig.DeepNorthCopperAmountMin, CurrencyConfig.DeepNorthCopperAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "gd_king" }, "RWc_Bear", CurrencyConfig.ElderBronzeChance, CurrencyConfig.ElderBronzeAmountMin, CurrencyConfig.ElderBronzeAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Bonemass" }, "RWc_Bear", CurrencyConfig.BonemassBronzeChance, CurrencyConfig.BonemassBronzeAmountMin, CurrencyConfig.BonemassBronzeAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Dragon" }, "RWc_Bear", CurrencyConfig.ModerBronzeChance, CurrencyConfig.ModerBronzeAmountMin, CurrencyConfig.ModerBronzeAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "GoblinKing" }, "RWc_Bear", CurrencyConfig.YagluthBronzeChance, CurrencyConfig.YagluthBronzeAmountMin, CurrencyConfig.YagluthBronzeAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "SeekerQueen" }, "RWc_Bear", CurrencyConfig.QueenBronzeChance, CurrencyConfig.QueenBronzeAmountMin, CurrencyConfig.QueenBronzeAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Fader" }, "RWc_Bear", CurrencyConfig.FaderBronzeChance, CurrencyConfig.FaderBronzeAmountMin, CurrencyConfig.FaderBronzeAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { deepNorthName }, "RWc_Bear", CurrencyConfig.DeepNorthBronzeChance, CurrencyConfig.DeepNorthBronzeAmountMin, CurrencyConfig.DeepNorthBronzeAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Bonemass" }, "RWc_Snake", CurrencyConfig.BonemassIronChance, CurrencyConfig.BonemassIronAmountMin, CurrencyConfig.BonemassIronAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Dragon" }, "RWc_Snake", CurrencyConfig.ModerIronChance, CurrencyConfig.ModerIronAmountMin, CurrencyConfig.ModerIronAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "GoblinKing" }, "RWc_Snake", CurrencyConfig.YagluthIronChance, CurrencyConfig.YagluthIronAmountMin, CurrencyConfig.YagluthIronAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "SeekerQueen" }, "RWc_Snake", CurrencyConfig.QueenIronChance, CurrencyConfig.QueenIronAmountMin, CurrencyConfig.QueenIronAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Fader" }, "RWc_Snake", CurrencyConfig.FaderIronChance, CurrencyConfig.FaderIronAmountMin, CurrencyConfig.FaderIronAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { deepNorthName }, "RWc_Snake", CurrencyConfig.DeepNorthIronChance, CurrencyConfig.DeepNorthIronAmountMin, CurrencyConfig.DeepNorthIronAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Dragon" }, "RWc_Wolf", CurrencyConfig.ModerSilverChance, CurrencyConfig.ModerSilverAmountMin, CurrencyConfig.ModerSilverAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "GoblinKing" }, "RWc_Wolf", CurrencyConfig.YagluthSilverChance, CurrencyConfig.YagluthSilverAmountMin, CurrencyConfig.YagluthSilverAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "SeekerQueen" }, "RWc_Wolf", CurrencyConfig.QueenSilverChance, CurrencyConfig.QueenSilverAmountMin, CurrencyConfig.QueenSilverAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Fader" }, "RWc_Wolf", CurrencyConfig.FaderSilverChance, CurrencyConfig.FaderSilverAmountMin, CurrencyConfig.FaderSilverAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { deepNorthName }, "RWc_Wolf", CurrencyConfig.DeepNorthSilverChance, CurrencyConfig.DeepNorthSilverAmountMin, CurrencyConfig.DeepNorthSilverAmountMax, isBossDrop: true); yield return new BossDropRule(new string[1] { "Greyling" }, "RWc_Deer", CurrencyConfig.GreylingCopperChance, CurrencyConfig.GreylingCopperAmountMin, CurrencyConfig.GreylingCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Greydwarf" }, "RWc_Deer", CurrencyConfig.GreydwarfCopperChance, CurrencyConfig.GreydwarfCopperAmountMin, CurrencyConfig.GreydwarfCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Greydwarf_Shaman" }, "RWc_Deer", CurrencyConfig.GreydwarfShamanCopperChance, CurrencyConfig.GreydwarfShamanCopperAmountMin, CurrencyConfig.GreydwarfShamanCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Greydwarf_Elite" }, "RWc_Deer", CurrencyConfig.GreydwarfEliteCopperChance, CurrencyConfig.GreydwarfEliteCopperAmountMin, CurrencyConfig.GreydwarfEliteCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Skeleton" }, "RWc_Deer", CurrencyConfig.SkeletonCopperChance, CurrencyConfig.SkeletonCopperAmountMin, CurrencyConfig.SkeletonCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Troll" }, "RWc_Deer", CurrencyConfig.TrollCopperChance, CurrencyConfig.TrollCopperAmountMin, CurrencyConfig.TrollCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Draugr" }, "RWc_Deer", CurrencyConfig.DraugrCopperChance, CurrencyConfig.DraugrCopperAmountMin, CurrencyConfig.DraugrCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Draugr_Elite" }, "RWc_Deer", CurrencyConfig.DraugrEliteCopperChance, CurrencyConfig.DraugrEliteCopperAmountMin, CurrencyConfig.DraugrEliteCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Goblin" }, "RWc_Deer", CurrencyConfig.GoblinCopperChance, CurrencyConfig.GoblinCopperAmountMin, CurrencyConfig.GoblinCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "GoblinShaman" }, "RWc_Deer", CurrencyConfig.GoblinShamanCopperChance, CurrencyConfig.GoblinShamanCopperAmountMin, CurrencyConfig.GoblinShamanCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "GoblinBrute" }, "RWc_Deer", CurrencyConfig.GoblinBruteCopperChance, CurrencyConfig.GoblinBruteCopperAmountMin, CurrencyConfig.GoblinBruteCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[6] { "Dverger", "DvergerAshlands", "DvergerMage", "DvergerMageFire", "DvergerMageIce", "DvergerMageSupport" }, "RWc_Deer", CurrencyConfig.DvergerCopperChance, CurrencyConfig.DvergerCopperAmountMin, CurrencyConfig.DvergerCopperAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Greydwarf" }, "RWc_Bear", CurrencyConfig.GreydwarfBronzeChance, CurrencyConfig.GreydwarfBronzeAmountMin, CurrencyConfig.GreydwarfBronzeAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Greydwarf_Shaman" }, "RWc_Bear", CurrencyConfig.GreydwarfShamanBronzeChance, CurrencyConfig.GreydwarfShamanBronzeAmountMin, CurrencyConfig.GreydwarfShamanBronzeAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Greydwarf_Elite" }, "RWc_Bear", CurrencyConfig.GreydwarfEliteBronzeChance, CurrencyConfig.GreydwarfEliteBronzeAmountMin, CurrencyConfig.GreydwarfEliteBronzeAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Troll" }, "RWc_Bear", CurrencyConfig.TrollBronzeChance, CurrencyConfig.TrollBronzeAmountMin, CurrencyConfig.TrollBronzeAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Skeleton" }, "RWc_Bear", CurrencyConfig.SkeletonBronzeChance, CurrencyConfig.SkeletonBronzeAmountMin, CurrencyConfig.SkeletonBronzeAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Skeleton_Poison" }, "RWc_Bear", CurrencyConfig.RancidRemainsBronzeChance, CurrencyConfig.RancidRemainsBronzeAmountMin, CurrencyConfig.RancidRemainsBronzeAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Draugr" }, "RWc_Snake", CurrencyConfig.DraugrIronChance, CurrencyConfig.DraugrIronAmountMin, CurrencyConfig.DraugrIronAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Draugr_Elite" }, "RWc_Snake", CurrencyConfig.DraugrEliteIronChance, CurrencyConfig.DraugrEliteIronAmountMin, CurrencyConfig.DraugrEliteIronAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Wraith" }, "RWc_Snake", CurrencyConfig.WraithIronChance, CurrencyConfig.WraithIronAmountMin, CurrencyConfig.WraithIronAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Surtling" }, "RWc_Snake", CurrencyConfig.SurtlingIronChance, CurrencyConfig.SurtlingIronAmountMin, CurrencyConfig.SurtlingIronAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Ulv" }, "RWc_Wolf", CurrencyConfig.UlvSilverChance, CurrencyConfig.UlvSilverAmountMin, CurrencyConfig.UlvSilverAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Fenring_Cultist" }, "RWc_Wolf", CurrencyConfig.CultistSilverChance, CurrencyConfig.CultistSilverAmountMin, CurrencyConfig.CultistSilverAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Fenring" }, "RWc_Wolf", CurrencyConfig.FenringSilverChance, CurrencyConfig.FenringSilverAmountMin, CurrencyConfig.FenringSilverAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "StoneGolem" }, "RWc_Wolf", CurrencyConfig.StoneGolemSilverChance, CurrencyConfig.StoneGolemSilverAmountMin, CurrencyConfig.StoneGolemSilverAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Wraith" }, "RWc_Wolf", CurrencyConfig.WraithSilverChance, CurrencyConfig.WraithSilverAmountMin, CurrencyConfig.WraithSilverAmountMax, isBossDrop: false); yield return new BossDropRule(new string[6] { "Dverger", "DvergerAshlands", "DvergerMage", "DvergerMageFire", "DvergerMageIce", "DvergerMageSupport" }, "RWc_Wolf", CurrencyConfig.DvergerSilverChance, CurrencyConfig.DvergerSilverAmountMin, CurrencyConfig.DvergerSilverAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Goblin" }, "RWc_Snake", CurrencyConfig.GoblinIronChance, CurrencyConfig.GoblinIronAmountMin, CurrencyConfig.GoblinIronAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "Goblin" }, "RWc_Bear", CurrencyConfig.GoblinBronzeChance, CurrencyConfig.GoblinBronzeAmountMin, CurrencyConfig.GoblinBronzeAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "GoblinShaman" }, "RWc_Snake", CurrencyConfig.GoblinShamanIronChance, CurrencyConfig.GoblinShamanIronAmountMin, CurrencyConfig.GoblinShamanIronAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "GoblinShaman" }, "RWc_Bear", CurrencyConfig.GoblinShamanBronzeChance, CurrencyConfig.GoblinShamanBronzeAmountMin, CurrencyConfig.GoblinShamanBronzeAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "GoblinBrute" }, "RWc_Snake", CurrencyConfig.GoblinBruteIronChance, CurrencyConfig.GoblinBruteIronAmountMin, CurrencyConfig.GoblinBruteIronAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "GoblinBrute" }, "RWc_Bear", CurrencyConfig.GoblinBruteBronzeChance, CurrencyConfig.GoblinBruteBronzeAmountMin, CurrencyConfig.GoblinBruteBronzeAmountMax, isBossDrop: false); yield return new BossDropRule(new string[1] { "FallenValkyrie" }, "RWc_Lion", CurrencyConfig.ValkyrieGoldChance, 1, 1, isBossDrop: false); yield return new BossDropRule(new string[1] { "FallenValkyrie" }, "RWc_Wolf", CurrencyConfig.ValkyrieSilverChance, CurrencyConfig.ValkyrieSilverAmountMin, CurrencyConfig.ValkyrieSilverAmountMax, isBossDrop: false); yield return new BossDropRule(new string[8] { "Charred_Archer", "Charred_Archer_Fader", "Charred_Mage", "Charred_Melee", "Charred_Melee_Dyrnwyn", "Charred_Melee_Fader", "Charred_Twitcher", "Charred_Twitcher_Summoned" }, "RWc_Snake", CurrencyConfig.CharredIronChance, CurrencyConfig.CharredIronAmountMin, CurrencyConfig.CharredIronAmountMax, isBossDrop: false); } private static string NormalizeName(string value) { return (value ?? string.Empty).Replace("(Clone)", string.Empty).Trim(); } } [HarmonyPatch(typeof(CharacterDrop), "Start")] internal static class CharacterDropStartPatch { private static void Postfix(CharacterDrop __instance) { BossDropManager.Apply(__instance); } } internal static class CurrencyChestSetup { private const string ExchangeBoxName = "exchange_box"; private const string ExchangePressName = "exchange_press"; private const string LidPivotName = "LidPivot"; private const float OpenAngleX = -20f; internal static void ConfigureBundlePrefabs(AssetBundle bundle) { if (!((Object)(object)bundle == (Object)null)) { ConfigureTablePrefab(bundle.LoadAsset("RWc_Table")); ConfigureChestPrefab(bundle.LoadAsset("RWc_Chest")); } } internal static void ConfigureRegisteredPrefabs() { ConfigureTablePrefab(PrefabManager.Instance.GetPrefab("RWc_Table")); ConfigureChestPrefab(PrefabManager.Instance.GetPrefab("RWc_Chest")); } private static void ConfigureTablePrefab(GameObject table) { if ((Object)(object)table == (Object)null) { return; } Transform val = PrefabRuntimeUtility.FindChildRecursive(table.transform, "exchange_box"); Transform val2 = PrefabRuntimeUtility.FindChildRecursive(table.transform, "exchange_press"); if ((Object)(object)val2 == (Object)null) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogError((object)"RWc_Table is missing required child 'exchange_press'."); } else { MaterialExchangeInteract[] componentsInChildren = table.GetComponentsInChildren(true); foreach (MaterialExchangeInteract materialExchangeInteract in componentsInChildren) { if ((Object)(object)((Component)materialExchangeInteract).transform != (Object)(object)val2) { Object.DestroyImmediate((Object)(object)materialExchangeInteract); } } PrefabRuntimeUtility.EnsureCollider(((Component)val2).gameObject); if ((Object)(object)((Component)val2).GetComponent() == (Object)null) { ((Component)val2).gameObject.AddComponent(); } } Container container = table.GetComponent() ?? table.AddComponent(); ConfigureContainer(container); if ((Object)(object)val == (Object)null) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogError((object)"RWc_Table is missing required child 'exchange_box'."); return; } PrefabRuntimeUtility.EnsureCollider(((Component)val).gameObject); TableChestInteract tableChestInteract = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); tableChestInteract.Configure(container); ConfigureLidAnimation(((Component)val).gameObject, container); } private static void ConfigureChestPrefab(GameObject chest) { if (!((Object)(object)chest == (Object)null)) { Container container = chest.GetComponent() ?? chest.AddComponent(); ConfigureContainer(container); ConfigureLidAnimation(chest, container); } } private static void ConfigureContainer(Container container) { container.m_name = "Ravenwood Currency Chest"; container.m_width = CurrencyConfig.ChestWidth.Value; container.m_height = CurrencyConfig.ChestHeight.Value; } private static void ConfigureLidAnimation(GameObject animationRoot, Container container) { bool flag = false; Transform[] componentsInChildren = animationRoot.GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name.Equals("LidPivot", StringComparison.Ordinal)) { ChestLidAnimation chestLidAnimation = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); chestLidAnimation.Configure(container, val, -20f); flag = true; } } if (!flag) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogError((object)(((Object)animationRoot).name + " is missing required child 'LidPivot'.")); } } } internal sealed class TableChestInteract : MonoBehaviour, Hoverable, Interactable { [SerializeField] private Container _container; internal void Configure(Container container) { _container = container; } public string GetHoverName() { Container val = ResolveContainer(); return ((Object)(object)val != (Object)null) ? val.GetHoverName() : "Ravenwood Currency Chest"; } public string GetHoverText() { Container val = ResolveContainer(); return ((Object)(object)val != (Object)null) ? val.GetHoverText() : "Ravenwood Currency Chest\n[E] Open"; } public bool Interact(Humanoid user, bool hold, bool alt) { Container val = ResolveContainer(); return (Object)(object)val != (Object)null && val.Interact(user, hold, alt); } public bool UseItem(Humanoid user, ItemData item) { Container val = ResolveContainer(); return (Object)(object)val != (Object)null && val.UseItem(user, item); } private Container ResolveContainer() { if ((Object)(object)_container == (Object)null) { _container = ((Component)this).GetComponentInParent(); } return _container; } } internal sealed class ChestLidAnimation : MonoBehaviour { private const float RotationSpeed = 80f; private const string OpenSoundPrefab = "sfx_chest_open"; private const string CloseSoundPrefab = "sfx_chest_close"; private static readonly MethodInfo IsInUseMethod = typeof(Container).GetMethod("IsInUse", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); private static readonly FieldInfo InUseField = typeof(Container).GetField("m_inUse", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); [SerializeField] private Container _container; [SerializeField] private Transform _lidPivot; [SerializeField] private Vector3 _closedEuler; [SerializeField] private Vector3 _openEuler; private bool _lastOpen; private bool _stateInitialized; internal void Configure(Container container, Transform lidPivot, float openAngleX) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) _container = container; _lidPivot = lidPivot; if (!((Object)(object)_lidPivot == (Object)null)) { _closedEuler = _lidPivot.localEulerAngles; _closedEuler.x = 0f; _openEuler = _closedEuler; _openEuler.x = openAngleX; _lidPivot.localRotation = Quaternion.Euler(_closedEuler); } } private void Start() { //IL_0039: 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_003e: Unknown result type (might be due to invalid IL or missing references) bool flag = (_lastOpen = ReadOpenState()); _stateInitialized = true; if ((Object)(object)_lidPivot != (Object)null) { _lidPivot.localRotation = Quaternion.Euler(flag ? _openEuler : _closedEuler); } } private void Update() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_009f: Unknown result type (might be due to invalid IL or missing references) bool flag = ReadOpenState(); if (!_stateInitialized) { _lastOpen = flag; _stateInitialized = true; } else if (flag != _lastOpen) { _lastOpen = flag; PlayChestSound(flag ? "sfx_chest_open" : "sfx_chest_close"); } if (!((Object)(object)_lidPivot == (Object)null)) { Quaternion val = Quaternion.Euler(flag ? _openEuler : _closedEuler); _lidPivot.localRotation = Quaternion.RotateTowards(_lidPivot.localRotation, val, 80f * Time.deltaTime); } } private bool ReadOpenState() { if ((Object)(object)_container == (Object)null) { _container = ((Component)this).GetComponentInParent(); } if ((Object)(object)_container == (Object)null) { return false; } try { if (IsInUseMethod != null && IsInUseMethod.ReturnType == typeof(bool)) { return (bool)IsInUseMethod.Invoke(_container, null); } if (InUseField != null && InUseField.FieldType == typeof(bool)) { return (bool)InUseField.GetValue(_container); } } catch { return false; } return false; } private void PlayChestSound(string prefabName) { //IL_004c: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(prefabName) : null); if (!((Object)(object)val == (Object)null)) { Vector3 val2 = (((Object)(object)_lidPivot != (Object)null) ? _lidPivot.position : ((Component)this).transform.position); Object.Instantiate(val, val2, Quaternion.identity); } } } internal static class CurrencyConfig { internal static ConfigEntry AllowTraderSales { get; private set; } internal static ConfigEntry EnableBossDrops { get; private set; } internal static ConfigEntry EnableMonsterDrops { get; private set; } internal static ConfigEntry TableBuildCost { get; private set; } internal static ConfigEntry ChestBuildCost { get; private set; } internal static ConfigEntry ChestWidth { get; private set; } internal static ConfigEntry ChestHeight { get; private set; } internal static ConfigEntry DeepNorthBossPrefab { get; private set; } internal static ConfigEntry EikthyrGoldChance { get; private set; } internal static ConfigEntry ElderGoldChance { get; private set; } internal static ConfigEntry BonemassGoldChance { get; private set; } internal static ConfigEntry ModerGoldChance { get; private set; } internal static ConfigEntry YagluthGoldChance { get; private set; } internal static ConfigEntry QueenGoldChance { get; private set; } internal static ConfigEntry FaderGoldChance { get; private set; } internal static ConfigEntry DeepNorthGoldChance { get; private set; } internal static ConfigEntry ModerMithrilChance { get; private set; } internal static ConfigEntry FaderMithrilChance { get; private set; } internal static ConfigEntry EikthyrCopperChance { get; private set; } internal static ConfigEntry ElderCopperChance { get; private set; } internal static ConfigEntry BonemassCopperChance { get; private set; } internal static ConfigEntry ModerCopperChance { get; private set; } internal static ConfigEntry YagluthCopperChance { get; private set; } internal static ConfigEntry QueenCopperChance { get; private set; } internal static ConfigEntry FaderCopperChance { get; private set; } internal static ConfigEntry DeepNorthCopperChance { get; private set; } internal static ConfigEntry EikthyrCopperAmountMin { get; private set; } internal static ConfigEntry EikthyrCopperAmountMax { get; private set; } internal static ConfigEntry ElderCopperAmountMin { get; private set; } internal static ConfigEntry ElderCopperAmountMax { get; private set; } internal static ConfigEntry BonemassCopperAmountMin { get; private set; } internal static ConfigEntry BonemassCopperAmountMax { get; private set; } internal static ConfigEntry ModerCopperAmountMin { get; private set; } internal static ConfigEntry ModerCopperAmountMax { get; private set; } internal static ConfigEntry YagluthCopperAmountMin { get; private set; } internal static ConfigEntry YagluthCopperAmountMax { get; private set; } internal static ConfigEntry QueenCopperAmountMin { get; private set; } internal static ConfigEntry QueenCopperAmountMax { get; private set; } internal static ConfigEntry FaderCopperAmountMin { get; private set; } internal static ConfigEntry FaderCopperAmountMax { get; private set; } internal static ConfigEntry DeepNorthCopperAmountMin { get; private set; } internal static ConfigEntry DeepNorthCopperAmountMax { get; private set; } internal static ConfigEntry ElderBronzeChance { get; private set; } internal static ConfigEntry BonemassBronzeChance { get; private set; } internal static ConfigEntry ModerBronzeChance { get; private set; } internal static ConfigEntry YagluthBronzeChance { get; private set; } internal static ConfigEntry QueenBronzeChance { get; private set; } internal static ConfigEntry FaderBronzeChance { get; private set; } internal static ConfigEntry DeepNorthBronzeChance { get; private set; } internal static ConfigEntry BonemassIronChance { get; private set; } internal static ConfigEntry ModerIronChance { get; private set; } internal static ConfigEntry YagluthIronChance { get; private set; } internal static ConfigEntry QueenIronChance { get; private set; } internal static ConfigEntry FaderIronChance { get; private set; } internal static ConfigEntry DeepNorthIronChance { get; private set; } internal static ConfigEntry ModerSilverChance { get; private set; } internal static ConfigEntry YagluthSilverChance { get; private set; } internal static ConfigEntry QueenSilverChance { get; private set; } internal static ConfigEntry FaderSilverChance { get; private set; } internal static ConfigEntry DeepNorthSilverChance { get; private set; } internal static ConfigEntry GreylingCopperChance { get; private set; } internal static ConfigEntry GreydwarfCopperChance { get; private set; } internal static ConfigEntry GreydwarfEliteCopperChance { get; private set; } internal static ConfigEntry TrollCopperChance { get; private set; } internal static ConfigEntry GreydwarfBronzeChance { get; private set; } internal static ConfigEntry GreydwarfShamanBronzeChance { get; private set; } internal static ConfigEntry GreydwarfEliteBronzeChance { get; private set; } internal static ConfigEntry TrollBronzeChance { get; private set; } internal static ConfigEntry SkeletonBronzeChance { get; private set; } internal static ConfigEntry RancidRemainsBronzeChance { get; private set; } internal static ConfigEntry DraugrIronChance { get; private set; } internal static ConfigEntry DraugrEliteIronChance { get; private set; } internal static ConfigEntry WraithIronChance { get; private set; } internal static ConfigEntry SurtlingIronChance { get; private set; } internal static ConfigEntry UlvSilverChance { get; private set; } internal static ConfigEntry CultistSilverChance { get; private set; } internal static ConfigEntry FenringSilverChance { get; private set; } internal static ConfigEntry StoneGolemSilverChance { get; private set; } internal static ConfigEntry WraithSilverChance { get; private set; } internal static ConfigEntry DvergerSilverChance { get; private set; } internal static ConfigEntry GoblinIronChance { get; private set; } internal static ConfigEntry GoblinBronzeChance { get; private set; } internal static ConfigEntry GoblinCopperChance { get; private set; } internal static ConfigEntry GoblinShamanIronChance { get; private set; } internal static ConfigEntry GoblinShamanBronzeChance { get; private set; } internal static ConfigEntry GoblinShamanCopperChance { get; private set; } internal static ConfigEntry GoblinBruteIronChance { get; private set; } internal static ConfigEntry GoblinBruteBronzeChance { get; private set; } internal static ConfigEntry GoblinBruteCopperChance { get; private set; } internal static ConfigEntry ValkyrieGoldChance { get; private set; } internal static ConfigEntry ValkyrieSilverChance { get; private set; } internal static ConfigEntry CharredIronChance { get; private set; } internal static ConfigEntry GreydwarfShamanCopperChance { get; private set; } internal static ConfigEntry SkeletonCopperChance { get; private set; } internal static ConfigEntry DraugrCopperChance { get; private set; } internal static ConfigEntry DraugrEliteCopperChance { get; private set; } internal static ConfigEntry DvergerCopperChance { get; private set; } internal static ConfigEntry GreylingCopperAmountMin { get; private set; } internal static ConfigEntry GreylingCopperAmountMax { get; private set; } internal static ConfigEntry GreydwarfCopperAmountMin { get; private set; } internal static ConfigEntry GreydwarfCopperAmountMax { get; private set; } internal static ConfigEntry GreydwarfShamanCopperAmountMin { get; private set; } internal static ConfigEntry GreydwarfShamanCopperAmountMax { get; private set; } internal static ConfigEntry GreydwarfEliteCopperAmountMin { get; private set; } internal static ConfigEntry GreydwarfEliteCopperAmountMax { get; private set; } internal static ConfigEntry SkeletonCopperAmountMin { get; private set; } internal static ConfigEntry SkeletonCopperAmountMax { get; private set; } internal static ConfigEntry TrollCopperAmountMin { get; private set; } internal static ConfigEntry TrollCopperAmountMax { get; private set; } internal static ConfigEntry DraugrCopperAmountMin { get; private set; } internal static ConfigEntry DraugrCopperAmountMax { get; private set; } internal static ConfigEntry DraugrEliteCopperAmountMin { get; private set; } internal static ConfigEntry DraugrEliteCopperAmountMax { get; private set; } internal static ConfigEntry GoblinCopperAmountMin { get; private set; } internal static ConfigEntry GoblinCopperAmountMax { get; private set; } internal static ConfigEntry GoblinShamanCopperAmountMin { get; private set; } internal static ConfigEntry GoblinShamanCopperAmountMax { get; private set; } internal static ConfigEntry GoblinBruteCopperAmountMin { get; private set; } internal static ConfigEntry GoblinBruteCopperAmountMax { get; private set; } internal static ConfigEntry DvergerCopperAmountMin { get; private set; } internal static ConfigEntry DvergerCopperAmountMax { get; private set; } internal static ConfigEntry ElderBronzeAmountMin { get; private set; } internal static ConfigEntry ElderBronzeAmountMax { get; private set; } internal static ConfigEntry BonemassBronzeAmountMin { get; private set; } internal static ConfigEntry BonemassBronzeAmountMax { get; private set; } internal static ConfigEntry ModerBronzeAmountMin { get; private set; } internal static ConfigEntry ModerBronzeAmountMax { get; private set; } internal static ConfigEntry YagluthBronzeAmountMin { get; private set; } internal static ConfigEntry YagluthBronzeAmountMax { get; private set; } internal static ConfigEntry QueenBronzeAmountMin { get; private set; } internal static ConfigEntry QueenBronzeAmountMax { get; private set; } internal static ConfigEntry FaderBronzeAmountMin { get; private set; } internal static ConfigEntry FaderBronzeAmountMax { get; private set; } internal static ConfigEntry DeepNorthBronzeAmountMin { get; private set; } internal static ConfigEntry DeepNorthBronzeAmountMax { get; private set; } internal static ConfigEntry BonemassIronAmountMin { get; private set; } internal static ConfigEntry BonemassIronAmountMax { get; private set; } internal static ConfigEntry ModerIronAmountMin { get; private set; } internal static ConfigEntry ModerIronAmountMax { get; private set; } internal static ConfigEntry YagluthIronAmountMin { get; private set; } internal static ConfigEntry YagluthIronAmountMax { get; private set; } internal static ConfigEntry QueenIronAmountMin { get; private set; } internal static ConfigEntry QueenIronAmountMax { get; private set; } internal static ConfigEntry FaderIronAmountMin { get; private set; } internal static ConfigEntry FaderIronAmountMax { get; private set; } internal static ConfigEntry DeepNorthIronAmountMin { get; private set; } internal static ConfigEntry DeepNorthIronAmountMax { get; private set; } internal static ConfigEntry ModerSilverAmountMin { get; private set; } internal static ConfigEntry ModerSilverAmountMax { get; private set; } internal static ConfigEntry YagluthSilverAmountMin { get; private set; } internal static ConfigEntry YagluthSilverAmountMax { get; private set; } internal static ConfigEntry QueenSilverAmountMin { get; private set; } internal static ConfigEntry QueenSilverAmountMax { get; private set; } internal static ConfigEntry FaderSilverAmountMin { get; private set; } internal static ConfigEntry FaderSilverAmountMax { get; private set; } internal static ConfigEntry DeepNorthSilverAmountMin { get; private set; } internal static ConfigEntry DeepNorthSilverAmountMax { get; private set; } internal static ConfigEntry GreydwarfBronzeAmountMin { get; private set; } internal static ConfigEntry GreydwarfBronzeAmountMax { get; private set; } internal static ConfigEntry GreydwarfShamanBronzeAmountMin { get; private set; } internal static ConfigEntry GreydwarfShamanBronzeAmountMax { get; private set; } internal static ConfigEntry GreydwarfEliteBronzeAmountMin { get; private set; } internal static ConfigEntry GreydwarfEliteBronzeAmountMax { get; private set; } internal static ConfigEntry TrollBronzeAmountMin { get; private set; } internal static ConfigEntry TrollBronzeAmountMax { get; private set; } internal static ConfigEntry SkeletonBronzeAmountMin { get; private set; } internal static ConfigEntry SkeletonBronzeAmountMax { get; private set; } internal static ConfigEntry RancidRemainsBronzeAmountMin { get; private set; } internal static ConfigEntry RancidRemainsBronzeAmountMax { get; private set; } internal static ConfigEntry GoblinBronzeAmountMin { get; private set; } internal static ConfigEntry GoblinBronzeAmountMax { get; private set; } internal static ConfigEntry GoblinShamanBronzeAmountMin { get; private set; } internal static ConfigEntry GoblinShamanBronzeAmountMax { get; private set; } internal static ConfigEntry GoblinBruteBronzeAmountMin { get; private set; } internal static ConfigEntry GoblinBruteBronzeAmountMax { get; private set; } internal static ConfigEntry DraugrIronAmountMin { get; private set; } internal static ConfigEntry DraugrIronAmountMax { get; private set; } internal static ConfigEntry DraugrEliteIronAmountMin { get; private set; } internal static ConfigEntry DraugrEliteIronAmountMax { get; private set; } internal static ConfigEntry WraithIronAmountMin { get; private set; } internal static ConfigEntry WraithIronAmountMax { get; private set; } internal static ConfigEntry SurtlingIronAmountMin { get; private set; } internal static ConfigEntry SurtlingIronAmountMax { get; private set; } internal static ConfigEntry GoblinIronAmountMin { get; private set; } internal static ConfigEntry GoblinIronAmountMax { get; private set; } internal static ConfigEntry GoblinShamanIronAmountMin { get; private set; } internal static ConfigEntry GoblinShamanIronAmountMax { get; private set; } internal static ConfigEntry GoblinBruteIronAmountMin { get; private set; } internal static ConfigEntry GoblinBruteIronAmountMax { get; private set; } internal static ConfigEntry CharredIronAmountMin { get; private set; } internal static ConfigEntry CharredIronAmountMax { get; private set; } internal static ConfigEntry UlvSilverAmountMin { get; private set; } internal static ConfigEntry UlvSilverAmountMax { get; private set; } internal static ConfigEntry CultistSilverAmountMin { get; private set; } internal static ConfigEntry CultistSilverAmountMax { get; private set; } internal static ConfigEntry FenringSilverAmountMin { get; private set; } internal static ConfigEntry FenringSilverAmountMax { get; private set; } internal static ConfigEntry StoneGolemSilverAmountMin { get; private set; } internal static ConfigEntry StoneGolemSilverAmountMax { get; private set; } internal static ConfigEntry WraithSilverAmountMin { get; private set; } internal static ConfigEntry WraithSilverAmountMax { get; private set; } internal static ConfigEntry DvergerSilverAmountMin { get; private set; } internal static ConfigEntry DvergerSilverAmountMax { get; private set; } internal static ConfigEntry ValkyrieSilverAmountMin { get; private set; } internal static ConfigEntry ValkyrieSilverAmountMax { get; private set; } internal static void Bind(ConfigFile config) { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown AllowTraderSales = config.Bind("General", "Allow coin sales to traders", true, "When enabled, each coin can be sold to a trader for its face value. Enabled by default."); EnableBossDrops = config.Bind("General", "Enable boss coin drops", true, "Enable all configured Ravenwood coin drops from bosses."); EnableMonsterDrops = config.Bind("General", "Enable monster coin drops", true, "Enable all configured Ravenwood coin drops from regular monsters."); TableBuildCost = config.Bind("Building", "Table build cost", "[RWc_Deer][10][RWc_Bear][5][RWc_Snake][2][RWc_Wolf][1]", "Build requirements in [Prefab][Amount] format."); ChestBuildCost = config.Bind("Building", "Chest build cost", "[RWc_Deer][1][RWc_Bear][1][RWc_Snake][1][RWc_Wolf][1]", "Build requirements in [Prefab][Amount] format."); if (TableBuildCost.Value == "[FineWood][20][Iron][5][SurtlingCore][2]" || TableBuildCost.Value == "[RWc_Deer][10][RWc_Bear][10][RWc_Snake][10][RWc_Wolf][10]") { TableBuildCost.Value = "[RWc_Deer][10][RWc_Bear][5][RWc_Snake][2][RWc_Wolf][1]"; } if (ChestBuildCost.Value == "[FineWood][10][Iron][2]" || ChestBuildCost.Value == "[RWc_Deer][5][RWc_Bear][5][RWc_Snake][2][RWc_Wolf][2]") { ChestBuildCost.Value = "[RWc_Deer][1][RWc_Bear][1][RWc_Snake][1][RWc_Wolf][1]"; } ChestWidth = config.Bind("Building", "Chest width", 8, new ConfigDescription("Standalone chest inventory width.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 8), Array.Empty())); ChestHeight = config.Bind("Building", "Chest height", 4, new ConfigDescription("Standalone chest inventory height.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 8), Array.Empty())); AcceptableValueRange range = new AcceptableValueRange(0f, 100f); EikthyrGoldChance = BindChance(config, "Eikthyr Gold chance", 1f, range); ElderGoldChance = BindChance(config, "Elder Gold chance", 2f, range); BonemassGoldChance = BindChance(config, "Bonemass Gold chance", 5f, range); ModerGoldChance = BindChance(config, "Moder Gold chance", 10f, range); YagluthGoldChance = BindChance(config, "Yagluth Gold chance", 12f, range); QueenGoldChance = BindChance(config, "Queen Gold chance", 15f, range); FaderGoldChance = BindChance(config, "Fader Gold chance", 20f, range); DeepNorthGoldChance = BindChance(config, "Deep North boss Gold chance", 25f, range); ModerMithrilChance = BindChance(config, "Moder Mithril chance", 1f, range); FaderMithrilChance = BindChance(config, "Fader Mithril chance", 5f, range); EikthyrCopperChance = BindChance(config, "Eikthyr Copper chance", 40f, range); ElderCopperChance = BindChance(config, "Elder Copper chance", 40f, range); BonemassCopperChance = BindChance(config, "Bonemass Copper chance", 40f, range); ModerCopperChance = BindChance(config, "Moder Copper chance", 40f, range); YagluthCopperChance = BindChance(config, "Yagluth Copper chance", 40f, range); QueenCopperChance = BindChance(config, "Queen Copper chance", 40f, range); FaderCopperChance = BindChance(config, "Fader Copper chance", 40f, range); DeepNorthCopperChance = BindChance(config, "Deep North boss Copper chance", 40f, range); EikthyrCopperAmountMin = BindAmount(config, "Boss Drops", "Eikthyr Copper minimum amount", 1); EikthyrCopperAmountMax = BindAmount(config, "Boss Drops", "Eikthyr Copper maximum amount", 3); ElderCopperAmountMin = BindAmount(config, "Boss Drops", "Elder Copper minimum amount", 1); ElderCopperAmountMax = BindAmount(config, "Boss Drops", "Elder Copper maximum amount", 5); BonemassCopperAmountMin = BindAmount(config, "Boss Drops", "Bonemass Copper minimum amount", 3); BonemassCopperAmountMax = BindAmount(config, "Boss Drops", "Bonemass Copper maximum amount", 8); ModerCopperAmountMin = BindAmount(config, "Boss Drops", "Moder Copper minimum amount", 5); ModerCopperAmountMax = BindAmount(config, "Boss Drops", "Moder Copper maximum amount", 10); YagluthCopperAmountMin = BindAmount(config, "Boss Drops", "Yagluth Copper minimum amount", 7); YagluthCopperAmountMax = BindAmount(config, "Boss Drops", "Yagluth Copper maximum amount", 12); QueenCopperAmountMin = BindAmount(config, "Boss Drops", "Queen Copper minimum amount", 10); QueenCopperAmountMax = BindAmount(config, "Boss Drops", "Queen Copper maximum amount", 15); FaderCopperAmountMin = BindAmount(config, "Boss Drops", "Fader Copper minimum amount", 15); FaderCopperAmountMax = BindAmount(config, "Boss Drops", "Fader Copper maximum amount", 20); DeepNorthCopperAmountMin = BindAmount(config, "Boss Drops", "Deep North boss Copper minimum amount", 15); DeepNorthCopperAmountMax = BindAmount(config, "Boss Drops", "Deep North boss Copper maximum amount", 20); ElderBronzeChance = BindChance(config, "Elder Bronze chance", 25f, range); BonemassBronzeChance = BindChance(config, "Bonemass Bronze chance", 25f, range); ModerBronzeChance = BindChance(config, "Moder Bronze chance", 25f, range); YagluthBronzeChance = BindChance(config, "Yagluth Bronze chance", 25f, range); QueenBronzeChance = BindChance(config, "Queen Bronze chance", 25f, range); FaderBronzeChance = BindChance(config, "Fader Bronze chance", 25f, range); DeepNorthBronzeChance = BindChance(config, "Deep North boss Bronze chance", 25f, range); BonemassIronChance = BindChance(config, "Bonemass Iron chance", 25f, range); ModerIronChance = BindChance(config, "Moder Iron chance", 25f, range); YagluthIronChance = BindChance(config, "Yagluth Iron chance", 25f, range); QueenIronChance = BindChance(config, "Queen Iron chance", 25f, range); FaderIronChance = BindChance(config, "Fader Iron chance", 25f, range); DeepNorthIronChance = BindChance(config, "Deep North boss Iron chance", 25f, range); ModerSilverChance = BindChance(config, "Moder Silver chance", 25f, range); YagluthSilverChance = BindChance(config, "Yagluth Silver chance", 25f, range); QueenSilverChance = BindChance(config, "Queen Silver chance", 25f, range); FaderSilverChance = BindChance(config, "Fader Silver chance", 25f, range); DeepNorthSilverChance = BindChance(config, "Deep North boss Silver chance", 25f, range); ElderBronzeAmountMin = BindAmount(config, "Boss Drops", "Elder Bronze minimum amount", 1); ElderBronzeAmountMax = BindAmount(config, "Boss Drops", "Elder Bronze maximum amount", 1); BonemassBronzeAmountMin = BindAmount(config, "Boss Drops", "Bonemass Bronze minimum amount", 1); BonemassBronzeAmountMax = BindAmount(config, "Boss Drops", "Bonemass Bronze maximum amount", 2); ModerBronzeAmountMin = BindAmount(config, "Boss Drops", "Moder Bronze minimum amount", 1); ModerBronzeAmountMax = BindAmount(config, "Boss Drops", "Moder Bronze maximum amount", 3); YagluthBronzeAmountMin = BindAmount(config, "Boss Drops", "Yagluth Bronze minimum amount", 1); YagluthBronzeAmountMax = BindAmount(config, "Boss Drops", "Yagluth Bronze maximum amount", 4); QueenBronzeAmountMin = BindAmount(config, "Boss Drops", "Queen Bronze minimum amount", 1); QueenBronzeAmountMax = BindAmount(config, "Boss Drops", "Queen Bronze maximum amount", 5); FaderBronzeAmountMin = BindAmount(config, "Boss Drops", "Fader Bronze minimum amount", 1); FaderBronzeAmountMax = BindAmount(config, "Boss Drops", "Fader Bronze maximum amount", 6); DeepNorthBronzeAmountMin = BindAmount(config, "Boss Drops", "Deep North boss Bronze minimum amount", 1); DeepNorthBronzeAmountMax = BindAmount(config, "Boss Drops", "Deep North boss Bronze maximum amount", 7); BonemassIronAmountMin = BindAmount(config, "Boss Drops", "Bonemass Iron minimum amount", 1); BonemassIronAmountMax = BindAmount(config, "Boss Drops", "Bonemass Iron maximum amount", 1); ModerIronAmountMin = BindAmount(config, "Boss Drops", "Moder Iron minimum amount", 1); ModerIronAmountMax = BindAmount(config, "Boss Drops", "Moder Iron maximum amount", 2); YagluthIronAmountMin = BindAmount(config, "Boss Drops", "Yagluth Iron minimum amount", 1); YagluthIronAmountMax = BindAmount(config, "Boss Drops", "Yagluth Iron maximum amount", 3); QueenIronAmountMin = BindAmount(config, "Boss Drops", "Queen Iron minimum amount", 1); QueenIronAmountMax = BindAmount(config, "Boss Drops", "Queen Iron maximum amount", 4); FaderIronAmountMin = BindAmount(config, "Boss Drops", "Fader Iron minimum amount", 1); FaderIronAmountMax = BindAmount(config, "Boss Drops", "Fader Iron maximum amount", 5); DeepNorthIronAmountMin = BindAmount(config, "Boss Drops", "Deep North boss Iron minimum amount", 1); DeepNorthIronAmountMax = BindAmount(config, "Boss Drops", "Deep North boss Iron maximum amount", 6); ModerSilverAmountMin = BindAmount(config, "Boss Drops", "Moder Silver minimum amount", 1); ModerSilverAmountMax = BindAmount(config, "Boss Drops", "Moder Silver maximum amount", 1); YagluthSilverAmountMin = BindAmount(config, "Boss Drops", "Yagluth Silver minimum amount", 1); YagluthSilverAmountMax = BindAmount(config, "Boss Drops", "Yagluth Silver maximum amount", 2); QueenSilverAmountMin = BindAmount(config, "Boss Drops", "Queen Silver minimum amount", 1); QueenSilverAmountMax = BindAmount(config, "Boss Drops", "Queen Silver maximum amount", 3); FaderSilverAmountMin = BindAmount(config, "Boss Drops", "Fader Silver minimum amount", 1); FaderSilverAmountMax = BindAmount(config, "Boss Drops", "Fader Silver maximum amount", 4); DeepNorthSilverAmountMin = BindAmount(config, "Boss Drops", "Deep North boss Silver minimum amount", 1); DeepNorthSilverAmountMax = BindAmount(config, "Boss Drops", "Deep North boss Silver maximum amount", 5); DeepNorthBossPrefab = config.Bind("Boss Drops", "Deep North boss prefab", "DeepNorthBoss", "Internal prefab name for the Deep North boss. Change this when the final/custom boss prefab name is known."); GreylingCopperChance = BindMonsterChance(config, "Greyling Copper chance", 5f, range); GreydwarfCopperChance = BindMonsterChance(config, "Greydwarf Copper chance", 5f, range); GreydwarfShamanCopperChance = BindMonsterChance(config, "Greydwarf Shaman Copper chance", 5f, range); GreydwarfEliteCopperChance = BindMonsterChance(config, "Greydwarf Brute Copper chance", 5f, range); SkeletonCopperChance = BindMonsterChance(config, "Skeleton Copper chance", 5f, range); TrollCopperChance = BindMonsterChance(config, "Troll Copper chance", 25f, range); DraugrCopperChance = BindMonsterChance(config, "Draugr Copper chance", 8f, range); DraugrEliteCopperChance = BindMonsterChance(config, "Draugr Elite Copper chance", 8f, range); DvergerCopperChance = BindMonsterChance(config, "Dverger Rogue/Mage Copper chance", 12f, range); GreylingCopperAmountMin = BindAmount(config, "Monster Drops", "Greyling Copper minimum amount", 1); GreylingCopperAmountMax = BindAmount(config, "Monster Drops", "Greyling Copper maximum amount", 1); GreydwarfCopperAmountMin = BindAmount(config, "Monster Drops", "Greydwarf Copper minimum amount", 1); GreydwarfCopperAmountMax = BindAmount(config, "Monster Drops", "Greydwarf Copper maximum amount", 2); GreydwarfShamanCopperAmountMin = BindAmount(config, "Monster Drops", "Greydwarf Shaman Copper minimum amount", 1); GreydwarfShamanCopperAmountMax = BindAmount(config, "Monster Drops", "Greydwarf Shaman Copper maximum amount", 2); GreydwarfEliteCopperAmountMin = BindAmount(config, "Monster Drops", "Greydwarf Brute Copper minimum amount", 1); GreydwarfEliteCopperAmountMax = BindAmount(config, "Monster Drops", "Greydwarf Brute Copper maximum amount", 3); SkeletonCopperAmountMin = BindAmount(config, "Monster Drops", "Skeleton Copper minimum amount", 1); SkeletonCopperAmountMax = BindAmount(config, "Monster Drops", "Skeleton Copper maximum amount", 2); TrollCopperAmountMin = BindAmount(config, "Monster Drops", "Troll Copper minimum amount", 1); TrollCopperAmountMax = BindAmount(config, "Monster Drops", "Troll Copper maximum amount", 5); DraugrCopperAmountMin = BindAmount(config, "Monster Drops", "Draugr Copper minimum amount", 1); DraugrCopperAmountMax = BindAmount(config, "Monster Drops", "Draugr Copper maximum amount", 4); DraugrEliteCopperAmountMin = BindAmount(config, "Monster Drops", "Draugr Elite Copper minimum amount", 1); DraugrEliteCopperAmountMax = BindAmount(config, "Monster Drops", "Draugr Elite Copper maximum amount", 5); GoblinCopperAmountMin = BindAmount(config, "Monster Drops", "Goblin Copper minimum amount", 1); GoblinCopperAmountMax = BindAmount(config, "Monster Drops", "Goblin Copper maximum amount", 6); GoblinShamanCopperAmountMin = BindAmount(config, "Monster Drops", "Goblin Shaman Copper minimum amount", 1); GoblinShamanCopperAmountMax = BindAmount(config, "Monster Drops", "Goblin Shaman Copper maximum amount", 7); GoblinBruteCopperAmountMin = BindAmount(config, "Monster Drops", "Goblin Brute Copper minimum amount", 1); GoblinBruteCopperAmountMax = BindAmount(config, "Monster Drops", "Goblin Brute Copper maximum amount", 8); DvergerCopperAmountMin = BindAmount(config, "Monster Drops", "Dverger Rogue/Mage Copper minimum amount", 1); DvergerCopperAmountMax = BindAmount(config, "Monster Drops", "Dverger Rogue/Mage Copper maximum amount", 10); GreydwarfBronzeChance = BindMonsterChance(config, "Greydwarf Bronze chance", 1f, range); GreydwarfShamanBronzeChance = BindMonsterChance(config, "Greydwarf Shaman Bronze chance", 2f, range); GreydwarfEliteBronzeChance = BindMonsterChance(config, "Greydwarf Brute Bronze chance", 3f, range); TrollBronzeChance = BindMonsterChance(config, "Troll Bronze chance", 5f, range); SkeletonBronzeChance = BindMonsterChance(config, "Skeleton Bronze chance", 1f, range); RancidRemainsBronzeChance = BindMonsterChance(config, "Rancid Remains Bronze chance", 3f, range); DraugrIronChance = BindMonsterChance(config, "Draugr Iron chance", 1f, range); DraugrEliteIronChance = BindMonsterChance(config, "Draugr Elite Iron chance", 2f, range); WraithIronChance = BindMonsterChance(config, "Wraith Iron chance", 3f, range); SurtlingIronChance = BindMonsterChance(config, "Surtling Iron chance", 1f, range); UlvSilverChance = BindMonsterChance(config, "Ulv Silver chance", 1f, range); CultistSilverChance = BindMonsterChance(config, "Cultist Silver chance", 2f, range); FenringSilverChance = BindMonsterChance(config, "Fenring Silver chance", 3f, range); StoneGolemSilverChance = BindMonsterChance(config, "Stone Golem Silver chance", 5f, range); WraithSilverChance = BindMonsterChance(config, "Wraith Silver chance", 1f, range); DvergerSilverChance = BindMonsterChance(config, "Dverger Silver chance", 2f, range); GoblinIronChance = BindMonsterChance(config, "Goblin Iron chance", 1f, range); GoblinBronzeChance = BindMonsterChance(config, "Goblin Bronze chance", 2f, range); GoblinCopperChance = BindMonsterChance(config, "Goblin Copper chance", 10f, range); GoblinShamanIronChance = BindMonsterChance(config, "Goblin Shaman Iron chance", 2f, range); GoblinShamanBronzeChance = BindMonsterChance(config, "Goblin Shaman Bronze chance", 2f, range); GoblinShamanCopperChance = BindMonsterChance(config, "Goblin Shaman Copper chance", 10f, range); GoblinBruteIronChance = BindMonsterChance(config, "Goblin Brute Iron chance", 3f, range); GoblinBruteBronzeChance = BindMonsterChance(config, "Goblin Brute Bronze chance", 4f, range); GoblinBruteCopperChance = BindMonsterChance(config, "Goblin Brute Copper chance", 10f, range); ValkyrieGoldChance = BindMonsterChance(config, "Valkyrie Gold chance", 1f, range); ValkyrieSilverChance = BindMonsterChance(config, "Valkyrie Silver chance", 5f, range); CharredIronChance = BindMonsterChance(config, "Ashlands Charred Iron chance", 5f, range); GreydwarfBronzeAmountMin = BindAmount(config, "Monster Drops", "Greydwarf Bronze minimum amount", 1); GreydwarfBronzeAmountMax = BindAmount(config, "Monster Drops", "Greydwarf Bronze maximum amount", 1); GreydwarfShamanBronzeAmountMin = BindAmount(config, "Monster Drops", "Greydwarf Shaman Bronze minimum amount", 1); GreydwarfShamanBronzeAmountMax = BindAmount(config, "Monster Drops", "Greydwarf Shaman Bronze maximum amount", 1); GreydwarfEliteBronzeAmountMin = BindAmount(config, "Monster Drops", "Greydwarf Brute Bronze minimum amount", 1); GreydwarfEliteBronzeAmountMax = BindAmount(config, "Monster Drops", "Greydwarf Brute Bronze maximum amount", 1); TrollBronzeAmountMin = BindAmount(config, "Monster Drops", "Troll Bronze minimum amount", 1); TrollBronzeAmountMax = BindAmount(config, "Monster Drops", "Troll Bronze maximum amount", 1); SkeletonBronzeAmountMin = BindAmount(config, "Monster Drops", "Skeleton Bronze minimum amount", 1); SkeletonBronzeAmountMax = BindAmount(config, "Monster Drops", "Skeleton Bronze maximum amount", 1); RancidRemainsBronzeAmountMin = BindAmount(config, "Monster Drops", "Rancid Remains Bronze minimum amount", 1); RancidRemainsBronzeAmountMax = BindAmount(config, "Monster Drops", "Rancid Remains Bronze maximum amount", 1); GoblinBronzeAmountMin = BindAmount(config, "Monster Drops", "Goblin Bronze minimum amount", 1); GoblinBronzeAmountMax = BindAmount(config, "Monster Drops", "Goblin Bronze maximum amount", 2); GoblinShamanBronzeAmountMin = BindAmount(config, "Monster Drops", "Goblin Shaman Bronze minimum amount", 1); GoblinShamanBronzeAmountMax = BindAmount(config, "Monster Drops", "Goblin Shaman Bronze maximum amount", 2); GoblinBruteBronzeAmountMin = BindAmount(config, "Monster Drops", "Goblin Brute Bronze minimum amount", 1); GoblinBruteBronzeAmountMax = BindAmount(config, "Monster Drops", "Goblin Brute Bronze maximum amount", 2); DraugrIronAmountMin = BindAmount(config, "Monster Drops", "Draugr Iron minimum amount", 1); DraugrIronAmountMax = BindAmount(config, "Monster Drops", "Draugr Iron maximum amount", 1); DraugrEliteIronAmountMin = BindAmount(config, "Monster Drops", "Draugr Elite Iron minimum amount", 1); DraugrEliteIronAmountMax = BindAmount(config, "Monster Drops", "Draugr Elite Iron maximum amount", 1); WraithIronAmountMin = BindAmount(config, "Monster Drops", "Wraith Iron minimum amount", 1); WraithIronAmountMax = BindAmount(config, "Monster Drops", "Wraith Iron maximum amount", 1); SurtlingIronAmountMin = BindAmount(config, "Monster Drops", "Surtling Iron minimum amount", 1); SurtlingIronAmountMax = BindAmount(config, "Monster Drops", "Surtling Iron maximum amount", 1); GoblinIronAmountMin = BindAmount(config, "Monster Drops", "Goblin Iron minimum amount", 1); GoblinIronAmountMax = BindAmount(config, "Monster Drops", "Goblin Iron maximum amount", 2); GoblinShamanIronAmountMin = BindAmount(config, "Monster Drops", "Goblin Shaman Iron minimum amount", 1); GoblinShamanIronAmountMax = BindAmount(config, "Monster Drops", "Goblin Shaman Iron maximum amount", 2); GoblinBruteIronAmountMin = BindAmount(config, "Monster Drops", "Goblin Brute Iron minimum amount", 1); GoblinBruteIronAmountMax = BindAmount(config, "Monster Drops", "Goblin Brute Iron maximum amount", 2); CharredIronAmountMin = BindAmount(config, "Monster Drops", "Ashlands Charred Iron minimum amount", 1); CharredIronAmountMax = BindAmount(config, "Monster Drops", "Ashlands Charred Iron maximum amount", 1); UlvSilverAmountMin = BindAmount(config, "Monster Drops", "Ulv Silver minimum amount", 1); UlvSilverAmountMax = BindAmount(config, "Monster Drops", "Ulv Silver maximum amount", 1); CultistSilverAmountMin = BindAmount(config, "Monster Drops", "Cultist Silver minimum amount", 1); CultistSilverAmountMax = BindAmount(config, "Monster Drops", "Cultist Silver maximum amount", 1); FenringSilverAmountMin = BindAmount(config, "Monster Drops", "Fenring Silver minimum amount", 1); FenringSilverAmountMax = BindAmount(config, "Monster Drops", "Fenring Silver maximum amount", 1); StoneGolemSilverAmountMin = BindAmount(config, "Monster Drops", "Stone Golem Silver minimum amount", 1); StoneGolemSilverAmountMax = BindAmount(config, "Monster Drops", "Stone Golem Silver maximum amount", 1); WraithSilverAmountMin = BindAmount(config, "Monster Drops", "Wraith Silver minimum amount", 1); WraithSilverAmountMax = BindAmount(config, "Monster Drops", "Wraith Silver maximum amount", 1); DvergerSilverAmountMin = BindAmount(config, "Monster Drops", "Dverger Silver minimum amount", 1); DvergerSilverAmountMax = BindAmount(config, "Monster Drops", "Dverger Silver maximum amount", 2); ValkyrieSilverAmountMin = BindAmount(config, "Monster Drops", "Valkyrie Silver minimum amount", 1); ValkyrieSilverAmountMax = BindAmount(config, "Monster Drops", "Valkyrie Silver maximum amount", 1); } private static ConfigEntry BindChance(ConfigFile config, string key, float defaultValue, AcceptableValueRange range) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown return config.Bind("Boss Drops", key, defaultValue, new ConfigDescription("Percent chance for this boss coin drop.", (AcceptableValueBase)(object)range, Array.Empty())); } private static ConfigEntry BindMonsterChance(ConfigFile config, string key, float defaultValue, AcceptableValueRange range) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown return config.Bind("Monster Drops", key, defaultValue, new ConfigDescription("Percent chance for this monster coin drop.", (AcceptableValueBase)(object)range, Array.Empty())); } private static ConfigEntry BindAmount(ConfigFile config, string section, string key, int defaultValue) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown return config.Bind(section, key, defaultValue, new ConfigDescription("Number of coins dropped.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 999), Array.Empty())); } } internal sealed class CoinDefinition { internal string PrefabName { get; } internal string DisplayName { get; } internal int Value { get; } internal CoinDefinition(string prefabName, string displayName, int value) { PrefabName = prefabName; DisplayName = displayName; Value = value; } } internal sealed class StatueDefinition { internal int Tier { get; } internal string PrefabName { get; } internal string DisplayName { get; } internal string Description { get; } internal string IconPrefab { get; } internal string RequiredStation { get; } internal string BuildCost { get; } internal StatueDefinition(int tier, string prefabName, string displayName, string description, string iconPrefab, string requiredStation, string buildCost) { Tier = tier; PrefabName = prefabName; DisplayName = displayName; Description = description; IconPrefab = iconPrefab; RequiredStation = requiredStation; BuildCost = buildCost; } } internal static class CurrencyDefinitions { internal const string CopperCoin = "RWc_Deer"; internal const string BronzeCoin = "RWc_Bear"; internal const string IronCoin = "RWc_Snake"; internal const string SilverCoin = "RWc_Wolf"; internal const string GoldCoin = "RWc_Lion"; internal const string MithrilCoin = "RWc_Raven"; internal const string TablePrefab = "RWc_Table"; internal const string ChestPrefab = "RWc_Chest"; internal const string MaterialChild = "exchange_box"; internal const string ScaleChild = "exchange_scale"; internal static readonly IReadOnlyList Statues = new StatueDefinition[6] { new StatueDefinition(1, "RWc_Deer_Statue", "Copper Deer Statue", "Upgrade 1: Copper Bars create 2 Copper Coins.", "RWc_Deer", "RWc_Table", "[RWc_Deer][25]"), new StatueDefinition(2, "RWc_Bear_Statue", "Bronze Bear Statue", "Upgrade 2: Bronze Bars create 2 Bronze Coins.", "RWc_Bear", "RWc_Deer_Statue", "[RWc_Bear][10]"), new StatueDefinition(3, "RWc_Snake_Statue", "Iron Snake Statue", "Upgrade 3: Iron Bars create 2 Iron Coins.", "RWc_Snake", "RWc_Bear_Statue", "[RWc_Snake][10]"), new StatueDefinition(4, "RWc_Wolf_Statue", "Silver Wolf Statue", "Upgrade 4: Copper Bars create 3 Copper Coins.", "RWc_Wolf", "RWc_Snake_Statue", "[RWc_Wolf][5]"), new StatueDefinition(5, "RWc_Lion_Statue", "Gold Lion Statue", "Upgrade 5: Copper Bars create 4 Copper Coins.", "RWc_Lion", "RWc_Wolf_Statue", "[RWc_Lion][1][RWc_Deer][50]"), new StatueDefinition(6, "RWc_Raven_Statue", "Mithril Raven Statue", "Upgrade 6: Bronze Bars create 3 Bronze Coins.", "RWc_Raven", "RWc_Lion_Statue", "[RWc_Raven][1][RWc_Bear][100]") }; internal static readonly IReadOnlyList Coins = new CoinDefinition[6] { new CoinDefinition("RWc_Deer", "Copper Coin", 1), new CoinDefinition("RWc_Bear", "Bronze Coin", 5), new CoinDefinition("RWc_Snake", "Iron Coin", 10), new CoinDefinition("RWc_Wolf", "Silver Coin", 25), new CoinDefinition("RWc_Lion", "Gold Coin", 100), new CoinDefinition("RWc_Raven", "Mithril Coin", 1000) }; } internal static class CurrencyRegistrar { private static readonly Dictionary CoinPrefabs = new Dictionary(StringComparer.Ordinal); private static bool wasAlreadyRegistered = false; internal static void RegisterAll(AssetBundle bundle) { if (wasAlreadyRegistered) { return; } foreach (CoinDefinition coin in CurrencyDefinitions.Coins) { RegisterCoin(bundle, coin); } RegisterTable(bundle); RegisterStatues(bundle); RegisterChest(bundle); wasAlreadyRegistered = true; } internal static GameObject GetCoinPrefab(string prefabName) { CoinPrefabs.TryGetValue(prefabName, out var value); return value; } internal static void RefreshTraderValues() { foreach (CoinDefinition coin in CurrencyDefinitions.Coins) { GameObject coinPrefab = GetCoinPrefab(coin.PrefabName); ItemDrop val = (((Object)(object)coinPrefab != (Object)null) ? coinPrefab.GetComponent() : null); if (val?.m_itemData?.m_shared != null) { val.m_itemData.m_shared.m_value = (CurrencyConfig.AllowTraderSales.Value ? coin.Value : 0); } } } internal static void RefreshPieceEffects() { CopyPieceEffects("RWc_Table", "piece_workbench"); CopyPieceEffects("RWc_Chest", "piece_chest_wood"); foreach (StatueDefinition statue in CurrencyDefinitions.Statues) { CopyPieceEffects(statue.PrefabName, "piece_workbench"); } } private static void RegisterCoin(AssetBundle bundle, CoinDefinition definition) { //IL_0087: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Expected O, but got Unknown GameObject val = bundle.LoadAsset(definition.PrefabName); Sprite val2 = bundle.LoadAsset(definition.PrefabName); if ((Object)(object)val == (Object)null) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogError((object)("Missing coin prefab in rwc: " + definition.PrefabName)); return; } if ((Object)(object)val2 == (Object)null) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogError((object)("Missing coin icon sprite in rwc: " + definition.PrefabName)); return; } Vector3 localScale = val.transform.localScale; ((Object)val).name = definition.PrefabName; PrefabRuntimeUtility.SetLayerRecursively(val, "item"); PrefabRuntimeUtility.PrepareNetworkedPrefab(val, persistent: true); ZNetView component = val.GetComponent(); component.m_syncInitialScale = false; ZSyncTransform val3 = val.GetComponent() ?? val.AddComponent(); val3.m_syncPosition = true; val3.m_syncRotation = true; val3.m_syncScale = false; Rigidbody val4 = val.GetComponent() ?? val.AddComponent(); val4.mass = 0.1f; val4.drag = 0.1f; val4.angularDrag = 0.05f; val4.useGravity = true; val4.isKinematic = false; val4.detectCollisions = true; val4.constraints = (RigidbodyConstraints)0; val4.interpolation = (RigidbodyInterpolation)1; val4.collisionDetectionMode = (CollisionDetectionMode)2; ItemDrop val5 = val.GetComponent() ?? val.AddComponent(); if (val5.m_itemData == null) { val5.m_itemData = new ItemData(); } if (val5.m_itemData.m_shared == null) { val5.m_itemData.m_shared = new SharedData(); } val5.m_itemData.m_dropPrefab = val; val5.m_itemData.m_stack = 1; val5.m_itemData.m_quality = 1; val5.m_itemData.m_variant = 0; val5.m_itemData.m_shared.m_name = definition.DisplayName; val5.m_itemData.m_shared.m_description = "Ravenwood currency worth " + definition.Value + " value."; val5.m_itemData.m_shared.m_itemType = (ItemType)1; val5.m_itemData.m_shared.m_maxStackSize = 999; val5.m_itemData.m_shared.m_weight = 0.01f; val5.m_itemData.m_shared.m_teleportable = true; val5.m_itemData.m_shared.m_value = (CurrencyConfig.AllowTraderSales.Value ? definition.Value : 0); val5.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 }; CoinWorldPhysics coinWorldPhysics = val.GetComponent() ?? val.AddComponent(); coinWorldPhysics.Configure(localScale); ItemManager.Instance.AddItem(new CustomItem(val, false)); CoinPrefabs[definition.PrefabName] = val; } private static void RegisterTable(AssetBundle bundle) { //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown GameObject val = bundle.LoadAsset("RWc_Table"); Sprite icon = bundle.LoadAsset("RWc_Table"); if ((Object)(object)val == (Object)null) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogError((object)"Missing table prefab in rwc: RWc_Table"); return; } ((Object)val).name = "RWc_Table"; PrefabRuntimeUtility.SetLayer(val, "piece"); PrefabRuntimeUtility.PrepareNetworkedPrefab(val, persistent: true); MaterialExchangeInteract[] componentsInChildren = val.GetComponentsInChildren(true); foreach (MaterialExchangeInteract materialExchangeInteract in componentsInChildren) { Object.DestroyImmediate((Object)(object)materialExchangeInteract); } CoinExchangeInteract[] componentsInChildren2 = val.GetComponentsInChildren(true); foreach (CoinExchangeInteract coinExchangeInteract in componentsInChildren2) { Object.DestroyImmediate((Object)(object)coinExchangeInteract); } WearNTear[] componentsInChildren3 = val.GetComponentsInChildren(true); foreach (WearNTear val2 in componentsInChildren3) { Object.DestroyImmediate((Object)(object)val2); } Container[] componentsInChildren4 = val.GetComponentsInChildren(true); foreach (Container val3 in componentsInChildren4) { Object.DestroyImmediate((Object)(object)val3); } Rigidbody[] componentsInChildren5 = val.GetComponentsInChildren(true); foreach (Rigidbody val4 in componentsInChildren5) { Object.DestroyImmediate((Object)(object)val4); } AttachTableInteraction(val, "exchange_box", materialExchange: true); AttachTableInteraction(val, "exchange_scale", materialExchange: false); Piece val5 = val.GetComponent() ?? val.AddComponent(); val5.m_name = "Ravenwood Currency Table"; val5.m_description = "Trade materials for coins and exchange coin denominations."; val5.m_icon = icon; val5.m_canBeRemoved = true; val5.m_groundOnly = false; val5.m_groundPiece = false; WearNTear val6 = val.GetComponent() ?? val.AddComponent(); val6.m_health = 1000f; CraftingStation station = val.GetComponent() ?? val.AddComponent(); ConfigureCraftingStation(station, "Ravenwood Currency Table", icon); PieceConfig val7 = CreatePieceConfig("Ravenwood Currency Table", "Trade materials for coins and exchange coin denominations.", icon, ParseRequirements(CurrencyConfig.TableBuildCost.Value)); val7.CraftingStation = null; CustomPiece val8 = new CustomPiece(val, true, val7); PieceManager.Instance.AddPiece(val8); } private static void RegisterStatues(AssetBundle bundle) { //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown GameObject val = bundle.LoadAsset("RWc_Table"); CraftingStation val2 = (((Object)(object)val != (Object)null) ? val.GetComponent() : null); if ((Object)(object)val2 == (Object)null) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogError((object)"RWc_Table has no CraftingStation for statue extensions."); return; } foreach (StatueDefinition statue in CurrencyDefinitions.Statues) { GameObject val3 = bundle.LoadAsset(statue.PrefabName); Sprite icon = bundle.LoadAsset(statue.PrefabName) ?? bundle.LoadAsset(statue.IconPrefab); if ((Object)(object)val3 == (Object)null) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogError((object)("Missing statue prefab in rwc: " + statue.PrefabName)); continue; } PreparePiecePrefab(val3, statue.DisplayName, statue.Description, icon, "piece_workbench"); PrefabRuntimeUtility.PrepareStaticPiecePhysics(val3); CraftingStation[] componentsInChildren = val3.GetComponentsInChildren(true); foreach (CraftingStation val4 in componentsInChildren) { Object.DestroyImmediate((Object)(object)val4); } StationExtension val5 = val3.GetComponent() ?? val3.AddComponent(); val5.m_craftingStation = val2; val5.m_maxStationDistance = 10f; val5.m_stack = false; StatueUpgradeMarker statueUpgradeMarker = val3.GetComponent() ?? val3.AddComponent(); statueUpgradeMarker.Configure(statue.Tier); PieceConfig val6 = CreatePieceConfig(statue.DisplayName, statue.Description, icon, ParseRequirements(statue.BuildCost)); val6.CraftingStation = "RWc_Table"; PieceManager.Instance.AddPiece(new CustomPiece(val3, true, val6)); } } private static void RegisterChest(AssetBundle bundle) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown GameObject val = bundle.LoadAsset("RWc_Chest"); Sprite icon = bundle.LoadAsset("RWc_Chest"); if ((Object)(object)val == (Object)null) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogError((object)"Missing chest prefab in rwc: RWc_Chest"); return; } PreparePiecePrefab(val, "Ravenwood Currency Chest", "A standalone Ravenwood storage chest.", icon, "piece_chest_wood"); Container val2 = val.GetComponent() ?? val.AddComponent(); val2.m_name = "Ravenwood Currency Chest"; val2.m_width = CurrencyConfig.ChestWidth.Value; val2.m_height = CurrencyConfig.ChestHeight.Value; PieceConfig val3 = CreatePieceConfig("Ravenwood Currency Chest", "A standalone Ravenwood storage chest.", icon, ParseRequirements(CurrencyConfig.ChestBuildCost.Value)); val3.CraftingStation = null; PieceManager.Instance.AddPiece(new CustomPiece(val, true, val3)); } private static void PreparePiecePrefab(GameObject prefab, string displayName, string description, Sprite icon, string effectSource) { ((Object)prefab).name = ((Object)prefab).name.Replace("(Clone)", string.Empty); PrefabRuntimeUtility.SetLayerRecursively(prefab, "piece"); PrefabRuntimeUtility.PrepareNetworkedPrefab(prefab, persistent: true); PrefabRuntimeUtility.EnsureCollider(prefab); Piece val = prefab.GetComponent() ?? prefab.AddComponent(); val.m_name = displayName; val.m_description = description; val.m_icon = icon; val.m_canBeRemoved = true; val.m_groundOnly = false; val.m_groundPiece = false; WearNTear val2 = prefab.GetComponent() ?? prefab.AddComponent(); val2.m_health = 1000f; GameObject val3 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(effectSource) : null); Piece val4 = (((Object)(object)val3 != (Object)null) ? val3.GetComponent() : null); WearNTear val5 = (((Object)(object)val3 != (Object)null) ? val3.GetComponent() : null); if ((Object)(object)val4 != (Object)null) { val.m_placeEffect = val4.m_placeEffect; } if ((Object)(object)val5 != (Object)null) { val2.m_destroyedEffect = val5.m_destroyedEffect; } } private static void ConfigureCraftingStation(CraftingStation station, string displayName, Sprite icon) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) station.m_name = displayName; station.m_icon = icon; station.m_discoverRange = 4f; station.m_rangeBuild = 10f; station.m_extraRangePerLevel = 0f; station.m_craftRequireRoof = false; station.m_craftRequireFire = false; station.m_showBasicRecipies = false; station.m_useDistance = 2f; station.m_craftingSkill = (SkillType)107; } private static void CopyPieceEffects(string targetPrefabName, string sourcePrefabName) { GameObject prefab = PrefabManager.Instance.GetPrefab(targetPrefabName); GameObject prefab2 = PrefabManager.Instance.GetPrefab(sourcePrefabName); Piece val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent() : null); Piece val2 = (((Object)(object)prefab2 != (Object)null) ? prefab2.GetComponent() : null); WearNTear val3 = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent() : null); WearNTear val4 = (((Object)(object)prefab2 != (Object)null) ? prefab2.GetComponent() : null); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { val.m_placeEffect = val2.m_placeEffect; } if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null) { val3.m_destroyedEffect = val4.m_destroyedEffect; } } private static PieceConfig CreatePieceConfig(string name, string description, Sprite icon, RequirementConfig[] requirements) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_004b: Expected O, but got Unknown return new PieceConfig { Name = name, Description = description, PieceTable = "Hammer", Category = "Ravenwood", CraftingStation = "piece_workbench", Icon = icon, Requirements = requirements }; } private static void AttachTableInteraction(GameObject table, string childName, bool materialExchange) { Transform val = PrefabRuntimeUtility.FindChildRecursive(table.transform, childName); if ((Object)(object)val == (Object)null) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogError((object)("RWc_Table is missing required child '" + childName + "'.")); return; } PrefabRuntimeUtility.EnsureCollider(((Component)val).gameObject); if (materialExchange) { if ((Object)(object)((Component)val).GetComponent() == (Object)null) { ((Component)val).gameObject.AddComponent(); } } else if ((Object)(object)((Component)val).GetComponent() == (Object)null) { ((Component)val).gameObject.AddComponent(); } } private static RequirementConfig[] ParseRequirements(string value) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown List list = new List(); MatchCollection source = Regex.Matches(value ?? string.Empty, "\\[([^\\]]+)\\]\\[(\\d+)\\]"); foreach (Match item in source.Cast()) { if (int.TryParse(item.Groups[2].Value, out var result) && result > 0) { list.Add(new RequirementConfig(item.Groups[1].Value, result, 0, true)); } } if (list.Count == 0) { RavenwoodCurrencyPlugin.Instance.ModLogger.LogWarning((object)("Invalid build requirement string: " + value)); } return list.ToArray(); } } internal sealed class CoinWorldPhysics : MonoBehaviour { [SerializeField] private Vector3 _authoredScale = Vector3.one; [SerializeField] private bool _configured; internal void Configure(Vector3 authoredScale) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _authoredScale = authoredScale; _configured = true; Apply(); } private void Awake() { Apply(); } private void OnEnable() { Apply(); } private void Start() { Apply(); } private void Apply() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_configured) { ((Component)this).transform.localScale = _authoredScale; Rigidbody component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { component.useGravity = true; component.isKinematic = false; component.detectCollisions = true; component.constraints = (RigidbodyConstraints)0; component.interpolation = (RigidbodyInterpolation)1; component.collisionDetectionMode = (CollisionDetectionMode)2; component.WakeUp(); } } } } internal static class ExchangeMenu { private static readonly List TradeButtons = new List(); private static GameObject _panel; private static Text _title; private static Text _subtitle; private static Text _status; private static Player _player; private static CraftingStation _tableStation; private static ExchangeMenuMode _mode; private static bool _isOpen; internal static void OnCustomGUIAvailable() { if (_isOpen) { GUIManager.BlockInput(false); } if ((Object)(object)_panel != (Object)null) { Object.Destroy((Object)(object)_panel); } _isOpen = false; _player = null; _tableStation = null; CreateGui(); } internal static void Show(ExchangeMenuMode mode, Player player, CraftingStation tableStation) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_panel == (Object)null) { CreateGui(); } if ((Object)(object)_panel == (Object)null) { if (player != null) { ((Character)player).Message((MessageType)2, "Ravenwood exchange menu is not available yet.", 0, (Sprite)null); } return; } _player = player; _tableStation = tableStation; _mode = mode; Populate(mode); _status.text = "Select a trade. Materials are taken from your inventory."; ((Graphic)_status).color = Color.white; _panel.SetActive(true); _isOpen = true; GUIManager.BlockInput(true); } internal static void Close() { if ((Object)(object)_panel != (Object)null) { _panel.SetActive(false); } if (_isOpen) { GUIManager.BlockInput(false); } _player = null; _tableStation = null; _isOpen = false; } internal static void Tick() { if (_isOpen && ((Object)(object)_player == (Object)null || Input.GetKeyDown((KeyCode)27))) { Close(); } } private static void CreateGui() { //IL_0039: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_0101: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown if (GUIManager.Instance != null && !((Object)(object)GUIManager.CustomGUIFront == (Object)null)) { _panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, 980f, 760f, false); ((Object)_panel).name = "RavenwoodCurrencyExchangePanel"; _panel.SetActive(false); _title = CreateText(string.Empty, new Vector2(0f, -42f), 30, GUIManager.Instance.ValheimOrange, 850f, 45f); _subtitle = CreateText(string.Empty, new Vector2(0f, -82f), 18, GUIManager.Instance.ValheimBeige, 850f, 35f); _status = CreateText(string.Empty, new Vector2(0f, -706f), 17, Color.white, 880f, 38f); GameObject val = GUIManager.Instance.CreateButton("X", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(445f, 340f), 48f, 44f); ((UnityEvent)val.GetComponent