Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of NovaChitinArmor v0.3.21
BepInEx/plugins/NovaChitinArmor/NovaChitinArmor.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using MagicaCloth2; using Microsoft.CodeAnalysis; using Unity.Mathematics; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NovaChitinArmor")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.21.0")] [assembly: AssemblyInformationalVersion("0.3.21")] [assembly: AssemblyProduct("NovaChitinArmor")] [assembly: AssemblyTitle("NovaChitinArmor")] [assembly: AssemblyVersion("0.3.21.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 NovaChitinArmor { internal static class ArmorConfig { internal sealed class RecipeSettings { internal string Id; internal string DefaultStation; internal string[] Defaults; internal ConfigEntry<string> Station; internal ConfigEntry<int> Level; internal ConfigEntry<string>[] Costs; } internal static readonly Dictionary<string, RecipeSettings> Recipes = new Dictionary<string, RecipeSettings>(); internal static ConfigEntry<bool> PearlEnabled; internal static ConfigEntry<bool> WetProtection; internal static ConfigEntry<bool> ColdProtection; internal static ConfigEntry<DamageModifier> Pierce; internal static ConfigEntry<DamageModifier> Slash; internal static ConfigEntry<string> ExistingEffect; private static readonly HashSet<string> Warnings = new HashSet<string>(); internal static void Bind(ConfigFile config) { Add(config, "ChitinHelmet", "forge", new string[4] { "Chitin:10,Iron:4,DeerHide:1,GreydwarfEye:2", "Chitin:2,Iron:2", "Chitin:4,Iron:4", "Chitin:6,Iron:6" }); string[] array = new string[2] { "ChitinChest", "ChitinLegs" }; foreach (string id in array) { Add(config, id, "forge", new string[4] { "Chitin:10,Iron:4,DeerHide:3,Resin:10", "Chitin:4,Iron:2", "Chitin:6,Iron:4", "Chitin:8,Iron:6" }); } Add(config, "ChitinCape", "piece_workbench", new string[4] { "Chitin:5,LeatherScraps:10", "Chitin:1,LeatherScraps:2", "Chitin:2,LeatherScraps:3", "Chitin:3,LeatherScraps:5" }); PearlEnabled = config.Bind<bool>("Set bonus", "Enabled", true, "Enable the three-piece Pearl bonus. Restart the game after editing this file."); ExistingEffect = config.Bind<string>("Set bonus", "ExistingStatusEffect", "", "Optional existing status-effect ID from the game or another mod. Empty uses the configurable Pearl resistances. Unknown IDs fall back to Pearl. Restart required."); Pierce = config.Bind<DamageModifier>("Set bonus", "PierceResistance", (DamageModifier)7, "Piercing damage modifier. Use Normal to disable this resistance."); Slash = config.Bind<DamageModifier>("Set bonus", "SlashResistance", (DamageModifier)7, "Slash damage modifier. Use Normal to disable this resistance."); WetProtection = config.Bind<bool>("Set bonus", "PreventWet", true, "The complete three-piece set prevents new Wet and dries existing Wet at campfire speed. Requires Enabled=true."); ColdProtection = config.Bind<bool>("Cape bonus", "PreventNightCold", true, "Prevent ordinary Cold while wearing the cape. Does not protect from Freezing or frost damage."); } private static void Add(ConfigFile config, string id, string station, string[] defaults) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown RecipeSettings recipeSettings = new RecipeSettings { Id = id, DefaultStation = station, Defaults = defaults }; recipeSettings.Station = config.Bind<string>("Recipe." + id, "Station", station, "Crafting station prefab ID, e.g. forge, piece_workbench, blackforge, piece_artisanstation. Empty = no station. Also used for repairs."); recipeSettings.Level = config.Bind<int>("Recipe." + id, "MinimumStationLevel", 2, new ConfigDescription("Station level for quality 1. Every upgrade requires +1 level.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); recipeSettings.Costs = new ConfigEntry<string>[4]; for (int i = 0; i < 4; i++) { recipeSettings.Costs[i] = config.Bind<string>("Recipe." + id, (i == 0) ? "Craft" : ("UpgradeTo" + (i + 1)), defaults[i], "Exact cost for this quality only: PrefabID:amount,PrefabID:amount. Empty = free. Example: Chitin:5,Resin:10. Restart the game to apply."); } Recipes[id] = recipeSettings; } internal static Dictionary<string, int> Parse(string value) { Dictionary<string, int> dictionary = new Dictionary<string, int>(StringComparer.Ordinal); string[] array = (value ?? "").Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { string[] array2 = text.Trim().Split(':'); if (array2.Length != 2 || string.IsNullOrWhiteSpace(array2[0]) || !int.TryParse(array2[1].Trim(), out var result) || result < 0 || result > 1000000) { throw new FormatException("Expected PrefabID:nonnegativeAmount: " + text); } string text2 = array2[0].Trim(); if (dictionary.ContainsKey(text2)) { throw new FormatException("Duplicate resource: " + text2); } if (result > 0) { dictionary.Add(text2, result); } } return dictionary; } private static void Warn(string text) { if (Warnings.Add(text)) { Logger.CreateLogSource("NovaChitinArmor").LogWarning((object)text); } } private static CraftingStation FindStation(ObjectDB db, string id, CraftingStation current) { if (string.IsNullOrWhiteSpace(id)) { return null; } GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(id) : null); if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<CraftingStation>() != (Object)null) { return val.GetComponent<CraftingStation>(); } string label = ((id == "forge") ? "$piece_forge" : ((id == "piece_workbench") ? "$piece_workbench" : ((id == "blackforge") ? "$piece_blackforge" : null))); return ((IEnumerable<CraftingStation>)(object)new CraftingStation[1] { current }).Concat(db.m_recipes.Where((Recipe r) => (Object)(object)r != (Object)null).SelectMany((Recipe r) => (IEnumerable<CraftingStation>)(object)new CraftingStation[2] { r.m_craftingStation, r.m_repairStation })).FirstOrDefault((Func<CraftingStation, bool>)((CraftingStation s) => (Object)(object)s != (Object)null && (((Object)((Component)s).gameObject).name == id || (label != null && s.m_name == label)))); } internal static bool Apply(ObjectDB db, Recipe recipe, string id, CraftingStation current = null) { RecipeSettings recipeSettings = Recipes[id]; string text = recipeSettings.Station.Value.Trim(); CraftingStation val = FindStation(db, text, current); if (text.Length > 0 && (Object)(object)val == (Object)null) { if ((Object)(object)ZNetScene.instance == (Object)null) { return false; } Warn(id + ": unknown station '" + text + "'; using " + recipeSettings.DefaultStation); val = FindStation(db, recipeSettings.DefaultStation, current); if ((Object)(object)val == (Object)null) { return false; } } Dictionary<string, int>[] array = new Dictionary<string, int>[4]; try { for (int i = 0; i < 4; i++) { array[i] = Parse(recipeSettings.Costs[i].Value); } foreach (string resource in array.SelectMany((Dictionary<string, int> c) => c.Keys).Distinct()) { if (!db.m_items.Any((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == resource && (Object)(object)p.GetComponent<ItemDrop>() != (Object)null)) { throw new FormatException("Unknown resource: " + resource); } } } catch (Exception ex) { Warn(id + ": invalid recipe config (" + ex.Message + "); using default resources."); array = recipeSettings.Defaults.Select(Parse).ToArray(); } string[] ids = array.SelectMany((Dictionary<string, int> c) => c.Keys).Distinct().ToArray(); if (ids.Any((string text2) => !db.m_items.Any((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == text2))) { return false; } bool flag = false; if (recipe.m_resources == null || !recipe.m_resources.Where((Requirement r) => !r.m_upgraderResource).Select(delegate(Requirement r) { ItemDrop resItem = r.m_resItem; return (resItem == null) ? null : ((Object)((Component)resItem).gameObject).name; }).SequenceEqual(ids)) { recipe.m_resources = ((IEnumerable<string>)ids).Select((Func<string, Requirement>)((string text2) => new Requirement { m_resItem = db.m_items.Find((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == text2).GetComponent<ItemDrop>(), m_recover = true })).ToArray(); flag = true; } Requirement[] array2 = recipe.m_resources.Where((Requirement r) => !r.m_upgraderResource).ToArray(); int i2; for (i2 = 0; i2 < ids.Length; i2++) { int value; int[] array3 = array.Select((Dictionary<string, int> c) => c.TryGetValue(ids[i2], out value) ? value : 0).ToArray(); if (array2[i2].m_amount != array3[0] || array2[i2].m_amountPerLevel != 0) { flag = true; } array2[i2].m_amount = array3[0]; array2[i2].m_amountPerLevel = 0; ChitinCosts.Set(array2[i2], array3); } if ((Object)(object)recipe.m_craftingStation != (Object)(object)val || (Object)(object)recipe.m_repairStation != (Object)(object)val || recipe.m_minStationLevel != recipeSettings.Level.Value || !recipe.m_enabled) { flag = true; } recipe.m_craftingStation = val; recipe.m_repairStation = val; recipe.m_minStationLevel = recipeSettings.Level.Value; recipe.m_enabled = true; return flag | PotentialUpgrades.Ensure(db, recipe); } } internal static class ArmorRecipeOrder { private static readonly HashSet<string> Own = new HashSet<string> { "ChitinHelmet", "ChitinChest", "ChitinLegs", "ChitinCape" }; internal static void Group<T>(List<T> entries, Func<T, Recipe> getRecipe) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) foreach (T item2 in entries.Where(delegate(T e) { HashSet<string> own = Own; Recipe obj = getRecipe(e); object obj2; if (obj == null) { obj2 = null; } else { ItemDrop item = obj.m_item; obj2 = ((item != null) ? ((Object)((Component)item).gameObject).name : null); } if (obj2 == null) { obj2 = ""; } return own.Contains((string)obj2); }).ToList()) { Recipe val = getRecipe(item2); ItemType type = val.m_item.m_itemData.m_shared.m_itemType; int num = entries.IndexOf(item2); entries.RemoveAt(num); int num2 = entries.FindLastIndex((T e) => (Object)(object)getRecipe(e)?.m_item != (Object)null && getRecipe(e).m_item.m_itemData.m_shared.m_itemType == type); entries.Insert((num2 >= 0) ? (num2 + 1) : Math.Min(num, entries.Count), item2); } } } [HarmonyPatch(typeof(InventoryGui), "UpdateRecipeList")] internal static class NovaArmorRecipeOrderPatch { private static readonly FieldInfo Recipes = AccessTools.Field(typeof(InventoryGui), "m_availableRecipes"); private static readonly FieldInfo Space = AccessTools.Field(typeof(InventoryGui), "m_recipeListSpace"); private static PropertyInfo recipeProperty; private static PropertyInfo elementProperty; [HarmonyPriority(0)] [HarmonyAfter(new string[] { "yadren1y.PerfectCraftTable" })] private static void Postfix(InventoryGui __instance) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (!(Recipes.GetValue(__instance) is IList { Count: >=2 } list)) { return; } if (recipeProperty == null) { Type type = list[0].GetType(); recipeProperty = AccessTools.Property(type, "Recipe"); elementProperty = AccessTools.Property(type, "InterfaceElement"); } List<object> list2 = list.Cast<object>().ToList(); ArmorRecipeOrder.Group(list2, (object e) => (Recipe)recipeProperty.GetValue(e)); float num = (float)Space.GetValue(__instance); for (int num2 = 0; num2 < list2.Count; num2++) { list[num2] = list2[num2]; object? value = elementProperty.GetValue(list2[num2]); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val != (Object)null) { Transform transform = val.transform; RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if (val2 != null) { val2.anchoredPosition = new Vector2(0f, (float)(-num2) * num); } } } } } internal static class ArmorVisuals { internal sealed class Part { internal string Slot; internal string Diffuse; internal string Normal; internal Mesh Mesh; } internal sealed class Model { internal string[] Bones; internal List<Part> Parts = new List<Part>(); } private sealed class HiddenUtility { internal readonly Dictionary<Renderer, bool> Renderers = new Dictionary<Renderer, bool>(); internal readonly HashSet<GameObject> Roots = new HashSet<GameObject>(); internal void Restore() { foreach (KeyValuePair<Renderer, bool> renderer in Renderers) { if ((Object)(object)renderer.Key != (Object)null) { renderer.Key.enabled = renderer.Value; } } Renderers.Clear(); Roots.Clear(); } } private static readonly Dictionary<string, Model> Models = new Dictionary<string, Model>(); private static readonly Dictionary<string, Texture2D> Textures = new Dictionary<string, Texture2D>(); private static readonly Dictionary<string, Material> Materials = new Dictionary<string, Material>(); private static readonly Dictionary<(Mesh, int), Mesh> Masks = new Dictionary<(Mesh, int), Mesh>(); private static readonly Dictionary<Mesh, Mesh> MaskSources = new Dictionary<Mesh, Mesh>(); private static readonly FieldInfo ShoulderHash = AccessTools.Field(typeof(VisEquipment), "m_currentShoulderItemHash"); private static readonly int CapeHash = StableHash("ChitinCape"); private static readonly Dictionary<int, Mesh> Linings = new Dictionary<int, Mesh>(); private static readonly Dictionary<int, string> Slots = new Dictionary<int, string>(); private static readonly FieldInfo ChestHash = AccessTools.Field(typeof(VisEquipment), "m_currentChestItemHash"); private static readonly FieldInfo LegsHash = AccessTools.Field(typeof(VisEquipment), "m_currentLegItemHash"); private static readonly FieldInfo HelmetHash = AccessTools.Field(typeof(VisEquipment), "m_currentHelmetItemHash"); private static Material template; private static readonly Dictionary<Mesh, Mesh> CoveredLegs = new Dictionary<Mesh, Mesh>(); private static readonly Dictionary<Model, Mesh> JoinedLegs = new Dictionary<Model, Mesh>(); private static Material liningMaterial; private static readonly ConditionalWeakTable<VisEquipment, HiddenUtility> HiddenUtilities = new ConditionalWeakTable<VisEquipment, HiddenUtility>(); private static readonly FieldInfo UtilityHash = AccessTools.Field(typeof(VisEquipment), "m_currentUtilityItemHash"); private static readonly FieldInfo UtilityInstances = AccessTools.Field(typeof(VisEquipment), "m_utilityItemInstances"); private static Stream Resource(string name) { return typeof(ArmorVisuals).Assembly.GetManifestResourceStream("NCA." + name) ?? throw new FileNotFoundException("Missing armor asset: " + name); } private static string ReadString(BinaryReader r) { return Encoding.UTF8.GetString(r.ReadBytes(r.ReadInt32())); } private static Vector3 ReadVector(BinaryReader r) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } internal static Model Load(string sex) { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Expected O, but got Unknown //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) if (Models.TryGetValue(sex, out var value)) { return value; } using (BinaryReader binaryReader = new BinaryReader(Resource(sex + ".bin"))) { if (binaryReader.ReadInt32() != 1346587697) { throw new InvalidDataException("Invalid armor data"); } int num = binaryReader.ReadInt32(); value = new Model { Bones = new string[num] }; Matrix4x4[] array = (Matrix4x4[])(object)new Matrix4x4[num]; for (int i = 0; i < num; i++) { value.Bones[i] = ReadString(binaryReader); for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { ((Matrix4x4)(ref array[i]))[j, k] = binaryReader.ReadSingle(); } } } int num2 = binaryReader.ReadInt32(); Vector2 val3 = default(Vector2); for (int l = 0; l < num2; l++) { Part part = new Part { Slot = ReadString(binaryReader), Diffuse = ReadString(binaryReader), Normal = ReadString(binaryReader) }; int num3 = binaryReader.ReadInt32(); Vector3[] array2 = (Vector3[])(object)new Vector3[num3]; Vector2[] array3 = (Vector2[])(object)new Vector2[num3]; BoneWeight[] array4 = (BoneWeight[])(object)new BoneWeight[num3]; BoneWeight val; for (int m = 0; m < num3; m++) { array2[m] = ReadVector(binaryReader); array3[m] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int num4 = m; val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).weight0 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).boneIndex1 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).weight1 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).boneIndex2 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).weight2 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).boneIndex3 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).weight3 = binaryReader.ReadSingle(); array4[num4] = val; } int[] array5 = new int[binaryReader.ReadInt32()]; for (int n = 0; n < array5.Length; n++) { array5[n] = binaryReader.ReadInt32(); } for (int num5 = 0; num5 < array5.Length; num5 += 3) { int num6 = array5[num5 + 1]; array5[num5 + 1] = array5[num5 + 2]; array5[num5 + 2] = num6; } if (part.Slot == "Helmet") { int num7 = Array.IndexOf(value.Bones, "Head"); int num8 = Array.IndexOf(value.Bones, "Neck"); for (int num9 = 0; num9 < array2.Length; num9++) { BoneWeight val2 = array4[num9]; float num10 = 0f; if (((BoneWeight)(ref val2)).boneIndex0 == num7 || ((BoneWeight)(ref val2)).boneIndex0 == num8) { num10 += ((BoneWeight)(ref val2)).weight0; } if (((BoneWeight)(ref val2)).boneIndex1 == num7 || ((BoneWeight)(ref val2)).boneIndex1 == num8) { num10 += ((BoneWeight)(ref val2)).weight1; } if (((BoneWeight)(ref val2)).boneIndex2 == num7 || ((BoneWeight)(ref val2)).boneIndex2 == num8) { num10 += ((BoneWeight)(ref val2)).weight2; } if (((BoneWeight)(ref val2)).boneIndex3 == num7 || ((BoneWeight)(ref val2)).boneIndex3 == num8) { num10 += ((BoneWeight)(ref val2)).weight3; } array2[num9].x *= 1f + 0.2f * num10; array2[num9].y *= 1f + 0.15f * num10; array2[num9].z += ((array2[num9].z - 0.0176f) * 0.1f + (Plugin.HelmetLiftMeters + 0.01f) * 0.01f) * num10; float num11 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.0167f, 0.0175f, array2[num9].z)); ((Vector2)(ref val3))..ctor(array2[num9].x, array2[num9].y); float magnitude = ((Vector2)(ref val3)).magnitude; if (magnitude > 0.00105f) { float num12 = Mathf.Lerp(magnitude, 0.00105f, num11); array2[num9].x *= num12 / magnitude; array2[num9].y *= num12 / magnitude; } if (num11 > 0.01f && num8 >= 0 && num7 >= 0) { int num13 = num9; val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = num8; ((BoneWeight)(ref val)).weight0 = num11; ((BoneWeight)(ref val)).boneIndex1 = num7; ((BoneWeight)(ref val)).weight1 = 1f - num11; array4[num13] = val; } } } Mesh val4 = new Mesh(); ((Object)val4).name = "Chitin_" + sex + "_" + part.Slot + "_" + l; val4.vertices = array2; val4.uv = array3; val4.boneWeights = array4; val4.bindposes = array; val4.triangles = array5; part.Mesh = val4; part.Mesh.RecalculateNormals(); part.Mesh.RecalculateTangents(); part.Mesh.RecalculateBounds(); if (part.Slot == "Helmet") { part.Mesh = MeshCut.Clip(part.Mesh, part.Mesh.triangles, 0.01635f, above: true); } value.Parts.Add(part); } } Models.Add(sex, value); return value; } private static float SmoothBand(float value, float low, float high, float feather) { return Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(low - feather, low, value)) * (1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(high, high + feather, value))); } private static Vector3 FitBody(Vector3 v) { //IL_0000: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) SmoothBand(v.z, 0.0105f, 0.016f, 0.002f); Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.0125f, 0.014f, v.z)); float num = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.003f, 0.006f, Mathf.Abs(v.x))); float num2 = SmoothBand(v.z, 0.009f, 0.0115f, 0.0018f); v.x *= 1f + 0.06f * num2 * num; v.y *= 1f + 0.05f * num2 * num; float num3 = SmoothBand(v.z, 0.0065f, 0.009f, 0.0015f); float num4 = Mathf.Sign(v.x) * 0.0011f; if (Mathf.Abs(v.x) < 0.0035f) { v.x += (v.x - num4) * 0.16f * num3; } return v; } private static Texture2D Texture(string name, bool linear = false) { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_00e5: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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_0271: Unknown result type (might be due to invalid IL or missing references) if (Textures.TryGetValue(name, out var value)) { return value; } using (Stream stream = Resource(name)) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); value = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, filterMode = (FilterMode)1, anisoLevel = 4 }; if (!ImageConversion.LoadImage(value, memoryStream.ToArray())) { throw new InvalidDataException(name); } if (!name.StartsWith("icon_")) { bool flag = name.Contains("helmet"); int num = (linear ? 64 : (flag ? 128 : 256)); float num2 = Mathf.Min(1f, (float)num / (float)Mathf.Max(((Texture)value).width, ((Texture)value).height)); int num3 = Mathf.Max(1, Mathf.RoundToInt((float)((Texture)value).width * num2)); int num4 = Mathf.Max(1, Mathf.RoundToInt((float)((Texture)value).height * num2)); Texture2D val = new Texture2D(num3, num4, (TextureFormat)4, true, linear) { name = name, filterMode = (FilterMode)(linear ? 1 : 0), anisoLevel = 1 }; Color[] array = (Color[])(object)new Color[num3 * num4]; Color32[] pixels = value.GetPixels32(); for (int i = 0; i < num4; i++) { for (int j = 0; j < num3; j++) { int num5 = j * ((Texture)value).width / num3; int num6 = (j + 1) * ((Texture)value).width / num3; int num7 = i * ((Texture)value).height / num4; int num8 = (i + 1) * ((Texture)value).height / num4; Color val2 = Color.clear; for (int k = num7; k < num8; k++) { for (int l = num5; l < num6; l++) { val2 += Color32.op_Implicit(pixels[k * ((Texture)value).width + l]); } } val2 /= (float)((num6 - num5) * (num8 - num7)); if (linear) { val2.a = Mathf.Lerp(0.5f, val2.a, 0.12f); val2.g = Mathf.Lerp(0.5f, val2.g, 0.12f); } else { float num9 = 31f; val2.r = Mathf.Round(val2.r * num9) / num9; val2.g = Mathf.Round(val2.g * num9) / num9; val2.b = Mathf.Round(val2.b * num9) / num9; val2.a = 1f; } array[i * num3 + j] = val2; } } val.SetPixels(array); val.Apply(true, false); Object.Destroy((Object)(object)value); value = val; } } Textures.Add(name, value); return value; } private static Color Opaque(Color color) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) color.a = 1f; return color; } private static void SetOpaqueFloat(Material material, string property, float value) { if (material.HasProperty(property)) { material.SetFloat(property, value); } } private static void SetOpaqueColor(Material material, string property) { //IL_000d: 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 (material.HasProperty(property)) { material.SetColor(property, Opaque(material.GetColor(property))); } } private static Material MaterialFor(Part part) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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) if (Materials.TryGetValue(part.Diffuse, out var value)) { return value; } if ((Object)(object)template == (Object)null || (Object)(object)template.shader == (Object)null) { throw new InvalidOperationException("Valheim armor material template is unavailable"); } value = new Material(template); ((Object)value).name = "Chitin_Opaque_" + part.Diffuse; Texture2D val = (Texture2D)(object)(value.mainTexture = (Texture)(object)Texture(part.Diffuse)); if (value.HasProperty("_MainTex")) { value.SetTexture("_MainTex", (Texture)(object)val); } if (value.HasProperty("_BaseMap")) { value.SetTexture("_BaseMap", (Texture)(object)val); } Texture2D val3 = Texture(part.Normal, linear: true); if (value.HasProperty("_BumpMap")) { value.SetTexture("_BumpMap", (Texture)(object)val3); } if (value.HasProperty("_NormalMap")) { value.SetTexture("_NormalMap", (Texture)(object)val3); } if (value.HasProperty("_BumpMap")) { value.EnableKeyword("_NORMALMAP"); } string[] array = new string[4] { "_Color", "_BaseColor", "_TintColor", "_MainColor" }; foreach (string property in array) { SetOpaqueColor(value, property); } if (value.HasProperty("_Color")) { value.SetColor("_Color", Opaque(value.GetColor("_Color"))); } array = new string[5] { "_Opacity", "_Alpha", "_Transparency", "_Fade", "_FadeAmount" }; foreach (string property2 in array) { SetOpaqueFloat(value, property2, 1f); } SetOpaqueFloat(value, "_Mode", 0f); SetOpaqueFloat(value, "_Surface", 0f); SetOpaqueFloat(value, "_AlphaClip", 0f); SetOpaqueFloat(value, "_Cutoff", 0f); value.SetOverrideTag("RenderType", "Opaque"); SetOpaqueFloat(value, "_Glossiness", 0.12f); SetOpaqueFloat(value, "_Smoothness", 0.12f); SetOpaqueFloat(value, "_Metallic", 0.05f); if (value.HasProperty("_SpecColor")) { value.SetColor("_SpecColor", new Color(0.12f, 0.12f, 0.12f, 1f)); } value.renderQueue = 2000; array = new string[6] { "_ALPHATEST_ON", "_ALPHABLEND_ON", "_ALPHAPREMULTIPLY_ON", "_ALPHAMODULATE_ON", "_SURFACE_TYPE_TRANSPARENT", "_ALPHATEST" }; foreach (string text in array) { value.DisableKeyword(text); } SetOpaqueFloat(value, "_SrcBlend", 1f); SetOpaqueFloat(value, "_DstBlend", 0f); SetOpaqueFloat(value, "_ZWrite", 1f); Materials.Add(part.Diffuse, value); return value; } private static bool IsUsableArmorMaterial(Material material) { if ((Object)(object)material == (Object)null || (Object)(object)material.shader == (Object)null) { return false; } string text = ((Object)material.shader).name ?? string.Empty; if (text.IndexOf("particle", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("ui/", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("unlit", StringComparison.OrdinalIgnoreCase) >= 0) { return false; } if (material.HasProperty("_Color")) { if (!material.HasProperty("_MainTex")) { return material.HasProperty("_BaseMap"); } return true; } return false; } private static Material FindArmorMaterialTemplate(GameObject source) { ItemDrop val = (((Object)(object)source != (Object)null) ? source.GetComponent<ItemDrop>() : null); if ((Object)(object)val != (Object)null && val.m_itemData != null && val.m_itemData.m_shared != null) { FieldInfo fieldInfo = AccessTools.Field(typeof(SharedData), "m_armorMaterial"); Material val2 = (Material)((fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null); if (IsUsableArmorMaterial(val2)) { return val2; } } List<Material> list = new List<Material>(); if ((Object)(object)source != (Object)null) { Renderer[] componentsInChildren = source.GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { if ((Object)(object)val3 == (Object)null || val3.sharedMaterials == null) { continue; } Material[] sharedMaterials = val3.sharedMaterials; foreach (Material val4 in sharedMaterials) { if (IsUsableArmorMaterial(val4) && !list.Contains(val4)) { list.Add(val4); } } } } return list.FirstOrDefault(); } internal static void PrepareItem(GameObject item, string slot, GameObject source) { //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren; if ((Object)(object)template == (Object)null) { template = FindArmorMaterialTemplate(source); if (!((Object)(object)template != (Object)null)) { List<string> list = new List<string>(); if ((Object)(object)source != (Object)null) { componentsInChildren = source.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val != (Object)null) || val.sharedMaterials == null) { continue; } Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null) { list.Add(((Object)val2).name + " [" + (((Object)(object)val2.shader != (Object)null) ? ((Object)val2.shader).name : "no shader") + "]"); } } } } throw new InvalidOperationException("No usable opaque armor material found on source prefab. Materials: " + string.Join("; ", list.ToArray())); } Logger.CreateLogSource("NovaChitinArmor").LogInfo((object)("Using Valheim armor shader: " + ((Object)template.shader).name + " (material " + ((Object)template).name + ")")); } componentsInChildren = item.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } foreach (Transform item2 in item.transform) { Transform val3 = item2; if (((Object)val3).name == "attach" || ((Object)val3).name.StartsWith("attach_")) { ((Object)val3).name = "old_" + ((Object)val3).name; } } GameObject val4 = new GameObject("attach"); val4.transform.SetParent(item.transform, false); Part[] array = Load("m").Parts.Where((Part p) => p.Slot == slot).ToArray(); if (array.Length == 0) { throw new InvalidDataException("No converted mesh parts for equipment slot: " + slot); } Bounds bounds = array[0].Mesh.bounds; Part[] array2 = array; foreach (Part part in array2) { ((Bounds)(ref bounds)).Encapsulate(part.Mesh.bounds); } MeshFilter[] array3 = (from f in source.GetComponentsInChildren<MeshFilter>(true) where (Object)(object)f.sharedMesh != (Object)null && (Object)(object)((Component)f).GetComponent<MeshRenderer>() != (Object)null && ((Renderer)((Component)f).GetComponent<MeshRenderer>()).enabled select f).ToArray(); Bounds val5 = default(Bounds); bool flag = false; MeshFilter[] array4 = array3; foreach (MeshFilter val6 in array4) { Matrix4x4 val7 = source.transform.worldToLocalMatrix * ((Component)val6).transform.localToWorldMatrix; Bounds bounds2 = val6.sharedMesh.bounds; for (int num = 0; num < 8; num++) { Vector3 val8 = ((Matrix4x4)(ref val7)).MultiplyPoint3x4(((Bounds)(ref bounds2)).center + Vector3.Scale(((Bounds)(ref bounds2)).extents, new Vector3((float)(((num & 1) != 0) ? 1 : (-1)), (float)(((num & 2) != 0) ? 1 : (-1)), (float)(((num & 4) != 0) ? 1 : (-1))))); if (!flag) { ((Bounds)(ref val5))..ctor(val8, Vector3.zero); flag = true; } else { ((Bounds)(ref val5)).Encapsulate(val8); } } } if (slot != "Helmet" && array3.Length != 0) { array4 = array3; foreach (MeshFilter val9 in array4) { Mesh sharedMesh = val9.sharedMesh; Matrix4x4 val10 = source.transform.worldToLocalMatrix * ((Component)val9).transform.localToWorldMatrix; GameObject val11 = new GameObject("Chitin_FoldedGroundItem"); val11.transform.SetParent(val4.transform, false); val11.transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref val10)).GetColumn(3)); val11.transform.localRotation = ((Matrix4x4)(ref val10)).rotation; val11.transform.localScale = ((Matrix4x4)(ref val10)).lossyScale; val11.AddComponent<MeshFilter>().sharedMesh = sharedMesh; ((Renderer)val11.AddComponent<MeshRenderer>()).sharedMaterials = Enumerable.Repeat<Material>(MaterialFor(array[0]), sharedMesh.subMeshCount).ToArray(); } } else { float num2 = (flag ? Mathf.Max(new float[3] { ((Bounds)(ref val5)).size.x, ((Bounds)(ref val5)).size.y, ((Bounds)(ref val5)).size.z }) : 0.28f) * ((slot == "Helmet") ? 1.12f : 1f) / Mathf.Max(1E-06f, Mathf.Max(new float[3] { ((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).size.z })); array2 = array; foreach (Part part2 in array2) { GameObject val12 = new GameObject("ChitinMesh"); val12.transform.SetParent(val4.transform, false); val12.AddComponent<MeshFilter>().sharedMesh = part2.Mesh; ((Renderer)val12.AddComponent<MeshRenderer>()).sharedMaterial = MaterialFor(part2); val12.transform.localPosition = -((Bounds)(ref bounds)).center * num2; val12.transform.localScale = Vector3.one * num2; } val4.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); val4.transform.localPosition = (flag ? ((Bounds)(ref val5)).center : Vector3.zero); } ItemDrop component = item.GetComponent<ItemDrop>(); Texture2D val13 = Texture("icon_" + slot + ".png"); component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { Sprite.Create(val13, new Rect(0f, 0f, (float)((Texture)val13).width, (float)((Texture)val13).height), new Vector2(0.5f, 0.5f)) }; component.m_itemData.m_shared.m_armorMaterial = null; Slots[StableHash(((Object)item).name)] = slot; } internal static int StableHash(string text) { int num = 5381; int num2 = num; for (int i = 0; i < text.Length && text[i] != 0; i += 2) { num = ((num << 5) + num) ^ text[i]; if (i == text.Length - 1 || text[i + 1] == '\0') { break; } num2 = ((num2 << 5) + num2) ^ text[i + 1]; } return num + num2 * 1566083941; } internal static bool IsArmor(int hash) { return Slots.ContainsKey(hash); } internal static GameObject Attach(VisEquipment vis, int hash) { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Expected O, but got Unknown if (!Slots.TryGetValue(hash, out var slot) || (Object)(object)vis.m_bodyModel == (Object)null || (Object)(object)vis.m_bodyModel.rootBone == (Object)null) { return null; } string text = ((vis.GetModelIndex() == 1) ? "f" : "m"); Model model = Load(text); Dictionary<string, Transform> bones = (from b in vis.m_bodyModel.bones group b by ((Object)b).name).ToDictionary((IGrouping<string, Transform> g) => g.Key, (IGrouping<string, Transform> g) => g.First()); Transform value2; Transform[] bones2 = model.Bones.Select((string name) => (!bones.TryGetValue(name, out value2)) ? vis.m_bodyModel.rootBone : value2).ToArray(); GameObject val = new GameObject("NovaChitin_" + slot); val.transform.SetParent(((Component)vis.m_bodyModel).transform, false); if (slot == "Legs") { Part[] array = model.Parts.Where((Part p) => p.Slot == "Legs").ToArray(); if (!JoinedLegs.TryGetValue(model, out var value)) { List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<Vector4> list4 = new List<Vector4>(); List<BoneWeight> list5 = new List<BoneWeight>(); List<int[]> list6 = new List<int[]>(); Part[] array2 = array; foreach (Part part in array2) { int offset = list.Count; list.AddRange(part.Mesh.vertices); list2.AddRange(part.Mesh.normals); list3.AddRange(part.Mesh.uv); list4.AddRange(part.Mesh.tangents); list5.AddRange(part.Mesh.boneWeights); list6.Add(part.Mesh.triangles.Select((int i) => i + offset).ToArray()); } value = new Mesh { name = "Chitin_PantsAndBoots_" + text }; value.SetVertices(list); value.SetNormals(list2); value.SetUVs(0, list3); value.SetTangents(list4); value.boneWeights = list5.ToArray(); value.bindposes = array[0].Mesh.bindposes; value.subMeshCount = list6.Count; for (int num2 = 0; num2 < list6.Count; num2++) { value.SetTriangles(list6[num2], num2); } value.RecalculateBounds(); JoinedLegs.Add(model, value); } SkinnedMeshRenderer obj = val.AddComponent<SkinnedMeshRenderer>(); obj.sharedMesh = value; ((Renderer)obj).sharedMaterials = array.Select(MaterialFor).ToArray(); obj.rootBone = vis.m_bodyModel.rootBone; obj.bones = bones2; obj.quality = (SkinQuality)4; ((Renderer)obj).localBounds = AnimationBounds(vis, value); obj.updateWhenOffscreen = false; return val; } foreach (Part item in model.Parts.Where((Part p) => p.Slot == slot)) { GameObject val2 = new GameObject(((Object)item.Mesh).name); val2.transform.SetParent(val.transform, false); SkinnedMeshRenderer obj2 = val2.AddComponent<SkinnedMeshRenderer>(); obj2.sharedMesh = item.Mesh; ((Renderer)obj2).sharedMaterial = MaterialFor(item); obj2.rootBone = vis.m_bodyModel.rootBone; obj2.bones = bones2; obj2.quality = (SkinQuality)4; ((Renderer)obj2).localBounds = AnimationBounds(vis, item.Mesh); obj2.updateWhenOffscreen = false; } return val; } private static Bounds AnimationBounds(VisEquipment vis, Mesh mesh) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) Bounds localBounds = ((Renderer)vis.m_bodyModel).localBounds; ((Bounds)(ref localBounds)).Encapsulate(mesh.bounds); ((Bounds)(ref localBounds)).Expand(((Bounds)(ref localBounds)).size * 0.5f); return localBounds; } internal static void UpdateLegFit(VisEquipment vis) { //IL_0117: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vis.m_bodyModel == (Object)null || LegsHash == null || !IsArmor((int)LegsHash.GetValue(vis))) { return; } Transform val = ((Component)vis.m_bodyModel).transform.Find("NovaChitin_Legs"); if ((Object)(object)val == (Object)null) { return; } SkinnedMeshRenderer component = ((Component)val).GetComponent<SkinnedMeshRenderer>(); if ((Object)(object)component == (Object)null) { return; } Model key = Load((vis.GetModelIndex() == 1) ? "f" : "m"); if (!JoinedLegs.TryGetValue(key, out var value)) { return; } string value2; bool num = ChestHash != null && Slots.TryGetValue((int)ChestHash.GetValue(vis), out value2) && value2 == "Chest"; Mesh value3 = value; if (num && !CoveredLegs.TryGetValue(value, out value3)) { value3 = Object.Instantiate<Mesh>(value); ((Object)value3).name = ((Object)value).name + "_UnderChest"; Vector3[] vertices = value3.vertices; for (int i = 0; i < vertices.Length; i++) { Vector3 val2 = vertices[i]; float num2 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.0107f, 0.0121f, val2.z)); float num3 = Mathf.Lerp(1f, 0.55f, num2); val2.x *= num3; val2.y = 0.00015f + (val2.y - 0.00015f) * num3; vertices[i] = val2; } value3.vertices = vertices; value3.RecalculateNormals(); value3.RecalculateTangents(); value3.RecalculateBounds(); CoveredLegs.Add(value, value3); } if ((Object)(object)component.sharedMesh != (Object)(object)value3) { component.sharedMesh = value3; } } internal static void UpdateUtilityVisibility(VisEquipment vis) { if (!(ChestHash != null) || (int)ChestHash.GetValue(vis) != StableHash("ChitinChest") || !(UtilityHash != null) || (int)UtilityHash.GetValue(vis) != StableHash("BeltStrength")) { if (HiddenUtilities.TryGetValue(vis, out var value)) { value.Restore(); HiddenUtilities.Remove(vis); } return; } List<GameObject> list = ((UtilityInstances != null) ? (UtilityInstances.GetValue(vis) as List<GameObject>) : null); if (list == null) { return; } HiddenUtility value2 = HiddenUtilities.GetValue(vis, (VisEquipment key) => new HiddenUtility()); bool flag = list.Count == value2.Roots.Count; if (flag) { foreach (GameObject item in list) { if (!value2.Roots.Contains(item)) { flag = false; break; } } } if (flag) { return; } value2.Restore(); foreach (GameObject item2 in list) { value2.Roots.Add(item2); if (!((Object)(object)item2 == (Object)null)) { Renderer[] componentsInChildren = item2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { value2.Renderers[val] = val.enabled; val.enabled = false; } } } } private static void AttachLining(VisEquipment vis, GameObject root) { //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //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_0327: Unknown result type (might be due to invalid IL or missing references) Mesh mesh = vis.m_models[vis.GetModelIndex()].m_mesh; int instanceID = ((Object)mesh).GetInstanceID(); if (!Linings.TryGetValue(instanceID, out var value)) { BoneWeight[] boneWeights = mesh.boneWeights; Vector3[] vertices = mesh.vertices; Transform[] bones = vis.m_bodyModel.bones; bool[] array = new bool[boneWeights.Length]; for (int i = 0; i < boneWeights.Length; i++) { BoneWeight val = boneWeights[i]; int[] array2 = new int[4] { ((BoneWeight)(ref val)).boneIndex0, ((BoneWeight)(ref val)).boneIndex1, ((BoneWeight)(ref val)).boneIndex2, ((BoneWeight)(ref val)).boneIndex3 }; float[] array3 = new float[4] { ((BoneWeight)(ref val)).weight0, ((BoneWeight)(ref val)).weight1, ((BoneWeight)(ref val)).weight2, ((BoneWeight)(ref val)).weight3 }; float num = 0f; for (int j = 0; j < 4; j++) { if (((Object)bones[array2[j]]).name.Contains("Arm")) { num += array3[j]; } } array[i] = num > 0.1f && Mathf.Abs(vertices[i].x) > 0.0024f; } List<int> list = new List<int>(); int[] triangles = mesh.triangles; for (int k = 0; k < triangles.Length; k += 3) { if (array[triangles[k]] && array[triangles[k + 1]] && array[triangles[k + 2]]) { list.Add(triangles[k]); list.Add(triangles[k + 1]); list.Add(triangles[k + 2]); } } Mesh obj = MeshCut.Clip(mesh, list.ToArray(), 0.0106f, above: true); value = MeshCut.Clip(obj, obj.triangles, 0.01685f, above: false); Object.Destroy((Object)(object)obj); ((Object)value).name = "Chitin_NativeFabricLining"; Linings.Add(instanceID, value); } if ((Object)(object)liningMaterial == (Object)null) { liningMaterial = new Material(template) { name = "Chitin_DarkFabricLining", mainTexture = (Texture)(object)Texture2D.whiteTexture, renderQueue = 2000 }; string[] array4 = new string[2] { "_MainTex", "_BaseMap" }; foreach (string text in array4) { if (liningMaterial.HasProperty(text)) { liningMaterial.SetTexture(text, (Texture)(object)Texture2D.whiteTexture); } } array4 = new string[2] { "_BumpMap", "_NormalMap" }; foreach (string text2 in array4) { if (liningMaterial.HasProperty(text2)) { liningMaterial.SetTexture(text2, (Texture)null); } } liningMaterial.DisableKeyword("_NORMALMAP"); array4 = new string[2] { "_Color", "_BaseColor" }; foreach (string text3 in array4) { if (liningMaterial.HasProperty(text3)) { liningMaterial.SetColor(text3, new Color(0.24f, 0.16f, 0.1f, 1f)); } } SetOpaqueFloat(liningMaterial, "_Glossiness", 0f); SetOpaqueFloat(liningMaterial, "_Metallic", 0f); SetOpaqueFloat(liningMaterial, "_Smoothness", 0f); SetOpaqueFloat(liningMaterial, "_Mode", 0f); SetOpaqueFloat(liningMaterial, "_ZWrite", 1f); SetOpaqueFloat(liningMaterial, "_SrcBlend", 1f); SetOpaqueFloat(liningMaterial, "_DstBlend", 0f); liningMaterial.SetOverrideTag("RenderType", "Opaque"); array4 = new string[3] { "_ALPHATEST_ON", "_ALPHABLEND_ON", "_ALPHAPREMULTIPLY_ON" }; foreach (string text4 in array4) { liningMaterial.DisableKeyword(text4); } } GameObject val2 = new GameObject("Chitin_FabricLining"); val2.transform.SetParent(root.transform, false); SkinnedMeshRenderer obj2 = val2.AddComponent<SkinnedMeshRenderer>(); obj2.sharedMesh = value; ((Renderer)obj2).sharedMaterial = liningMaterial; obj2.bones = vis.m_bodyModel.bones; obj2.rootBone = vis.m_bodyModel.rootBone; obj2.quality = (SkinQuality)4; ((Renderer)obj2).localBounds = new Bounds(Vector3.zero, Vector3.one * 0.05f); obj2.updateWhenOffscreen = true; } internal static bool HasBodyMask(VisEquipment vis, int modelIndex) { if ((Object)(object)vis.m_bodyModel == (Object)null || vis.m_models == null || modelIndex < 0 || modelIndex >= vis.m_models.Length || vis.m_models[modelIndex] == null) { return false; } Mesh sharedMesh = vis.m_bodyModel.sharedMesh; if ((Object)(object)sharedMesh != (Object)null && MaskSources.TryGetValue(sharedMesh, out var value)) { return (Object)(object)value == (Object)(object)vis.m_models[modelIndex].m_mesh; } return false; } internal static void RefreshCustomAttachments(VisEquipment vis) { FieldInfo[] array = new FieldInfo[4] { ChestHash, LegsHash, HelmetHash, ShoulderHash }; foreach (FieldInfo fieldInfo in array) { if (!(fieldInfo == null)) { int num = (int)fieldInfo.GetValue(vis); if (IsArmor(num) || num == CapeHash) { fieldInfo.SetValue(vis, int.MinValue); } } } } internal static void MaskBody(VisEquipment vis) { //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)vis).GetComponentInParent<Player>() == (Object)null || !vis.m_isPlayer || (Object)(object)vis.m_bodyModel == (Object)null || vis.m_models == null || vis.m_models.Length == 0) { return; } int modelIndex = vis.GetModelIndex(); if (modelIndex < 0 || modelIndex >= vis.m_models.Length || vis.m_models[modelIndex] == null) { return; } Mesh mesh = vis.m_models[modelIndex].m_mesh; if ((Object)(object)mesh == (Object)null || !mesh.isReadable) { return; } int num = 0; if (ChestHash != null && IsArmor((int)ChestHash.GetValue(vis))) { num |= 1; } if (LegsHash != null && IsArmor((int)LegsHash.GetValue(vis))) { num |= 2; } if (HelmetHash != null && IsArmor((int)HelmetHash.GetValue(vis))) { num |= 4; } if (num == 0) { Mesh sharedMesh = vis.m_bodyModel.sharedMesh; if ((Object)(object)sharedMesh != (Object)null && MaskSources.TryGetValue(sharedMesh, out var value) && (Object)(object)value == (Object)(object)mesh) { vis.m_bodyModel.sharedMesh = mesh; } return; } (Mesh, int) key = (mesh, num); if (!Masks.TryGetValue(key, out var value2)) { BoneWeight[] boneWeights = mesh.boneWeights; Vector3[] sourceVertices = mesh.vertices; Transform[] bones = vis.m_bodyModel.bones; if (boneWeights.Length != sourceVertices.Length || boneWeights.Length != mesh.vertexCount || bones == null || bones.Length == 0 || mesh.normals.Length != mesh.vertexCount || mesh.uv.Length != mesh.vertexCount || mesh.tangents.Length != mesh.vertexCount) { return; } for (int i = 0; i < mesh.subMeshCount; i++) { if (mesh.GetTriangles(i).Any((int index) => index < 0 || index >= sourceVertices.Length)) { return; } } value2 = Object.Instantiate<Mesh>(mesh); ((Object)value2).name = "ChitinBodyMask"; BoneWeight[] array = boneWeights; Transform[] array2 = bones; bool[] array3 = new bool[array.Length]; Vector3[] array4 = sourceVertices; for (int num2 = 0; num2 < array.Length; num2++) { BoneWeight val = array[num2]; int num3 = ((BoneWeight)(ref val)).boneIndex0; float num4 = ((BoneWeight)(ref val)).weight0; if (((BoneWeight)(ref val)).weight1 > num4) { num3 = ((BoneWeight)(ref val)).boneIndex1; num4 = ((BoneWeight)(ref val)).weight1; } if (((BoneWeight)(ref val)).weight2 > num4) { num3 = ((BoneWeight)(ref val)).boneIndex2; num4 = ((BoneWeight)(ref val)).weight2; } if (((BoneWeight)(ref val)).weight3 > num4) { num3 = ((BoneWeight)(ref val)).boneIndex3; } if (array2 != null && array2.Length != 0 && num3 >= 0 && num3 < array2.Length && !((Object)(object)array2[num3] == (Object)null)) { string name = ((Object)array2[num3]).name; bool flag = name == "Head" || name == "Jaw"; bool flag2 = name == "Hips" || name.Contains("Leg") || name.Contains("Foot") || name.Contains("Toe"); bool flag3 = name.StartsWith("Spine") || name.Contains("Arm") || name.Contains("Hand") || name.Contains("Shoulder"); array3[num2] = (flag && (num & 4) != 0) || (flag2 && (num & 2) != 0) || (flag3 && (num & 1) != 0); if ((num & 1) != 0 && name == "Hips") { array3[num2] = true; } if ((num & 2) != 0 && flag2) { array3[num2] = true; } if ((num & 2) != 0 && Mathf.Abs(array4[num2].x) < 0.0033f && array4[num2].z >= 0.008f && array4[num2].z < 0.01195f) { array3[num2] = true; } if (name == "Neck" && (num & 4) != 0) { array3[num2] = true; } } } for (int num5 = 0; num5 < value2.subMeshCount; num5++) { int[] triangles = mesh.GetTriangles(num5); List<int> list = new List<int>(); for (int num6 = 0; num6 < triangles.Length; num6 += 3) { if (!array3[triangles[num6]] || !array3[triangles[num6 + 1]] || !array3[triangles[num6 + 2]]) { list.Add(triangles[num6]); list.Add(triangles[num6 + 1]); list.Add(triangles[num6 + 2]); } } value2.SetTriangles(list, num5); } if ((num & 2) != 0) { Mesh obj = MeshCut.ClipWaist(value2, 0.01195f); Object.Destroy((Object)(object)value2); value2 = obj; } if ((num & 1) != 0) { Mesh obj2 = MeshCut.ClipWaist(value2, 0.0174f, neckOnly: true); Object.Destroy((Object)(object)value2); value2 = obj2; } Masks.Add(key, value2); MaskSources.Add(value2, mesh); } if ((Object)(object)vis.m_bodyModel.sharedMesh != (Object)(object)value2) { vis.m_bodyModel.sharedMesh = value2; } } } [HarmonyPatch(typeof(VisEquipment), "AttachArmor")] internal static class ArmorAttachmentPatch { private static bool Prefix(VisEquipment __instance, int itemHash, ref List<GameObject> __result) { if (!ArmorVisuals.IsArmor(itemHash)) { return true; } GameObject val = ArmorVisuals.Attach(__instance, itemHash); __result = (((Object)(object)val == (Object)null) ? new List<GameObject>() : new List<GameObject> { val }); return false; } } [HarmonyPatch(typeof(VisEquipment), "AttachItem")] internal static class HelmetAttachmentPatch { private static bool Prefix(VisEquipment __instance, int itemHash, ref GameObject __result) { if (!ArmorVisuals.IsArmor(itemHash)) { return true; } __result = ArmorVisuals.Attach(__instance, itemHash); return false; } } [HarmonyPatch(typeof(VisEquipment), "UpdateBaseModel")] internal static class NovaBaseModelPatch { private static bool Prefix(VisEquipment __instance, int ___m_currentModelIndex, out int __state) { __state = ___m_currentModelIndex; if (__instance.m_models != null && __instance.m_models.Length != 0 && ___m_currentModelIndex == __instance.GetModelIndex()) { return !ArmorVisuals.HasBodyMask(__instance, ___m_currentModelIndex); } return true; } private static void Postfix(VisEquipment __instance, int ___m_currentModelIndex, int __state) { if (___m_currentModelIndex != __state) { ArmorVisuals.RefreshCustomAttachments(__instance); } } } [HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")] internal static class ArmorBodyMaskPatch { private static void Postfix(VisEquipment __instance) { ArmorVisuals.MaskBody(__instance); ArmorVisuals.UpdateLegFit(__instance); ArmorVisuals.UpdateUtilityVisibility(__instance); } } internal static class ChitinCosts { private static readonly ConditionalWeakTable<Requirement, int[]> Amounts = new ConditionalWeakTable<Requirement, int[]>(); internal static void Set(Requirement requirement, int[] amounts) { Amounts.Remove(requirement); Amounts.Add(requirement, amounts); } internal static bool TryGet(Requirement req, int quality, out int amount) { if (Amounts.TryGetValue(req, out var value)) { amount = value[Math.Max(0, Math.Min(3, quality - 1))]; return true; } amount = 0; return false; } } [HarmonyPatch] internal static class ChitinRequirementPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Requirement), "GetAmount", new Type[1] { typeof(int) }, (Type[])null); } private static void Postfix(Requirement __instance, int __0, ref int __result) { if (ChitinCosts.TryGet(__instance, __0, out var amount)) { __result = amount; } } } internal static class CrimsonCape { internal const string ItemName = "ChitinCape"; private static Mesh capeMesh; private static Mesh femaleCapeMesh; private static byte[] clothFlags; private static Material capeMaterial; private static Texture2D capeTexture; private static Sprite icon; private static readonly Color CapeColor = new Color(0.65f, 0.4f, 0.455f, 1f); private static Stream Resource(string name) { return typeof(CrimsonCape).Assembly.GetManifestResourceStream("NCA." + name) ?? throw new FileNotFoundException(name); } private static Texture2D LoadTexture() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if ((Object)(object)capeTexture != (Object)null) { return capeTexture; } using (Stream stream = Resource("cape_texture.png")) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); capeTexture = new Texture2D(2, 2, (TextureFormat)4, true); ImageConversion.LoadImage(capeTexture, memoryStream.ToArray()); ((Texture)capeTexture).filterMode = (FilterMode)1; ((Texture)capeTexture).wrapMode = (TextureWrapMode)1; ((Texture)capeTexture).anisoLevel = 2; } return capeTexture; } internal static Mesh LoadMesh(bool female = false) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown if (female ? ((Object)(object)femaleCapeMesh != (Object)null) : ((Object)(object)capeMesh != (Object)null)) { if (!female) { return capeMesh; } return femaleCapeMesh; } using (BinaryReader binaryReader = new BinaryReader(Resource(female ? "cape_f.bin" : "cape.bin"))) { if (binaryReader.ReadInt32() != 1346587715) { throw new InvalidDataException("Cape data"); } Matrix4x4[] array = (Matrix4x4[])(object)new Matrix4x4[binaryReader.ReadInt32()]; for (int i = 0; i < array.Length; i++) { for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { ((Matrix4x4)(ref array[i]))[j, k] = binaryReader.ReadSingle(); } } } int num = binaryReader.ReadInt32(); Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector2[] array3 = (Vector2[])(object)new Vector2[num]; BoneWeight[] array4 = (BoneWeight[])(object)new BoneWeight[num]; for (int l = 0; l < num; l++) { array2[l] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[l] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int num2 = l; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).weight0 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).boneIndex1 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).weight1 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).boneIndex2 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).weight2 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).boneIndex3 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).weight3 = binaryReader.ReadSingle(); array4[num2] = val; } int[] array5 = new int[binaryReader.ReadInt32()]; for (int m = 0; m < array5.Length; m++) { array5[m] = binaryReader.ReadInt32(); } Mesh val2 = new Mesh { name = (female ? "Chitin_CrimsonCape_Female" : "Chitin_CrimsonCape"), vertices = array2, uv = array3, boneWeights = array4, bindposes = array, triangles = array5 }; val2.RecalculateNormals(); val2.RecalculateTangents(); val2.RecalculateBounds(); if (female) { femaleCapeMesh = val2; } else { capeMesh = val2; } using Stream stream = Resource("cape_cloth.bin"); clothFlags = new byte[num]; if (stream.Read(clothFlags, 0, num) != num) { throw new InvalidDataException("Cape cloth flags"); } } if (!female) { return capeMesh; } return femaleCapeMesh; } private static Sprite LoadIcon() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)icon != (Object)null) { return icon; } using (Stream stream = Resource("icon_Cape.png")) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, memoryStream.ToArray()); ((Texture)val).filterMode = (FilterMode)1; icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); ((Object)icon).name = "Chitin_CrimsonCape_Icon"; } return icon; } private static void Prepare(GameObject item, ObjectDB db) { //IL_0073: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) SkinnedMeshRenderer val = item.GetComponentsInChildren<SkinnedMeshRenderer>(true).First((SkinnedMeshRenderer r) => (Object)(object)r.sharedMesh != (Object)null); if ((Object)(object)((Component)val).GetComponent<NovaCapeSimulation>() == (Object)null) { ((Component)val).gameObject.AddComponent<NovaCapeSimulation>(); } Mesh val2 = LoadMesh(); if (val.bones.Length != val2.bindposes.Length) { throw new InvalidDataException("Deer cape skeleton mismatch"); } val.sharedMesh = val2; Bounds bounds = val2.bounds; Vector3 center = ((Bounds)(ref bounds)).center; bounds = val2.bounds; ((Renderer)val).localBounds = new Bounds(center, ((Bounds)(ref bounds)).size + Vector3.one * 0.006f); MagicaCloth component = ((Component)val).GetComponent<MagicaCloth>(); if ((Object)(object)component == (Object)null) { throw new InvalidDataException("Missing native deer cape cloth"); } ClothSerializeData2 serializeData = component.GetSerializeData2(); if (serializeData.initData == null || !serializeData.initData.HasData()) { throw new InvalidDataException("Missing native deer cape rest pose"); } foreach (RenderSetupSerializeData clothSetupData in serializeData.initData.clothSetupDataList) { clothSetupData.originalMesh = val2; clothSetupData.vertexCount = val2.vertexCount; } serializeData.preBuildData = new PreBuildSerializeData { enabled = false }; Vector3[] vertices = val2.vertices; SelectionData val3 = new SelectionData(vertices.Length); for (int num = 0; num < vertices.Length; num++) { Vector3 val4 = vertices[num]; val3.positions[num] = new float3(val4.x, val4.y, val4.z); val3.attributes[num] = new VertexAttribute(clothFlags[num]); } val3.maxConnectionDistance = 0.002921007f; val3.userEdit = true; serializeData.selectionData = val3; serializeData.vertexAttributeList = new List<VertexAttribute[]> { val3.attributes }; if ((Object)(object)capeMaterial == (Object)null) { GameObject val5 = db.m_items.Find((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == "CapeLox"); SkinnedMeshRenderer val6 = (((Object)(object)val5 != (Object)null) ? ((IEnumerable<SkinnedMeshRenderer>)val5.GetComponentsInChildren<SkinnedMeshRenderer>(true)).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer r) => (Object)(object)((Renderer)r).sharedMaterial != (Object)null)) : null); capeMaterial = new Material(((Object)(object)val6 != (Object)null) ? ((Renderer)val6).sharedMaterial : ((Renderer)val).sharedMaterial) { name = "Chitin_ShortCrimsonCape", color = Color.white }; string[] array = new string[2] { "_MainTex", "_BaseMap" }; foreach (string text in array) { if (capeMaterial.HasProperty(text)) { capeMaterial.SetTexture(text, (Texture)(object)LoadTexture()); capeMaterial.SetTextureScale(text, new Vector2(2.5f, 1f)); capeMaterial.SetTextureOffset(text, Vector2.zero); } } array = new string[2] { "_BumpMap", "_NormalMap" }; foreach (string text2 in array) { if (capeMaterial.HasProperty(text2)) { capeMaterial.SetTexture(text2, (Texture)null); } } capeMaterial.DisableKeyword("_NORMALMAP"); array = new string[5] { "_AddRain", "_Glossiness", "_Metallic", "_MetalGloss", "_UseGlossmap" }; foreach (string text3 in array) { if (capeMaterial.HasProperty(text3)) { capeMaterial.SetFloat(text3, 0f); } } capeMaterial.DisableKeyword("_ADDRAIN_ON"); capeMaterial.DisableKeyword("_METALLICGLOSSMAP"); if (capeMaterial.HasProperty("_Cutoff")) { capeMaterial.SetFloat("_Cutoff", 0.5f); } if (capeMaterial.HasProperty("_Mode")) { capeMaterial.SetFloat("_Mode", 1f); } if (capeMaterial.HasProperty("_Cull")) { capeMaterial.SetFloat("_Cull", 0f); } capeMaterial.EnableKeyword("_ALPHATEST_ON"); capeMaterial.DisableKeyword("_ALPHABLEND_ON"); capeMaterial.DisableKeyword("_ALPHAPREMULTIPLY_ON"); capeMaterial.SetOverrideTag("RenderType", "TransparentCutout"); capeMaterial.renderQueue = 2450; } ((Renderer)val).sharedMaterials = ((Renderer)val).sharedMaterials.Select((Material m) => capeMaterial).ToArray(); MeshRenderer[] componentsInChildren = item.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val7 in componentsInChildren) { if ((Object)(object)((Component)val7).GetComponent<MeshFilter>() != (Object)null) { ((Renderer)val7).sharedMaterials = ((IEnumerable<Material>)((Renderer)val7).sharedMaterials).Select((Func<Material, Material>)((Material m) => new Material(m) { name = "Chitin_CrimsonCape_Dropped", color = CapeColor })).ToArray(); } } } internal static bool Register(ObjectDB db, Transform root, CraftingStation preferredStation = null) { GameObject val = db.m_items.Find((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == "ChitinCape"); bool flag = false; if ((Object)(object)val == (Object)null) { GameObject val2 = db.m_items.Find((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == "CapeDeerHide"); if ((Object)(object)val2 == (Object)null) { return false; } val = Object.Instantiate<GameObject>(val2, root); ((Object)val).name = "ChitinCape"; val.SetActive(true); try { ItemDrop component = val.GetComponent<ItemDrop>(); ItemDrop component2 = val2.GetComponent<ItemDrop>(); component.m_itemData = component2.m_itemData.Clone(); component.m_itemData.m_shared = Plugin.CopySharedData(component2.m_itemData.m_shared); component.m_itemData.m_shared.m_name = "$nca_cape"; component.m_itemData.m_shared.m_description = "$nca_cape_desc"; component.m_itemData.m_shared.m_maxQuality = 4; component.m_itemData.m_shared.m_equipStatusEffect = (ArmorConfig.ColdProtection.Value ? WeatherProtection.CapeEffect() : null); component.m_itemData.m_dropPrefab = val; if (Plugin.HasGraphics) { Prepare(val, db); component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { LoadIcon() }; } db.m_items.Add(val); flag = true; } catch (Exception ex) { Object.Destroy((Object)(object)val); Logger.CreateLogSource("NovaChitinArmor").LogError((object)("Crimson cape: " + ex)); return false; } } Plugin.RegisterNetworkPrefab(val); Recipe val3 = db.m_recipes?.Find((Recipe r) => (Object)(object)r != (Object)null && ((Object)r).name == "Recipe_ChitinCape"); bool num = (Object)(object)val3 == (Object)null; if (num) { val3 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val3).name = "Recipe_ChitinCape"; val3.m_item = val.GetComponent<ItemDrop>(); val3.m_amount = 1; val3.m_enabled = false; } flag |= ArmorConfig.Apply(db, val3, "ChitinCape", preferredStation); if (num && val3.m_enabled) { db.m_recipes.Add(val3); flag = true; } return flag; } } internal static class MeshCut { private struct V { public Vector3 p; public Vector3 n; public Vector2 uv; public Vector4 tangent; public BoneWeight w; } private static BoneWeight Blend(BoneWeight a, BoneWeight b, float t) { //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) Dictionary<int, float> d = new Dictionary<int, float>(); Action<int, float> obj = delegate(int i, float w) { if (!d.ContainsKey(i)) { d[i] = 0f; } d[i] += w; }; obj(((BoneWeight)(ref a)).boneIndex0, ((BoneWeight)(ref a)).weight0 * (1f - t)); obj(((BoneWeight)(ref a)).boneIndex1, ((BoneWeight)(ref a)).weight1 * (1f - t)); obj(((BoneWeight)(ref a)).boneIndex2, ((BoneWeight)(ref a)).weight2 * (1f - t)); obj(((BoneWeight)(ref a)).boneIndex3, ((BoneWeight)(ref a)).weight3 * (1f - t)); obj(((BoneWeight)(ref b)).boneIndex0, ((BoneWeight)(ref b)).weight0 * t); obj(((BoneWeight)(ref b)).boneIndex1, ((BoneWeight)(ref b)).weight1 * t); obj(((BoneWeight)(ref b)).boneIndex2, ((BoneWeight)(ref b)).weight2 * t); obj(((BoneWeight)(ref b)).boneIndex3, ((BoneWeight)(ref b)).weight3 * t); KeyValuePair<int, float>[] array = d.OrderByDescending((KeyValuePair<int, float> x) => x.Value).Take(4).ToArray(); float num = array.Sum((KeyValuePair<int, float> x) => x.Value); int[] array2 = new int[4]; float[] array3 = new float[4]; for (int num2 = 0; num2 < array.Length; num2++) { array2[num2] = array[num2].Key; array3[num2] = array[num2].Value / num; } BoneWeight result = default(BoneWeight); ((BoneWeight)(ref result)).boneIndex0 = array2[0]; ((BoneWeight)(ref result)).weight0 = array3[0]; ((BoneWeight)(ref result)).boneIndex1 = array2[1]; ((BoneWeight)(ref result)).weight1 = array3[1]; ((BoneWeight)(ref result)).boneIndex2 = array2[2]; ((BoneWeight)(ref result)).weight2 = array3[2]; ((BoneWeight)(ref result)).boneIndex3 = array2[3]; ((BoneWeight)(ref result)).weight3 = array3[3]; return result; } private static V Lerp(V a, V b, float t) { //IL_000b: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_004b: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0088: Unknown result type (might be due to invalid IL or missing references) V result = new V { p = Vector3.Lerp(a.p, b.p, t) }; Vector3 val = Vector3.Lerp(a.n, b.n, t); result.n = ((Vector3)(ref val)).normalized; result.uv = Vector2.Lerp(a.uv, b.uv, t); result.tangent = Vector4.Lerp(a.tangent, b.tangent, t); result.w = Blend(a.w, b.w, t); return result; } internal static Mesh Clip(Mesh src, int[] triangles, float height, bool above, bool rim = false, bool trunkOnly = false, bool neckOnly = false) { //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00a9: 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_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_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) Vector3[] vertices = src.vertices; Vector3[] normals = src.normals; Vector2[] uv = src.uv; Vector4[] tangents = src.tangents; BoneWeight[] boneWeights = src.boneWeights; List<V> verts = new List<V>(); List<int> indices = new List<int>(); Action<V, V, V> action = delegate(V a, V item2, V c) { int count = verts.Count; verts.Add(a); verts.Add(item2); verts.Add(c); indices.Add(count); indices.Add(count + 1); indices.Add(count + 2); }; for (int num = 0; num < triangles.Length; num += 3) { List<V> list = new List<V>(); for (int num2 = 0; num2 < 3; num2++) { int num3 = triangles[num + num2]; list.Add(new V { p = vertices[num3], n = normals[num3], uv = uv[num3], tangent = tangents[num3], w = boneWeights[num3] }); } if (neckOnly && list.Any((V x) => Mathf.Abs(x.p.x) >= 0.0035f || x.p.z < 0.014f)) { action(list[0], list[1], list[2]); continue; } if (trunkOnly && list.Any((V x) => Mathf.Abs(x.p.x) >= 0.0035f)) { action(list[0], list[1], list[2]); continue; } List<V> list2 = new List<V>(); List<V> list3 = new List<V>(); for (int num4 = 0; num4 < 3; num4++) { V v = list[num4]; V b = list[(num4 + 1) % 3]; bool num5 = (above ? (v.p.z >= height) : (v.p.z <= height)); bool flag = (above ? (b.p.z >= height) : (b.p.z <= height)); if (num5) { list2.Add(v); } if (num5 != flag) { V item = Lerp(v, b, (height - v.p.z) / (b.p.z - v.p.z)); item.p.z = height; list2.Add(item); list3.Add(item); } } for (int num6 = 1; num6 + 1 < list2.Count; num6++) { action(list2[0], list2[num6], list2[num6 + 1]); } if (rim && list3.Count == 2) { V v2 = list3[0]; V v3 = list3[1]; V v4 = v2; V arg = v3; v4.p.x *= 0.94f; v4.p.y *= 0.94f; arg.p.x *= 0.94f; arg.p.y *= 0.94f; v4.p.z -= 0.00012f; arg.p.z -= 0.00012f; action(v2, v3, v4); action(v3, arg, v4); action(v4, v3, v2); action(v4, arg, v3); } } Mesh val = new Mesh { name = ((Object)src).name + "_Clipped", indexFormat = (IndexFormat)1, vertices = verts.Select((V v5) => v5.p).ToArray(), normals = verts.Select((V v5) => v5.n).ToArray(), uv = verts.Select((V v5) => v5.uv).ToArray(), tangents = verts.Select((V v5) => v5.tangent).ToArray(), boneWeights = verts.Select((V v5) => v5.w).ToArray(), bindposes = src.bindposes, triangles = indices.ToArray() }; val.RecalculateBounds(); return val; } internal static Mesh ClipWaist(Mesh src, float height, bool neckOnly = false) { //IL_00db: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<Vector4> list4 = new List<Vector4>(); List<BoneWeight> list5 = new List<BoneWeight>(); List<int[]> list6 = new List<int[]>(); for (int i = 0; i < src.subMeshCount; i++) { Mesh val = Clip(src, src.GetTriangles(i), height, above: true, rim: false, !neckOnly, neckOnly); int offset = list.Count; list.AddRange(val.vertices); list2.AddRange(val.normals); list3.AddRange(val.uv); list4.AddRange(val.tangents); list5.AddRange(val.boneWeights); list6.Add(val.triangles.Select((int x) => x + offset).ToArray()); Object.Destroy((Object)(object)val); } Mesh val2 = new Mesh { name = ((Object)src).name + "_Waist", indexFormat = (IndexFormat)1 }; val2.SetVertices(list); val2.SetNormals(list2); val2.SetUVs(0, list3); val2.SetTangents(list4); val2.boneWeights = list5.ToArray(); val2.bindposes = src.bindposes; val2.subMeshCount = list6.Count; for (int num = 0; num < list6.Count; num++) { val2.SetTriangles(list6[num], num); } val2.RecalculateBounds(); return val2; } internal static bool Arm(BoneWeight w, string[] names) { float num = 0f; int[] array = new int[4] { ((BoneWeight)(ref w)).boneIndex0, ((BoneWeight)(ref w)).boneIndex1, ((BoneWeight)(ref w)).boneIndex2, ((BoneWeight)(ref w)).boneIndex3 }; float[] array2 = new float[4] { ((BoneWeight)(ref w)).weight0, ((BoneWeight)(ref w)).weight1, ((BoneWeight)(ref w)).weight2, ((BoneWeight)(ref w)).weight3 }; for (int i = 0; i < 4; i++) { string text = names[array[i]]; if (text.Contains("Arm") || text.Contains("Hand") || text.Contains("Shoulder")) { num += array2[i]; } } return num > 0.45f; } } internal static class ModLocalization { private static TextAsset text; internal static void Install(Localization localization, string language = null) { //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_0061: Expected O, but got Unknown if (localization == null) { return; } if ((Object)(object)text == (Object)null) { using Stream stream = typeof(ModLocalization).Assembly.GetManifestResourceStream("NCA.localization.csv"); using StreamReader streamReader = new StreamReader(stream ?? throw new FileNotFoundException("NCA.localization.csv"), Encoding.UTF8); text = new TextAsset(streamReader.ReadToEnd()) { name = "NovaChitinArmor_Localization" }; } if (!localization.LoadCSV(text, language ?? localization.GetSelectedLanguage())) { localization.LoadCSV(text, "English"); } } } [HarmonyPatch(typeof(Localization), "SetupLanguage")] internal static class NovaLanguagePatch { private static void Postfix(Localization __instance, string language) { ModLocalization.Install(__instance, language); } } internal sealed class NovaCapeSimulation : MonoBehaviour { } [HarmonyPatch(typeof(VisEquipment), "SetupCloth")] internal static class NovaCapeEquipPatch { private static void Prefix(VisEquipment __instance, GameObject item) { //IL_0074: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) NovaCapeSimulation[] componentsInChildren = item.GetComponentsInChildren<NovaCapeSimulation>(true); foreach (NovaCapeSimulation obj in componentsInChildren) { SkinnedMeshRenderer component = ((Component)obj).GetComponent<SkinnedMeshRenderer>(); MagicaCloth component2 = ((Component)obj).GetComponent<MagicaCloth>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { continue; } Mesh val = (component.sharedMesh = CrimsonCape.LoadMesh(__instance.GetModelIndex() == 1)); component.bones = __instance.m_bodyModel.bones; component.rootBone = __instance.m_bodyModel.rootBone; Bounds bounds = val.bounds; Vector3 center = ((Bounds)(ref bounds)).center; bounds = val.bounds; ((Renderer)component).localBounds = new Bounds(center, ((Bounds)(ref bounds)).size + Vector3.one * 0.006f); ClothSerializeData2 serializeData = component2.GetSerializeData2(); foreach (RenderSetupSerializeData clothSetupData in serializeData.initData.clothSetupDataList) { clothSetupData.originalMesh = val; clothSetupData.vertexCount = val.vertexCount; } Vector3[] vertices = val.vertices; for (int j = 0; j < vertices.Length; j++) { serializeData.selectionData.positions[j] = new float3(vertices[j].x, vertices[j].y, vertices[j].z); } } } } [HarmonyPatch(typeof(MagicaCloth), "BuildAndRun")] internal static class NovaCapeCollisionPatch { internal static bool IsLeg(Transform transform) { Transform val = transform; while ((Object)(object)val != (Object)null) { if (((Object)val).name == "LeftUpLeg" || ((Object)val).name == "RightUpLeg" || ((Object)val).name == "LeftLeg" || ((Object)val).name == "RightLeg" || ((Object)val).name == "LeftFoot" || ((Object)val).name == "RightFoot" || ((Object)val).name.StartsWith("LeftToe", StringComparison.Ordinal) || ((Object)val).name.StartsWith("RightToe", StringComparison.Ordinal)) { return true; } val = val.parent; } return false; } private static void Prefix(MagicaCloth __instance) { if ((Object)(object)((Component)__instance).GetComponent<NovaCapeSimulation>() == (Object)null) { return; } SerializeData colliderCollisionConstraint = __instance.SerializeData.colliderCollisionConstraint; if (colliderCollisionConstraint.colliderList != null) { colliderCollisionConstraint.colliderList = colliderCollisionConstraint.colliderList.Where((ColliderComponent c) => (Object)(object)c != (Object)null && !IsLeg(((Component)c).transform)).ToList(); } } } [BepInIncompatibility("perfect.chitinlight")] [BepInPlugin("nova.chitinarmor", "NovaChitinArmor", "0.3.21")] public sealed class Plugin : BaseUnityPlugin { private sealed class ArmorDefinition { internal readonly string Name; internal readonly string Source; internal readonly string DisplayName; internal readonly int Armor; internal ArmorDefinition(string name, string source, string displayName, int armor) { Name = name; Source = source; DisplayName = displayName; Armor = armor; } } internal const string ModVersion = "0.3.21"; private const string PluginId = "nova.chitinarmor"; private Harmony harmony; private static Transform prefabRoot; internal static float HelmetLiftMeters; private static readonly ArmorDefinition[] Armor = new ArmorDefinition[3] { new ArmorDefinition("ChitinHelmet", "HelmetLeather", "$nca_helmet", 8), new ArmorDefinition("ChitinChest", "ArmorLeatherChest", "$nca_chest", 8), new ArmorDefinition("ChitinLegs", "ArmorLeatherLegs", "$nca_legs", 8) }; private static readonly HashSet<int> ReportedForgeDBs = new HashSet<int>(); internal static bool HasGraphics => (int)SystemInfo.graphicsDeviceType != 4; private void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown ArmorConfig.Bind(((BaseUnityPlugin)this).Config); ModLocalization.Install(Localization.instance); HelmetLiftMeters = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "HelmetLift