using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EpicJewels.Common; using EpicJewels.EffectHelpers; using EpicJewels.GemEffects; using HarmonyLib; using JetBrains.Annotations; using Jewelcrafting; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("EpicJewels")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("EpicJewels")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("1.0.3")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace Jewelcrafting { [Flags] public enum VisualEffectCondition : uint { IsSkill = 0xFFFu, Swords = 1u, Knives = 2u, Clubs = 3u, Polearms = 4u, Spears = 5u, Blocking = 6u, Axes = 7u, Bows = 8u, Unarmed = 0xBu, Pickaxes = 0xCu, WoodCutting = 0xDu, Crossbows = 0xEu, IsItem = 0xFF000u, Helmet = 0x6000u, Chest = 0x7000u, Legs = 0xB000u, Hands = 0xC000u, Shoulder = 0x11000u, Tool = 0x13000u, GenericExtraAttributes = 0xFF000000u, Blackmetal = 0x40000000u, TwoHanded = 0x80000000u, SpecificExtraAttributes = 0xF00000u, Hammer = 0x113000u, Hoe = 0x213000u, Buckler = 0x100006u, Towershield = 0x200006u, FineWoodBow = 0x100008u, BowHuntsman = 0x200008u, BowDraugrFang = 0x300008u, PickaxeIron = 0x10000Cu, Club = 0x100003u } [AttributeUsage(AttributeTargets.Field)] public abstract class PowerAttribute : Attribute { public abstract float Add(float a, float b); } [AttributeUsage(AttributeTargets.Field)] public class OptionalPowerAttribute : Attribute { public readonly float DefaultValue; public OptionalPowerAttribute(float defaultValue) { DefaultValue = defaultValue; } } public class MultiplicativePercentagePowerAttribute : PowerAttribute { public override float Add(float a, float b) { return (float)(((1.0 + (double)a / 100.0) * (1.0 + (double)b / 100.0) - 1.0) * 100.0); } } public class MinPowerAttribute : PowerAttribute { public override float Add(float a, float b) { return Mathf.Min(a, b); } } public class MaxPowerAttribute : PowerAttribute { public override float Add(float a, float b) { return Mathf.Max(a, b); } } public class InverseMultiplicativePercentagePowerAttribute : PowerAttribute { public override float Add(float a, float b) { return (float)((1.0 - (1.0 - (double)a / 100.0) * (1.0 - (double)b / 100.0)) * 100.0); } } public class AdditivePowerAttribute : PowerAttribute { public override float Add(float a, float b) { return a + b; } } [PublicAPI] public static class API { [PublicAPI] public class GemInfo { public readonly string gemPrefab; public readonly Sprite gemSprite; public readonly Dictionary gemEffects; public GemInfo(string gemPrefab, Sprite gemSprite, Dictionary gemEffects) { this.gemPrefab = gemPrefab; this.gemSprite = gemSprite; this.gemEffects = gemEffects; } } public delegate bool GemBreakHandler(ItemData? container, ItemData gem, int count = 1); public delegate bool ItemBreakHandler(ItemData? container); public delegate bool ItemMirroredHandler(ItemData? item); public static event Action? OnEffectRecalc; public static bool IsLoaded() { return false; } internal static void InvokeEffectRecalc() { API.OnEffectRecalc?.Invoke(); } public static GameObject CreateNecklaceFromTemplate(string colorName, Color color) { return null; } public static GameObject CreateNecklaceFromTemplate(string colorName, Material material) { return null; } public static GameObject CreateRingFromTemplate(string colorName, Color color) { return null; } public static GameObject CreateRingFromTemplate(string colorName, Material material) { return null; } public static void MarkJewelry(GameObject jewelry) { } public static void AddGems(string type, string colorName, Color color) { } public static List AddGems(string type, string colorName, Material material, Color color) { return null; } public static GameObject AddDestructibleFromTemplate(string type, string colorName, Color color) { return null; } public static GameObject AddDestructibleFromTemplate(string type, string colorName, Material material) { return null; } public static GameObject AddUncutFromTemplate(string type, string colorName, Color color) { return null; } public static GameObject AddUncutFromTemplate(string type, string colorName, Material material) { return null; } public static GameObject AddAndRegisterUncutFromTemplate(string type, string colorName, Color color) { return null; } public static GameObject AddAndRegisterUncutFromTemplate(string type, string colorName, Material material) { return null; } public static GameObject AddShardFromTemplate(string type, string colorName, Color color) { return null; } public static GameObject AddShardFromTemplate(string type, string colorName, Material material) { return null; } public static GameObject[] AddTieredGemFromTemplate(string type, string colorName, Color color) { return null; } public static GameObject[] AddTieredGemFromTemplate(string type, string colorName, Material material, Color color) { return null; } public static void AddGem(GameObject prefab, string colorName) { } public static void AddShard(GameObject prefab, string colorName) { } public static void AddDestructible(GameObject prefab, string colorName) { } public static void AddUncutGem(GameObject prefab, string colorName, ConfigEntry? dropChance = null) { } public static void AddGemEffect(string name, string? englishDescription = null, string? englishDescriptionDetailed = null) where T : struct { } public static void AddGemConfig(string yaml) { } public static T GetEffectPower(this Player player, string name) where T : struct { return default(T); } public static List GetGems(ItemData item) { return new List(); } public static bool SetGems(ItemData item, List gems) { return false; } public static Sprite GetSocketBorder() { return null; } public static GameObject GetGemcuttersTable() { return null; } public static void AddParticleEffect(string prefabName, GameObject effect, VisualEffectCondition displayCondition) { } public static void SetSocketsLock(ItemData item, bool enabled) { } public static void OnGemBreak(GemBreakHandler callback) { } public static void OnItemBreak(ItemBreakHandler callback) { } public static void OnItemMirrored(ItemMirroredHandler callback) { } public static bool IsJewelryEquipped(Player player, string prefabName) { return false; } public static bool BlacklistItem(GameObject item) { return false; } } } namespace EpicJewels { [BepInPlugin("MidnightsFX.EpicJewels", "EpicJewels", "1.0.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class EpicJewels : BaseUnityPlugin { [HarmonyPatch(typeof(InventoryGui), "Awake")] public static class EnableSynergyTextfit { [HarmonyPriority(0)] public static void Postfix() { IEnumerable enumerable = from obj in Resources.FindObjectsOfTypeAll() where ((Object)obj).name.StartsWith("JC_Synergies_Window") select obj; EJLogger.LogDebug($"Found {enumerable.Count()} Synergy panels to update."); foreach (GameObject item in enumerable) { try { EJLogger.LogDebug($"Updating Synergy GO {item}"); ((Component)item.transform.Find("Bkg/Left_Text/Left_Text_1")).gameObject.GetComponent().resizeTextForBestFit = true; } catch (Exception) { } } } } public const string PluginGUID = "MidnightsFX.EpicJewels"; public const string PluginName = "EpicJewels"; public const string PluginVersion = "1.0.3"; public static ManualLogSource Log; internal static bool CrystalLightsLoaded = false; internal ValConfig cfg; internal static AssetBundle EmbeddedResourceBundle; internal static Harmony Harmony = new Harmony("MidnightsFX.EpicJewels"); public static IDeserializer yamldeserializer = ((BuilderSkeleton)new DeserializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).Build(); public static ISerializer yamlserializer = ((BuilderSkeleton)new SerializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).DisableAliases().Build(); public static Material spiritCreature; public void Awake() { Log = ((BaseUnityPlugin)this).Logger; cfg = new ValConfig(((BaseUnityPlugin)this).Config); AddLocalizations(); EmbeddedResourceBundle = LoadAssetBundle("EpicJewels.AssetsEmbedded.epicjewels"); EJLogger.LogDebug("Logging embedded assets."); string[] allAssetNames = EmbeddedResourceBundle.GetAllAssetNames(); foreach (string message in allAssetNames) { EJLogger.LogDebug(message); } EJLogger.LogInfo("Let the gems flow."); EffectList.AddGemEffects(); GemResources.AddGems(); Dictionary plugins = BepInExUtils.GetPlugins(false); if (Enumerable.Contains(plugins.Keys, "org.bepinex.plugins.crystallights") || ValConfig.EnableCrystalLightsAlways.Value) { CrystalLightsLoaded = true; GemResources.AddAllCrystalLights(); EJLogger.LogInfo("Epic Crystal Lights enabled."); } spiritCreature = EmbeddedResourceBundle.LoadAsset("spirit_animal_mat.mat"); Assembly executingAssembly = Assembly.GetExecutingAssembly(); Harmony.PatchAll(executingAssembly); ValConfig.cfg.SaveOnConfigSet = true; ValConfig.cfg.Save(); } public static AssetBundle LoadAssetBundle(string bundleName) { Assembly assembly = typeof(EpicJewels).Assembly; string name = null; try { name = assembly.GetManifestResourceNames().Single((string str) => str.EndsWith(bundleName)); } catch (Exception) { } using Stream stream = assembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } public static string LoadEmbeddedAssetToString(string assetName) { Assembly assembly = typeof(EpicJewels).Assembly; string text = null; try { text = assembly.GetManifestResourceNames().Single((string str) => str.EndsWith(assetName)); } catch (Exception) { } if (text == null) { return null; } string result; using (Stream stream = assembly.GetManifestResourceStream(text)) { using StreamReader streamReader = new StreamReader(stream); result = streamReader.ReadToEnd(); } return result; } private void AddLocalizations() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); EJLogger.LogInfo("Loading Localizations."); string[] manifestResourceNames = typeof(EpicJewels).Assembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (text.Contains("Localizations")) { EJLogger.LogDebug("Reading localization resource: " + text); string input = ReadEmbeddedResourceFile(text); string text2 = Regex.Replace(input, "\\/\\/.*", ""); string[] array = text.Split(new char[1] { '.' }); EJLogger.LogDebug("Adding localization: " + array[2]); localization.AddJsonFile(array[2], text2); } } } internal static string ReadEmbeddedResourceFile(string filename) { using Stream stream = typeof(EpicJewels).Assembly.GetManifestResourceStream(filename); using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); } } internal static class GemResources { private class GemDefition { public Color Color { get; set; } public Material Material { get; set; } } private static Dictionary GemDefinitions = new Dictionary(); public static void AddGems() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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) Material material = EpicJewels.EmbeddedResourceBundle.LoadAsset("gem_jade.mat"); Color color = default(Color); ((Color)(ref color))..ctor(0.031f, 0.69f, 0.043f, 1f); GemDefinitions.Add("Jade", new GemDefition { Color = color, Material = material }); Material material2 = EpicJewels.EmbeddedResourceBundle.LoadAsset("garnet_gem.mat"); Color color2 = default(Color); ((Color)(ref color2))..ctor(1f, 0.141f, 0.039f, 1f); GemDefinitions.Add("Garnet", new GemDefition { Color = color2, Material = material2 }); Material material3 = EpicJewels.EmbeddedResourceBundle.LoadAsset("amber_gem.mat"); Color color3 = default(Color); ((Color)(ref color3))..ctor(81f / 85f, 0.7568628f, 5f / 51f, 1f); GemDefinitions.Add("Amber", new GemDefition { Color = color3, Material = material3 }); Material material4 = EpicJewels.EmbeddedResourceBundle.LoadAsset("opal_gem.mat"); Color color4 = default(Color); ((Color)(ref color4))..ctor(0.945f, 0.988f, 0.988f, 1f); GemDefinitions.Add("Opal", new GemDefition { Color = color4, Material = material4 }); Material material5 = EpicJewels.EmbeddedResourceBundle.LoadAsset("amethyst_gem.mat"); Color color5 = default(Color); ((Color)(ref color5))..ctor(0.784f, 0.302f, 0.98f, 1f); GemDefinitions.Add("Amethyst", new GemDefition { Color = color5, Material = material5 }); Material material6 = EpicJewels.EmbeddedResourceBundle.LoadAsset("aquamarine_gem.mat"); Color color6 = default(Color); ((Color)(ref color6))..ctor(0.259f, 0.663f, 0.71f, 1f); GemDefinitions.Add("Aquamarine", new GemDefition { Color = color6, Material = material6 }); AddGemRegisterOverride("Jade"); AddGemRegisterOverride("Amber"); AddGemRegisterOverride("Aquamarine"); AddGemRegisterOverride("Garnet"); AddGemRegisterOverride("Opal"); AddGemRegisterOverride("Amethyst"); API.AddGemConfig(EpicJewels.LoadEmbeddedAssetToString("EJConfig.yaml")); } internal static void AddGemRegisterOverride(string name) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) API.AddGems(name, name.ToLower(), GemDefinitions[name].Color); MinimapManager.OnVanillaMapAvailable += delegate { string prefabName = "Raw_" + name.ToLower() + "_Gemstone"; IEnumerable enumerable = from obj in Resources.FindObjectsOfTypeAll() where ((Object)obj).name == prefabName select obj; EJLogger.LogDebug($"Found {enumerable.Count()} objects in the scene with the name {prefabName} to apply gem material to."); foreach (GameObject item in enumerable) { item.GetComponentsInChildren().ToList().ForEach(delegate(MeshRenderer renderer) { ((Renderer)renderer).material = GemDefinitions[name].Material; }); } }; } internal static void AddAllCrystalLights() { AddCrystalLightResources("Jade"); AddCrystalLightResources("Amber"); AddCrystalLightResources("Aquamarine"); AddCrystalLightResources("Garnet"); AddCrystalLightResources("Opal"); AddCrystalLightResources("Amethyst"); JotunnPiece.SetupJotunnPieces(); } internal static void AddCrystalLightResources(string name) { JotunnPiece.JotunnBuildPiece jotunnBuildPiece = new JotunnPiece.JotunnBuildPiece(); jotunnBuildPiece.Name = name + " Brazier"; jotunnBuildPiece.Prefab = "CL_Brazier_" + name; jotunnBuildPiece.Sprite = "CL_Brazier_" + name; jotunnBuildPiece.Workbench = "forge"; jotunnBuildPiece.Category = "Crystal Lights"; jotunnBuildPiece.PieceCost = new List { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 10, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 4, refundable = true } }; jotunnBuildPiece.BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent(); component.m_name = "$EJ_Brazier_" + name; component.m_description = "$EJ_Brazier_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); }; JotunnPiece.RegisterJotunnPiece(jotunnBuildPiece); JotunnPiece.JotunnBuildPiece jotunnBuildPiece2 = new JotunnPiece.JotunnBuildPiece(); jotunnBuildPiece2.Name = name + " Chandelier"; jotunnBuildPiece2.Prefab = "CL_Chandelier_" + name; jotunnBuildPiece2.Sprite = "CL_Chandelier_" + name; jotunnBuildPiece2.Workbench = "forge"; jotunnBuildPiece2.Category = "Crystal Lights"; jotunnBuildPiece2.PieceCost = new List { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 15, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 5, refundable = true } }; jotunnBuildPiece2.BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent(); component.m_name = "$EJ_Chandelier_" + name; component.m_description = "$EJ_Chandelier_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); }; JotunnPiece.RegisterJotunnPiece(jotunnBuildPiece2); JotunnPiece.JotunnBuildPiece jotunnBuildPiece3 = new JotunnPiece.JotunnBuildPiece(); jotunnBuildPiece3.Name = name + " Hanging Bowl"; jotunnBuildPiece3.Prefab = "CL_Hanging_" + name; jotunnBuildPiece3.Sprite = "CL_Hanging_" + name; jotunnBuildPiece3.Workbench = "forge"; jotunnBuildPiece3.Category = "Crystal Lights"; jotunnBuildPiece3.PieceCost = new List { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 5, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 2, refundable = true } }; jotunnBuildPiece3.BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent(); component.m_name = "$EJ_Hanging_" + name; component.m_description = "$EJ_Hanging_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); }; JotunnPiece.RegisterJotunnPiece(jotunnBuildPiece3); JotunnPiece.JotunnBuildPiece jotunnBuildPiece4 = new JotunnPiece.JotunnBuildPiece(); jotunnBuildPiece4.Name = name + " Large Wall Light"; jotunnBuildPiece4.Prefab = "CL_Large_Wall_" + name; jotunnBuildPiece4.Sprite = "CL_Large_Wall_" + name; jotunnBuildPiece4.Workbench = "forge"; jotunnBuildPiece4.Category = "Crystal Lights"; jotunnBuildPiece4.PieceCost = new List { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 10, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 2, refundable = true } }; jotunnBuildPiece4.BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent(); component.m_name = "$EJ_Large_Wall_" + name; component.m_description = "$EJ_Large_Wall_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); }; JotunnPiece.RegisterJotunnPiece(jotunnBuildPiece4); JotunnPiece.JotunnBuildPiece jotunnBuildPiece5 = new JotunnPiece.JotunnBuildPiece(); jotunnBuildPiece5.Name = name + " Pole Light"; jotunnBuildPiece5.Prefab = "CL_Pole_" + name; jotunnBuildPiece5.Sprite = "CL_Pole_" + name; jotunnBuildPiece5.Workbench = "forge"; jotunnBuildPiece5.Category = "Crystal Lights"; jotunnBuildPiece5.PieceCost = new List { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 5, refundable = true }, new JotunnPiece.PieceCost { prefab = "Iron", amount = 2, refundable = true } }; jotunnBuildPiece5.BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent(); component.m_name = "$EJ_Pole_" + name; component.m_description = "$EJ_Pole_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); }; JotunnPiece.RegisterJotunnPiece(jotunnBuildPiece5); JotunnPiece.JotunnBuildPiece jotunnBuildPiece6 = new JotunnPiece.JotunnBuildPiece(); jotunnBuildPiece6.Name = name + " Raw Crystal"; jotunnBuildPiece6.Prefab = "CL_Raw_" + name; jotunnBuildPiece6.Sprite = "CL_Raw_" + name; jotunnBuildPiece6.Workbench = "piece_workbench"; jotunnBuildPiece6.Category = "Crystal Lights"; jotunnBuildPiece6.PieceCost = new List { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 5, refundable = true } }; jotunnBuildPiece6.BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent(); component.m_name = "$EJ_Raw_" + name; component.m_description = "$EJ_Raw_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); }; JotunnPiece.RegisterJotunnPiece(jotunnBuildPiece6); JotunnPiece.JotunnBuildPiece jotunnBuildPiece7 = new JotunnPiece.JotunnBuildPiece(); jotunnBuildPiece7.Name = name + " Small Wall Light"; jotunnBuildPiece7.Prefab = "CL_Small_Wall_" + name; jotunnBuildPiece7.Sprite = "CL_Small_Wall_" + name; jotunnBuildPiece7.Workbench = "forge"; jotunnBuildPiece7.Category = "Crystal Lights"; jotunnBuildPiece7.PieceCost = new List { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 3, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 1, refundable = true } }; jotunnBuildPiece7.BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent(); component.m_name = "$EJ_Small_Wall_" + name; component.m_description = "$EJ_Small_Wall_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); }; JotunnPiece.RegisterJotunnPiece(jotunnBuildPiece7); JotunnPiece.JotunnBuildPiece jotunnBuildPiece8 = new JotunnPiece.JotunnBuildPiece(); jotunnBuildPiece8.Name = name + " Standing Lamp"; jotunnBuildPiece8.Prefab = "CL_Standing_Lamp_" + name; jotunnBuildPiece8.Sprite = "CL_Standing_Lamp_" + name; jotunnBuildPiece8.Workbench = "forge"; jotunnBuildPiece8.Category = "Crystal Lights"; jotunnBuildPiece8.PieceCost = new List { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 1, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 1, refundable = true } }; jotunnBuildPiece8.BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent(); component.m_name = "$EJ_Standing_Lamp_" + name; component.m_description = "$EJ_Standing_Lamp_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); }; JotunnPiece.RegisterJotunnPiece(jotunnBuildPiece8); JotunnPiece.JotunnBuildPiece jotunnBuildPiece9 = new JotunnPiece.JotunnBuildPiece(); jotunnBuildPiece9.Name = name + " Standing Torch"; jotunnBuildPiece9.Prefab = "CL_Standing_Torch_" + name; jotunnBuildPiece9.Sprite = "CL_Standing_Torch_" + name; jotunnBuildPiece9.Workbench = "forge"; jotunnBuildPiece9.Category = "Crystal Lights"; jotunnBuildPiece9.PieceCost = new List { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 1, refundable = true }, new JotunnPiece.PieceCost { prefab = "Wood", amount = 2, refundable = true } }; jotunnBuildPiece9.BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent(); component.m_name = "$EJ_Standing_Torch_" + name; component.m_description = "$EJ_Standing_Torch_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); }; JotunnPiece.RegisterJotunnPiece(jotunnBuildPiece9); } } } namespace EpicJewels.GemEffects { public static class EffectList { public enum DmgEffect { AddBluntDamage, AddPierceDamage, AddSlashDamage, AddSpiritDamage, AddLightningDamage, AddPickaxeDamage, AddChopDamage } public static void AddGemEffects() { API.AddGemEffect("Blunt Resistance", "$EJ_blunt_resistance_header.", "$EJ_blunt_resistance_header $EJ_by $1%."); API.AddGemEffect("Pierce Resistance", "$EJ_pierce_resistance_header.", "$EJ_pierce_resistance_header $EJ_by $1%."); API.AddGemEffect("Slash Resistance", "$EJ_slash_resistance_header.", "$EJ_slash_resistance_header $EJ_by $1%."); API.AddGemEffect("Fire Resistance", "$EJ_fire_resistance_header.", "$EJ_fire_resistance_header $EJ_by $1%."); API.AddGemEffect("Poison Resistance", "$EJ_poison_resistance_header.", "$EJ_poison_resistance_header $EJ_by $1%."); API.AddGemEffect("Lightning Resistance", "$EJ_lightning_resistance_header.", "$EJ_lightning_resistance_header $EJ_by $1%."); API.AddGemEffect("Add Blunt Damage", "$EJ_blunt_dmg_header.", "$EJ_blunt_dmg_header $EJ_eq $1% $EJ_dmg_explained_end $EJ_dmg_tooltip"); API.AddGemEffect("Add Pierce Damage", "$EJ_pierce_dmg_header.", "$EJ_pierce_dmg_header $EJ_eq $1% $EJ_dmg_explained_end $EJ_dmg_tooltip"); API.AddGemEffect("Add Slash Damage", "$EJ_slash_dmg_header.", "$EJ_slash_dmg_header $EJ_eq $1% $EJ_dmg_explained_end $EJ_dmg_tooltip"); API.AddGemEffect("Add Spirit Damage", "$EJ_spirit_dmg_header.", "$EJ_spirit_dmg_header $EJ_eq $1% $EJ_dmg_explained_end $EJ_dmg_tooltip"); API.AddGemEffect("Add Lightning Damage", "$EJ_lightning_dmg_header.", "$EJ_lightning_dmg_header $EJ_eq $1% $EJ_dmg_explained_end $EJ_dmg_tooltip"); API.AddGemEffect("Add Pickaxe Damage", "$EJ_pickaxe_dmg_header.", "$EJ_pickaxe_dmg_header $EJ_eq $1% $EJ_dmg_explained_end"); API.AddGemEffect("Add Chop Damage", "$EJ_woodcutting_dmg_header.", "$EJ_woodcutting_dmg_header $EJ_eq $1% $EJ_dmg_explained_end"); API.AddGemEffect("Inferno", "$EJ_inferno_header", "$2% $EJ_inferno_ep1 $1% $EJ_inferno_ep2"); API.AddGemEffect("Increase Eitr", "$EJ_more_eitr_header", "$EJ_more_eitr_details $1."); API.AddGemEffect("Increase Stamina", "$EJ_more_stamina_header", "$EJ_more_stamina_explained $1."); API.AddGemEffect("Increase Stamina Regen", "$EJ_stamina_regen_header", "$EJ_stamina_regen_explained $1%."); API.AddGemEffect("Block Reduce Stamina", "$EJ_stamina_block_cost_header", "$EJ_stamina_block_cost_explained $1%."); API.AddGemEffect("Weapon Reduced Stamina", "$EJ_stamina_weapon_cost_header", "$EJ_stamina_weapon_cost_explained $1%."); API.AddGemEffect("Coin Greed", "$EJ_coingreed_header", "$EJ_coingreed_pt1 $2% $EJ_coingreed_pt2 1-$1 $EJ_coingreed_pt3"); API.AddGemEffect("Coin Hoarder", "$EJ_coinhoarder", "Increase all of your damage by a fraction of the coins you carry."); API.AddGemEffect("Water Resistant", "$EJ_water_prevent", "$EJ_water_prevent_pt1 $1 $EJ_water_prevent_pt2"); API.AddGemEffect("Water Frenzy", "$EJ_water_dmg_buff", "$EJ_dmg_buff_pt1 $1% $EJ_water_dmg_buff_pt2"); API.AddGemEffect("Water Swiftness", "$EJ_water_speed_buff", "$EJ_speed_buff_pt1 $1% $EJ_water_speed_buff_pt2"); API.AddGemEffect("Burning Viking", "$EJ_fire_speed_buff", "$EJ_speed_buff_pt1 $1% $EJ_fire_speed_buff_pt2"); API.AddGemEffect("Burning Frenzy", "$EJ_fire_dmg_buff", "$EJ_dmg_buff_pt1 $1% $EJ_fire_dmg_buff_pt2"); API.AddGemEffect("Expert Fisher", "$EJ_skill_fishing", "$EJ_skill_fishing_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Mage", "$EJ_skill_magic", "$EJ_skill_magic_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Harvester", "$EJ_skill_harvest", "$EJ_skill_harvest_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Brawler", "$EJ_brawling", "$EJ_brawling_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Acrobat", "$EJ_jump", "$EJ_jump_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Daggers", "$EJ_knives", "$EJ_knives_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Swordsman", "$EJ_swords", "$EJ_swords_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Smasher", "$EJ_maces", "$EJ_maces_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Polearms", "$EJ_polearms", "$EJ_polearms_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Spearmaiden", "$EJ_spears", "$EJ_spears_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Axemaster", "$EJ_axes", "$EJ_axes_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Expert Sprinter", "$EJ_sprinter", "$EJ_sprinter_pt1 $1% $EJ_skill_higher $EJ_skill_inc_visible"); API.AddGemEffect("Reduce Weight", "$EJ_weight_reduce", "$EJ_weight_reduce_pt1 $1% $EJ_weight_reduce_pt2"); API.AddGemEffect("Cover of Darkness", "$EJ_cover_darkness", "$2% $EJ_cover_darkness_pt1 $1% $EJ_cover_darkness_pt2"); API.AddGemEffect("Eitr Conversion", "$EJ_eitr_conversion", "$2% $EJ_eitr_conversion_pt1 $1% $EJ_eitr_conversion_pt2"); API.AddGemEffect("Retribution", "$EJ_retribution", "$2% $EJ_retribution_pt1 $1% $EJ_retribution_pt2"); API.AddGemEffect("Staggering Block", "Blocking can stagger attackers.", "$1% chance to stagger your attacker."); API.AddGemEffect("Burning Guard", "On block chance to return fire damage.", "$1% chance to set your attacker on fire for $2% of the blocked damage."); API.AddGemEffect("Freezing Guard", "On block chance to return frost damage.", "$1% chance to return frost damage for $2% of the blocked damage."); API.AddGemEffect("Wet Worker", "Reduces stamina usage when wet.", "$1% usage stamina cost reduction when wet."); API.AddGemEffect("Eitr Fused", "Uses eitr to increase damage.", "$1% increase to damage at the cost of $2 eitr per hit."); API.AddGemEffect("Farmer", "Chance for bigger harvests.", "$2% chance to get $1 additional crops when harvesting."); API.AddGemEffect("Toxifier", "Gain adrenaline from poison damage around you.", "Gain $1 adrenaline whenever poison damage is applied within $2m."); API.AddGemEffect("Adrenal Rewire", "Gain adrenaline from damage taken.", "Gain a small amount of adrenaline for each point of damage taken."); API.AddGemEffect("Soaked Fury", "Gain additional adrenaline while wet.", "Gain $1% more adrenaline while you are wet."); API.AddGemEffect("Burning Adrenaline", "Gain additional adreanline while on fire.", "Gain $1% more adrenaline while you are on fire."); API.AddGemEffect("Harvest Adrenaline", "Chance to gain adrenaline from harvesting.", "$2% Chance to gain $1% of damage done as adrenaline."); API.AddGemEffect("Eitr Feedback", "Chance to restore adrenaline from eitr use.", "$2% Chance to restore $1 adrenaline when consuming eitr."); API.AddGemEffect("Combat Spirit", "A spirit helps you in combat.", "A spirit aids you in combat for $1 seconds. Returns after a cooldown."); API.AddGemEffect("Intense Fire", "An affinity for fire.", "You are +$1% fire resistant and have a higher chance to trigger Inferno."); API.AddGemEffect("Slippery When Wet", "Water quickens you.", "You are $1% faster when wet."); API.AddGemEffect("Waterproof", "You do not get wet.", "You do not get wet."); API.AddGemEffect("Weapon Master", "Experianced with weapons.", "Your skill with all weapons is $1% higher."); API.AddGemEffect("Spellsword", "Use eitr to increase weapon damage.", "$1% increase to damage at the cost of 5 eitr per hit."); } } public static class AddBluntDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } public static class AddChopDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } public static class AddLightningDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } internal class AddPickaxeDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } public static class AddPierceDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } public static class AddSlashDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } public static class AddSpiritDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } internal class AdrenalRewire { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class DamageTakenProvidesStamina { public static void Postfix(Character __instance, HitData hit) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsPlayer()) { return; } Player player = (Player)(object)((__instance is Player) ? __instance : null); float chance = player.GetEffectPower("Adrenal Rewire").Chance; if (!(Random.Range(0f, 100f) > chance)) { float power = player.GetEffectPower("Adrenal Rewire").Power; if (power > 0f) { float totalDamageOptions = hit.m_damage.GetTotalDamageOptions(); float num = totalDamageOptions * (power / (100f + __instance.GetMaxAdrenaline())); EJLogger.LogDebug($"Adrenal Rewire is restoring {num} stamina based on total damage of {totalDamageOptions} and power of {power}"); __instance.AddAdrenaline(num); } } } } } public static class BlockReduceStamina { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] public static class ModifyBlockStaminaUse_Humanoid_BlockAttack_Patch { public static void Prefix(Humanoid __instance, HitData hit, Character attacker) { if (((Character)__instance).IsPlayer()) { Player player = (Player)(object)((__instance is Player) ? __instance : null); if (player.GetEffectPower("Block Reduce Stamina").Power > 0f) { float num = 100f / (100f + player.GetEffectPower("Block Reduce Stamina").Power); __instance.m_blockStaminaDrain *= num; } } } } } public static class BluntResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReduceBluntDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_blunt > 0f && val.GetEffectPower("Blunt Resistance").Power > 0f) { float num = (100f - val.GetEffectPower("Blunt Resistance").Power) / 100f; hit.m_damage.m_slash *= num; } } } } } internal class BurningAdrenaline { [PublicAPI] public struct Config { [MultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Player), "AddAdrenaline")] public static class ReducePoisonDamageTaken { private static readonly int Wetstatus = StringExtensionMethods.GetStableHashCode("Burning"); [UsedImplicitly] private static void Prefix(Player __instance, ref float v) { float power = __instance.GetEffectPower("Burning Adrenaline").Power; if (power > 0f && ((Character)__instance).GetSEMan().HaveStatusEffect(Wetstatus)) { float num = (power + 100f) / 100f; EJLogger.LogDebug($"Burning Adrenaline is increasing adrenaline gain by {num}"); v *= num; } } } } public static class BurningFrenzy { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Character), "Damage")] private class AddBonusBonusDamageWhileOnFire { private static void Prefix(HitData hit) { if (hit.GetAttacker() is Player) { Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if (((Character)val).GetSEMan().HaveStatusEffect(burningstatus)) { float num = (100f + val.GetEffectPower("Burning Frenzy").Power) / 100f; hit.m_damage.m_blunt *= num; hit.m_damage.m_pierce *= num; hit.m_damage.m_pierce *= num; hit.m_damage.m_fire *= num; hit.m_damage.m_lightning *= num; hit.m_damage.m_frost *= num; hit.m_damage.m_spirit *= num; hit.m_damage.m_poison *= num; hit.m_damage.m_pickaxe *= num; } } } } private static int burningstatus = StringExtensionMethods.GetStableHashCode("Burning"); } public static class BurningViking { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Player), "GetJogSpeedFactor")] private class IncreaseJogSpeed { private static void Postfix(Player __instance, ref float __result) { if (((Character)__instance).GetSEMan().HaveStatusEffect(burningstatus) && __instance.GetEffectPower("Burning Viking").Power > 0f) { __result *= (__instance.GetEffectPower("Burning Viking").Power + 100f) / 100f; } } } [HarmonyPatch(typeof(Player), "GetRunSpeedFactor")] private class IncreaseRunSpeed { private static void Postfix(Player __instance, ref float __result) { if (((Character)__instance).GetSEMan().HaveStatusEffect(burningstatus) && __instance.GetEffectPower("Burning Viking").Power > 0f) { __result *= (__instance.GetEffectPower("Burning Viking").Power + 100f) / 100f; } } } private static int burningstatus = StringExtensionMethods.GetStableHashCode("Burning"); } public static class CoinGreed { [PublicAPI] public struct Config { [AdditivePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Character), "OnDeath")] public static class AddGreedOnDeathFromPlayer { [UsedImplicitly] private static void Postfix(Character __instance) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_lastHit == null) { return; } Character attacker = __instance.m_lastHit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if ((Object)(object)val == (Object)null) { return; } float power = val.GetEffectPower("Coin Greed").Power; if (power > 0f) { float num = val.GetEffectPower("Coin Greed").Chance / 100f; float value = Random.value; if (value < num) { float num2 = Random.Range(1f, Math.Max(1f, power)); GameObject val2 = Object.Instantiate(ObjectDB.instance.GetItemPrefab("Coins"), ((Component)__instance).gameObject.transform.position, ((Component)__instance).gameObject.transform.rotation); val2.GetComponent().m_itemData.m_stack = (int)num2; } } } } } internal static class CoinHoarder { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "Damage")] internal static class IncreaseAllDamageByCoins { internal static void Prefix(HitData hit) { Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if (val != null) { Character attacker2 = hit.GetAttacker(); Player val2 = (Player)(object)((attacker2 is Player) ? attacker2 : null); if ((Object)(object)val2 != (Object)null && val2.GetEffectPower("Coin Hoarder").Power > 0f) { float num = CoinHoarderBonusCalc(val2); hit.m_damage.m_blunt *= num; hit.m_damage.m_pierce *= num; hit.m_damage.m_slash *= num; hit.m_damage.m_fire *= num; hit.m_damage.m_lightning *= num; hit.m_damage.m_frost *= num; hit.m_damage.m_spirit *= num; hit.m_damage.m_poison *= num; hit.m_damage.m_pickaxe *= num; } } } } internal static float CoinHoarderBonusCalc(Player player) { ItemData[] array = (from val2 in ((Humanoid)player).m_inventory.GetAllItems() where ((Object)val2.m_dropPrefab).name == "Coins" select val2).ToArray(); if (array.Length == 0) { return 1f; } float num = 0f; ItemData[] array2 = array; foreach (ItemData val in array2) { num += (float)val.m_stack; } float power = player.GetEffectPower("Coin Hoarder").Power; float num3 = (float)Math.Log10(power * num); return num3 * 5.5f / 100f + 1f; } } public static class CombatSpirit { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Player), "OnTargeted")] public static class CombatCompanion { private static void Postfix(Player __instance, bool sensed, bool alerted) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) if (!(__instance.GetEffectPower("Combat Spirit").Power > 0f && sensed && alerted)) { return; } if ((Object)(object)wolf == (Object)null && !have_spirit_companion) { ZNetScene.instance.m_namedPrefabs.TryGetValue(StringExtensionMethods.GetStableHashCode("Wolf"), out var value); Quaternion val = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); Vector3 position = ((Component)__instance).gameObject.transform.position; position.x += 1f; wolf = Object.Instantiate(value, position, val); cooldown_timer = 120f; have_spirit_companion = true; wolf.AddComponent(); Character component = wolf.GetComponent(); wolf.GetComponent().m_character = component; wolf.GetComponent().Trigger(__instance.GetEffectPower("Combat Spirit").Power); SkinnedMeshRenderer componentInChildren = wolf.GetComponentInChildren(); ((Renderer)componentInChildren).material = EpicJewels.spiritCreature; Object.Destroy((Object)(object)wolf.GetComponent()); Object.Destroy((Object)(object)wolf.GetComponent()); Humanoid component2 = wolf.GetComponent(); Character component3 = wolf.GetComponent(); MonsterAI component4 = wolf.GetComponent(); component4.m_attackPlayerObjects = false; ((Character)component2).m_health = 1000f; ((Character)component2).m_deathEffects.m_effectPrefabs[1].m_enabled = false; ((Character)component2).m_deathEffects.m_effectPrefabs[0].m_enabled = false; ((Object)component2).name = "EJ_spirit_wolf"; if ((Object)(object)component2 != (Object)null) { ((Character)component2).m_faction = (Faction)0; } ((Object)wolf).name = "Spirit Wolf"; } float deltaTime = Time.deltaTime; if (cooldown_timer > 0f) { if (deltaTime > cooldown_timer * 60f) { cooldown_timer = 0f; } cooldown_timer -= deltaTime; if (cooldown_timer < 0f) { cooldown_timer = 0f; } } else if (recheck_spirit_spawn_timer > 3f) { recheck_spirit_spawn_timer = 0f; if (Character.s_characters.Any((Character c) => Vector3.Distance(((Component)__instance).gameObject.transform.position, ((Component)c).transform.position) < 100f && ((Object)c).name == "Spirit Wolf")) { have_spirit_companion = true; } else { have_spirit_companion = false; } } else { recheck_spirit_spawn_timer += Time.deltaTime; } } } private static GameObject wolf = null; private static bool have_spirit_companion = false; private static float recheck_spirit_spawn_timer = 0f; private static float cooldown_timer = 5f; } public static class CoverOfDarkness { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; [AdditivePower] public float MaxCount; } [HarmonyPatch(typeof(Character), "Damage")] public static class SummonBatHelpers { private static void Prefix(HitData hit) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) if (!(hit.GetAttacker() is Player)) { return; } Character attacker = hit.GetAttacker(); Player player = (Player)(object)((attacker is Player) ? attacker : null); if (!(player.GetEffectPower("Cover of Darkness").Power > 0f) || !(Random.value < player.GetEffectPower("Cover of Darkness").Chance / 100f)) { return; } int stars = 1; float power = player.GetEffectPower("Cover of Darkness").Power; float num = power; if (num > 70f) { stars = 4; } else { float num2 = num; if (num2 > 50f) { stars = 3; } else { float num3 = num; if (num3 > 30f) { stars = 2; } } } if ((float)spawnedBats.Count >= player.GetEffectPower("Cover of Darkness").MaxCount) { List list = new List(); foreach (ZDOID spawnedBat in spawnedBats) { GameObject val = ZNetScene.instance.FindInstance(spawnedBat); if ((Object)(object)val != (Object)null && !list.Contains(spawnedBat)) { list.Add(spawnedBat); } } spawnedBats = list; if ((float)spawnedBats.Count >= player.GetEffectPower("Cover of Darkness").MaxCount) { return; } } if (player.GetEffectPower("Cover of Darkness").Power > 90f) { SpawnBat(player, stars); SpawnBat(player, stars); } else { SpawnBat(player, stars); } } } public static List spawnedBats = new List(); private static GameObject bat = null; private static void SpawnBat(Player player, int stars = 1) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bat == (Object)null) { ZNetScene.instance.m_namedPrefabs.TryGetValue(StringExtensionMethods.GetStableHashCode("Bat"), out bat); } Quaternion val = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); Vector3 position = ((Component)player).gameObject.transform.position; position.y += 1f; GameObject val2 = Object.Instantiate(bat, position, val); Character component = val2.GetComponent(); ZNetView component2 = val2.GetComponent(); component2.m_persistent = true; component.m_level = stars; Object.Destroy((Object)(object)val2.GetComponent()); MonsterAI component3 = val2.GetComponent(); if ((Object)(object)component3 != (Object)null) { if ((Object)(object)val2.GetComponent() == (Object)null) { Tameable val3 = val2.AddComponent(); } component3.MakeTame(); } else { Object.Destroy((Object)(object)val2); } val2.AddComponent(); val2.GetComponent().m_character = component; val2.GetComponent().Trigger(player.GetEffectPower("Cover of Darkness").Power); spawnedBats.Add(component.GetZDOID()); } } public static class EitrConversion { [PublicAPI] public struct Config { [AdditivePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] private static class HealOnParry { private static void Postfix(Humanoid __instance, ref bool __result) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower("Eitr Conversion").Power > 0f) { float value = Random.value; float num = val.GetEffectPower("Eitr Conversion").Chance / 100f; if (value < num) { ((Character)val).AddEitr(((Character)val).GetMaxEitr() * (val.GetEffectPower("Eitr Conversion").Power / 100f)); } } } } } internal class EitrFeedback { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Player), "RPC_UseEitr")] public static class ReducePierceDamageTaken { [UsedImplicitly] private static void Prefix(Player __instance, float v) { if (!(__instance.m_eitr <= 0f)) { float chance = __instance.GetEffectPower("Eitr Feedback").Chance; if (chance > 0f && Random.Range(0f, 100f) <= chance) { float power = __instance.GetEffectPower("Eitr Feedback").Power; EJLogger.LogDebug($"Eitr Feedback restoring {power} adrenaline from eitr use."); ((Character)__instance).AddAdrenaline(power); } } } } } public static class EitrFused { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; [AdditivePower] public float Cost; } } public static class ExpertAcrobat { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertAxemaster { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertBrawler { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertDaggers { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertFisher { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertHarvester { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertMage { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertPolearms { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertSmasher { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertSpearmaiden { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertSprinter { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertSwordsman { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class Farmer { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; [AdditivePower] public float Pickup; } [HarmonyPatch(typeof(Pickable), "Interact")] public static class IncreaseCarryWeight { public static void Postfix(ref bool __result, Humanoid character, Pickable __instance) { if (!__result || !((Object)(object)character != (Object)null)) { return; } Player val = (Player)(object)((character is Player) ? character : null); if (val == null || !(val.GetEffectPower("Farmer").Power > 0f)) { return; } string item = ((Object)__instance.m_itemPrefab).name.Replace("(Clone)", "").Replace("Pickable_", ""); if (UnallowedGreenThumbPickables.Contains(item)) { return; } float value = Random.value; float num = val.GetEffectPower("Farmer").Chance / 100f; if (value < num) { int num2 = 0; for (int i = 0; (float)i < val.GetEffectPower("Farmer").Power; i++) { __instance.Drop(__instance.m_itemPrefab, num2++, 1); } } } } [HarmonyPatch(typeof(Player), "Update")] public static class AutoPickupNearby_Pickables { private static readonly int pickableMask = LayerMask.GetMask(new string[3] { "piece_nonsolid", "item", "Default_small" }); private static float fdt = Time.fixedDeltaTime; private static float last_update = 0f; private static float current_tick_time = 0f; public static void Postfix(Player __instance) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance != (Object)null) || !(__instance.GetEffectPower("Farmer").Pickup > 0f)) { return; } current_tick_time += fdt; if (!(current_tick_time > last_update + 0.5f)) { return; } last_update = current_tick_time; Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position, 2f + __instance.GetEffectPower("Farmer").Pickup, pickableMask); foreach (Collider val in array) { Pickable val2 = ((Component)val).GetComponent() ?? ((Component)val).GetComponentInParent(); if ((Object)(object)val2 != (Object)null) { string item = ((Object)val2).name.Replace("(Clone)", "").Replace("Pickable_", ""); if (!UnallowedGreenThumbPickables.Contains(item) && val2.CanBePicked()) { val2.Interact((Humanoid)(object)__instance, false, false); } } } } } private static List UnallowedGreenThumbPickables = new List { "SurtlingCore", "Flint", "Wood", "Stone", "Amber", "AmberPearl", "Coins", "Ruby", "CryptRemains", "Obsidian", "Crystal", "Pot_Shard", "DragonEgg", "DvergrLantern", "DvergrMineTreasure", "SulfurRock", "VoltureEgg", "Swordpiece", "MoltenCore", "Hairstrands", "Tar", "BlackCore" }; } public static class FireResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReducePierceDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_fire > 0f && (val.GetEffectPower("Fire Resistance").Power > 0f || val.GetEffectPower("Intense Fire").Power > 0f)) { float num = (100f - (val.GetEffectPower("Fire Resistance").Power + val.GetEffectPower("Intense Fire").Power)) / 100f; hit.m_damage.m_fire *= num; } } } } } public static class FlamingGuard { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } [HarmonyPriority(600)] [HarmonyPatch(typeof(Humanoid), "BlockAttack")] private static class FlamingBlock_Patch { private static HitData originalHit = null; private static int burningstatus = StringExtensionMethods.GetStableHashCode("Burning"); private static void Prefix(HitData hit) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown originalHit = new HitData(hit.GetTotalDamage()); } private static void Postfix(Humanoid __instance, HitData hit, Character attacker, ref bool __result) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower("Burning Guard").Chance > 0f && __result && !attacker.IsDead()) { float value = Random.value; float num = val.GetEffectPower("Burning Guard").Chance / 100f; if (value < num) { HitData val2 = new HitData(); val2.m_damage.m_fire = val.GetEffectPower("Burning Guard").Power / 100f * ((DamageTypes)(ref originalHit.m_damage)).GetTotalDamage(); val2.m_attacker = ((Character)val).GetZDOID(); val2.m_point = hit.m_point + new Vector3(0f, 0.5f); attacker.Damage(val2); attacker.m_seman.AddStatusEffect(burningstatus, true, 1, val.m_skills.GetSkill((SkillType)6).m_level); } } } } } internal class FreezingGuard { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } [HarmonyPriority(600)] [HarmonyPatch(typeof(Humanoid), "BlockAttack")] private static class FreezingBlock_Patch { private static HitData originalHit = null; private static int froststatus = StringExtensionMethods.GetStableHashCode("Frost"); private static void Prefix(HitData hit) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown originalHit = new HitData(hit.GetTotalDamage()); } private static void Postfix(Humanoid __instance, HitData hit, Character attacker, ref bool __result) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower("Freezing Guard").Chance > 0f && __result && !attacker.IsDead()) { float value = Random.value; float num = val.GetEffectPower("Freezing Guard").Chance / 100f; if (value < num) { HitData val2 = new HitData(); val2.m_damage.m_frost = val.GetEffectPower("Freezing Guard").Power / 100f * ((DamageTypes)(ref originalHit.m_damage)).GetTotalDamage(); val2.m_attacker = ((Character)val).GetZDOID(); val2.m_point = hit.m_point + new Vector3(0f, 0.5f); attacker.Damage(val2); attacker.m_seman.AddStatusEffect(froststatus, true, 3, val.m_skills.GetSkill((SkillType)6).m_level); } } } } } internal class HarvestAdrenaline { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Destructible), "RPC_Damage")] public static class AdrenalineFromDestructibles { public static void Postfix(HitData hit) { AddadrenalineForHarvest(hit); } } [HarmonyPatch(typeof(MineRock), "RPC_Hit")] public static class AdrenalineFromMineRocks { public static void Postfix(HitData hit) { AddadrenalineForHarvest(hit); } } [HarmonyPatch(typeof(MineRock5), "RPC_Damage")] public static class AdrenalineFromMineRocks5 { public static void Postfix(HitData hit) { AddadrenalineForHarvest(hit); } } [HarmonyPatch(typeof(TreeBase), "RPC_Damage")] public static class AdrenalineFromTreeBase { public static void Postfix(HitData hit) { AddadrenalineForHarvest(hit); } } [HarmonyPatch(typeof(TreeLog), "RPC_Damage")] public static class AdrenalineFromTreeLog { public static void Postfix(HitData hit) { AddadrenalineForHarvest(hit); } } public static void AddadrenalineForHarvest(HitData hit) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) if ((hit.m_damage.m_chop > 0f || hit.m_damage.m_pickaxe > 0f) && hit.GetAttacker() is Player) { float num = Random.Range(0f, 100f); Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if (num <= val.GetEffectPower("Harvest Adrenaline").Chance) { float totalDamageOptions = hit.m_damage.GetTotalDamageOptions(include_poison: false, include_spirit: false, include_pickaxe_and_chop: true); float power = val.GetEffectPower("Harvest Adrenaline").Power; float num2 = totalDamageOptions * (power / 100f); EJLogger.LogDebug($"Harvest Adrenaline is restoring {num2} adrenaline based on total damage of {totalDamageOptions} and power of {power}"); ((Character)val).AddAdrenaline(num2); } } } } public static class IncreaseEitr { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] public static class IncreaseTotalStamina { public static void Postfix(Player __instance, ref float eitr) { eitr += __instance.GetEffectPower("Increase Eitr").Power; } } } public static class IncreaseStamina { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] public static class IncreaseTotalStamina { public static void Postfix(Player __instance, ref float stamina) { stamina += __instance.GetEffectPower("Increase Stamina").Power; } } } public static class IncreaseStaminaRegen { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(SEMan), "ModifyStaminaRegen")] public static class IncreasePlayerStaminaRegen { public static void Postfix(SEMan __instance, ref float staminaMultiplier) { Character character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && (Object)(object)val != (Object)null && val.GetEffectPower("Increase Stamina Regen").Power > 0f) { float num = (val.GetEffectPower("Increase Stamina Regen").Power + 100f) / 100f; staminaMultiplier *= num; } } } } public static class Inferno { [PublicAPI] public struct Config { [MultiplicativePercentagePower] public float Power; [MultiplicativePercentagePower] public float Chance; } } public static class IntenseFire { [PublicAPI] public struct Config { [AdditivePower] public float Power; } } public static class LightningResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReducePierceDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_lightning > 0f && val.GetEffectPower("Lightning Resistance").Power > 0f) { float num = (100f - val.GetEffectPower("Lightning Resistance").Power) / 100f; hit.m_damage.m_lightning *= num; } } } } } public static class PierceResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReducePierceDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_pierce > 0f && val.GetEffectPower("Pierce Resistance").Power > 0f) { float num = (100f - val.GetEffectPower("Pierce Resistance").Power) / 100f; hit.m_damage.m_pierce *= num; } } } } } public static class PoisonResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReducePoisonDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_poison > 0f && val.GetEffectPower("Poison Resistance").Power > 0f) { float num = (100f - val.GetEffectPower("Poison Resistance").Power) / 100f; hit.m_damage.m_poison *= num; } } } } } public static class PracticedGemcutter { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [UsedImplicitly] private unsafe static void Postfix(Skills __instance, SkillType skillType, ref float __result) { if (!(((object)(*(SkillType*)(&skillType))/*cast due to .constrained prefix*/).ToString() != "gemcutting") && !((Object)(object)Player.m_localPlayer == (Object)null)) { __result += Mathf.RoundToInt(Player.m_localPlayer.GetEffectPower("PracticedGemcutter").Power); } } } public static class ReduceWeight { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(ItemData), "GetWeight")] public static class ReduceWeight_ItemData_GetWeight_Patch { public static void Postfix(ref float __result) { __result = ReduceWeightByPower(__result); } } [HarmonyPatch(typeof(ItemData), "GetNonStackedWeight")] public static class ReduceWeight_ItemData_GetNonstackedWeight_Patch { public static void Postfix(ref float __result) { __result = ReduceWeightByPower(__result); } } public static float ReduceWeightByPower(float original) { if ((Object)(object)Player.m_localPlayer == (Object)null) { return original; } if (Player.m_localPlayer.GetEffectPower("Reduce Weight").Power > 0f) { float num = 100f / (Player.m_localPlayer.GetEffectPower("Reduce Weight").Power + 100f); original *= num; } return original; } } public static class Retribution { [PublicAPI] public struct Config { [AdditivePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] private static class Retribution_Patch { private static HitData originalHit; private static void Prefix(HitData hit) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown originalHit = new HitData(hit.GetTotalDamage()); } private static void Postfix(Humanoid __instance, HitData hit, Character attacker, ref bool __result) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower("Retribution").Power > 0f && __result && !attacker.IsDead()) { float value = Random.value; float num = val.GetEffectPower("Retribution").Chance / 100f; if (value < num) { HitData val2 = new HitData(); float totalDamage = originalHit.GetTotalDamage(); val2.m_damage.m_damage = totalDamage * (val.GetEffectPower("Retribution").Power / 100f); val2.m_attacker = ((Character)val).GetZDOID(); val2.m_point = hit.m_point + new Vector3(0f, 0.5f); attacker.Damage(val2); } } } } } public static class SlashResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReduceSlashDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_slash > 0f && val.GetEffectPower("Slash Resistance").Power > 0f) { float num = (100f - val.GetEffectPower("Slash Resistance").Power) / 100f; hit.m_damage.m_slash *= num; } } } } } public static class SlipperyWhenWet { [PublicAPI] public struct Config { [AdditivePower] public float Power; } } internal class SoakedFury { [PublicAPI] public struct Config { [MultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Player), "AddAdrenaline")] public static class ReducePoisonDamageTaken { private static readonly int Wetstatus = StringExtensionMethods.GetStableHashCode("Wet"); [UsedImplicitly] private static void Prefix(Player __instance, ref float v) { float power = __instance.GetEffectPower("Soaked Fury").Power; if (power > 0f && ((Character)__instance).GetSEMan().HaveStatusEffect(Wetstatus)) { float num = (power + 100f) / 100f; EJLogger.LogDebug($"Soaked Fury is increasing adrenaline gain by {num}"); v *= num; } } } } public static class Spellsword { [PublicAPI] public struct Config { [AdditivePower] public float Power; } } public static class StaggeringBlock { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] private static class StaggeringBlock_Patch { private static void Postfix(Humanoid __instance, HitData hit, Character attacker, ref bool __result) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower("Staggering Block").Power > 0f && __result && (Object)(object)attacker != (Object)null && !attacker.IsDead()) { float value = Random.value; float num = val.GetEffectPower("Staggering Block").Power / 100f; if (value < num) { attacker.AddStaggerDamage(999f, -hit.m_dir, (HitData)null); } } } } } internal class Toxifier { [PublicAPI] public struct Config { [MultiplicativePercentagePower] public float Power; [MultiplicativePercentagePower] public float Distance; } [HarmonyPatch(typeof(Character), "AddPoisonDamage")] public static class ReducePoisonDamageTaken { [UsedImplicitly] private static void Postfix(Character __instance) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { float power = Player.m_localPlayer.GetEffectPower("Toxifier").Power; if (power > 0f && Player.m_localPlayer.GetEffectPower("Toxifier").Distance > Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)__instance).transform.position)) { ((Character)Player.m_localPlayer).AddAdrenaline(power); } } } } } public static class WaterFrenzy { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Character), "Damage")] private class AddBonusSlashDamage { private static void Prefix(HitData hit) { Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if (val != null && (Object)(object)val != (Object)null && ((Character)val).GetSEMan().HaveStatusEffect(wetstatus)) { float num = (val.GetEffectPower("Water Frenzy").Power + 100f) / 100f; hit.m_damage.m_blunt *= num; hit.m_damage.m_pierce *= num; hit.m_damage.m_pierce *= num; hit.m_damage.m_fire *= num; hit.m_damage.m_lightning *= num; hit.m_damage.m_frost *= num; hit.m_damage.m_spirit *= num; hit.m_damage.m_poison *= num; hit.m_damage.m_pickaxe *= num; } } } private static int wetstatus = StringExtensionMethods.GetStableHashCode("Wet"); } public static class Waterproof { [PublicAPI] public struct Config { [AdditivePower] public float Power; } } internal class WaterResistant { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })] public static class Waterproof_SEMan_AddStatusEffect_Patch { public static bool Prefix(SEMan __instance, int nameHash) { if (__instance.m_character.IsPlayer()) { Character character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && nameHash == wet_hash) { if (val.GetEffectPower("Waterproof").Power > 0f) { return false; } if (val.GetEffectPower("Water Resistant").Power > 0f) { if (delayWetTill == 0f) { delayWetTill = Time.time + val.GetEffectPower("Water Resistant").Power; return false; } if (delayWetTill < Time.time) { if (delayWetTill + 2f < Time.time) { delayWetTill = 0f; return false; } delayWetTill = 0f; return true; } return false; } } } return true; } } private static float delayWetTill = 0f; private static int wet_hash = "Wet".GetHashCode(); } public static class WaterSwiftness { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Player), "GetJogSpeedFactor")] private class IncreaseJogSpeed { private static void Postfix(Player __instance, ref float __result) { if (((Character)__instance).GetSEMan().HaveStatusEffect(wetstatus) || (__instance.GetEffectPower("Waterproof").Power > 0f && (__instance.GetEffectPower("Water Swiftness").Power > 0f || __instance.GetEffectPower("Slippery When Wet").Power > 0f))) { float num = (__instance.GetEffectPower("Water Swiftness").Power + __instance.GetEffectPower("Slippery When Wet").Power + 100f) / 100f; __result *= num; } } } [HarmonyPatch(typeof(Player), "GetRunSpeedFactor")] private class IncreaseRunSpeed { private static void Postfix(Player __instance, ref float __result) { if (((Character)__instance).GetSEMan().HaveStatusEffect(wetstatus) || (__instance.GetEffectPower("Waterproof").Power > 0f && (__instance.GetEffectPower("Water Swiftness").Power > 0f || __instance.GetEffectPower("Slippery When Wet").Power > 0f))) { float num = (__instance.GetEffectPower("Water Swiftness").Power + __instance.GetEffectPower("Slippery When Wet").Power + 100f) / 100f; __result *= num; } } } private static int wetstatus = StringExtensionMethods.GetStableHashCode("Wet"); } public static class WeaponMaster { [PublicAPI] public struct Config { [AdditivePower] public float Power; } } public static class WeaponReducedStamina { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Attack), "GetAttackStamina")] public class ReduceStaminaCostForAttack { public static void Postfix(Attack __instance, ref float __result) { Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && val.GetEffectPower("Weapon Reduced Stamina").Power > 0f) { float num = 100f / (val.GetEffectPower("Weapon Reduced Stamina").Power + 100f); __result *= num; } } } } public static class WetWorker { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Attack), "GetAttackStamina")] public class ReduceStaminaCostWet_Patch { public static void Postfix(Attack __instance, ref float __result) { Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && val.GetEffectPower("Wet Worker").Power > 0f && ((Character)val).GetSEMan().HaveStatusEffect(wetstatus)) { float num = 100f / (val.GetEffectPower("Wet Worker").Power + 100f); __result *= num; } } } private static int wetstatus = StringExtensionMethods.GetStableHashCode("Wet"); } } namespace EpicJewels.EffectHelpers { public static class AddDamageHarvestables { [HarmonyPatch(typeof(MineRock), "RPC_Hit")] private static class DamageRock { private static void Prefix(HitData hit) { ModifyHarvestDamage(hit); } } [HarmonyPatch(typeof(MineRock5), "RPC_Damage")] private static class DamageRock5 { private static void Prefix(HitData hit) { ModifyHarvestDamage(hit); } } [HarmonyPatch(typeof(TreeBase), "RPC_Damage")] private static class DamageTreebase { private static void Prefix(HitData hit) { ModifyHarvestDamage(hit); } } [HarmonyPatch(typeof(TreeLog), "RPC_Damage")] private static class DamageTreeLog { private static void Prefix(HitData hit) { ModifyHarvestDamage(hit); } } [HarmonyPatch(typeof(Destructible), "RPC_Damage")] private static class DamageDestructible { private static void Prefix(HitData hit) { ModifyHarvestDamage(hit); } } private static HitData ModifyHarvestDamage(HitData hit) { if (hit.GetAttacker() is Player) { Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); float totalDamage = ((DamageTypes)(ref hit.m_damage)).GetTotalDamage(); float num = 0f; if (val.GetEffectPower("Add Pickaxe Damage").Chance >= Random.value) { num = totalDamage * (val.GetEffectPower("Add Pickaxe Damage").Power / 100f); } float num2 = 0f; if (val.GetEffectPower("Add Chop Damage").Chance >= Random.value) { num2 = totalDamage * (val.GetEffectPower("Add Chop Damage").Power / 100f); } if (val.GetEffectPower("Eitr Fused").Power > 0f || val.GetEffectPower("Spellsword").Power > 0f) { float num3 = val.GetEffectPower("Eitr Fused").Cost; if (val.GetEffectPower("Spellsword").Power > 0f) { num3 += 5f; } if (((Character)val).HaveEitr(num3)) { float num4 = (val.GetEffectPower("Eitr Fused").Power + val.GetEffectPower("Spellsword").Power) / 100f; num2 += hit.m_damage.m_chop * num4; num += hit.m_damage.m_pickaxe * num4; ((Character)val).UseEitr(num3); } else { EJLogger.LogDebug($"Eitr powered attack not triggered due to cost {num3}"); } } float num5 = num2 + num; EJLogger.LogDebug($"Added Damage {num5} = pickaxe: {num} chop: {num2} original_total_dmg {totalDamage}"); hit.m_damage.m_chop += num2; hit.m_damage.m_pickaxe += num; } return hit; } } [HarmonyPatch(typeof(Character), "Damage")] public static class IncreaseDamageByPowers { private static void Prefix(HitData hit) { if (!(hit.GetAttacker() is Player)) { return; } Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); float totalDamage = ((DamageTypes)(ref hit.m_damage)).GetTotalDamage(); float value = Random.value; float value2 = Random.value; float num = 0f; if (val.GetEffectPower("Add Blunt Damage").Chance / 100f >= value2) { num = totalDamage * (val.GetEffectPower("Add Blunt Damage").Power / 100f); } float num2 = 0f; if (val.GetEffectPower("Add Slash Damage").Chance / 100f >= value2) { num2 = totalDamage * (val.GetEffectPower("Add Slash Damage").Power / 100f); } float num3 = 0f; if (val.GetEffectPower("Add Pierce Damage").Chance / 100f >= value2) { num3 = totalDamage * (val.GetEffectPower("Add Pierce Damage").Power / 100f); } float num4 = 0f; if (val.GetEffectPower("Add Lightning Damage").Chance / 100f >= value) { num4 = totalDamage * (val.GetEffectPower("Add Lightning Damage").Power / 100f); } float num5 = 0f; if (val.GetEffectPower("Add Spirit Damage").Chance / 100f >= value) { num5 = totalDamage * (val.GetEffectPower("Add Spirit Damage").Power / 100f); } float num6 = 0f; if (val.GetEffectPower("Add Pickaxe Damage").Chance / 100f >= value2) { num6 = totalDamage * (val.GetEffectPower("Add Pickaxe Damage").Power / 100f); } float num7 = 0f; if (val.GetEffectPower("Add Chop Damage").Chance / 100f >= value2) { num7 = totalDamage * (val.GetEffectPower("Add Chop Damage").Power / 100f); } if (val.GetEffectPower("Eitr Fused").Power > 0f || val.GetEffectPower("Spellsword").Power > 0f) { float num8 = val.GetEffectPower("Eitr Fused").Cost; if (val.GetEffectPower("Spellsword").Power > 0f) { num8 += 5f; } if (((Character)val).HaveEitr(num8)) { float num9 = (val.GetEffectPower("Eitr Fused").Power + val.GetEffectPower("Spellsword").Power) / 100f; num7 += hit.m_damage.m_chop * num9; num6 += hit.m_damage.m_pickaxe * num9; num5 += hit.m_damage.m_spirit * num9; num4 += hit.m_damage.m_lightning * num9; num3 += hit.m_damage.m_pierce * num9; num2 += hit.m_damage.m_slash * num9; num += hit.m_damage.m_blunt * num9; ((Character)val).UseEitr(num8); } else { EJLogger.LogDebug($"Eitr powered attack not triggered due to cost {num8}"); } } float num10 = num + num2 + num3 + num4 + num5 + num6 + num7; float num11 = val.GetEffectPower("Inferno").Chance; if (val.GetEffectPower("Intense Fire").Power > 0f) { num11 *= 1.5f; } num11 /= 100f; float value3 = Random.value; if (val.GetEffectPower("Inferno").Power > 0f && value3 < num11) { float num12 = totalDamage * (val.GetEffectPower("Inferno").Power / 100f); hit.m_damage.m_fire += num12; EJLogger.LogDebug($"Inferno activated, added fire damage: {num12}"); } EJLogger.LogDebug($"Inferno chance: {value3} < {num11} | elemental chance: {value} physical chance: {value2} \n Added Damage {num10} = blunt:{num} slash:{num2} pierce:{num3} lightning: {num4} spirit: {num5} pickaxe: {num6} original_total_dmg {totalDamage}"); hit.m_damage.m_blunt += num; hit.m_damage.m_pierce += num3; hit.m_damage.m_slash += num2; hit.m_damage.m_lightning += num4; hit.m_damage.m_spirit += num5; hit.m_damage.m_chop += num7; hit.m_damage.m_pickaxe += num6; } } public static class ItemDisplay { [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int) })] public static class ItemToolTipDisplayEnhancer { public static List allowed_item_types = new List { (ItemType)20, (ItemType)4, (ItemType)3, (ItemType)14, (ItemType)22 }; private static void Postfix(ItemData item, ref string __result) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || !((Humanoid)Player.m_localPlayer).IsItemEquiped(item) || !ValConfig.EnableItemTooltipDisplay.Value || !allowed_item_types.Contains(item.m_shared.m_itemType)) { return; } float min = default(float); float max = default(float); ((Character)Player.m_localPlayer).GetSkills().GetRandomSkillRange(ref min, ref max, item.m_shared.m_skillType); float totalDamage = ((DamageTypes)(ref item.m_shared.m_damages)).GetTotalDamage(); Dictionary dictionary = DetermineCharacterDamageModifiers(); float num = Player.m_localPlayer.GetEffectPower("Coin Hoarder").Power; if (num > 0f) { num = CoinHoarder.CoinHoarderBonusCalc(Player.m_localPlayer); } float power = Player.m_localPlayer.GetEffectPower("Spellsword").Power; List list = __result.Split(new char[1] { '\n' }).ToList(); List list2 = new List(list); for (int i = 0; i < list.Count; i++) { if (list[i].Length < 17) { continue; } switch (list[i].Split(new char[1] { ':' })[0].Trim()) { case "$inventory_fire": if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_blunt, min, max, 0f, num, power); } break; case "$inventory_poison": if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_blunt, min, max, 0f, num, power); } break; case "$inventory_frost": if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_blunt, min, max, 0f, num, power); } break; case "$inventory_blunt": if (dictionary.ContainsKey("Add Blunt Damage")) { dictionary["Add Blunt Damage"].added = true; list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_blunt, min, max, dictionary["Add Blunt Damage"].power, num, power); } else if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_blunt, min, max, 0f, num, power); } break; case "$inventory_slash": if (dictionary.ContainsKey("Add Slash Damage")) { dictionary["Add Slash Damage"].added = true; list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_slash, min, max, dictionary["Add Slash Damage"].power, num, power); } else if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_slash, min, max, 0f, num, power); } break; case "$inventory_pierce": if (dictionary.ContainsKey("Add Pierce Damage")) { dictionary["Add Pierce Damage"].added = true; list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_pierce, min, max, dictionary["Add Pierce Damage"].power, num, power); } else if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_pierce, min, max, 0f, num, power); } break; case "$inventory_lightning": if (dictionary.ContainsKey("Add Lightning Damage")) { dictionary["Add Lightning Damage"].added = true; list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_lightning, min, max, dictionary["Add Lightning Damage"].power, num, power); } else if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_lightning, min, max, 0f, num, power); } break; case "$inventory_spirit": if (dictionary.ContainsKey("Add Spirit Damage")) { dictionary["Add Spirit Damage"].added = true; list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_spirit, min, max, dictionary["Add Spirit Damage"].power, num, power); } else if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_spirit, min, max, 0f, num, power); } break; } } foreach (KeyValuePair item2 in dictionary) { if (!item2.Value.added) { list2.Add(BuildModifierExplainer(item2.Value.localizedName, totalDamage, min, max, item2.Value.power)); } } string text = string.Join("\n", list2.ToArray()); __result = text; } } private class DmgModDetails { public string localizedName { get; set; } public bool added { get; set; } public float power { get; set; } } private static Dictionary DetermineCharacterDamageModifiers() { Dictionary dictionary = new Dictionary(); if (Player.m_localPlayer.GetEffectPower("Add Spirit Damage").Power > 0f) { dictionary.Add("Add Spirit Damage", new DmgModDetails { added = false, localizedName = "$inventory_spirit", power = Player.m_localPlayer.GetEffectPower("Add Spirit Damage").Power }); } if (Player.m_localPlayer.GetEffectPower("Add Lightning Damage").Power > 0f) { dictionary.Add("Add Lightning Damage", new DmgModDetails { added = false, localizedName = "$inventory_lightning", power = Player.m_localPlayer.GetEffectPower("Add Lightning Damage").Power }); } if (Player.m_localPlayer.GetEffectPower("Add Pierce Damage").Power > 0f) { dictionary.Add("Add Pierce Damage", new DmgModDetails { added = false, localizedName = "$inventory_pierce", power = Player.m_localPlayer.GetEffectPower("Add Pierce Damage").Power }); } if (Player.m_localPlayer.GetEffectPower("Add Slash Damage").Power > 0f) { dictionary.Add("Add Slash Damage", new DmgModDetails { added = false, localizedName = "$inventory_slash", power = Player.m_localPlayer.GetEffectPower("Add Slash Damage").Power }); } if (Player.m_localPlayer.GetEffectPower("Add Blunt Damage").Power > 0f) { dictionary.Add("Add Blunt Damage", new DmgModDetails { added = false, localizedName = "$inventory_blunt", power = Player.m_localPlayer.GetEffectPower("Add Blunt Damage").Power }); } return dictionary; } private static string AddModifierExplainer(string current_line, float total_dmg, float m_dmg_value, float min, float max, float bonus_power, float coinhoarder_mult = 1f, float spellsword_mult = 0f) { float num = total_dmg * (bonus_power / 100f); float num2 = coinhoarder_mult; string[] array = current_line.Split(new char[1] { ' ' }); Match match = Regex.Match(array[1], "(?<=>)(\\d+)(?=<)"); if (!match.Success) { return current_line; } EJLogger.LogInfo("Match " + match.Value); if (!int.TryParse(match.Value, out var result)) { return current_line; } if (num2 == 0f) { num2 = 1f; } if (spellsword_mult > 0f) { float num3 = Player.m_localPlayer.GetEffectPower("Eitr Fused").Cost + 5f; if (((Character)Player.m_localPlayer).HaveEitr(num3)) { num2 += 1f + spellsword_mult / 100f; } } array[1] = "" + (((float)result + num) * num2).ToString("F1") + ""; ref string reference = ref array[1]; reference = reference + " [+" + (num + (num2 * (float)result - (float)result)).ToString("F1") + "]"; array[2] = $"({Mathf.RoundToInt((m_dmg_value + num + (num2 * (float)result - (float)result)) * min)}-{Mathf.RoundToInt((m_dmg_value + num + (num2 * (float)result - (float)result)) * max)})"; return string.Join(" ", array); } private static string BuildModifierExplainer(string dmg_localization, float total_dmg, float min, float max, float bonus_power) { float num = total_dmg * (bonus_power / 100f); return string.Format("{0}: {1} ({2}-{3})", dmg_localization, num.ToString("F1"), Mathf.RoundToInt(num * min), Mathf.RoundToInt(num * max)); } } [HarmonyPatch(typeof(Skills), "GetSkillLevel")] public static class IncreaseSkillLevelPatch { private static void Postfix(Skills __instance, SkillType skillType, ref float __result) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) __result = IncreaseSkillPatch.DetermineSkillIncrease(__instance.m_player, skillType, __result, factor: false); } } [HarmonyPatch(typeof(Skills), "GetSkillFactor")] public static class IncreaseSkillPatch { [UsedImplicitly] private static void Postfix(Skills __instance, SkillType skillType, ref float __result) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) __result = DetermineSkillIncrease(__instance.m_player, skillType, __result); } public static float DetermineSkillIncrease(Player player, SkillType selectedSkill, float current_skill_level, bool factor = true) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected I4, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected I4, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Invalid comparison between Unknown and I4 float num = 0f; switch ((int)selectedSkill) { default: switch (selectedSkill - 100) { default: if ((int)selectedSkill == 999) { float power = player.GetEffectPower("Weapon Master").Power; num += player.GetEffectPower("Expert Harvester").Power; num += player.GetEffectPower("Expert Harvester").Power; num += power + player.GetEffectPower("Expert Swordsman").Power; num += power + player.GetEffectPower("Expert Spearmaiden").Power; num += power + player.GetEffectPower("Expert Smasher").Power; num += power + player.GetEffectPower("Expert Polearms").Power; num += player.GetEffectPower("Expert Mage").Power; num += player.GetEffectPower("Expert Mage").Power; num += player.GetEffectPower("Expert Fisher").Power; num += power + player.GetEffectPower("Expert Daggers").Power; num += power + player.GetEffectPower("Expert Brawler").Power; num += power + player.GetEffectPower("Expert Axemaster").Power; num += player.GetEffectPower("Expert Acrobat").Power; } break; case 4: if (player.GetEffectPower("Expert Fisher").Power > 0f) { num += player.GetEffectPower("Expert Fisher").Power; } break; case 0: if (player.GetEffectPower("Expert Acrobat").Power > 0f) { num += player.GetEffectPower("Expert Acrobat").Power; } break; case 2: if (player.GetEffectPower("Expert Sprinter").Power > 0f) { num += player.GetEffectPower("Expert Sprinter").Power; } break; case 1: case 3: case 5: case 6: case 7: case 8: case 9: case 10: break; } break; case 1: if (player.GetEffectPower("Expert Swordsman").Power > 0f || player.GetEffectPower("Weapon Master").Power > 0f) { num += player.GetEffectPower("Expert Swordsman").Power; num += player.GetEffectPower("Weapon Master").Power; } break; case 5: if (player.GetEffectPower("Expert Spearmaiden").Power > 0f || player.GetEffectPower("Weapon Master").Power > 0f) { num += player.GetEffectPower("Expert Spearmaiden").Power; num += player.GetEffectPower("Weapon Master").Power; } break; case 3: if (player.GetEffectPower("Expert Smasher").Power > 0f || player.GetEffectPower("Weapon Master").Power > 0f) { num += player.GetEffectPower("Expert Smasher").Power; num += player.GetEffectPower("Weapon Master").Power; } break; case 4: if (player.GetEffectPower("Expert Polearms").Power > 0f || player.GetEffectPower("Weapon Master").Power > 0f) { num += player.GetEffectPower("Expert Polearms").Power; num += player.GetEffectPower("Weapon Master").Power; } break; case 9: case 10: if (player.GetEffectPower("Expert Mage").Power > 0f) { num += player.GetEffectPower("Expert Mage").Power; } break; case 2: if (player.GetEffectPower("Expert Daggers").Power > 0f || player.GetEffectPower("Weapon Master").Power > 0f) { num += player.GetEffectPower("Expert Daggers").Power; num += player.GetEffectPower("Weapon Master").Power; } break; case 11: if (player.GetEffectPower("Expert Brawler").Power > 0f || player.GetEffectPower("Weapon Master").Power > 0f) { num += player.GetEffectPower("Expert Brawler").Power; num += player.GetEffectPower("Weapon Master").Power; } break; case 7: if (player.GetEffectPower("Expert Axemaster").Power > 0f || player.GetEffectPower("Weapon Master").Power > 0f) { num += player.GetEffectPower("Expert Axemaster").Power; num += player.GetEffectPower("Weapon Master").Power; } break; case 12: case 13: if (player.GetEffectPower("Expert Harvester").Power > 0f) { num += player.GetEffectPower("Expert Harvester").Power; } break; case 8: case 14: if (player.GetEffectPower("Weapon Master").Power > 0f) { num += player.GetEffectPower("Weapon Master").Power; } break; case 0: case 6: break; } float num2 = current_skill_level; if (factor) { return num2 + num / 100f; } return num2 + num; } } internal static class Utils { internal static float GetTotalDamageOptions(this DamageTypes hitdmg, bool include_poison = false, bool include_spirit = false, bool include_pickaxe_and_chop = false, float modElement = 1f, float modPhysical = 1f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) float num = (hitdmg.m_damage + hitdmg.m_blunt + hitdmg.m_slash + hitdmg.m_pierce) * modPhysical; float num2 = (hitdmg.m_fire + hitdmg.m_frost + hitdmg.m_lightning) * modElement; float num3 = num + num2; if (include_poison) { num3 += hitdmg.m_poison * modElement; } if (include_spirit) { num3 += hitdmg.m_spirit * modElement; } if (include_pickaxe_and_chop) { num3 += hitdmg.m_pickaxe + hitdmg.m_chop; } return num3; } } } namespace EpicJewels.Common { internal class EJLogger { public static LogLevel Level = (LogLevel)16; public static void EnableDebugLogging(object sender, EventArgs e) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (ValConfig.EnableDebugMode.Value) { Level = (LogLevel)32; } else { Level = (LogLevel)16; } } public static void CheckEnableDebugLogging() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (ValConfig.EnableDebugMode.Value) { Level = (LogLevel)32; } else { Level = (LogLevel)16; } } public static void LogDebug(string message) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)Level >= 32) { EpicJewels.Log.LogInfo((object)("[DEBUG]" + message)); } } public static void LogInfo(string message) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)Level >= 16) { EpicJewels.Log.LogInfo((object)message); } } public static void LogWarning(string message) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)Level >= 4) { EpicJewels.Log.LogWarning((object)message); } } public static void LogError(string message) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)Level >= 2) { EpicJewels.Log.LogError((object)message); } } } public static class JotunnPiece { public class LoadedGameObjects { public GameObject Prefab { get; set; } public Sprite Sprite { get; set; } public GameObject ScenePrefab { get; set; } } public class PieceCost { public string prefab { get; set; } public int amount { get; set; } public bool refundable { get; set; } = true; } public class PieceConfigs { public ConfigEntry Enabled { get; set; } public ConfigEntry RequiresWorkbench { get; set; } public ConfigEntry Workbench { get; set; } public ConfigEntry PieceCategory { get; set; } public ConfigEntry PieceCost { get; set; } public List UpdatedCost { get; set; } = new List(); } public class JotunnBuildPiece { public string Name { get; set; } public bool Enabled { get; set; } = true; public string Prefab { get; set; } public string Sprite { get; set; } public string Category { get; set; } = "Misc"; public string Workbench { get; set; } = "piece_workbench"; public List PieceCost { get; set; } = new List(); public LoadedGameObjects Objs { get; set; } public PieceConfigs Cfgs { get; set; } public Action BeforePrefabRegistered { get; set; } = null; } private static List BuildPieces = new List(); private static bool PiecesReady = false; public static void RegisterJotunnPiece(JotunnBuildPiece jbuildpiece) { BuildPieces.Add(jbuildpiece); } public static void SetupJotunnPieces() { foreach (JotunnBuildPiece item in BuildPieces.OrderBy((JotunnBuildPiece x) => x.Prefab).ToList()) { SetupJotunBuildPiece(item); } BuildPieces.Clear(); } public static void SetupJotunBuildPiece(JotunnBuildPiece jbuildpiece) { LoadedGameObjects loadedGameObjects = new LoadedGameObjects(); loadedGameObjects.Prefab = EpicJewels.EmbeddedResourceBundle.LoadAsset(jbuildpiece.Prefab + ".prefab"); loadedGameObjects.Sprite = EpicJewels.EmbeddedResourceBundle.LoadAsset(jbuildpiece.Sprite + ".png"); if ((Object)(object)loadedGameObjects.Prefab == (Object)null) { EJLogger.LogError("Could not load prefab for " + jbuildpiece.Name + " with name " + jbuildpiece.Prefab + "."); EJLogger.LogInfo("Available assets:\n" + string.Join("\n", EpicJewels.EmbeddedResourceBundle.GetAllAssetNames())); return; } if ((Object)(object)loadedGameObjects.Sprite == (Object)null) { EJLogger.LogError("Could not load sprite for " + jbuildpiece.Name + " with name " + jbuildpiece.Sprite + "."); EJLogger.LogInfo("Available assets:\n" + string.Join("\n", EpicJewels.EmbeddedResourceBundle.GetAllAssetNames())); return; } jbuildpiece.Objs = loadedGameObjects; jbuildpiece.Cfgs = new PieceConfigs(); if (jbuildpiece.BeforePrefabRegistered != null) { jbuildpiece.BeforePrefabRegistered(jbuildpiece); } InitialPieceSetup(jbuildpiece); BuildPieces.Add(jbuildpiece); PrefabManager.OnPrefabsRegistered += ResolveAndApplyScenePrefab; void ResolveAndApplyScenePrefab() { IEnumerable source = from obj in Resources.FindObjectsOfTypeAll() where ((Object)obj).name == jbuildpiece.Prefab select obj; if (ValConfig.EnableDebugMode.Value) { EJLogger.LogDebug($"Found {jbuildpiece.Prefab} scene parent objects: {source.Count()}"); } GameObject val = source.FirstOrDefault(); if ((Object)(object)val == (Object)null) { EJLogger.LogWarning("Could not find scene prefab '" + jbuildpiece.Prefab + "' after prefab registration; skipping in-place setup for " + jbuildpiece.Name + "."); } else { jbuildpiece.Objs.ScenePrefab = val; PiecesReady = true; ApplyWorkbench(jbuildpiece); ApplyCategory(jbuildpiece); ApplyRecipe(jbuildpiece); } } } private static void InitialPieceSetup(JotunnBuildPiece jbuildpiece) { //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: 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_0321: Unknown result type (might be due to invalid IL or missing references) //IL_033d: 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_0363: Expected O, but got Unknown //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Expected O, but got Unknown jbuildpiece.Cfgs.Workbench = ValConfig.BindServerConfig(jbuildpiece.Name ?? "", "Workbench", jbuildpiece.Workbench, "The table required to allow building this piece, eg: 'forge', 'piece_workbench', 'blackforge', 'piece_artisanstation'."); jbuildpiece.Cfgs.Workbench.SettingChanged += RequiredBench_SettingChanged; jbuildpiece.Cfgs.Enabled = ValConfig.BindServerConfig(jbuildpiece.Name ?? "", "Enabled", jbuildpiece.Enabled, "Enable/Disable the " + jbuildpiece.Name + "."); jbuildpiece.Cfgs.Enabled.SettingChanged += BuildRecipeChanged_SettingChanged; jbuildpiece.Cfgs.PieceCategory = ValConfig.BindServerConfig(jbuildpiece.Name ?? "", "Piece Category", jbuildpiece.Category, "Piece category for building."); jbuildpiece.Cfgs.PieceCategory.SettingChanged += CraftingCategory_SettingChanged; List list = new List(); foreach (PieceCost item in jbuildpiece.PieceCost) { list.Add($"{item.prefab},{item.amount},{item.refundable}"); } string text = string.Join("|", list); jbuildpiece.Cfgs.PieceCost = ValConfig.BindServerConfig(jbuildpiece.Name ?? "", "Building Cost", text, "Cost to build. Find item ids: https://valheim.fandom.com/wiki/Item_IDs Format: resouce_id,amount,refund eg: Wood,8,true|LeatherScraps,4,false", null, advanced: true); if (!PieceRecipeConfigUpdater(jbuildpiece, jbuildpiece.Cfgs.PieceCost.Value, during_runtime: false)) { EJLogger.LogWarning(jbuildpiece.Name + " has an invalid piece cost. The default will be used instead."); PieceRecipeConfigUpdater(jbuildpiece, text, during_runtime: false); } jbuildpiece.Cfgs.PieceCost.SettingChanged += BuildRecipeChanged_SettingChanged; List list2 = new List(); foreach (PieceCost item2 in jbuildpiece.Cfgs.UpdatedCost) { list2.Add(new RequirementConfig { Item = item2.prefab, Amount = item2.amount, Recover = item2.refundable }); } PieceConfig val = new PieceConfig { CraftingStation = jbuildpiece.Cfgs.Workbench.Value, PieceTable = PieceTables.Hammer, Category = jbuildpiece.Cfgs.PieceCategory.Value, Icon = jbuildpiece.Objs.Sprite, Requirements = list2.ToArray() }; PieceManager.Instance.AddPiece(new CustomPiece(jbuildpiece.Objs.Prefab, true, val)); void BuildRecipeChanged_SettingChanged(object sender, EventArgs e) { if (PiecesReady && !((Object)(object)jbuildpiece.Objs.ScenePrefab == (Object)null)) { if (sender.GetType() == typeof(ConfigEntry)) { ConfigEntry val2 = (ConfigEntry)sender; if (ValConfig.EnableDebugMode.Value) { EJLogger.LogDebug("Recieved new piece config " + val2.Value); } if (!PieceRecipeConfigUpdater(jbuildpiece, val2.Value)) { return; } } ApplyRecipe(jbuildpiece); } } void CraftingCategory_SettingChanged(object sender, EventArgs e) { if (PiecesReady && !((Object)(object)jbuildpiece.Objs.ScenePrefab == (Object)null)) { ApplyCategory(jbuildpiece); } } void RequiredBench_SettingChanged(object sender, EventArgs e) { if (PiecesReady && !((Object)(object)jbuildpiece.Objs.ScenePrefab == (Object)null)) { ApplyWorkbench(jbuildpiece); } } } private static void ApplyWorkbench(JotunnBuildPiece jbuildpiece) { ConfigEntry requiresWorkbench = jbuildpiece.Cfgs.RequiresWorkbench; if ((requiresWorkbench != null && !requiresWorkbench.Value) || string.IsNullOrEmpty(jbuildpiece.Cfgs.Workbench.Value) || jbuildpiece.Cfgs.Workbench.Value.ToLower() == "none") { EJLogger.LogDebug("Setting required crafting station to none."); jbuildpiece.Objs.ScenePrefab.GetComponent().m_craftingStation = null; return; } GameObject prefab = PrefabManager.Instance.GetPrefab(jbuildpiece.Cfgs.Workbench.Value); CraftingStation val = ((prefab != null) ? prefab.GetComponent() : null); if ((Object)(object)val == (Object)null) { EJLogger.LogWarning("Required crafting station does not exist or does not have a crafting station componet, check your prefab name (" + jbuildpiece.Cfgs.Workbench.Value + ")."); return; } if (ValConfig.EnableDebugMode.Value) { EJLogger.LogDebug("Setting crafting station to " + jbuildpiece.Cfgs.Workbench.Value + "."); } jbuildpiece.Objs.ScenePrefab.GetComponent().m_craftingStation = val; } private static void ApplyCategory(JotunnBuildPiece jbuildpiece) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) PieceCategory? val = PieceManager.Instance.GetPieceCategory(jbuildpiece.Cfgs.PieceCategory.Value); if (!val.HasValue) { val = PieceManager.Instance.AddPieceCategory(jbuildpiece.Cfgs.PieceCategory.Value); } jbuildpiece.Objs.ScenePrefab.GetComponent().m_category = val.Value; } private static void ApplyRecipe(JotunnBuildPiece jbuildpiece) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown List list = new List(); if (ValConfig.EnableDebugMode.Value) { EJLogger.LogDebug("Validating and building requirementsConfig"); } foreach (PieceCost item in jbuildpiece.Cfgs.UpdatedCost) { if ((Object)(object)PrefabManager.Instance.GetPrefab(item.prefab) == (Object)null) { if (ValConfig.EnableDebugMode.Value) { EJLogger.LogDebug(item.prefab + " is not a valid prefab, skipping recipe update."); } return; } if (ValConfig.EnableDebugMode.Value) { EJLogger.LogDebug($"Checking entry {item.prefab} amount:{item.amount} refund?:{item.refundable}"); } list.Add(new RequirementConfig { Item = item.prefab, Amount = item.amount, Recover = item.refundable }); } if (jbuildpiece.Cfgs.Enabled.Value) { if (ValConfig.EnableDebugMode.Value) { EJLogger.LogDebug("Updating Piece."); } List list2 = new List(); foreach (RequirementConfig item2 in list) { Requirement val = new Requirement(); GameObject prefab = PrefabManager.Instance.GetPrefab(item2.Item.Replace("JVLmock_", "")); val.m_resItem = ((prefab != null) ? prefab.GetComponent() : null); val.m_amount = item2.Amount; val.m_recover = item2.Recover; list2.Add(val); } if (ValConfig.EnableDebugMode.Value) { EJLogger.LogDebug($"Fixed mock requirements {list2.Count}."); } jbuildpiece.Objs.ScenePrefab.GetComponent().m_resources = list2.ToArray(); if (ValConfig.EnableDebugMode.Value) { EJLogger.LogDebug($"New requirements set {jbuildpiece.Objs.ScenePrefab.GetComponent().m_resources}."); } } else { jbuildpiece.Objs.ScenePrefab.GetComponent().m_enabled = false; } } private static bool PieceRecipeConfigUpdater(JotunnBuildPiece jbuildpiece, string rawrecipe, bool during_runtime = true) { string[] array = rawrecipe.Split(new char[1] { '|' }); List list = new List(); if (array.Length >= 1) { string[] array2 = array; foreach (string text in array2) { string[] array3 = text.Split(new char[1] { ',' }); if (array3.Length != 3) { EJLogger.LogWarning(text + " is invalid, it does not have enough segments. Proper format is: PREFABNAME,COST,REFUND_BOOL eg: Wood,8,false"); return false; } if (ValConfig.EnableDebugMode.Value) { string text2 = ""; string[] array4 = array3; foreach (string text3 in array4) { text2 = text2 + " " + text3; } } if (during_runtime && (Object)(object)PrefabManager.Instance.GetPrefab(array3[0]) == (Object)null) { EJLogger.LogWarning(array3[0] + " is an invalid prefab and does not exist."); return false; } if (array3[0].Length == 0 || array3[1].Length == 0 || array3[2].Length == 0) { EJLogger.LogWarning(text + " is invalid, one segment does not have enough data. Proper format is: PREFABNAME,CRAFT_COST,REFUND_BOOL eg: Wood,8,false"); return false; } if (!bool.TryParse(array3[2], out var result)) { EJLogger.LogWarning(text + " is invalid, the REFUND_BOOL could not be parsed to (true/false). Proper format is: PREFABNAME,CRAFT_COST,REFUND_BOOL eg: Wood,8,false"); return false; } if (ValConfig.EnableDebugMode.Value) { EJLogger.LogDebug("prefab: " + array3[0] + " c:" + array3[1] + " u:" + array3[2]); } list.Add(new PieceCost { prefab = array3[0], amount = int.Parse(array3[1]), refundable = result }); } jbuildpiece.Cfgs.UpdatedCost.Clear(); foreach (PieceCost item in list) { jbuildpiece.Cfgs.UpdatedCost.Add(item); } if (ValConfig.EnableDebugMode.Value) { string text4 = ""; foreach (PieceCost item2 in list) { text4 += $" {item2.prefab} c:{item2.amount} r:{item2.refundable}"; } EJLogger.LogDebug("Updated recipe:" + text4); } return true; } EJLogger.LogWarning("Invalid recipe: " + rawrecipe + ". defaults will be used. Check your prefab names."); jbuildpiece.Cfgs.UpdatedCost = jbuildpiece.PieceCost; return false; } } internal class ValConfig { public static ConfigFile cfg; public static ConfigEntry EnableItemTooltipDisplay; public static ConfigEntry EnableDebugMode; public static ConfigEntry EnableCrystalLightsAlways; public ValConfig(ConfigFile cfgref) { cfg = cfgref; cfg.SaveOnConfigSet = false; CreateConfigValues(cfgref); } private void CreateConfigValues(ConfigFile Config) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown EnableItemTooltipDisplay = Config.Bind("Client config", "EnableItemTooltipDisplay", true, new ConfigDescription("Enables displaying some stat modifications on the item tooltip.", (AcceptableValueBase)null, Array.Empty())); EnableDebugMode = Config.Bind("Client config", "EnableDebugMode", false, new ConfigDescription("Enables debug logging.", (AcceptableValueBase)null, Array.Empty())); EnableDebugMode.SettingChanged += EJLogger.EnableDebugLogging; EJLogger.CheckEnableDebugLogging(); EnableCrystalLightsAlways = BindServerConfig("Server config", "EnableCrystalLightsAlways", value: false, "If true, Epic Jewels crystal lights will always be enabled, requires a restart."); } public static ConfigEntry> BindServerConfig(string catagory, string key, List value, string description, bool advanced = false) { //IL_0013: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown return cfg.Bind>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry BindServerConfig(string catagory, string key, float[] value, string description, bool advanced = false, float valmin = 0f, float valmax = 150f) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown return cfg.Bind(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry BindServerConfig(string catagory, string key, bool value, string description, AcceptableValueBase acceptableValues = null, bool advanced = false) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_002f: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown return cfg.Bind(catagory, key, value, new ConfigDescription(description, acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry BindServerConfig(string catagory, string key, int value, string description, bool advanced = false, int valmin = 0, int valmax = 150) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown return cfg.Bind(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry BindServerConfig(string catagory, string key, float value, string description, bool advanced = false, float valmin = 0f, float valmax = 150f) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown return cfg.Bind(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry BindServerConfig(string catagory, string key, string value, string description, AcceptableValueList acceptableValues = null, bool advanced = false) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_002f: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown return cfg.Bind(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } } }