using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BronzeBattleaxe { internal static class BronzeAppearance { private static readonly Color BronzeTone = new Color(1.35f, 0.95f, 0.5f); private static readonly Quaternion IconRotation = Quaternion.LookRotation(new Vector3(-1f, 1f, 0f), Vector3.forward); public static void TryApply(CustomItem item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType == 4) { return; } SharedData shared = item.ItemDrop.m_itemData.m_shared; bool flag = false; try { BronzeModel.Apply(item.ItemPrefab); flag = true; } catch (Exception arg) { BronzeBattleaxePlugin.Log.LogWarning((object)$"Could not load the bronze model, using the recoloured iron one: {arg}"); } try { if (!flag) { TintModel(item.ItemPrefab); } TintIcons(shared); } catch (Exception arg2) { BronzeBattleaxePlugin.Log.LogWarning((object)$"Could not re-colour the Bronze Battleaxe, keeping the iron look: {arg2}"); } if (flag) { RenderIcon(item.ItemPrefab, shared); } } private static void RenderIcon(GameObject prefab, SharedData shared) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown GameObject val = new GameObject("BronzeBattleaxeIcon"); try { Object.Instantiate(((Component)prefab.GetComponentInChildren(true)).gameObject, val.transform, false); Sprite val2 = RenderManager.Instance.Render(new RenderRequest(val) { Width = 128, Height = 128, Rotation = IconRotation }); if ((Object)(object)val2 != (Object)null) { shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 }; } else { BronzeBattleaxePlugin.Log.LogWarning((object)"Icon render returned nothing, keeping the placeholder icon"); } } catch (Exception arg) { BronzeBattleaxePlugin.Log.LogWarning((object)$"Could not render the Bronze Battleaxe icon, keeping the placeholder: {arg}"); } finally { Object.DestroyImmediate((Object)(object)val); } } private static void TintModel(GameObject prefab) { Dictionary dictionary = new Dictionary(); Dictionary cache = new Dictionary(); MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (MeshRenderer val in componentsInChildren) { Material[] sharedMaterials = ((Renderer)val).sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if (!((Object)(object)val2 == (Object)null) && val2.HasProperty("_MainTex")) { if (!dictionary.TryGetValue(val2, out var value)) { value = (dictionary[val2] = BronzeMaterial(val2, cache)); } sharedMaterials[j] = value; } } ((Renderer)val).sharedMaterials = sharedMaterials; } } private static Material BronzeMaterial(Material original, Dictionary cache) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown Material val = new Material(original) { name = ((Object)original).name + "_bronze" }; Texture texture = original.GetTexture("_MainTex"); if ((Object)(object)texture == (Object)null) { return val; } if (!cache.TryGetValue(texture, out var value)) { Texture mask = (original.HasProperty("_MetallicGlossMap") ? original.GetTexture("_MetallicGlossMap") : null); value = (cache[texture] = TintByMask(texture, mask)); } val.SetTexture("_MainTex", value); return val; } private static Texture TintByMask(Texture diffuse, Texture mask) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00f3: Expected O, but got Unknown //IL_0081: 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) int width = diffuse.width; int height = diffuse.height; Color32[] array = ReadPixels(diffuse, width, height, srgb: true); Color32[] array2 = (((Object)(object)mask != (Object)null) ? ReadPixels(mask, width, height, srgb: false) : null); for (int i = 0; i < array.Length; i++) { float strength = ((array2 != null) ? ((float)(int)array2[i].r / 255f) : 1f); array[i] = Recolour(array[i], strength); } Texture2D val = new Texture2D(width, height, (TextureFormat)4, true, false) { name = ((Object)diffuse).name + "_bronze", filterMode = diffuse.filterMode, wrapMode = diffuse.wrapMode, anisoLevel = diffuse.anisoLevel }; val.SetPixels32(array); val.Apply(true, true); return (Texture)val; } private static void TintIcons(SharedData shared) { Sprite[] icons = shared.m_icons; if (icons != null) { Sprite[] array = (Sprite[])(object)new Sprite[icons.Length]; for (int i = 0; i < icons.Length; i++) { array[i] = TintSprite(icons[i]); } shared.m_icons = array; } } private static Sprite TintSprite(Sprite sprite) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sprite == (Object)null) { return null; } Rect textureRect = sprite.textureRect; Color32[] array = ReadPixels((Texture)(object)sprite.texture, (int)((Rect)(ref textureRect)).width, (int)((Rect)(ref textureRect)).height, srgb: true, (Vector2?)new Vector2(((Rect)(ref textureRect)).width / (float)((Texture)sprite.texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)sprite.texture).height), (Vector2?)new Vector2(((Rect)(ref textureRect)).x / (float)((Texture)sprite.texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)sprite.texture).height)); float num = default(float); float num2 = default(float); float num3 = default(float); for (int i = 0; i < array.Length; i++) { Color32 val = array[i]; if (val.a != 0) { Color.RGBToHSV(Color32.op_Implicit(val), ref num, ref num2, ref num3); float strength = 1f - Mathf.SmoothStep(0.12f, 0.35f, num2); array[i] = Recolour(val, strength); } } Texture2D val2 = new Texture2D((int)((Rect)(ref textureRect)).width, (int)((Rect)(ref textureRect)).height, (TextureFormat)4, false, false) { name = ((Object)sprite).name + "_bronze", filterMode = ((Texture)sprite.texture).filterMode }; val2.SetPixels32(array); val2.Apply(false, true); Sprite obj = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), sprite.pixelsPerUnit); ((Object)obj).name = ((Object)sprite).name + "_bronze"; return obj; } private static Color32 Recolour(Color32 pixel, float strength) { //IL_0005: 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) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) float num = (0.299f * (float)(int)pixel.r + 0.587f * (float)(int)pixel.g + 0.114f * (float)(int)pixel.b) / 255f; float num2 = Mathf.Lerp((float)(int)pixel.r / 255f, Mathf.Min(1f, num * BronzeTone.r), strength); float num3 = Mathf.Lerp((float)(int)pixel.g / 255f, Mathf.Min(1f, num * BronzeTone.g), strength); float num4 = Mathf.Lerp((float)(int)pixel.b / 255f, Mathf.Min(1f, num * BronzeTone.b), strength); return Color32.op_Implicit(new Color(num2, num3, num4, (float)(int)pixel.a / 255f)); } private static Color32[] ReadPixels(Texture source, int width, int height, bool srgb, Vector2? scale = null, Vector2? offset = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)((!srgb) ? 1 : 2)); RenderTexture active = RenderTexture.active; try { if (scale.HasValue) { Graphics.Blit(source, temporary, scale.Value, (Vector2)(((??)offset) ?? Vector2.zero)); } else { Graphics.Blit(source, temporary); } RenderTexture.active = temporary; Texture2D val = new Texture2D(width, height, (TextureFormat)4, false, !srgb); val.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0); Color32[] pixels = val.GetPixels32(); Object.Destroy((Object)val); return pixels; } finally { RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); } } } [BepInPlugin("com.ixillia.bronzebattleaxe", "Bronze Battleaxe", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class BronzeBattleaxePlugin : BaseUnityPlugin { public const string PluginGuid = "com.ixillia.bronzebattleaxe"; public const string PluginName = "Bronze Battleaxe"; public const string PluginVersion = "1.1.0"; private const string BasePrefab = "Battleaxe"; private const string PrefabName = "BronzeBattleaxe"; internal const string NameToken = "item_bronzebattleaxe"; private const string DescriptionToken = "item_bronzebattleaxe_description"; internal static ManualLogSource Log; internal static ConfigEntry MaxSwingSpeedBonus; private void Awake() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; MaxSwingSpeedBonus = ((BaseUnityPlugin)this).Config.Bind("Combat", "MaxSwingSpeedBonus", 0.25f, new ConfigDescription("Swing speed bonus at Axes skill 100, scaled linearly from 0 at skill 0 (0.25 = 25% faster).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); new Harmony("com.ixillia.bronzebattleaxe").PatchAll(Assembly.GetExecutingAssembly()); CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary { { "item_bronzebattleaxe", "Bronze Battleaxe" }, { "item_bronzebattleaxe_description", "A heavy two-handed axe cast from bronze. Duller than iron, but swings faster as your Axes skill grows." } }); PrefabManager.OnVanillaPrefabsAvailable += AddBronzeBattleaxe; } private void AddBronzeBattleaxe() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= AddBronzeBattleaxe; ItemConfig val = new ItemConfig { Name = "$item_bronzebattleaxe", Description = "$item_bronzebattleaxe_description", CraftingStation = CraftingStations.Forge, MinStationLevel = 2, Requirements = BronzeBattleaxeStats.Requirements }; CustomItem val2 = new CustomItem("BronzeBattleaxe", "Battleaxe", val); if ((Object)(object)val2.ItemPrefab == (Object)null || (Object)(object)val2.ItemDrop == (Object)null) { Log.LogError((object)"Could not clone 'Battleaxe', Bronze Battleaxe was not added"); return; } BronzeBattleaxeStats.Apply(val2.ItemDrop.m_itemData.m_shared); CustomRecipe recipe = val2.Recipe; BronzeBattleaxeStats.FlagUpgraderResource((recipe != null) ? recipe.Recipe : null); BronzeAppearance.TryApply(val2); ItemManager.Instance.AddItem(val2); Log.LogInfo((object)"Added Bronze Battleaxe"); } } internal static class BronzeBattleaxeStats { public const float Slash = 50f; public const float Chop = 30f; public const float MaxDurability = 150f; public const float BlockPower = 16f; public const float AttackForce = 60f; public const float MovementModifier = -0.05f; public const float StaminaMultiplier = 0.8f; public const int ToolTier = 2; public const int StationLevel = 2; public static readonly RequirementConfig[] Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("FineWood", 20, 3, false), new RequirementConfig("Bronze", 14, 7, false), new RequirementConfig("LeatherScraps", 4, 0, false), new RequirementConfig("Upgrader1Weapon", 1, 0, false) }; private const string UpgraderItem = "Upgrader1Weapon"; public static void Apply(SharedData shared) { shared.m_damages.m_slash = 50f; shared.m_damages.m_chop = 30f; shared.m_maxDurability = 150f; shared.m_blockPower = 16f; shared.m_attackForce = 60f; shared.m_movementModifier = -0.05f; shared.m_toolTier = 2; Attack attack = shared.m_attack; attack.m_attackStamina *= 0.8f; Attack secondaryAttack = shared.m_secondaryAttack; secondaryAttack.m_attackStamina *= 0.8f; } public static void FlagUpgraderResource(Recipe recipe) { if ((Object)(object)recipe == (Object)null) { return; } Requirement[] resources = recipe.m_resources; foreach (Requirement val in resources) { if ((Object)(object)val.m_resItem != (Object)null && ((Object)val.m_resItem).name.EndsWith("Upgrader1Weapon")) { val.m_upgraderResource = true; } } } } internal static class BronzeModel { private const string ResourcePrefix = "BronzeBattleaxe.assets."; private static readonly MethodInfo LoadImage = typeof(ImageConversion).GetMethod("LoadImage", new Type[3] { typeof(Texture2D), typeof(byte[]), typeof(bool) }); public static void Apply(GameObject prefab) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown MeshFilter val = FindAxeMeshFilter(prefab); MeshRenderer component = ((Component)val).GetComponent(); Mesh sharedMesh; using (Stream stream = Open("bronze_battleaxe.obj")) { sharedMesh = ObjMesh.Load(stream, "bronze_battleaxe"); } Texture2D val2 = LoadTexture("bronze_battleaxe_albedo.png", linear: false); Texture2D val3 = LoadTexture("bronze_battleaxe_normal.png", linear: true); Texture2D val4 = LoadTexture("bronze_battleaxe_metallic.png", linear: true); Dictionary points = ReadTrail(); Material val5 = new Material(((Renderer)component).sharedMaterials[0]) { name = "bronze_battleaxe" }; val5.SetTexture("_MainTex", (Texture)(object)val2); val5.SetTexture("_BumpMap", (Texture)(object)val3); val5.SetTexture("_MetallicGlossMap", (Texture)(object)val4); val.sharedMesh = sharedMesh; ((Renderer)component).sharedMaterials = (Material[])(object)new Material[1] { val5 }; MoveTrail(prefab, points); } private static MeshFilter FindAxeMeshFilter(GameObject prefab) { MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (MeshFilter val in componentsInChildren) { if ((Object)(object)((Component)val).GetComponent() != (Object)null) { return val; } } throw new InvalidOperationException("no mesh found on " + ((Object)prefab).name); } private static void MoveTrail(GameObject prefab, Dictionary points) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) string[] array = new string[2] { "base", "tip" }; foreach (string text in array) { Transform val = prefab.transform.Find("attach/equiped/trail/" + text); if ((Object)(object)val != (Object)null && points.TryGetValue(text, out var value)) { val.localPosition = value; } } } private static Dictionary ReadTrail() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); using StreamReader streamReader = new StreamReader(Open("bronze_battleaxe.trail")); string text; while ((text = streamReader.ReadLine()) != null) { string[] array = text.Split(new char[1] { ' ' }); if (array.Length == 4) { dictionary[array[0]] = new Vector3(Float(array[1]), Float(array[2]), Float(array[3])); } } return dictionary; } private static Texture2D LoadTexture(string file, bool linear) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown byte[] array; using (Stream stream = Open(file)) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = Path.GetFileNameWithoutExtension(file), wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)2, anisoLevel = 4 }; if (!(bool)LoadImage.Invoke(null, new object[3] { val, array, false })) { throw new InvalidOperationException("could not decode " + file); } return val; } private static Stream Open(string file) { return Assembly.GetExecutingAssembly().GetManifestResourceStream("BronzeBattleaxe.assets." + file) ?? throw new FileNotFoundException("embedded resource missing: " + file); } private static float Float(string s) { return float.Parse(s, CultureInfo.InvariantCulture); } } internal static class ObjMesh { public static Mesh Load(Stream stream, string name) { //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); List list5 = new List(); List list6 = new List(); List list7 = new List(); Dictionary dictionary = new Dictionary(); using (StreamReader streamReader = new StreamReader(stream)) { string text; while ((text = streamReader.ReadLine()) != null) { string[] array = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { continue; } switch (array[0]) { case "v": list.Add(new Vector3(0f - Float(array[1]), Float(array[2]), Float(array[3]))); break; case "vt": list2.Add(new Vector2(Float(array[1]), Float(array[2]))); break; case "vn": list3.Add(new Vector3(0f - Float(array[1]), Float(array[2]), Float(array[3]))); break; case "f": { int[] array2 = new int[array.Length - 1]; for (int i = 1; i < array.Length; i++) { if (!dictionary.TryGetValue(array[i], out var value)) { string[] array3 = array[i].Split(new char[1] { '/' }); value = list4.Count; list4.Add(list[int.Parse(array3[0]) - 1]); list5.Add((array3.Length > 1 && array3[1].Length > 0) ? list2[int.Parse(array3[1]) - 1] : Vector2.zero); list6.Add((array3.Length > 2 && array3[2].Length > 0) ? list3[int.Parse(array3[2]) - 1] : Vector3.up); dictionary[array[i]] = value; } array2[i - 1] = value; } for (int j = 1; j < array2.Length - 1; j++) { list7.Add(array2[0]); list7.Add(array2[j + 1]); list7.Add(array2[j]); } break; } } } } Mesh val = new Mesh { name = name }; val.SetVertices(list4); val.SetUVs(0, list5); val.SetNormals(list6); val.SetTriangles(list7, 0); val.RecalculateBounds(); val.RecalculateTangents(); return val; } private static float Float(string s) { return float.Parse(s, CultureInfo.InvariantCulture); } } internal static class SwingSpeed { public static float Multiplier(Character character) { Humanoid val = (Humanoid)(object)((character is Humanoid) ? character : null); if (val == null || !((Character)val).IsOwner() || !((Character)val).InAttack()) { return 1f; } return MultiplierForWeapon(val, val.GetCurrentWeapon()); } public static float MultiplierForWeapon(Humanoid humanoid, ItemData weapon) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (weapon == null || weapon.m_shared.m_name != "$item_bronzebattleaxe") { return 1f; } return 1f + BronzeBattleaxePlugin.MaxSwingSpeedBonus.Value * ((Character)humanoid).GetSkillFactor(weapon.m_shared.m_skillType); } } [HarmonyPatch(typeof(CharacterAnimEvent), "Speed")] internal static class CharacterAnimEvent_Speed_Patch { private static void Prefix(ref float speedScale, Character ___m_character) { speedScale *= SwingSpeed.Multiplier(___m_character); } } [HarmonyPatch(typeof(Attack), "Start")] internal static class Attack_Start_Patch { private static void Postfix(bool __result, Humanoid character, ZSyncAnimation zanim, ItemData weapon) { if (__result && ((Character)character).IsOwner()) { float num = SwingSpeed.MultiplierForWeapon(character, weapon); if (num != 1f) { zanim.SetSpeed(num); } } } } }