Decompiled source of ForsakenJVL v2.0.28
plugins/Digitalroot.Valheim.ForsakenJVL.dll
Decompiled 3 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Dynamic; using System.Globalization; using System.IO; using System.Linq; using System.Net.Http; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Timers; using System.Xml.Serialization; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Digitalroot.Valheim.Common; using Digitalroot.Valheim.Common.Json; using Digitalroot.Valheim.Common.Names.Vanilla; using Digitalroot.Valheim.ForsakenJVL.Properties; using JetBrains.Annotations; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; using fastJSON; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Digitalroot.Valheim.ForsakenJVL")] [assembly: AssemblyDescription("Digitalroot ForsakenJVL")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Digitalroot Technologies")] [assembly: AssemblyProduct("Digitalroot Valheim Mods")] [assembly: AssemblyCopyright("Copyright © Digitalroot Technologies 2021 - 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("3ccc4dc1-5b17-47c1-b996-ca03b8639a61")] [assembly: AssemblyFileVersion("2.0.28")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.28.0")] [module: UnverifiableCode] namespace Digitalroot.Valheim.ForsakenJVL { public class CMB_BurnWhenHeld : MonoBehaviour { private readonly System.Timers.Timer _timer; public CMB_BurnWhenHeld() { try { Log.Trace(Main.Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); _timer = new System.Timers.Timer { AutoReset = true, Enabled = false, Interval = 10000.0 }; _timer.Elapsed += TimerElapsed; } catch (Exception e) { Log.Error(Main.Instance, e); } } private void TimerElapsed(object sender, ElapsedEventArgs e) { try { Log.Trace(Main.Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); if (Utils.IsPlayerReady() && ((Humanoid)Player.m_localPlayer).IsItemEquiped(((Component)this).gameObject.GetComponent<ItemDrop>().m_itemData)) { ((Character)Player.m_localPlayer).AddFireDamage(10f); } } catch (Exception e2) { Log.Error(Main.Instance, e2); } } [UsedImplicitly] public void Start() { Log.Trace(Main.Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); _timer.Elapsed += TimerElapsed; _timer.Start(); } [UsedImplicitly] private void OnDestroy() { Log.Trace(Main.Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); _timer.Elapsed -= TimerElapsed; _timer.Stop(); _timer.Dispose(); } } [BepInPlugin("digitalroot.valheim.mods.forsaken.jvl", "Digitalroot ForsakenJVL", "2.0.28")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("com.bepinex.plugins.forsaken")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Main : BaseUnityPlugin, ITraceableLogging { [UsedImplicitly] public static ConfigEntry<int> NexusId; public static Main Instance; private AssetBundle _assetBundle; [UsedImplicitly] public const string Version = "2.0.28"; [UsedImplicitly] public const string Name = "Digitalroot ForsakenJVL"; [UsedImplicitly] public const string Guid = "digitalroot.valheim.mods.forsaken.jvl"; [UsedImplicitly] public const string Namespace = "Digitalroot.Valheim.ForsakenJVL"; public string Source => "Digitalroot.Valheim.ForsakenJVL"; public bool EnableTrace { get; } public Main() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown Instance = this; NexusId = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 1538, new ConfigDescription("Nexus mod ID for updates", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = false, Browsable = false, ReadOnly = true } })); EnableTrace = false; Log.RegisterSource(Instance); Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); } [UsedImplicitly] private void Awake() { try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); LoadAssetFile(); PrefabManager.OnVanillaPrefabsAvailable += AddCustomItems; } catch (Exception e) { Log.Error(Instance, e); } } private async void LoadAssetFile() { try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); FileInfo assetFile = new FileInfo(Path.Combine(new FileInfo(typeof(Main).Assembly.Location).DirectoryName ?? throw new InvalidOperationException("Unable to load assetFile."), "forsakenmod")); if (!assetFile.Exists) { HttpUtil.DownloadFileAsync(Resources.asseturl, assetFile); } for (int i = 0; i < 36000; i++) { assetFile.Refresh(); if (assetFile.Exists) { break; } await Task.Delay(25); } if (!assetFile.Exists) { Log.Error(Instance, "Unable to find asset file 'forsakenmod', please make sure 'forsakenmod' and 'Digitalroot.Valheim.ForsakenJVL.dll' are in " + assetFile.DirectoryName); Log.Error(Instance, "Digitalroot.Valheim.ForsakenJVL is not loaded."); } else { _assetBundle = AssetUtils.LoadAssetBundle(assetFile.FullName); } } catch (Exception e) { Log.Error(Instance, e); } } private void AddCustomItems() { try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); if (!((Object)(object)_assetBundle == (Object)null)) { AddBattleaxeLightning(); AddBowFrost(); AddSledgeFire(); AddSledgePoison(); AddSpearSpirit(); AddUnarmedFenring(); AddKnifeFrost(); AddUnarmedFrost(); AddUnarmedFrostOh(); AddSwordFire(); AddSwordLightning(); AddShieldFire(); AddSpellFire(); _assetBundle.Unload(false); PrefabManager.OnVanillaPrefabsAvailable -= AddCustomItems; } } catch (Exception e) { Log.Error(Instance, e); } } private void AddSpellFire() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_SpellFire/v801_SpellFire.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_spellfire"; component.m_itemData.m_shared.m_description = "$item_forsaken_spellfire_description"; component.m_itemData.m_shared.m_itemType = (ItemType)3; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_weight = 0.1f; component.m_itemData.m_shared.m_maxDurability = 600f; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_blockPower = 0f; component.m_itemData.m_shared.m_timedBlockBonus = 0f; component.m_itemData.m_shared.m_deflectionForce = 0f; component.m_itemData.m_shared.m_attackForce = 0f; component.m_itemData.m_shared.m_damagesPerLevel.m_fire = 20f; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 7; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig { Item = ItemDropNames.Crystal, Amount = 40, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.TrophyGoblinKing, Amount = 12, AmountPerLevel = 0 }, new RequirementConfig { Item = ItemDropNames.YagluthDrop, Amount = 36, AmountPerLevel = 2 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddShieldFire() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_ShieldFire/v801_ShieldFire.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_shieldfire"; component.m_itemData.m_shared.m_description = "$item_forsaken_shieldfire_description"; component.m_itemData.m_shared.m_itemType = (ItemType)5; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_weight = 10f; component.m_itemData.m_shared.m_maxDurability = 600f; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_blockPower = 120f; component.m_itemData.m_shared.m_timedBlockBonus = 6f; component.m_itemData.m_shared.m_deflectionForce = 8f; component.m_itemData.m_shared.m_attackForce = 0f; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 7; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.Silver, Amount = 20, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.Flametal, Amount = 40, AmountPerLevel = 12 }, new RequirementConfig { Item = ItemDropNames.TrophyGoblinKing, Amount = 10, AmountPerLevel = 0 }, new RequirementConfig { Item = ItemDropNames.YagluthDrop, Amount = 30, AmountPerLevel = 2 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddSwordLightning() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Expected O, but got Unknown //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Expected O, but got Unknown //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Expected O, but got Unknown //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Expected O, but got Unknown //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_SwordLightning/v801_SwordLightning.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_swordlightning"; component.m_itemData.m_shared.m_description = "$item_forsaken_swordlightning_description"; component.m_itemData.m_shared.m_itemType = (ItemType)3; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_maxDurability = 700f; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_timedBlockBonus = 2f; component.m_itemData.m_shared.m_deflectionForce = 2f; component.m_itemData.m_shared.m_attackForce = 8f; component.m_itemData.m_shared.m_blockPower = 30f; component.m_itemData.m_shared.m_damages.m_slash = 40f; component.m_itemData.m_shared.m_damages.m_pierce = 40f; component.m_itemData.m_shared.m_damages.m_lightning = 70f; component.m_itemData.m_shared.m_damagesPerLevel.m_slash = 5f; component.m_itemData.m_shared.m_damagesPerLevel.m_pierce = 5f; component.m_itemData.m_shared.m_damagesPerLevel.m_lightning = 10f; component.m_itemData.m_shared.m_attack.m_attackStamina = 20f; component.m_itemData.m_shared.m_secondaryAttack.m_damageMultiplier = 1f; component.m_itemData.m_shared.m_secondaryAttack.m_attackStamina = 30f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactor = 0.3f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactorRotation = 0.3f; component.m_itemData.m_shared.m_secondaryAttack.m_forceMultiplier = 10f; component.m_itemData.m_shared.m_secondaryAttack.m_staggerMultiplier = 6f; component.m_itemData.m_shared.m_secondaryAttack.m_lowerDamagePerHit = false; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 7; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.Crystal, Amount = 40, AmountPerLevel = 40 }, new RequirementConfig { Item = ItemDropNames.Flametal, Amount = 60, AmountPerLevel = 60 }, new RequirementConfig { Item = ItemDropNames.TrophyGoblinKing, Amount = 12, AmountPerLevel = 0 }, new RequirementConfig { Item = ItemDropNames.YagluthDrop, Amount = 36, AmountPerLevel = 2 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddSwordFire() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Expected O, but got Unknown //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Expected O, but got Unknown //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Expected O, but got Unknown //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Expected O, but got Unknown //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Expected O, but got Unknown //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_SwordFire/v801_SwordFire.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_swordfire"; component.m_itemData.m_shared.m_description = "$item_forsaken_swordfire_description"; component.m_itemData.m_shared.m_itemType = (ItemType)14; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_weight = 30f; component.m_itemData.m_shared.m_maxDurability = 800f; component.m_itemData.m_shared.m_equipDuration = 1f; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_blockPower = 70f; component.m_itemData.m_shared.m_timedBlockBonus = 4f; component.m_itemData.m_shared.m_deflectionForce = 8f; component.m_itemData.m_shared.m_attackForce = 0f; component.m_itemData.m_shared.m_movementModifier = -0.25f; component.m_itemData.m_shared.m_damages.m_slash = 0f; component.m_itemData.m_shared.m_damages.m_fire = 46f; component.m_itemData.m_shared.m_damages.m_frost = 46f; component.m_itemData.m_shared.m_damages.m_lightning = 46f; component.m_itemData.m_shared.m_damages.m_spirit = 46f; component.m_itemData.m_shared.m_damages.m_poison = 46f; component.m_itemData.m_shared.m_damagesPerLevel.m_slash = 0f; component.m_itemData.m_shared.m_damagesPerLevel.m_fire = 10f; component.m_itemData.m_shared.m_damagesPerLevel.m_frost = 10f; component.m_itemData.m_shared.m_damagesPerLevel.m_lightning = 10f; component.m_itemData.m_shared.m_damagesPerLevel.m_spirit = 10f; component.m_itemData.m_shared.m_damagesPerLevel.m_poison = 10f; component.m_itemData.m_shared.m_attack.m_attackStamina = 25f; component.m_itemData.m_shared.m_attack.m_attackAnimation = "battleaxe_attack"; component.m_itemData.m_shared.m_attack.m_attackChainLevels = 3; component.m_itemData.m_shared.m_attack.m_speedFactor = 0.1f; component.m_itemData.m_shared.m_attack.m_speedFactorRotation = 0.1f; component.m_itemData.m_shared.m_secondaryAttack.m_attackAnimation = "battleaxe_secondary"; component.m_itemData.m_shared.m_secondaryAttack.m_attackChainLevels = 0; component.m_itemData.m_shared.m_secondaryAttack.m_attackStamina = 30f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactor = 0.1f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactorRotation = 0.1f; component.m_itemData.m_shared.m_secondaryAttack.m_damageMultiplier = 1f; component.m_itemData.m_shared.m_secondaryAttack.m_forceMultiplier = 10f; component.m_itemData.m_shared.m_secondaryAttack.m_staggerMultiplier = 6f; component.m_itemData.m_shared.m_secondaryAttack.m_lowerDamagePerHit = false; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 7; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.Iron, Amount = 40, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.Crystal, Amount = 40, AmountPerLevel = 15 }, new RequirementConfig { Item = ItemDropNames.Silver, Amount = 36, AmountPerLevel = 12 }, new RequirementConfig { Item = ItemDropNames.TrophyEikthyr, Amount = 12, AmountPerLevel = 0 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddUnarmedFrostOh() { //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Expected O, but got Unknown //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Expected O, but got Unknown //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Expected O, but got Unknown //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Expected O, but got Unknown //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Expected O, but got Unknown //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_UnarmedFrost/v801_UnarmedFrostOH.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_unarmedfrostoh"; component.m_itemData.m_shared.m_description = "$item_forsaken_unarmedfrostoh_description"; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_maxDurability = 700f; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_timedBlockBonus = 2f; component.m_itemData.m_shared.m_deflectionForce = 2f; component.m_itemData.m_shared.m_attackForce = 8f; component.m_itemData.m_shared.m_blockPower = 90f; component.m_itemData.m_shared.m_deflectionForce = 1f; component.m_itemData.m_shared.m_damages.m_blunt = 90f; component.m_itemData.m_shared.m_damages.m_frost = 80f; component.m_itemData.m_shared.m_damagesPerLevel.m_blunt = 5f; component.m_itemData.m_shared.m_damagesPerLevel.m_frost = 10f; component.m_itemData.m_shared.m_attack.m_attackStamina = 20f; component.m_itemData.m_shared.m_secondaryAttack.m_attackStamina = 20f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactor = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactorRotation = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_damageMultiplier = 1f; component.m_itemData.m_shared.m_secondaryAttack.m_forceMultiplier = 10f; component.m_itemData.m_shared.m_secondaryAttack.m_staggerMultiplier = 6f; component.m_itemData.m_shared.m_secondaryAttack.m_attackRange = 3.5f; component.m_itemData.m_shared.m_secondaryAttack.m_attackAngle = 180f; component.m_itemData.m_shared.m_secondaryAttack.m_attackRayWidth = 0.3f; component.m_itemData.m_shared.m_secondaryAttack.m_lowerDamagePerHit = false; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 6; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.FreezeGland, Amount = 10, AmountPerLevel = 2 }, new RequirementConfig { Item = ItemDropNames.TrophyHatchling, Amount = 4, AmountPerLevel = 0 }, new RequirementConfig { Item = ItemDropNames.DragonTear, Amount = 20, AmountPerLevel = 5 }, new RequirementConfig { Item = ItemDropNames.TrophyDragonQueen, Amount = 4, AmountPerLevel = 0 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddUnarmedFrost() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Expected O, but got Unknown //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Expected O, but got Unknown //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Expected O, but got Unknown //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Expected O, but got Unknown //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Expected O, but got Unknown //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_UnarmedFrost/v801_UnarmedFrost.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_unarmedfrost"; component.m_itemData.m_shared.m_description = "$item_forsaken_unarmedfrost_description"; component.m_itemData.m_shared.m_itemType = (ItemType)3; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_maxDurability = 700f; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_timedBlockBonus = 2f; component.m_itemData.m_shared.m_deflectionForce = 2f; component.m_itemData.m_shared.m_attackForce = 8f; component.m_itemData.m_shared.m_blockPower = 70f; component.m_itemData.m_shared.m_damages.m_blunt = 70f; component.m_itemData.m_shared.m_damages.m_frost = 90f; component.m_itemData.m_shared.m_damagesPerLevel.m_blunt = 5f; component.m_itemData.m_shared.m_damagesPerLevel.m_frost = 10f; component.m_itemData.m_shared.m_attack.m_attackStamina = 15f; component.m_itemData.m_shared.m_secondaryAttack.m_attackAnimation = "knife_secondary"; component.m_itemData.m_shared.m_secondaryAttack.m_attackRayWidth = 0.3f; component.m_itemData.m_shared.m_secondaryAttack.m_attackStamina = 20f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactor = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactorRotation = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_damageMultiplier = 1.25f; component.m_itemData.m_shared.m_secondaryAttack.m_forceMultiplier = 10f; component.m_itemData.m_shared.m_secondaryAttack.m_staggerMultiplier = 6f; component.m_itemData.m_shared.m_secondaryAttack.m_attackRange = 2.5f; component.m_itemData.m_shared.m_secondaryAttack.m_attackAngle = 50f; component.m_itemData.m_shared.m_secondaryAttack.m_attackRayWidth = 0.3f; component.m_itemData.m_shared.m_secondaryAttack.m_lowerDamagePerHit = false; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 6; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.FreezeGland, Amount = 20, AmountPerLevel = 4 }, new RequirementConfig { Item = ItemDropNames.TrophyHatchling, Amount = 10, AmountPerLevel = 0 }, new RequirementConfig { Item = ItemDropNames.DragonTear, Amount = 80, AmountPerLevel = 20 }, new RequirementConfig { Item = ItemDropNames.TrophyDragonQueen, Amount = 8, AmountPerLevel = 0 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddKnifeFrost() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Expected O, but got Unknown //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Expected O, but got Unknown //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Expected O, but got Unknown //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Expected O, but got Unknown //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/weapons/v801_KnifeFrost/v801_KnifeFrost.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_knifefrost"; component.m_itemData.m_shared.m_description = "$item_forsaken_knifefrost_description"; component.m_itemData.m_shared.m_itemType = (ItemType)3; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_weight = 1.5f; component.m_itemData.m_shared.m_maxDurability = 500f; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_backstabBonus = 4f; component.m_itemData.m_shared.m_damages.m_slash = 0f; component.m_itemData.m_shared.m_damages.m_pierce = 75f; component.m_itemData.m_shared.m_damages.m_frost = 75f; component.m_itemData.m_shared.m_damagesPerLevel.m_slash = 0f; component.m_itemData.m_shared.m_damagesPerLevel.m_pierce = 5f; component.m_itemData.m_shared.m_damagesPerLevel.m_frost = 5f; component.m_itemData.m_shared.m_attack.m_attackStamina = 15f; component.m_itemData.m_shared.m_attack.m_speedFactor = 0.1f; component.m_itemData.m_shared.m_attack.m_speedFactorRotation = 0.1f; component.m_itemData.m_shared.m_attack.m_attackHeight = 1f; component.m_itemData.m_shared.m_secondaryAttack.m_damageMultiplier = 1.15f; component.m_itemData.m_shared.m_secondaryAttack.m_attackStamina = 30f; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 6; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.FreezeGland, Amount = 24, AmountPerLevel = 6 }, new RequirementConfig { Item = ItemDropNames.Needle, Amount = 60, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.DragonTear, Amount = 80, AmountPerLevel = 20 }, new RequirementConfig { Item = ItemDropNames.TrophyDragonQueen, Amount = 8, AmountPerLevel = 0 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddBattleaxeLightning() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Expected O, but got Unknown //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Expected O, but got Unknown //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Expected O, but got Unknown //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Expected O, but got Unknown //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Expected O, but got Unknown //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_BattleaxeLightning/v801_BattleaxeLightning.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_battleaxelightning"; component.m_itemData.m_shared.m_description = "$item_forsaken_battleaxelightning_description"; component.m_itemData.m_shared.m_itemType = (ItemType)3; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_maxDurability = 400f; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_weight = 2.5f; component.m_itemData.m_shared.m_attackForce = 12f; component.m_itemData.m_shared.m_deflectionForce = 6f; component.m_itemData.m_shared.m_timedBlockBonus = 6f; component.m_itemData.m_shared.m_damages.m_slash = 75f; component.m_itemData.m_shared.m_damages.m_lightning = 40f; component.m_itemData.m_shared.m_damagesPerLevel.m_slash = 5f; component.m_itemData.m_shared.m_damagesPerLevel.m_lightning = 5f; component.m_itemData.m_shared.m_attack.m_attackStamina = 30f; component.m_itemData.m_shared.m_attack.m_attackAnimation = "swing_longsword"; component.m_itemData.m_shared.m_secondaryAttack.m_attackAnimation = "atgeir_secondary"; component.m_itemData.m_shared.m_secondaryAttack.m_attackChainLevels = 0; component.m_itemData.m_shared.m_secondaryAttack.m_attackStamina = 20f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactor = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactorRotation = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_damageMultiplier = 0.75f; component.m_itemData.m_shared.m_secondaryAttack.m_forceMultiplier = 10f; component.m_itemData.m_shared.m_secondaryAttack.m_staggerMultiplier = 6f; component.m_itemData.m_shared.m_secondaryAttack.m_attackRange = 3.5f; component.m_itemData.m_shared.m_secondaryAttack.m_attackAngle = 360f; component.m_itemData.m_shared.m_secondaryAttack.m_attackRayWidth = 0.3f; component.m_itemData.m_shared.m_secondaryAttack.m_lowerDamagePerHit = false; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.FineWood, Amount = 30, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.LeatherScraps, Amount = 12, AmountPerLevel = 4 }, new RequirementConfig { Item = ItemDropNames.Silver, Amount = 90, AmountPerLevel = 25 }, new RequirementConfig { Item = ItemDropNames.TrophyEikthyr, Amount = 1, AmountPerLevel = 0 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddBowFrost() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01bc: 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_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_BowFrost/v801_BowFrost.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_bowfrost"; component.m_itemData.m_shared.m_description = "$item_forsaken_bowfrost_description"; component.m_itemData.m_shared.m_itemType = (ItemType)4; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_maxDurability = 600f; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_weight = 10f; component.m_itemData.m_shared.m_timedBlockBonus = 6f; component.m_itemData.m_shared.m_deflectionForce = 8f; component.m_itemData.m_shared.m_attackForce = 0f; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 6; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.FreezeGland, Amount = 20, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.Crystal, Amount = 20, AmountPerLevel = 6 }, new RequirementConfig { Item = ItemDropNames.DragonTear, Amount = 20, AmountPerLevel = 15 }, new RequirementConfig { Item = ItemDropNames.TrophyDragonQueen, Amount = 6, AmountPerLevel = 0 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddSledgeFire() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Expected O, but got Unknown //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Expected O, but got Unknown //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Expected O, but got Unknown //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Expected O, but got Unknown //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_SledgeFire/v801_SledgeFire.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_sledgefire"; component.m_itemData.m_shared.m_description = "$item_forsaken_sledgefire_description"; component.m_itemData.m_shared.m_itemType = (ItemType)14; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_maxDurability = 750f; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_weight = 4f; component.m_itemData.m_shared.m_blockPower = 80f; component.m_itemData.m_shared.m_timedBlockBonus = 6f; component.m_itemData.m_shared.m_deflectionForce = 6f; component.m_itemData.m_shared.m_attackForce = 6f; component.m_itemData.m_shared.m_damages.m_blunt = 40f; component.m_itemData.m_shared.m_damages.m_pierce = 100f; component.m_itemData.m_shared.m_damages.m_fire = 112f; component.m_itemData.m_shared.m_damagesPerLevel.m_blunt = 3f; component.m_itemData.m_shared.m_damagesPerLevel.m_pierce = 10f; component.m_itemData.m_shared.m_damagesPerLevel.m_fire = 5f; component.m_itemData.m_shared.m_attack.m_attackStamina = 20f; component.m_itemData.m_shared.m_attack.m_attackAnimation = "battleaxe_attack"; component.m_itemData.m_shared.m_attack.m_attackChainLevels = 3; component.m_itemData.m_shared.m_secondaryAttack.m_attackAnimation = "swing_sledge"; component.m_itemData.m_shared.m_secondaryAttack.m_attackStamina = 35f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactor = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactorRotation = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_forceMultiplier = 10f; component.m_itemData.m_shared.m_secondaryAttack.m_staggerMultiplier = 6f; component.m_itemData.m_shared.m_secondaryAttack.m_lowerDamagePerHit = false; SE_Burning val2 = ScriptableObject.CreateInstance<SE_Burning>(); if ((Object)(object)val2 == (Object)null) { throw new NullReferenceException("statusEffect"); } val2.m_fireDamagePerHit = 1f; val2.m_damageInterval = 1f; component.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)val2; ItemManager instance = ItemManager.Instance; ItemConfig val3 = new ItemConfig(); val3.CraftingStation = CraftingStationNames.Forge; val3.MinStationLevel = 6; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.Flametal, Amount = 60, AmountPerLevel = 15 }, new RequirementConfig { Item = ItemDropNames.SurtlingCore, Amount = 60, AmountPerLevel = 15 }, new RequirementConfig { Item = ItemDropNames.BlackMetal, Amount = 60, AmountPerLevel = 15 }, new RequirementConfig { Item = ItemDropNames.TrophySurtling, Amount = 60, AmountPerLevel = 8 } }; instance.AddItem(new CustomItem(val, false, val3)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddSledgePoison() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Expected O, but got Unknown //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Expected O, but got Unknown //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Expected O, but got Unknown //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Expected O, but got Unknown //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_SledgePoison/v801_SledgePoison.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_sledgepoison"; component.m_itemData.m_shared.m_description = "$item_forsaken_sledgepoison_description"; component.m_itemData.m_shared.m_itemType = (ItemType)14; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_maxDurability = 550f; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_weight = 4f; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_timedBlockBonus = 6f; component.m_itemData.m_shared.m_deflectionForce = 6f; component.m_itemData.m_shared.m_attackForce = 12f; component.m_itemData.m_shared.m_blockPower = 40f; component.m_itemData.m_shared.m_damages.m_blunt = 140f; component.m_itemData.m_shared.m_damages.m_poison = 80f; component.m_itemData.m_shared.m_damagesPerLevel.m_blunt = 5f; component.m_itemData.m_shared.m_damagesPerLevel.m_poison = 10f; component.m_itemData.m_shared.m_attack.m_attackStamina = 20f; component.m_itemData.m_shared.m_attack.m_attackAnimation = "battleaxe_attack"; component.m_itemData.m_shared.m_attack.m_attackChainLevels = 3; component.m_itemData.m_shared.m_secondaryAttack.m_attackAnimation = "swing_sledge"; component.m_itemData.m_shared.m_secondaryAttack.m_attackStamina = 35f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactor = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactorRotation = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_forceMultiplier = 10f; component.m_itemData.m_shared.m_secondaryAttack.m_staggerMultiplier = 6f; component.m_itemData.m_shared.m_secondaryAttack.m_lowerDamagePerHit = false; StatusEffect equipStatusEffect = component.m_itemData.m_shared.m_equipStatusEffect; StatusEffect obj = ((equipStatusEffect is SE_Poison) ? equipStatusEffect : null); if ((Object)(object)obj == (Object)null) { throw new NullReferenceException("statusEffect"); } ((SE_Poison)obj).m_damageInterval = 1f; ((SE_Poison)obj).m_damagePerHit = 1f; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 4; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.WitheredBone, Amount = 20, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.Guck, Amount = 20, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.BlackMetal, Amount = 40, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.TrophyBonemass, Amount = 6, AmountPerLevel = 0 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddSpearSpirit() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Expected O, but got Unknown //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Expected O, but got Unknown //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Expected O, but got Unknown //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Expected O, but got Unknown //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Expected O, but got Unknown //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_SpearSpirit/v801_SpearSpirit.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_spearspirit"; component.m_itemData.m_shared.m_description = "$item_forsaken_spearspirit_description"; component.m_itemData.m_shared.m_itemType = (ItemType)3; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_maxDurability = 500f; component.m_itemData.m_shared.m_equipDuration = 0.2f; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_timedBlockBonus = 1f; component.m_itemData.m_shared.m_deflectionForce = 1f; component.m_itemData.m_shared.m_attackForce = 12f; component.m_itemData.m_shared.m_damages.m_pierce = 75f; component.m_itemData.m_shared.m_damages.m_spirit = 75f; component.m_itemData.m_shared.m_damagesPerLevel.m_pierce = 5f; component.m_itemData.m_shared.m_damagesPerLevel.m_spirit = 5f; component.m_itemData.m_shared.m_attack.m_attackStamina = 20f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactor = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactorRotation = 0.2f; component.m_itemData.m_shared.m_secondaryAttack.m_damageMultiplier = 0.75f; component.m_itemData.m_shared.m_secondaryAttack.m_forceMultiplier = 10f; component.m_itemData.m_shared.m_secondaryAttack.m_staggerMultiplier = 6f; component.m_itemData.m_shared.m_secondaryAttack.m_lowerDamagePerHit = false; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 4; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.ElderBark, Amount = 40, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.Crystal, Amount = 12, AmountPerLevel = 4 }, new RequirementConfig { Item = ItemDropNames.AncientSeed, Amount = 40, AmountPerLevel = 15 }, new RequirementConfig { Item = ItemDropNames.TrophyTheElder, Amount = 3, AmountPerLevel = 0 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } private void AddUnarmedFenring() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Expected O, but got Unknown //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Expected O, but got Unknown //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Expected O, but got Unknown //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Expected O, but got Unknown try { Log.Trace(Instance, "Digitalroot.Valheim.ForsakenJVL." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name); GameObject val = _assetBundle.LoadAsset<GameObject>("Assets/Custom_Items/v801_UnarmedFenring/v801_UnarmedFenring.prefab"); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("prefab"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new NullReferenceException("itemDrop"); } component.m_itemData.m_shared.m_name = "$item_forsaken_unarmedfenring"; component.m_itemData.m_shared.m_description = "$item_forsaken_unarmedfenring_description"; component.m_itemData.m_shared.m_itemType = (ItemType)3; component.m_itemData.m_shared.m_equipDuration = 0.25f; component.m_itemData.m_shared.m_maxDurability = 800f; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_variants = 1; component.m_itemData.m_shared.m_weight = 2f; component.m_itemData.m_shared.m_blockPower = 30f; component.m_itemData.m_shared.m_timedBlockBonus = 2f; component.m_itemData.m_shared.m_deflectionForce = 2f; component.m_itemData.m_shared.m_attackForce = 2f; component.m_itemData.m_shared.m_movementModifier = 0f; component.m_itemData.m_shared.m_damages.m_slash = 60f; component.m_itemData.m_shared.m_damages.m_pierce = 60f; component.m_itemData.m_shared.m_damagesPerLevel.m_slash = 5f; component.m_itemData.m_shared.m_damagesPerLevel.m_pierce = 5f; component.m_itemData.m_shared.m_attack.m_attackStamina = 15f; component.m_itemData.m_shared.m_attack.m_speedFactor = 0.1f; component.m_itemData.m_shared.m_attack.m_speedFactorRotation = 0.1f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactor = 0.1f; component.m_itemData.m_shared.m_secondaryAttack.m_speedFactorRotation = 0.1f; component.m_itemData.m_shared.m_secondaryAttack.m_damageMultiplier = 1.15f; component.m_itemData.m_shared.m_secondaryAttack.m_forceMultiplier = 10f; component.m_itemData.m_shared.m_secondaryAttack.m_staggerMultiplier = 6f; component.m_itemData.m_shared.m_secondaryAttack.m_lowerDamagePerHit = false; ItemManager instance = ItemManager.Instance; ItemConfig val2 = new ItemConfig(); val2.CraftingStation = CraftingStationNames.Forge; val2.MinStationLevel = 5; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = ItemDropNames.FreezeGland, Amount = 40, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.Silver, Amount = 60, AmountPerLevel = 10 }, new RequirementConfig { Item = ItemDropNames.Chain, Amount = 4, AmountPerLevel = 2 }, new RequirementConfig { Item = ItemDropNames.TrophyFenring, Amount = 10, AmountPerLevel = 0 } }; instance.AddItem(new CustomItem(val, false, val2)); } catch (Exception e) { Log.Error(Instance, e); } } } } namespace Digitalroot.Valheim.ForsakenJVL.Properties { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] internal class Resources { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static ResourceManager ResourceManager { get { if (resourceMan == null) { resourceMan = new ResourceManager("Digitalroot.Valheim.ForsakenJVL.Properties.Resources", typeof(Resources).Assembly); } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static string asseturl => ResourceManager.GetString("asseturl", resourceCulture); internal Resources() { } } } namespace Digitalroot.Valheim.Common { internal sealed class Log { private static readonly Dictionary<string, TraceLogger> TraceLoggers; [UsedImplicitly] private static Log Instance { get; } static Log() { TraceLoggers = new Dictionary<string, TraceLogger>(); Instance = new Log(); } private Log() { TraceLoggers.Add("Digitalroot", new TraceLogger("Digitalroot", enableTrace: false)); } public static void RegisterSource(ITraceableLogging sender) { if ((!TraceLoggers.ContainsKey(sender.Source) || TraceLoggers[sender.Source].IsTraceEnabled != sender.EnableTrace) && (!TraceLoggers.ContainsKey(sender.Source) || sender.EnableTrace)) { if (TraceLoggers.ContainsKey(sender.Source) && sender.EnableTrace) { TraceLoggers[sender.Source].EnableTrace(); } else { TraceLoggers.Add(sender.Source, new TraceLogger(sender.Source, sender.EnableTrace)); } } } private static TraceLogger GetTraceLogger(ITraceableLogging sender) { if (!TraceLoggers.ContainsKey(sender.Source)) { return TraceLoggers["Digitalroot"]; } return TraceLoggers[sender.Source]; } [UsedImplicitly] public static void SetEnableTrace(ITraceableLogging sender, bool value) { if (value) { GetTraceLogger(sender).EnableTrace(); } else { GetTraceLogger(sender).DisableTrace(); } } [UsedImplicitly] public static void SetEnableTraceForAllLoggers(bool value) { foreach (TraceLogger value2 in TraceLoggers.Values) { if (value) { value2.EnableTrace(); } else { value2.DisableTrace(); } } } [UsedImplicitly] public static void Debug(ITraceableLogging sender, object value) { GetTraceLogger(sender).LoggerRef.LogDebug(value); } [UsedImplicitly] public static void Error(ITraceableLogging sender, Exception e, int i = 1) { Error(sender, "Message: " + e.Message); Error(sender, $"TargetSite: {e.TargetSite}"); Error(sender, "StackTrace: " + e.StackTrace); Error(sender, "Source: " + e.Source); if (e.Data.Count > 0) { foreach (object key in e.Data.Keys) { Error(sender, $"key: {key}, value: {e.Data[key]}"); } } if (e.InnerException != null) { Error(sender, $"--- InnerException [{i}][Start] ---"); Error(sender, e.InnerException, ++i); } } [UsedImplicitly] public static void Error(ITraceableLogging sender, object value) { GetTraceLogger(sender).LoggerRef.LogError(value); } [UsedImplicitly] public static void Info(ITraceableLogging sender, object value) { GetTraceLogger(sender).LoggerRef.LogInfo(value); } [UsedImplicitly] public static void Fatal(ITraceableLogging sender, Exception e, int i = 1) { Fatal(sender, "Message: " + e.Message); Fatal(sender, $"TargetSite: {e.TargetSite}"); Fatal(sender, "StackTrace: " + e.StackTrace); Fatal(sender, "Source: " + e.Source); if (e.Data.Count > 0) { foreach (object key in e.Data.Keys) { Fatal(sender, $"key: {key}, value: {e.Data[key]}"); } } if (e.InnerException != null) { Fatal(sender, $"--- InnerException [{i}][Start] ---"); Fatal(sender, e.InnerException, ++i); } } [UsedImplicitly] public static void Fatal(ITraceableLogging sender, object value) { GetTraceLogger(sender).LoggerRef.LogFatal(value); } [UsedImplicitly] public static void Message(ITraceableLogging sender, object value) { GetTraceLogger(sender).LoggerRef.LogMessage(value); } [UsedImplicitly] public static void Trace(ITraceableLogging sender, object value) { if (GetTraceLogger(sender).IsTraceEnabled || sender.EnableTrace) { GetTraceLogger(sender).LoggerRef.Log((LogLevel)63, value); } } [UsedImplicitly] public static void Warning(ITraceableLogging sender, object value) { GetTraceLogger(sender).LoggerRef.LogWarning(value); } } internal class TraceLogger { internal readonly ManualLogSource LoggerRef; private readonly string _source; private readonly FileInfo _traceFileInfo; public bool IsTraceEnabled { get; private set; } private DirectoryInfo AssemblyDirectory => new FileInfo(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path)).Directory; public TraceLogger(string source, bool enableTrace) { _source = source; IsTraceEnabled = enableTrace; LoggerRef = Logger.CreateLogSource(_source); _traceFileInfo = new FileInfo(Path.Combine(Paths.BepInExRootPath ?? AssemblyDirectory.FullName, "logs", _source + ".Trace.log")); if (_traceFileInfo.DirectoryName != null) { Directory.CreateDirectory(_traceFileInfo.DirectoryName); } if (_traceFileInfo.Exists) { _traceFileInfo.Delete(); _traceFileInfo.Refresh(); } LoggerRef.LogEvent += OnLogEvent; } public void EnableTrace() { IsTraceEnabled = true; } public void DisableTrace() { IsTraceEnabled = false; } private void StopTrace() { LoggerRef.LogEvent -= OnLogEvent; } private void OnLogEvent(object sender, LogEventArgs e) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (e.Source.SourceName != _source || !IsTraceEnabled) { return; } using Mutex mutex = new Mutex(initiallyOwned: false, "Digitalroot.Valheim.Common.TraceLogger." + _source); mutex.WaitOne(); try { if (e.Data is string) { string contents = $"[{e.Level,-7}:{e.Source.SourceName,10}] {e.Data}{Environment.NewLine}"; File.AppendAllText(_traceFileInfo.FullName, contents, Encoding.UTF8); } else { string contents2 = $"[{e.Level,-7}:{e.Source.SourceName,10}] {JsonSerializationProvider.ToJson(e.Data)}{Environment.NewLine}"; File.AppendAllText(_traceFileInfo.FullName, contents2, Encoding.UTF8); } } finally { mutex.ReleaseMutex(); } } } internal interface ITraceableLogging { string Source { get; } bool EnableTrace { get; } } } namespace Digitalroot.Valheim.Common.Json { [UsedImplicitly] internal static class JsonSerializationProvider { private static readonly JSONParameters JsonParameters = new JSONParameters { SerializeNullValues = false, SerializeToLowerCaseNames = false, BadListTypeChecking = true, ShowReadOnlyProperties = true, KVStyleStringDictionary = false, UseEscapedUnicode = true, InlineCircularReferences = true }; private static bool _customTypeLoaded; private static void Init() { if (!_customTypeLoaded) { JSON.RegisterCustomType(typeof(Vector3), delegate(object x) { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Vector3 val2 = (Vector3)x; return JSON.ToJSON(new float[3] { val2.x, val2.y, val2.z }); }, delegate(string x) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) float[] array2 = JSON.ToObject<float[]>(x); return (object)new Vector3(array2[0], array2[1], array2[2]); }); JSON.RegisterCustomType(typeof(Quaternion), delegate(object x) { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Quaternion val = (Quaternion)x; return JSON.ToJSON(new float[4] { val.x, val.y, val.z, val.w }); }, delegate(string x) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) float[] array = JSON.ToObject<float[]>(x); return (object)new Quaternion(array[0], array[1], array[2], array[3]); }); _customTypeLoaded = true; } } public static T FromJson<T>(string json) { Init(); return JSON.ToObject<T>(json, JsonParameters); } public static string ToJson(object obj, bool pretty = false) { Init(); if (pretty) { return JSON.ToNiceJSON(obj, JsonParameters); } return JSON.ToJSON(obj, JsonParameters); } } } namespace fastJSON { internal sealed class JSONParameters { public bool UseOptimizedDatasetSchema = true; public bool UseFastGuid = true; public bool SerializeNullValues = true; public bool UseUTCDateTime = true; public bool ShowReadOnlyProperties; public bool UsingGlobalTypes = true; [Obsolete("Not needed anymore and will always match")] public bool IgnoreCaseOnDeserialize; public bool EnableAnonymousTypes; public bool UseExtensions = true; public bool UseEscapedUnicode = true; public bool KVStyleStringDictionary; public bool UseValuesOfEnums; public List<Type> IgnoreAttributes = new List<Type> { typeof(XmlIgnoreAttribute), typeof(NonSerializedAttribute) }; public bool ParametricConstructorOverride; public bool DateTimeMilliseconds; public byte SerializerMaxDepth = 20; public bool InlineCircularReferences; public bool SerializeToLowerCaseNames; public byte FormatterIndentSpaces = 3; public bool AllowNonQuotedKeys; public bool AutoConvertStringToNumbers = true; public bool OverrideObjectHashCodeChecking; [Obsolete("Racist term removed, please use BadListTypeChecking")] public bool BlackListTypeChecking = true; public bool BadListTypeChecking = true; public bool FullyQualifiedDataSetSchema; public void FixValues() { if (!UseExtensions) { UsingGlobalTypes = false; InlineCircularReferences = true; } if (EnableAnonymousTypes) { ShowReadOnlyProperties = true; } } public JSONParameters MakeCopy() { return new JSONParameters { AllowNonQuotedKeys = AllowNonQuotedKeys, DateTimeMilliseconds = DateTimeMilliseconds, EnableAnonymousTypes = EnableAnonymousTypes, FormatterIndentSpaces = FormatterIndentSpaces, IgnoreAttributes = new List<Type>(IgnoreAttributes), InlineCircularReferences = InlineCircularReferences, KVStyleStringDictionary = KVStyleStringDictionary, ParametricConstructorOverride = ParametricConstructorOverride, SerializeNullValues = SerializeNullValues, SerializerMaxDepth = SerializerMaxDepth, SerializeToLowerCaseNames = SerializeToLowerCaseNames, ShowReadOnlyProperties = ShowReadOnlyProperties, UseEscapedUnicode = UseEscapedUnicode, UseExtensions = UseExtensions, UseFastGuid = UseFastGuid, UseOptimizedDatasetSchema = UseOptimizedDatasetSchema, UseUTCDateTime = UseUTCDateTime, UseValuesOfEnums = UseValuesOfEnums, UsingGlobalTypes = UsingGlobalTypes, AutoConvertStringToNumbers = AutoConvertStringToNumbers, OverrideObjectHashCodeChecking = OverrideObjectHashCodeChecking, FullyQualifiedDataSetSchema = FullyQualifiedDataSetSchema, BadListTypeChecking = BadListTypeChecking }; } } internal sealed class Reflection { private delegate object CreateObject(); private delegate object CreateList(int capacity); public delegate object GenericGetter(object obj); public delegate object GenericSetter(object target, object value); public delegate object Deserialize(string data); public delegate string Serialize(object data); private static readonly Reflection instance; public static bool RDBMode; private SafeDictionary<Type, string> _tyname = new SafeDictionary<Type, string>(10); private SafeDictionary<string, Type> _typecache = new SafeDictionary<string, Type>(10); private SafeDictionary<Type, CreateObject> _constrcache = new SafeDictionary<Type, CreateObject>(10); private SafeDictionary<Type, CreateList> _conlistcache = new SafeDictionary<Type, CreateList>(10); private SafeDictionary<Type, Getters[]> _getterscache = new SafeDictionary<Type, Getters[]>(10); private SafeDictionary<string, Dictionary<string, myPropInfo>> _propertycache = new SafeDictionary<string, Dictionary<string, myPropInfo>>(10); private SafeDictionary<Type, Type[]> _genericTypes = new SafeDictionary<Type, Type[]>(10); private SafeDictionary<Type, Type> _genericTypeDef = new SafeDictionary<Type, Type>(10); private static SafeDictionary<short, OpCode> _opCodes; private static List<string> _badlistTypes; private static UTF8Encoding utf8; internal SafeDictionary<Type, Serialize> _customSerializer = new SafeDictionary<Type, Serialize>(); internal SafeDictionary<Type, Deserialize> _customDeserializer = new SafeDictionary<Type, Deserialize>(); public static Reflection Instance => instance; static Reflection() { instance = new Reflection(); RDBMode = false; _badlistTypes = new List<string> { "system.configuration.install.assemblyinstaller", "system.activities.presentation.workflowdesigner", "system.windows.resourcedictionary", "system.windows.data.objectdataprovider", "system.windows.forms.bindingsource", "microsoft.exchange.management.systemmanager.winforms.exchangesettingsprovider" }; utf8 = new UTF8Encoding(); } private Reflection() { } private static bool TryGetOpCode(short code, out OpCode opCode) { if (_opCodes != null) { return _opCodes.TryGetValue(code, out opCode); } SafeDictionary<short, OpCode> safeDictionary = new SafeDictionary<short, OpCode>(); FieldInfo[] fields = typeof(OpCodes).GetFields(BindingFlags.Static | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (typeof(OpCode).IsAssignableFrom(fieldInfo.FieldType)) { OpCode value = (OpCode)fieldInfo.GetValue(null); if (value.OpCodeType != OpCodeType.Nternal) { safeDictionary.Add(value.Value, value); } } } _opCodes = safeDictionary; return _opCodes.TryGetValue(code, out opCode); } public static byte[] UTF8GetBytes(string str) { return utf8.GetBytes(str); } public static string UTF8GetString(byte[] bytes, int offset, int len) { return utf8.GetString(bytes, offset, len); } public unsafe static byte[] UnicodeGetBytes(string str) { int num = str.Length * 2; byte[] array = new byte[num]; fixed (void* value = str) { Marshal.Copy(new IntPtr(value), array, 0, num); } return array; } public static string UnicodeGetString(byte[] b) { return UnicodeGetString(b, 0, b.Length); } public unsafe static string UnicodeGetString(byte[] bytes, int offset, int buflen) { string text = ""; fixed (byte* ptr = bytes) { char* value = (char*)(ptr + offset); text = new string(value, 0, buflen / 2); } return text; } internal object CreateCustom(string v, Type type) { _customDeserializer.TryGetValue(type, out var value); return value(v); } internal void RegisterCustomType(Type type, Serialize serializer, Deserialize deserializer) { if (type != null && serializer != null && deserializer != null) { _customSerializer.Add(type, serializer); _customDeserializer.Add(type, deserializer); Instance.ResetPropertyCache(); } } internal bool IsTypeRegistered(Type t) { if (_customSerializer.Count() == 0) { return false; } Serialize value; return _customSerializer.TryGetValue(t, out value); } public Type GetGenericTypeDefinition(Type t) { Type value = null; if (_genericTypeDef.TryGetValue(t, out value)) { return value; } value = t.GetGenericTypeDefinition(); _genericTypeDef.Add(t, value); return value; } public Type[] GetGenericArguments(Type t) { Type[] value = null; if (_genericTypes.TryGetValue(t, out value)) { return value; } value = t.GetGenericArguments(); _genericTypes.Add(t, value); return value; } public Dictionary<string, myPropInfo> Getproperties(Type type, string typename, bool ShowReadOnlyProperties) { Dictionary<string, myPropInfo> value = null; if (_propertycache.TryGetValue(typename, out value)) { return value; } value = new Dictionary<string, myPropInfo>(10); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public; PropertyInfo[] properties = type.GetProperties(bindingAttr); PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo in array) { if (propertyInfo.GetIndexParameters().Length != 0) { continue; } myPropInfo myPropInfo2 = CreateMyProp(propertyInfo.PropertyType, propertyInfo.Name); myPropInfo2.setter = CreateSetMethod(type, propertyInfo, ShowReadOnlyProperties); if (myPropInfo2.setter != null) { myPropInfo2.CanWrite = true; } myPropInfo2.getter = CreateGetMethod(type, propertyInfo); object[] customAttributes = propertyInfo.GetCustomAttributes(inherit: true); object[] array2 = customAttributes; foreach (object obj in array2) { if (obj is System.Runtime.Serialization.DataMemberAttribute) { System.Runtime.Serialization.DataMemberAttribute dataMemberAttribute = (System.Runtime.Serialization.DataMemberAttribute)obj; if (dataMemberAttribute.Name != "") { myPropInfo2.memberName = dataMemberAttribute.Name; } } if (obj is DataMemberAttribute) { DataMemberAttribute dataMemberAttribute2 = (DataMemberAttribute)obj; if (dataMemberAttribute2.Name != "") { myPropInfo2.memberName = dataMemberAttribute2.Name; } } } if (myPropInfo2.memberName != null) { value.Add(myPropInfo2.memberName, myPropInfo2); } else { value.Add(propertyInfo.Name.ToLowerInvariant(), myPropInfo2); } } FieldInfo[] fields = type.GetFields(bindingAttr); FieldInfo[] array3 = fields; foreach (FieldInfo fieldInfo in array3) { myPropInfo myPropInfo3 = CreateMyProp(fieldInfo.FieldType, fieldInfo.Name); if (fieldInfo.IsLiteral) { continue; } if (!fieldInfo.IsInitOnly) { myPropInfo3.setter = CreateSetField(type, fieldInfo); } if (myPropInfo3.setter != null) { myPropInfo3.CanWrite = true; } myPropInfo3.getter = CreateGetField(type, fieldInfo); object[] customAttributes2 = fieldInfo.GetCustomAttributes(inherit: true); object[] array4 = customAttributes2; foreach (object obj2 in array4) { if (obj2 is System.Runtime.Serialization.DataMemberAttribute) { System.Runtime.Serialization.DataMemberAttribute dataMemberAttribute3 = (System.Runtime.Serialization.DataMemberAttribute)obj2; if (dataMemberAttribute3.Name != "") { myPropInfo3.memberName = dataMemberAttribute3.Name; } } if (obj2 is DataMemberAttribute) { DataMemberAttribute dataMemberAttribute4 = (DataMemberAttribute)obj2; if (dataMemberAttribute4.Name != "") { myPropInfo3.memberName = dataMemberAttribute4.Name; } } } if (myPropInfo3.memberName != null) { value.Add(myPropInfo3.memberName, myPropInfo3); } else { value.Add(fieldInfo.Name.ToLowerInvariant(), myPropInfo3); } } _propertycache.Add(typename, value); return value; } private myPropInfo CreateMyProp(Type t, string name) { myPropInfo myPropInfo2 = new myPropInfo(); myPropInfoType type = myPropInfoType.Unknown; if (t == typeof(int) || t == typeof(int?)) { type = myPropInfoType.Int; } else if (t == typeof(long) || t == typeof(long?)) { type = myPropInfoType.Long; } else if (t == typeof(string)) { type = myPropInfoType.String; } else if (t == typeof(bool) || t == typeof(bool?)) { type = myPropInfoType.Bool; } else if (t == typeof(DateTime) || t == typeof(DateTime?)) { type = myPropInfoType.DateTime; } else if (t.IsEnum) { type = myPropInfoType.Enum; } else if (t == typeof(Guid) || t == typeof(Guid?)) { type = myPropInfoType.Guid; } else if (t == typeof(StringDictionary)) { type = myPropInfoType.StringDictionary; } else if (t == typeof(NameValueCollection)) { type = myPropInfoType.NameValue; } else if (t.IsArray) { myPropInfo2.bt = t.GetElementType(); type = ((!(t == typeof(byte[]))) ? myPropInfoType.Array : myPropInfoType.ByteArray); } else if (t.Name.Contains("Dictionary")) { myPropInfo2.GenericTypes = Instance.GetGenericArguments(t); type = ((myPropInfo2.GenericTypes.Length == 0 || !(myPropInfo2.GenericTypes[0] == typeof(string))) ? myPropInfoType.Dictionary : myPropInfoType.StringKeyDictionary); } else if (t == typeof(Hashtable)) { type = myPropInfoType.Hashtable; } else if (t == typeof(DataSet)) { type = myPropInfoType.DataSet; } else if (t == typeof(DataTable)) { type = myPropInfoType.DataTable; } else if (IsTypeRegistered(t)) { type = myPropInfoType.Custom; } if (t.IsValueType && !t.IsPrimitive && !t.IsEnum && t != typeof(decimal)) { myPropInfo2.IsStruct = true; } myPropInfo2.IsInterface = t.IsInterface; myPropInfo2.IsClass = t.IsClass; myPropInfo2.IsValueType = t.IsValueType; if (t.IsGenericType) { myPropInfo2.IsGenericType = true; myPropInfo2.bt = Instance.GetGenericArguments(t)[0]; } myPropInfo2.pt = t; myPropInfo2.Name = name; myPropInfo2.changeType = GetChangeType(t); myPropInfo2.Type = type; return myPropInfo2; } private Type GetChangeType(Type conversionType) { if (conversionType.IsGenericType && conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) { return Instance.GetGenericArguments(conversionType)[0]; } return conversionType; } public string GetTypeAssemblyName(Type t) { string value = ""; if (_tyname.TryGetValue(t, out value)) { return value; } string assemblyQualifiedName = t.AssemblyQualifiedName; _tyname.Add(t, assemblyQualifiedName); return assemblyQualifiedName; } internal Type GetTypeFromCache(string typename, bool badlistChecking) { Type value = null; if (_typecache.TryGetValue(typename, out value)) { return value; } if (badlistChecking) { string text = typename.Trim().ToLowerInvariant(); foreach (string badlistType in _badlistTypes) { if (text.StartsWith(badlistType, StringComparison.Ordinal)) { throw new Exception("Black list type encountered, possible attack vector when using $type : " + typename); } } } Type type = Type.GetType(typename); if (RDBMode && type == null) { type = Type.GetType(typename, (AssemblyName name) => (from z in AppDomain.CurrentDomain.GetAssemblies() where z.FullName == name.FullName select z).FirstOrDefault(), null, throwOnError: true); } _typecache.Add(typename, type); return type; } internal object FastCreateList(Type objtype, int capacity) { try { int capacity2 = 10; if (capacity > 10) { capacity2 = capacity; } CreateList value = null; if (_conlistcache.TryGetValue(objtype, out value)) { if (value != null) { return value(capacity2); } return FastCreateInstance(objtype); } ConstructorInfo constructor = objtype.GetConstructor(new Type[1] { typeof(int) }); if (constructor != null) { DynamicMethod dynamicMethod = new DynamicMethod("_fcil", objtype, new Type[1] { typeof(int) }, restrictedSkipVisibility: true); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Newobj, objtype.GetConstructor(new Type[1] { typeof(int) })); iLGenerator.Emit(OpCodes.Ret); value = (CreateList)dynamicMethod.CreateDelegate(typeof(CreateList)); _conlistcache.Add(objtype, value); return value(capacity2); } _conlistcache.Add(objtype, null); return FastCreateInstance(objtype); } catch (Exception innerException) { throw new Exception($"Failed to fast create instance for type '{objtype.FullName}' from assembly '{objtype.AssemblyQualifiedName}'", innerException); } } internal object FastCreateInstance(Type objtype) { try { CreateObject value = null; if (_constrcache.TryGetValue(objtype, out value)) { return value(); } if (objtype.IsClass) { DynamicMethod dynamicMethod = new DynamicMethod("_fcic", objtype, null, restrictedSkipVisibility: true); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); iLGenerator.Emit(OpCodes.Newobj, objtype.GetConstructor(Type.EmptyTypes)); iLGenerator.Emit(OpCodes.Ret); value = (CreateObject)dynamicMethod.CreateDelegate(typeof(CreateObject)); _constrcache.Add(objtype, value); } else { DynamicMethod dynamicMethod2 = new DynamicMethod("_fcis", typeof(object), null, restrictedSkipVisibility: true); ILGenerator iLGenerator2 = dynamicMethod2.GetILGenerator(); LocalBuilder local = iLGenerator2.DeclareLocal(objtype); iLGenerator2.Emit(OpCodes.Ldloca_S, local); iLGenerator2.Emit(OpCodes.Initobj, objtype); iLGenerator2.Emit(OpCodes.Ldloc_0); iLGenerator2.Emit(OpCodes.Box, objtype); iLGenerator2.Emit(OpCodes.Ret); value = (CreateObject)dynamicMethod2.CreateDelegate(typeof(CreateObject)); _constrcache.Add(objtype, value); } return value(); } catch (Exception innerException) { throw new Exception($"Failed to fast create instance for type '{objtype.FullName}' from assembly '{objtype.AssemblyQualifiedName}'", innerException); } } internal static GenericSetter CreateSetField(Type type, FieldInfo fieldInfo) { Type[] array = new Type[2]; array[0] = (array[1] = typeof(object)); DynamicMethod dynamicMethod = new DynamicMethod("_csf", typeof(object), array, type, skipVisibility: true); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); if (!type.IsClass) { LocalBuilder local = iLGenerator.DeclareLocal(type); iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Unbox_Any, type); iLGenerator.Emit(OpCodes.Stloc_0); iLGenerator.Emit(OpCodes.Ldloca_S, local); iLGenerator.Emit(OpCodes.Ldarg_1); if (fieldInfo.FieldType.IsClass) { iLGenerator.Emit(OpCodes.Castclass, fieldInfo.FieldType); } else { iLGenerator.Emit(OpCodes.Unbox_Any, fieldInfo.FieldType); } iLGenerator.Emit(OpCodes.Stfld, fieldInfo); iLGenerator.Emit(OpCodes.Ldloc_0); iLGenerator.Emit(OpCodes.Box, type); iLGenerator.Emit(OpCodes.Ret); } else { iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Ldarg_1); if (fieldInfo.FieldType.IsValueType) { iLGenerator.Emit(OpCodes.Unbox_Any, fieldInfo.FieldType); } iLGenerator.Emit(OpCodes.Stfld, fieldInfo); iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Ret); } return (GenericSetter)dynamicMethod.CreateDelegate(typeof(GenericSetter)); } internal static FieldInfo GetGetterBackingField(PropertyInfo autoProperty) { MethodInfo getMethod = autoProperty.GetGetMethod(); if (!getMethod.IsDefined(typeof(CompilerGeneratedAttribute), inherit: false)) { return null; } byte[] array = getMethod.GetMethodBody()?.GetILAsByteArray() ?? new byte[0]; OpCode opCode; for (int i = 0; i < array.Length; i += ((opCode.OperandType != OperandType.InlineNone) ? ((opCode.OperandType == OperandType.ShortInlineBrTarget || opCode.OperandType == OperandType.ShortInlineI || opCode.OperandType == OperandType.ShortInlineVar) ? 1 : ((opCode.OperandType == OperandType.InlineVar) ? 2 : ((opCode.OperandType == OperandType.InlineI8 || opCode.OperandType == OperandType.InlineR) ? 8 : ((opCode.OperandType == OperandType.InlineSwitch) ? (4 * (BitConverter.ToInt32(array, i) + 1)) : 4)))) : 0)) { byte b = array[i++]; if (!TryGetOpCode(b, out opCode) && (i >= array.Length || !TryGetOpCode((short)(b * 256 + array[i++]), out opCode))) { throw new NotSupportedException("Unknown IL code detected."); } if (opCode == OpCodes.Ldfld && opCode.OperandType == OperandType.InlineField && i + 4 <= array.Length)