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 M16A4 v0.1.1
M16A4.dll
Decompiled 3 hours 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.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Photon.Pun; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] namespace M16A4; internal static class ConfigLabels { private sealed class TrackedLabel { internal WeakReference Target; internal string English; } private static readonly Dictionary<string, string> EnToCn = new Dictionary<string, string>(StringComparer.Ordinal) { { "General", "通用" }, { "Language", "语言" }, { "Gun", "枪" }, { "Burst", "三连发" }, { "MuzzleFlash", "枪口火光" }, { "Muzzle Flash", "枪口火光" }, { "Debug", "调试模式" }, { "DebugLog", "调试日志" }, { "Debug Log", "调试日志" }, { "Auto", "自动" }, { "Chinese", "中文" }, { "English", "英文" } }; private static readonly Dictionary<string, string> CnToEn = new Dictionary<string, string>(StringComparer.Ordinal); private static readonly List<TrackedLabel> Tracked = new List<TrackedLabel>(); private const int MaxTracked = 512; private static readonly Dictionary<Type, PropertyInfo> TextSetters = new Dictionary<Type, PropertyInfo>(); internal static void AddPair(string english, string chinese, bool bothWays) { if (!string.IsNullOrEmpty(english) && !string.IsNullOrEmpty(chinese) && !string.Equals(english, chinese, StringComparison.Ordinal)) { EnToCn[english] = chinese; if (bothWays) { CnToEn[chinese] = english; } } } private static void Translate(ref string __0, object __instance) { if (string.IsNullOrEmpty(__0)) { return; } string text = __0; string value2; if (EnToCn.TryGetValue(text, out var value)) { value2 = text; } else { if (!CnToEn.TryGetValue(text, out value2)) { return; } value = text; } Track(__instance, value2); __0 = (Plugin.Chinese ? value : value2); } private static void TranslateOnly(ref string __0) { if (!string.IsNullOrEmpty(__0) && EnToCn.TryGetValue(__0, out var value) && Plugin.Chinese) { __0 = value; } } internal static void Install(Harmony harmony) { int num = PatchEverything(harmony, "Translate"); if (num == 0) { num = PatchEverything(harmony, "TranslateOnly"); } if (Plugin.Log != null) { if (num == 0) { Plugin.Log.LogWarning((object)"[M16A4] no text setter found - config labels stay English."); } else { Plugin.Log.LogInfo((object)("[M16A4] config labels: " + num + " text setter(s) patched.")); } } } private static int PatchEverything(Harmony harmony, string prefixName) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown MethodInfo method = typeof(ConfigLabels).GetMethod(prefixName, BindingFlags.Static | BindingFlags.NonPublic); if (method == null) { return 0; } HarmonyMethod prefix = new HarmonyMethod(method); HashSet<MethodInfo> seen = new HashSet<MethodInfo>(); return 0 + PatchSetter(harmony, prefix, seen, "TMPro.TMP_Text", "Unity.TextMeshPro") + PatchSetter(harmony, prefix, seen, "TMPro.TextMeshProUGUI", "Unity.TextMeshPro") + PatchSetter(harmony, prefix, seen, "TMPro.TextMeshPro", "Unity.TextMeshPro") + PatchSetter(harmony, prefix, seen, "UnityEngine.UI.Text", "UnityEngine.UI"); } private static int PatchSetter(Harmony harmony, HarmonyMethod prefix, HashSet<MethodInfo> seen, string typeName, string assemblyName) { int num = 0; try { Type type = FindType(typeName, assemblyName); if (type == null) { return 0; } PropertyInfo property = type.GetProperty("text", BindingFlags.Instance | BindingFlags.Public); MethodInfo methodInfo = ((property == null) ? null : property.GetSetMethod()); if (methodInfo != null && methodInfo.GetParameters().Length == 1 && seen.Add(methodInfo)) { harmony.Patch((MethodBase)methodInfo, prefix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo2 in methods) { if (!(methodInfo2.Name != "SetText")) { ParameterInfo[] parameters = methodInfo2.GetParameters(); if (parameters.Length == 1 && !(parameters[0].ParameterType != typeof(string)) && seen.Add(methodInfo2)) { harmony.Patch((MethodBase)methodInfo2, prefix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } } } } catch (Exception ex) { WeaponRegistrar.Dbg("label patch skipped for " + typeName + ": " + ex.Message); } return num; } private static Type FindType(string typeName, string assemblyName) { Type type = Type.GetType(typeName + ", " + assemblyName, throwOnError: false); if (type != null) { return type; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!(assembly.GetName().Name != assemblyName)) { type = assembly.GetType(typeName, throwOnError: false); if (type != null) { return type; } } } return null; } private static void Track(object instance, string english) { if (instance == null) { return; } for (int i = 0; i < Tracked.Count; i++) { object target = Tracked[i].Target.Target; if (target != null && target == instance) { Tracked[i].English = english; return; } } if (Tracked.Count >= 512) { for (int num = Tracked.Count - 1; num >= 0; num--) { if (!Tracked[num].Target.IsAlive) { Tracked.RemoveAt(num); } } if (Tracked.Count >= 512) { Tracked.RemoveAt(0); } } Tracked.Add(new TrackedLabel { Target = new WeakReference(instance), English = english }); } internal static void RefreshAll() { int num = 0; for (int num2 = Tracked.Count - 1; num2 >= 0; num2--) { TrackedLabel trackedLabel = Tracked[num2]; object target = trackedLabel.Target.Target; if (target == null) { Tracked.RemoveAt(num2); } else { try { if (SetText(target, trackedLabel.English)) { num++; } } catch (Exception ex) { Tracked.RemoveAt(num2); WeaponRegistrar.Dbg("label refresh dropped: " + ex.GetType().Name); } } } if (Plugin.Log != null) { Plugin.Log.LogInfo((object)("[M16A4] config labels re-applied on " + num + " component(s).")); } } private static bool SetText(object target, string english) { Type type = target.GetType(); if (!TextSetters.TryGetValue(type, out var value)) { value = type.GetProperty("text", BindingFlags.Instance | BindingFlags.Public); TextSetters[type] = value; } if (value == null || !value.CanWrite) { return false; } value.SetValue(target, english, null); return true; } } internal static class GunTunePatch { private static void Postfix(ItemGun __instance) { if (!((Object)(object)__instance == (Object)null) && Plugin.BundleMode) { GameObject gameObject = ((Component)__instance).gameObject; if (!((Object)(object)gameObject == (Object)null) && ((Object)gameObject).name.IndexOf("M16A4", StringComparison.OrdinalIgnoreCase) >= 0) { ItemAttributes component = gameObject.GetComponent<ItemAttributes>(); WeaponRegistrar.TuneGun(gameObject, ((Object)(object)component != (Object)null) ? component.item : null); FixMaterials(gameObject); } } } private static void FixMaterials(GameObject go) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) Shader val = FindRealShader(); if ((Object)(object)val == (Object)null) { WeaponRegistrar.Dbg("[MAT] no real 'Fresnel Opaque' found - bundle shader left as is"); return; } bool flag = ((Object)val).name.IndexOf("Fresnel", StringComparison.OrdinalIgnoreCase) >= 0; int num = 0; MeshRenderer[] componentsInChildren = go.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val2 in componentsInChildren) { if (!((Renderer)val2).enabled) { continue; } Material[] sharedMaterials = ((Renderer)val2).sharedMaterials; bool flag2 = false; for (int j = 0; j < sharedMaterials.Length; j++) { Material val3 = sharedMaterials[j]; if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.shader == (Object)(object)val)) { Color c = (Prop(val3, "_BaseColor") ? val3.GetColor("_BaseColor") : (Prop(val3, "_Color") ? val3.GetColor("_Color") : Color.white)); Color c2 = (Prop(val3, "_FresnelColor") ? val3.GetColor("_FresnelColor") : Color.black); float v = (Prop(val3, "_FresnelScale") ? val3.GetFloat("_FresnelScale") : 0.12f); float v2 = (Prop(val3, "_Metallic") ? val3.GetFloat("_Metallic") : 0.15f); float v3 = (Prop(val3, "_Smoothness") ? val3.GetFloat("_Smoothness") : 0.35f); Material val4 = new Material(val); ((Object)val4).name = ((Object)val3).name; SetTex(val4, "_BaseTexture", null); SetTex(val4, "_MainTex", null); SetTex(val4, "_MetallicTexture", null); SetTex(val4, "_MetallicGlossMap", null); SetTex(val4, "_SmoothnessTexture", null); SetTex(val4, "_NormalTexture", null); SetTex(val4, "_BumpMap", null); SetTex(val4, "_EmissionTexture", null); SetTex(val4, "_EmissionMap", null); SetCol(val4, "_BaseColor", c); SetCol(val4, "_Color", c); SetCol(val4, "_EmissionColor", Color.black); SetCol(val4, "_FresnelEmissionColor", Color.black); SetCol(val4, "_FresnelColor", c2); SetFlt(val4, "_Metallic", v2); SetFlt(val4, "_Smoothness", v3); SetFlt(val4, "_Glossiness", v3); SetFlt(val4, "_NormalStrength", 0f); SetFlt(val4, "_FresnelBias", 0f); SetFlt(val4, "_FresnelPower", 4f); SetFlt(val4, "_FresnelScale", v); sharedMaterials[j] = val4; flag2 = true; num++; } } if (flag2) { ((Renderer)val2).sharedMaterials = sharedMaterials; } } WeaponRegistrar.Dbg("[MAT] shader repaired on " + num + " material(s) -> '" + ((Object)val).name + "' (fresnel=" + flag + ")"); DumpMaterials(go); } private static Shader FindRealShader() { Shader val = ShaderFrom(Resources.Load<GameObject>("Items/Item Gun Shotgun")); if ((Object)(object)val != (Object)null) { return val; } StatsManager instance = StatsManager.instance; if ((Object)(object)instance != (Object)null && instance.itemDictionary != null) { foreach (KeyValuePair<string, Item> item in instance.itemDictionary) { Item value = item.Value; if (!((Object)(object)value == (Object)null) && value.prefab != null && (value.itemName == null || value.itemName.IndexOf("M16A4", StringComparison.OrdinalIgnoreCase) < 0)) { val = ShaderFrom(((PrefabRef<GameObject>)(object)value.prefab).Prefab); if ((Object)(object)val != (Object)null) { return val; } } } } return null; } private static Shader ShaderFrom(GameObject go) { if ((Object)(object)go == (Object)null) { return null; } Transform val = go.transform.Find("Mesh/Gun"); if ((Object)(object)val != (Object)null) { MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null) { Material[] sharedMaterials = ((Renderer)component).sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { if ((Object)(object)sharedMaterials[i] != (Object)null && (Object)(object)sharedMaterials[i].shader != (Object)null && ((Object)sharedMaterials[i].shader).name.IndexOf("Fresnel", StringComparison.OrdinalIgnoreCase) >= 0) { return sharedMaterials[i].shader; } } } } MeshRenderer[] componentsInChildren = go.GetComponentsInChildren<MeshRenderer>(true); for (int j = 0; j < componentsInChildren.Length; j++) { Material[] sharedMaterials2 = ((Renderer)componentsInChildren[j]).sharedMaterials; for (int k = 0; k < sharedMaterials2.Length; k++) { if ((Object)(object)sharedMaterials2[k] != (Object)null && (Object)(object)sharedMaterials2[k].shader != (Object)null && ((Object)sharedMaterials2[k].shader).name.IndexOf("Fresnel", StringComparison.OrdinalIgnoreCase) >= 0) { return sharedMaterials2[k].shader; } } } return null; } private static bool Prop(Material m, string name) { return Prop(m.shader, name); } private static bool Prop(Shader s, string name) { if ((Object)(object)s == (Object)null) { return false; } int propertyCount = s.GetPropertyCount(); for (int i = 0; i < propertyCount; i++) { if (s.GetPropertyName(i) == name) { return true; } } return false; } private static void SetTex(Material m, string n, Texture t) { if (Prop(m, n)) { m.SetTexture(n, t); } } private static void SetCol(Material m, string n, Color c) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (Prop(m, n)) { m.SetColor(n, c); } } private static void SetFlt(Material m, string n, float v) { if (Prop(m, n)) { m.SetFloat(n, v); } } private static void DumpMaterials(GameObject go) { //IL_00e7: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); MeshRenderer[] componentsInChildren = go.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { if (!((Renderer)val).enabled) { continue; } stringBuilder.Append("[MAT] ").Append(((Object)((Component)val).transform).name).Append(" n=") .Append(((Renderer)val).sharedMaterials.Length); Material[] sharedMaterials = ((Renderer)val).sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 == (Object)null) { stringBuilder.Append(" <null>"); continue; } stringBuilder.Append(" | '").Append(((Object)val2).name).Append("' shader=") .Append(((Object)(object)val2.shader != (Object)null) ? ((Object)val2.shader).name : "<null>"); if (Prop(val2, "_BaseColor")) { Color color = val2.GetColor("_BaseColor"); stringBuilder.Append(" base=(").Append(color.r.ToString("F2")).Append(',') .Append(color.g.ToString("F2")) .Append(',') .Append(color.b.ToString("F2")) .Append(')'); } else if (Prop(val2, "_Color")) { Color color2 = val2.GetColor("_Color"); stringBuilder.Append(" color=(").Append(color2.r.ToString("F2")).Append(',') .Append(color2.g.ToString("F2")) .Append(',') .Append(color2.b.ToString("F2")) .Append(')'); } } stringBuilder.AppendLine(); } WeaponRegistrar.Dbg(stringBuilder.ToString()); } } internal static class MuzzleFlashPatch { private static bool Prefix(ItemGun __instance) { if ((Object)(object)__instance == (Object)null) { return true; } if (Plugin.MuzzleFlash == null || Plugin.MuzzleFlash.Value) { return true; } return !BurstPatch.IsOurs(__instance); } } internal static class HoldPose { internal static float Drop = 0.2f; private static string path; private static float nextScan; private static bool missingLogged; internal static void Tick() { if (Plugin.DebugLog == null || !Plugin.DebugLog.Value) { return; } float unscaledTime = Time.unscaledTime; if (unscaledTime < nextScan) { return; } nextScan = unscaledTime + 0.25f; if (path == null) { try { path = Path.Combine(Paths.PluginPath, "M16A4", "holddrop.txt"); } catch { path = string.Empty; } } if (string.IsNullOrEmpty(path)) { return; } try { float result; if (!File.Exists(path)) { if (!missingLogged && Plugin.Log != null) { missingLogged = true; Plugin.Log.LogInfo((object)("[M16A4] no holddrop.txt, held pose uses the build value " + Drop.ToString("F3", CultureInfo.InvariantCulture))); } } else if (float.TryParse(File.ReadAllText(path).Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out result) && !(result < 0.05f) && !(result > 1f) && !(Math.Abs(result - Drop) < 0.0005f)) { Drop = result; if (Plugin.Log != null) { Plugin.Log.LogInfo((object)("[M16A4] hold drop -> " + result.ToString("F3", CultureInfo.InvariantCulture) + " m")); } } } catch { } } } internal static class HoldPosePatch { private static void Prefix(ItemGun __instance) { if (!((Object)(object)__instance == (Object)null) && BurstPatch.IsOurs(__instance)) { HoldPose.Tick(); __instance.grabVerticalOffset = 0f - HoldPose.Drop; } } } internal static class M16Builder { public const int MatBlack = 0; public const int MatAlu = 1; public const int MatSteel = 2; public const int MatBright = 3; public const int MatVoid = 4; public const int MatMark = 5; public const int MatLens = 6; public const int MaterialCount = 7; public static readonly Color[] Colors = (Color[])(object)new Color[7] { new Color(0.15f, 0.152f, 0.158f), new Color(0.235f, 0.242f, 0.255f), new Color(0.19f, 0.196f, 0.208f), new Color(0.31f, 0.322f, 0.345f), new Color(0.03f, 0.031f, 0.034f), new Color(0.76f, 0.47f, 0.12f), new Color(0.18f, 0.4f, 0.54f) }; public static readonly float[] Metallic = new float[7] { 0f, 0.8f, 0.82f, 1f, 0.1f, 0f, 0.2f }; public static readonly float[] Smoothness = new float[7] { 0.1f, 0.46f, 0.4f, 0.7f, 0.08f, 0.3f, 0.9f }; public static readonly string[] MaterialNames = new string[7] { "M16Polymer", "M16Receiver", "M16Steel", "M16Bright", "M16Recess", "M16Mark", "M16Lens" }; public static readonly Vector3 GripPoint = new Vector3(0f, -0.1f, -0.195f); private const float BarrelY = 0.022f; private const float RecvZ = -0.148f; private const float RecvW = 0.056f; private const float RecvH = 0.076f; private const float RecvD = 0.225f; private const float RecvTop = 0.038f; private const float HgZ = 0.13f; private const float HgD = 0.325f; private const float RailTop = 0.046f; private static void AddBox(MeshBuilder t, Vector3 size, float c, int mat, Vector3 pos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); meshBuilder.AddBox(size, c, mat); meshBuilder.Translate(pos); t.Merge(meshBuilder); } private static void AddBoxRot(MeshBuilder t, Vector3 size, float c, int mat, Vector3 pos, float deg, Vector3 axis) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); meshBuilder.AddBox(size, c, mat); meshBuilder.Rotate(deg, axis); meshBuilder.Translate(pos); t.Merge(meshBuilder); } private static void AddCyl(MeshBuilder t, int side, int cap, float r0, float r1, float len, int seg, Vector3 pos, char axis, float rotDeg = 0f, Vector3? rotAxis = null) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); meshBuilder.AddCylinder(r0, r1, len, seg, side, cap, axis); if (rotDeg != 0f && rotAxis.HasValue) { meshBuilder.Rotate(rotDeg, rotAxis.Value); } meshBuilder.Translate(pos); t.Merge(meshBuilder); } private static void AddPicatinny(MeshBuilder t, float z0, float z1, float yBase) { //IL_0010: 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_0078: 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) float num = z1 - z0; AddBox(t, new Vector3(0.021f, 0.008f, num), 0.002f, 1, new Vector3(0f, yBase + 0.004f, (z0 + z1) * 0.5f)); int num2 = Mathf.Max(1, (int)(num / 0.016f)); for (int i = 0; i < num2; i++) { float num3 = z0 + 0.008f + (float)i * 0.016f; if (!(num3 > z1 - 0.006f)) { AddBox(t, new Vector3(0.022f, 0.004f, 0.008f), 0.001f, 1, new Vector3(0f, yBase + 0.009f, num3)); continue; } break; } } public static MeshBuilder Compose() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0257: 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) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_034a: 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_037a: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_055e: 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_046e: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Unknown result type (might be due to invalid IL or missing references) //IL_06c0: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_073a: Unknown result type (might be due to invalid IL or missing references) //IL_0754: Unknown result type (might be due to invalid IL or missing references) //IL_0783: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_07e6: Unknown result type (might be due to invalid IL or missing references) //IL_081f: Unknown result type (might be due to invalid IL or missing references) //IL_0874: Unknown result type (might be due to invalid IL or missing references) //IL_088b: Unknown result type (might be due to invalid IL or missing references) //IL_08b5: Unknown result type (might be due to invalid IL or missing references) //IL_08d3: Unknown result type (might be due to invalid IL or missing references) //IL_08f8: Unknown result type (might be due to invalid IL or missing references) //IL_0912: Unknown result type (might be due to invalid IL or missing references) //IL_093f: Unknown result type (might be due to invalid IL or missing references) //IL_097c: Unknown result type (might be due to invalid IL or missing references) //IL_09b9: Unknown result type (might be due to invalid IL or missing references) //IL_09e3: Unknown result type (might be due to invalid IL or missing references) //IL_09fd: Unknown result type (might be due to invalid IL or missing references) //IL_0a17: Unknown result type (might be due to invalid IL or missing references) //IL_0a31: Unknown result type (might be due to invalid IL or missing references) //IL_0a4b: Unknown result type (might be due to invalid IL or missing references) //IL_0a65: Unknown result type (might be due to invalid IL or missing references) //IL_0a7f: Unknown result type (might be due to invalid IL or missing references) //IL_0a99: Unknown result type (might be due to invalid IL or missing references) //IL_0ac5: Unknown result type (might be due to invalid IL or missing references) //IL_0ad1: Unknown result type (might be due to invalid IL or missing references) //IL_0af0: Unknown result type (might be due to invalid IL or missing references) //IL_0b0a: Unknown result type (might be due to invalid IL or missing references) //IL_0b14: Unknown result type (might be due to invalid IL or missing references) //IL_0b33: Unknown result type (might be due to invalid IL or missing references) //IL_0b57: Unknown result type (might be due to invalid IL or missing references) //IL_0b61: Unknown result type (might be due to invalid IL or missing references) //IL_0bf0: Unknown result type (might be due to invalid IL or missing references) //IL_0c0a: Unknown result type (might be due to invalid IL or missing references) //IL_0c24: Unknown result type (might be due to invalid IL or missing references) //IL_0c3e: Unknown result type (might be due to invalid IL or missing references) //IL_0c58: Unknown result type (might be due to invalid IL or missing references) //IL_0c72: Unknown result type (might be due to invalid IL or missing references) //IL_0c7c: Unknown result type (might be due to invalid IL or missing references) //IL_0ca8: Unknown result type (might be due to invalid IL or missing references) //IL_0cd2: Unknown result type (might be due to invalid IL or missing references) //IL_0cec: Unknown result type (might be due to invalid IL or missing references) //IL_0d06: Unknown result type (might be due to invalid IL or missing references) //IL_0d20: Unknown result type (might be due to invalid IL or missing references) //IL_0d2a: Unknown result type (might be due to invalid IL or missing references) //IL_0d44: Unknown result type (might be due to invalid IL or missing references) //IL_0d5e: Unknown result type (might be due to invalid IL or missing references) //IL_0d68: Unknown result type (might be due to invalid IL or missing references) //IL_0d82: Unknown result type (might be due to invalid IL or missing references) //IL_0d9c: Unknown result type (might be due to invalid IL or missing references) //IL_0da6: Unknown result type (might be due to invalid IL or missing references) //IL_0bb0: Unknown result type (might be due to invalid IL or missing references) //IL_0dc5: Unknown result type (might be due to invalid IL or missing references) //IL_0df3: Unknown result type (might be due to invalid IL or missing references) //IL_0dfd: Unknown result type (might be due to invalid IL or missing references) //IL_0e35: Unknown result type (might be due to invalid IL or missing references) //IL_0e5f: Unknown result type (might be due to invalid IL or missing references) //IL_0e79: Unknown result type (might be due to invalid IL or missing references) //IL_0e93: Unknown result type (might be due to invalid IL or missing references) //IL_0ead: Unknown result type (might be due to invalid IL or missing references) //IL_0eb7: Unknown result type (might be due to invalid IL or missing references) //IL_0ed1: Unknown result type (might be due to invalid IL or missing references) //IL_0eeb: Unknown result type (might be due to invalid IL or missing references) //IL_0f05: Unknown result type (might be due to invalid IL or missing references) //IL_0f1f: Unknown result type (might be due to invalid IL or missing references) //IL_0f29: Unknown result type (might be due to invalid IL or missing references) //IL_0f43: Unknown result type (might be due to invalid IL or missing references) //IL_0f5d: Unknown result type (might be due to invalid IL or missing references) //IL_0f67: Unknown result type (might be due to invalid IL or missing references) //IL_0f93: Unknown result type (might be due to invalid IL or missing references) //IL_0fbd: Unknown result type (might be due to invalid IL or missing references) //IL_0fd7: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); AddCyl(meshBuilder, 2, 2, 0.0125f, 0.0125f, 0.34f, 12, new Vector3(0f, 0.022f, 0.16f), 'z'); AddCyl(meshBuilder, 2, 2, 0.0106f, 0.0102f, 0.175f, 12, new Vector3(0f, 0.022f, 0.395f), 'z'); AddCyl(meshBuilder, 2, 2, 0.0126f, 0.0126f, 0.006f, 12, new Vector3(0f, 0.022f, 0.33f), 'z'); AddCyl(meshBuilder, 2, 2, 0.0152f, 0.0144f, 0.058f, 12, new Vector3(0f, 0.022f, 0.492f), 'z'); AddCyl(meshBuilder, 2, 2, 0.0162f, 0.0162f, 0.007f, 12, new Vector3(0f, 0.022f, 0.521f), 'z'); for (int i = 0; i < 4; i++) { AddBoxRot(meshBuilder, new Vector3(0.02f, 0.004f, 0.03f), 0.001f, 4, new Vector3(0f, 0.022f, 0.482f), -45f + (float)i * 90f, Vector3.forward); } AddCyl(meshBuilder, 4, 4, 0.006f, 0.006f, 0.014f, 10, new Vector3(0f, 0.022f, 0.51f), 'z'); AddCyl(meshBuilder, 2, 2, 0.024f, 0.018f, 0.062f, 3, new Vector3(0f, 0.044f, 0.33499998f), 'y', 180f, Vector3.up); for (int j = -1; j <= 1; j += 2) { AddBox(meshBuilder, new Vector3(0.005f, 0.026f, 0.016f), 0.0015f, 2, new Vector3((float)j * 0.014f, 0.074f, 0.33499998f)); } AddBox(meshBuilder, new Vector3(0.004f, 0.02f, 0.004f), 0.0008f, 4, new Vector3(0f, 0.072f, 0.33499998f)); AddBox(meshBuilder, new Vector3(0.014f, 0.016f, 0.03f), 0.002f, 2, new Vector3(0f, 0.004f, 0.342f)); AddCyl(meshBuilder, 2, 2, 0.0045f, 0.0045f, 0.15f, 8, new Vector3(0f, 0.04f, 0.26f), 'z'); AddCyl(meshBuilder, 2, 2, 0.0032f, 0.0032f, 0.09f, 8, new Vector3(0f, 0.046f, 0.19f), 'z'); AddCyl(meshBuilder, 0, 0, 0.0295f, 0.029f, 0.325f, 16, new Vector3(0f, 0.01f, 0.13f), 'z', 11.25f, Vector3.forward); for (int k = -1; k <= 1; k += 2) { AddBox(meshBuilder, new Vector3(0.02f, 0.01f, 0.3f), 0.002f, 1, new Vector3(0f, 0.01f + (float)k * 0.034f, 0.13f)); } for (int l = 0; l < 7; l++) { float num = 0.009999998f + (float)l * 0.04f; for (int m = -1; m <= 1; m += 2) { AddCyl(meshBuilder, 4, 4, 0.0078f, 0.0078f, 0.007f, 10, new Vector3((float)m * 0.029f, 0.01f, num), 'x'); } } for (int n = 0; n < 8; n++) { float num2 = -0.00500001f + (float)n * 0.039f; for (int num3 = -1; num3 <= 1; num3 += 2) { AddBox(meshBuilder, new Vector3(0.021f, 0.003f, 0.012f), 0.001f, 4, new Vector3(0f, 0.01f + (float)num3 * 0.039f, num2)); } } AddCyl(meshBuilder, 2, 2, 0.0315f, 0.0305f, 0.016f, 16, new Vector3(0f, 0.01f, 0.3f), 'z', 11.25f, Vector3.forward); AddBox(meshBuilder, new Vector3(0.062f, 0.058f, 0.018f), 0.007f, 2, new Vector3(0f, 0.01f, -0.04200001f)); AddBox(meshBuilder, new Vector3(0.056f, 0.076f, 0.225f), 0.018f, 1, new Vector3(0f, 0f, -0.148f)); AddBox(meshBuilder, new Vector3(0.058000002f, 0.002f, 0.21499999f), 0.001f, 2, new Vector3(0f, 0.012f, -0.148f)); for (int num4 = -1; num4 <= 1; num4 += 2) { AddBoxRot(meshBuilder, new Vector3(0.02f, 0.016f, 0.219f), 0.004f, 1, new Vector3((float)num4 * 0.02f, 0.026999999f, -0.148f), (float)num4 * 42f, Vector3.forward); } AddBox(meshBuilder, new Vector3(0.004f, 0.022f, 0.054f), 0.001f, 4, new Vector3(0.024f, 0.014f, -0.103f)); AddBox(meshBuilder, new Vector3(0.0022f, 0.006f, 0.058f), 0.0008f, 5, new Vector3(0.028800001f, -0.017f, -0.122f)); for (int num5 = 0; num5 < 2; num5++) { AddCyl(meshBuilder, 3, 3, 0.005f, 0.005f, 0.005f, 8, new Vector3(0.028800001f, -0.024f, -0.060000002f - (float)num5 * 0.166f), 'x'); } AddBox(meshBuilder, new Vector3(0.006f, 0.026f, 0.058f), 0.002f, 4, new Vector3(0.028f, 0.014f, -0.103f)); AddBoxRot(meshBuilder, new Vector3(0.01f, 0.02f, 0.026f), 0.003f, 1, new Vector3(0.034f, 0.012f, -0.143f), -18f, Vector3.up); AddCyl(meshBuilder, 2, 2, 0.0075f, 0.0075f, 0.022f, 8, new Vector3(0.038000003f, 0.01f, -0.238f), 'x'); AddBox(meshBuilder, new Vector3(0.044f, 0.03f, 0.074f), 0.004f, 1, new Vector3(0f, -0.052f, -0.108f)); AddPicatinny(meshBuilder, -0.25250003f, 0.29f, 0.036f); AddBox(meshBuilder, new Vector3(0.03f, 0.012f, 0.19f), 0.002f, 0, new Vector3(0f, 0.052f, -0.16f)); for (int num6 = 0; num6 < 2; num6++) { float num7 = -0.148f + ((num6 == 0) ? 0.072f : (-0.086f)); AddCyl(meshBuilder, 2, 2, 0.009f, 0.009f, 0.014f, 8, new Vector3(-0.024f, 0.052f, num7), 'x'); AddCyl(meshBuilder, 2, 2, 0.004f, 0.004f, 0.02f, 6, new Vector3(-0.03f, 0.052f, num7), 'x'); } for (int num8 = 0; num8 < 2; num8++) { float num9 = -0.148f + ((num8 == 0) ? 0.07f : (-0.086f)); AddBox(meshBuilder, new Vector3(0.016f, 0.03f, 0.013f), 0.0015f, 0, new Vector3(0f, 0.073f, num9)); } for (int num10 = -1; num10 <= 1; num10 += 2) { AddBox(meshBuilder, new Vector3(0.004f, 0.026f, 0.168f), 0.0012f, 0, new Vector3((float)num10 * 0.009f, 0.074f, -0.158f)); } AddBox(meshBuilder, new Vector3(0.022f, 0.011f, 0.19f), 0.0015f, 0, new Vector3(0f, 0.092999995f, -0.16f)); AddCyl(meshBuilder, 0, 0, 0.012f, 0.012f, 0.024f, 12, new Vector3(0f, 0.11f, -0.218f), 'y'); AddCyl(meshBuilder, 2, 2, 0.016f, 0.016f, 0.005f, 16, new Vector3(0f, 0.124f, -0.218f), 'y'); AddCyl(meshBuilder, 2, 2, 0.01f, 0.01f, 0.013f, 10, new Vector3(0.018f, 0.102f, -0.218f), 'x'); AddBox(meshBuilder, new Vector3(0.006f, 0.012f, 0.007f), 0.001f, 0, new Vector3(0f, 0.104f, -0.248f)); AddBox(meshBuilder, new Vector3(0.003f, 0.004f, 0.004f), 0.0005f, 4, new Vector3(0f, 0.109f, -0.251f)); AddBox(meshBuilder, new Vector3(0.014f, 0.012f, 0.06f), 0.003f, 3, new Vector3(0f, 0.048f, -0.31300002f)); AddBox(meshBuilder, new Vector3(0.034f, 0.01f, 0.014f), 0.003f, 3, new Vector3(0f, 0.048f, -0.34100002f)); AddCyl(meshBuilder, 0, 0, 0.026f, 0.021f, 0.108f, 8, new Vector3(0f, -0.1f, -71f / (100f * MathF.PI)), 'y', 20f, Vector3.right); AddBoxRot(meshBuilder, new Vector3(0.036f, 0.008f, 0.056f), 0.003f, 0, new Vector3(0f, -0.152f, -0.24000001f), 20f, Vector3.right); for (int num11 = 0; num11 < 6; num11++) { AddBoxRot(meshBuilder, new Vector3(0.036f, 0.003f, 0.01f), 0.0008f, 4, new Vector3(0f, -0.082f - (float)num11 * 0.014f, -0.21000001f), 20f, Vector3.right); } for (int num12 = -1; num12 <= 1; num12 += 2) { for (int num13 = 0; num13 < 2; num13++) { AddCyl(meshBuilder, 2, 2, 0.0042f, 0.0042f, 0.006f, 6, new Vector3((float)num12 * 0.029000001f, -0.022f, -0.073f - (float)num13 * 0.15f), 'x'); } } AddBox(meshBuilder, new Vector3(0.01f, 0.03f, 0.01f), 0.002f, 1, new Vector3(0f, -0.058f, -0.168f)); AddBox(meshBuilder, new Vector3(0.01f, 0.01f, 0.07f), 0.002f, 1, new Vector3(0f, -0.074f, -0.20300001f)); AddBoxRot(meshBuilder, new Vector3(0.008f, 0.026f, 0.012f), 0.002f, 2, new Vector3(0f, -0.05f, -0.2f), -12f, Vector3.right); AddCyl(meshBuilder, 2, 2, 0.009f, 0.009f, 0.012f, 8, new Vector3(-0.028f, -0.008f, -0.178f), 'x'); AddBox(meshBuilder, new Vector3(0.004f, 0.01f, 0.03f), 0.001f, 5, new Vector3(-0.028f, 0.006f, -0.178f)); AddBoxRot(meshBuilder, new Vector3(0.028f, 0.094f, 0.064f), 0.0025f, 1, new Vector3(0f, -0.116f, -0.1f), -4f, Vector3.right); AddBoxRot(meshBuilder, new Vector3(0.028f, 0.076f, 0.064f), 0.0025f, 1, new Vector3(0f, -0.196f, -0.078f), -14f, Vector3.right); AddBoxRot(meshBuilder, new Vector3(0.032f, 0.013f, 0.07f), 0.003f, 0, new Vector3(0f, -0.234f, -0.062f), -14f, Vector3.right); for (int num14 = 0; num14 < 3; num14++) { AddBoxRot(meshBuilder, new Vector3(0.03f, 0.006f, 0.006f), 0.001f, 1, new Vector3(0f, -0.102f - (float)num14 * 0.04f, -0.094f + (float)num14 * 0.012f), -9f, Vector3.right); } AddCyl(meshBuilder, 0, 0, 0.019f, 0.019f, 0.062f, 10, new Vector3(0f, -0.002f, -0.294f), 'z'); AddBox(meshBuilder, new Vector3(0.04f, 0.062f, 0.112f), 0.003f, 0, new Vector3(0f, -0.006f, -0.36f)); AddBoxRot(meshBuilder, new Vector3(0.044f, 0.086f, 0.104f), 0.003f, 0, new Vector3(0f, -0.014f, -0.45f), -3f, Vector3.right); AddBox(meshBuilder, new Vector3(0.036f, 0.01f, 0.17f), 0.0025f, 0, new Vector3(0f, 0.03f, -0.393f)); AddBoxRot(meshBuilder, new Vector3(0.046f, 0.1f, 0.016f), 0.003f, 0, new Vector3(0f, -0.018f, -0.504f), -3f, Vector3.right); AddBoxRot(meshBuilder, new Vector3(0.042f, 0.096f, 0.007f), 0.0025f, 4, new Vector3(0f, -0.018f, -0.514f), -3f, Vector3.right); AddCyl(meshBuilder, 2, 2, 0.007f, 0.007f, 0.01f, 8, new Vector3(0f, -0.048f, -0.496f), 'x'); AddBox(meshBuilder, new Vector3(0.012f, 0.018f, 0.01f), 0.002f, 2, new Vector3(0f, -0.014f, 0.302f)); return meshBuilder; } public static Mesh BuildMesh() { return Compose().Build("M16A4", 7); } } internal sealed class MeshBuilder { private readonly List<Vector3> _v = new List<Vector3>(); private readonly List<Vector3> _n = new List<Vector3>(); private readonly List<Vector2> _uv = new List<Vector2>(); private readonly List<int> _t = new List<int>(); private readonly List<int> _m = new List<int>(); public int VertexCount => _v.Count; public int TriangleCount => _t.Count / 3; private void Push(Vector3[] pts, Vector3 n, int mat) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) int count = _v.Count; Vector2 val = default(Vector2); for (int i = 0; i < pts.Length; i++) { _v.Add(pts[i]); _n.Add(n); if (Mathf.Abs(n.y) >= 0.7f) { ((Vector2)(ref val))..ctor(pts[i].x, pts[i].z); } else if (Mathf.Abs(n.x) >= Mathf.Abs(n.z)) { ((Vector2)(ref val))..ctor(pts[i].z, pts[i].y); } else { ((Vector2)(ref val))..ctor(pts[i].x, pts[i].y); } _uv.Add(val * 2f + new Vector2(0.5f, 0.5f)); } for (int j = 1; j + 1 < pts.Length; j++) { _t.Add(count); _t.Add(count + j); _t.Add(count + j + 1); _m.Add(mat); } } private void Poly(Vector3[] pts, int mat) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) int num = pts.Length; Vector3 val = Vector3.zero; for (int i = 0; i < num; i++) { val += pts[i]; } val /= (float)num; Vector3 val2 = Vector3.Cross(pts[1] - pts[0], pts[2] - pts[0]); if (Vector3.Dot(val2, val) < 0f) { Vector3[] array = (Vector3[])(object)new Vector3[num]; for (int j = 0; j < num; j++) { array[j] = pts[num - 1 - j]; } pts = array; val2 = Vector3.Cross(pts[1] - pts[0], pts[2] - pts[0]); } if (!(((Vector3)(ref val2)).sqrMagnitude < 1E-14f)) { Push(pts, ((Vector3)(ref val2)).normalized, mat); } } public void AddBox(Vector3 size, float chamfer, int mat) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: 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_026d: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027f: 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_0288: 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_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) float num = size.x * 0.5f; float num2 = size.y * 0.5f; float num3 = size.z * 0.5f; float num4 = Mathf.Min(chamfer, Mathf.Min(num, Mathf.Min(num2, num3)) * 0.45f); if (num4 < 0f) { num4 = 0f; } float[] array = new float[3] { num, num2, num3 }; for (int i = 0; i < 3; i++) { int num5 = (i + 1) % 3; int num6 = (i + 2) % 3; for (int j = -1; j <= 1; j += 2) { int[][] array2 = new int[4][] { new int[2] { -1, -1 }, new int[2] { 1, -1 }, new int[2] { 1, 1 }, new int[2] { -1, 1 } }; Vector3[] array3 = (Vector3[])(object)new Vector3[4]; for (int k = 0; k < 4; k++) { Vector3 zero = Vector3.zero; ((Vector3)(ref zero))[i] = (float)j * array[i]; ((Vector3)(ref zero))[num5] = (float)array2[k][0] * (array[num5] - num4); ((Vector3)(ref zero))[num6] = (float)array2[k][1] * (array[num6] - num4); array3[k] = zero; } Poly(array3, mat); } } for (int l = 0; l < 3; l++) { int num7 = (l + 1) % 3; int num8 = (l + 2) % 3; for (int m = -1; m <= 1; m += 2) { for (int n = -1; n <= 1; n += 2) { Vector3 zero2 = Vector3.zero; Vector3 zero3 = Vector3.zero; Vector3 zero4 = Vector3.zero; Vector3 zero5 = Vector3.zero; ((Vector3)(ref zero2))[l] = 0f - array[l]; ((Vector3)(ref zero3))[l] = array[l]; ((Vector3)(ref zero4))[l] = array[l]; ((Vector3)(ref zero5))[l] = 0f - array[l]; float num9 = (((Vector3)(ref zero3))[num7] = (float)m * array[num7]); ((Vector3)(ref zero2))[num7] = num9; num9 = (((Vector3)(ref zero5))[num7] = (float)m * (array[num7] - num4)); ((Vector3)(ref zero4))[num7] = num9; num9 = (((Vector3)(ref zero3))[num8] = (float)n * (array[num8] - num4)); ((Vector3)(ref zero2))[num8] = num9; num9 = (((Vector3)(ref zero5))[num8] = (float)n * array[num8]); ((Vector3)(ref zero4))[num8] = num9; Poly((Vector3[])(object)new Vector3[4] { zero2, zero3, zero4, zero5 }, mat); } } } for (int num14 = -1; num14 <= 1; num14 += 2) { for (int num15 = -1; num15 <= 1; num15 += 2) { for (int num16 = -1; num16 <= 1; num16 += 2) { int[] array4 = new int[3] { num14, num15, num16 }; Vector3[] array5 = (Vector3[])(object)new Vector3[3]; for (int num17 = 0; num17 < 3; num17++) { Vector3 zero6 = Vector3.zero; for (int num18 = 0; num18 < 3; num18++) { ((Vector3)(ref zero6))[num18] = (float)array4[num18] * (array[num18] - num4); } ((Vector3)(ref zero6))[num17] = (float)array4[num17] * array[num17]; array5[num17] = zero6; } Poly(array5, mat); } } } } public void AddCylinder(float r0, float r1, float length, int seg, int mat, int capMat = -1, char axis = 'z') { //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: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_018d: 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) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (capMat < 0) { capMat = mat; } float num = length * 0.5f; Vector3[] array = (Vector3[])(object)new Vector3[seg]; Vector3[] array2 = (Vector3[])(object)new Vector3[seg]; for (int i = 0; i < seg; i++) { float num2 = MathF.PI * 2f * (float)i / (float)seg; float num3 = Mathf.Cos(num2); float num4 = Mathf.Sin(num2); array[i] = new Vector3(r0 * num3, r0 * num4, 0f - num); array2[i] = new Vector3(r1 * num3, r1 * num4, num); } for (int j = 0; j < seg; j++) { int num5 = (j + 1) % seg; Poly((Vector3[])(object)new Vector3[4] { array[j], array[num5], array2[num5], array2[j] }, mat); } for (int k = 0; k < 2; k++) { Vector3 val = ((k == 0) ? new Vector3(0f, 0f, 0f - num) : new Vector3(0f, 0f, num)); Vector3[] array3 = ((k == 0) ? array : array2); for (int l = 0; l < seg; l++) { int num6 = (l + 1) % seg; Poly((Vector3[])(object)new Vector3[3] { val, array3[l], array3[num6] }, capMat); } } switch (axis) { case 'y': Apply(Matrix4x4.Rotate(Quaternion.Euler(-90f, 0f, 0f))); break; case 'x': Apply(Matrix4x4.Rotate(Quaternion.Euler(0f, 90f, 0f))); break; } } public void Translate(Vector3 t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Apply(Matrix4x4.Translate(t)); } public void Rotate(float degrees, Vector3 axis) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Apply(Matrix4x4.Rotate(Quaternion.AngleAxis(degrees, axis))); } public void Scale(Vector3 s) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Apply(Matrix4x4.Scale(s)); } public void Apply(Matrix4x4 m) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 inverse = ((Matrix4x4)(ref m)).inverse; Matrix4x4 transpose = ((Matrix4x4)(ref inverse)).transpose; for (int i = 0; i < _v.Count; i++) { _v[i] = ((Matrix4x4)(ref m)).MultiplyPoint3x4(_v[i]); } for (int j = 0; j < _n.Count; j++) { List<Vector3> n = _n; int index = j; Vector3 val = ((Matrix4x4)(ref transpose)).MultiplyVector(_n[j]); n[index] = ((Vector3)(ref val)).normalized; } } public void Merge(MeshBuilder other) { int count = _v.Count; _v.AddRange(other._v); _n.AddRange(other._n); _uv.AddRange(other._uv); for (int i = 0; i < other._t.Count; i++) { _t.Add(other._t[i] + count); } _m.AddRange(other._m); } public Mesh Build(string name, int materialCount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown Mesh val = new Mesh { name = name }; if (_v.Count > 65000) { val.indexFormat = (IndexFormat)1; } val.SetVertices(_v); val.SetNormals(_n); val.SetUVs(0, _uv); val.subMeshCount = materialCount; List<int>[] array = new List<int>[materialCount]; for (int i = 0; i < materialCount; i++) { array[i] = new List<int>(); } for (int j = 0; j < _m.Count; j++) { int num = Mathf.Clamp(_m[j], 0, materialCount - 1); array[num].Add(_t[j * 3]); array[num].Add(_t[j * 3 + 1]); array[num].Add(_t[j * 3 + 2]); } for (int k = 0; k < materialCount; k++) { val.SetTriangles(array[k], k); } val.RecalculateBounds(); return val; } } internal static class MicrowaveHammerBuilder { public const int MatBody = 0; public const int MatGlass = 1; public const int MatChrome = 2; public const int MatScreen = 3; public const int MatButton = 4; public const int MatPipe = 5; public const int MatGrip = 6; public const int MatVoid = 7; public const int MaterialCount = 8; public static readonly Color[] Colors = (Color[])(object)new Color[8] { new Color(0.86f, 0.7f, 0.34f), new Color(0.05f, 0.055f, 0.065f), new Color(0.7f, 0.71f, 0.73f), new Color(0.28f, 0.62f, 0.34f), new Color(0.85f, 0.15f, 0.12f), new Color(0.52f, 0.54f, 0.58f), new Color(0.15f, 0.16f, 0.18f), new Color(0.035f, 0.037f, 0.042f) }; public static readonly string[] MaterialNames = new string[8] { "Shell", "DoorGlass", "Chrome", "Display", "Button", "Pipe", "Grip", "Recess" }; public static readonly Vector3 GripPoint = new Vector3(0f, -0.3f, 0f); private const float BodyY = 0.28f; private const float BodyH = 0.23f; private const float BodyD = 0.2f; public static MeshBuilder Compose() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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) //IL_01f8: 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_0230: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: 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_0334: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_043d: 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_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_056a: 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) MeshBuilder meshBuilder = new MeshBuilder(); AddPart(meshBuilder, 5, 5, 0.0195f, 0.0175f, 0.57f, 12, new Vector3(0f, -0.125f, 0f), 'y'); AddPart(meshBuilder, 5, 5, 0.0285f, 0.027f, 0.022f, 12, new Vector3(0f, -0.4f, 0f), 'y'); AddPart(meshBuilder, 6, 6, 0.0255f, 0.0255f, 0.18f, 12, new Vector3(0f, -0.3f, 0f), 'y'); for (int i = 0; i < 4; i++) { AddPart(meshBuilder, 6, 6, 0.027f, 0.027f, 0.012f, 12, new Vector3(0f, -0.37f + (float)i * 0.042f, 0f), 'y'); } AddBox(meshBuilder, new Vector3(0.092f, 0.034f, 0.092f), 0.006f, 5, new Vector3(0f, 0.155f, 0f)); AddBox(meshBuilder, new Vector3(0.3f, 0.23f, 0.2f), 0.012f, 0, new Vector3(0f, 0.28f, 0f)); for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { AddBox(meshBuilder, new Vector3(0.03f, 0.014f, 0.03f), 0.003f, 7, new Vector3((float)j * 0.118f, 0.15799999f, (float)k * 0.072f)); } } AddBox(meshBuilder, new Vector3(0.15f, 0.13f, 0.032f), 0.006f, 0, new Vector3(0f, 0.28f, -0.11f)); for (int l = -1; l <= 1; l += 2) { AddBox(meshBuilder, new Vector3(0.008f, 0.09f, 0.011f), 0.001f, 7, new Vector3((float)l * 0.149f, 0.28f, -0.085f)); AddBox(meshBuilder, new Vector3(0.008f, 0.09f, 0.011f), 0.001f, 7, new Vector3((float)l * 0.149f, 0.28f, 0.048f)); } for (int m = 0; m < 4; m++) { AddBox(meshBuilder, new Vector3(0.15f, 0.008f, 0.008f), 0.001f, 7, new Vector3(-0.02f, 0.401f, -0.06f + (float)m * 0.04f)); } AddBox(meshBuilder, new Vector3(0.208f, 0.196f, 0.018f), 0.004f, 2, new Vector3(-0.035f, 0.28f, 0.098f)); AddBox(meshBuilder, new Vector3(0.184f, 0.174f, 0.012f), 0.003f, 1, new Vector3(-0.035f, 0.28f, 0.108f)); for (int n = 0; n < 3; n++) { AddBox(meshBuilder, new Vector3(0.174f, 0.004f, 0.004f), 0.001f, 2, new Vector3(-0.035f, 0.235f + (float)n * 0.045f, 0.1155f)); } for (int num = 0; num < 2; num++) { AddBox(meshBuilder, new Vector3(0.004f, 0.166f, 0.004f), 0.001f, 2, new Vector3(-0.105f + (float)num * 0.14f, 0.28f, 0.1155f)); } AddPart(meshBuilder, 2, 2, 0.0125f, 0.0125f, 0.15f, 8, new Vector3(0.062f, 0.28f, 0.126f), 'y'); for (int num2 = -1; num2 <= 1; num2 += 2) { AddBox(meshBuilder, new Vector3(0.022f, 0.016f, 0.02f), 0.003f, 2, new Vector3(0.062f, 0.28f + (float)num2 * 0.07f, 0.108f)); } AddBox(meshBuilder, new Vector3(0.082f, 0.196f, 0.016f), 0.004f, 2, new Vector3(0.11f, 0.28f, 0.098f)); AddBox(meshBuilder, new Vector3(0.058f, 0.032f, 0.008f), 0.002f, 3, new Vector3(0.11f, 0.354f, 0.104f)); for (int num3 = 0; num3 < 3; num3++) { AddBox(meshBuilder, new Vector3(0.042f, 0.015f, 0.008f), 0.002f, 4, new Vector3(0.11f, 0.272f - (float)num3 * 0.03f, 0.104f)); } AddPart(meshBuilder, 2, 2, 0.019f, 0.019f, 0.014f, 10, new Vector3(0.11f, 0.18f, 0.104f), 'z'); AddBox(meshBuilder, new Vector3(0.004f, 0.036f, 0.048f), 0.001f, 3, new Vector3(-0.15f, 0.328f, 0.03f)); AddPart(meshBuilder, 7, 7, 0.008f, 0.008f, 0.1f, 6, new Vector3(-0.075f, 0.114999995f, -0.115f), 'y'); AddBox(meshBuilder, new Vector3(0.03f, 0.036f, 0.024f), 0.004f, 7, new Vector3(-0.075f, 0.048000008f, -0.115f)); return meshBuilder; } private static void AddBox(MeshBuilder target, Vector3 size, float chamfer, int mat, Vector3 pos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); meshBuilder.AddBox(size, chamfer, mat); meshBuilder.Translate(pos); target.Merge(meshBuilder); } private static void AddPart(MeshBuilder target, int sideMat, int capMat, float r0, float r1, float length, int seg, Vector3 pos, char axis) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); meshBuilder.AddCylinder(r0, r1, length, seg, sideMat, capMat, axis); meshBuilder.Translate(pos); target.Merge(meshBuilder); } public static Mesh BuildMesh() { return Compose().Build("MicrowaveHammer", 8); } } [BepInPlugin("com.peachh.M16A4", "M16A4", "0.1.1")] public class Plugin : BaseUnityPlugin { public enum UiLanguage { Auto, Chinese, English } public const string Guid = "com.peachh.M16A4"; public const string ModName = "M16A4"; public const string Version = "0.1.1"; internal static ManualLogSource Log; internal static ConfigEntry<UiLanguage> Language; internal static ConfigEntry<bool> Burst; internal static ConfigEntry<bool> MuzzleFlash; internal static ConfigEntry<bool> DebugLog; private const string BurstCn = "每次扣动扳机打出三发。关闭后变成单发武器。"; private const string BurstEn = "Fire three rounds per trigger pull. Off turns the rifle into a single-shot weapon."; private const string FlashCn = "显示枪口火光。觉得晃眼就关掉 —— 这把枪很长,火光 prefab 的黑烟会直接糊在脸上。"; private const string FlashEn = "Show the muzzle flash effect. Turn this off if it is distracting - the rifle is long enough that the flash prefab's smoke ends up right in front of your face."; private const string DebugCn = "在插件目录写 M16A4.debug.log。默认关闭,只在报问题时打开。"; private const string DebugEn = "Write M16A4.debug.log next to the plugin. Off by default; only turn it on when reporting a problem."; internal const int BurstShots = 3; internal const float BurstGap = 0.072f; internal const string ItemName = "M16A4"; internal const string ItemDescription = "Select fire, three-round burst, or a very loud argument. Military surplus, condition unknown."; internal const int ShopStock = 3; internal const float ShootCooldown = 0.45f; internal const float RecoilForce = 3.5f; internal const float BatteryDrain = 3.3f; internal const float GunMass = 12f; internal const float PhysicsMass = 9f; internal const float HoldDrop = 0.2f; internal static bool Chinese { get; private set; } internal static bool BundleMode { get; private set; } private static string T(string cn, string en) { if (!Chinese) { return en; } return cn; } private static bool DetectBundle() { try { string pluginPath = Paths.PluginPath; if (string.IsNullOrEmpty(pluginPath) || !Directory.Exists(pluginPath)) { return false; } string[] files = Directory.GetFiles(pluginPath, "*.repobundle", SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { if (Path.GetFileName(files[i]).IndexOf("M16A4", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } } catch (Exception ex) { if (Log != null) { Log.LogWarning((object)("[M16A4] bundle detect failed: " + ex.Message)); } } return false; } private void BindEntries() { Burst = ((BaseUnityPlugin)this).Config.Bind<bool>("Gun", "Burst", true, T("每次扣动扳机打出三发。关闭后变成单发武器。", "Fire three rounds per trigger pull. Off turns the rifle into a single-shot weapon.")); MuzzleFlash = ((BaseUnityPlugin)this).Config.Bind<bool>("Gun", "MuzzleFlash", true, T("显示枪口火光。觉得晃眼就关掉 —— 这把枪很长,火光 prefab 的黑烟会直接糊在脸上。", "Show the muzzle flash effect. Turn this off if it is distracting - the rifle is long enough that the flash prefab's smoke ends up right in front of your face.")); DebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DebugLog", false, T("在插件目录写 M16A4.debug.log。默认关闭,只在报问题时打开。", "Write M16A4.debug.log next to the plugin. Off by default; only turn it on when reporting a problem.")); ForceDescription((ConfigEntryBase)(object)Burst, T("每次扣动扳机打出三发。关闭后变成单发武器。", "Fire three rounds per trigger pull. Off turns the rifle into a single-shot weapon.")); ForceDescription((ConfigEntryBase)(object)MuzzleFlash, T("显示枪口火光。觉得晃眼就关掉 —— 这把枪很长,火光 prefab 的黑烟会直接糊在脸上。", "Show the muzzle flash effect. Turn this off if it is distracting - the rifle is long enough that the flash prefab's smoke ends up right in front of your face.")); ForceDescription((ConfigEntryBase)(object)DebugLog, T("在插件目录写 M16A4.debug.log。默认关闭,只在报问题时打开。", "Write M16A4.debug.log next to the plugin. Off by default; only turn it on when reporting a problem.")); ConfigLabels.AddPair("Fire three rounds per trigger pull. Off turns the rifle into a single-shot weapon.", "每次扣动扳机打出三发。关闭后变成单发武器。", bothWays: true); ConfigLabels.AddPair("Show the muzzle flash effect. Turn this off if it is distracting - the rifle is long enough that the flash prefab's smoke ends up right in front of your face.", "显示枪口火光。觉得晃眼就关掉 —— 这把枪很长,火光 prefab 的黑烟会直接糊在脸上。", bothWays: true); ConfigLabels.AddPair("Write M16A4.debug.log next to the plugin. Off by default; only turn it on when reporting a problem.", "在插件目录写 M16A4.debug.log。默认关闭,只在报问题时打开。", bothWays: true); } private static void ForceDescription(ConfigEntryBase entry, string text) { if (entry == null) { return; } try { FieldInfo field = typeof(ConfigEntryBase).GetField("<Description>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { return; } object value = field.GetValue(entry); if (value != null) { FieldInfo field2 = value.GetType().GetField("<Description>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic); if (!(field2 == null)) { field2.SetValue(value, text); field.SetValue(entry, value); } } } catch { } } private static bool ResolveChinese(UiLanguage mode) { return mode switch { UiLanguage.Chinese => true, UiLanguage.English => false, _ => IsGameLocaleChinese(), }; } private static bool IsGameLocaleChinese() { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_011f: Invalid comparison between Unknown and I4 //IL_0121: 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_0127: Invalid comparison between Unknown and I4 try { Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { type = assemblies[i].GetType("LocalizationManager"); if (type != null) { break; } } if (type != null) { object obj = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public)?.GetValue(null); object obj2 = ((obj == null) ? null : type.GetProperty("ActiveLocale")?.GetValue(obj)); if (obj2 != null) { object obj3 = obj2.GetType().GetProperty("LocaleReference")?.GetValue(obj2); object obj4 = obj3?.GetType().GetProperty("Identifier")?.GetValue(obj3); string text = obj4?.GetType().GetProperty("Code")?.GetValue(obj4) as string; if (!string.IsNullOrEmpty(text)) { return text.StartsWith("zh", StringComparison.OrdinalIgnoreCase); } } } } catch { } SystemLanguage systemLanguage = Application.systemLanguage; if ((int)systemLanguage == 6 || systemLanguage - 40 <= 1) { return true; } return false; } private void Awake() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; WeaponRegistrar.Dbg("=== M16A4 0.1.1 awake ==="); BundleMode = DetectBundle(); Log.LogInfo((object)("[M16A4] bundle mode = " + BundleMode)); Language = ((BaseUnityPlugin)this).Config.Bind<UiLanguage>("General", "Language", UiLanguage.Auto, "Auto 跟随游戏语言;Chinese / English 强制指定。\nAuto follows the game language; Chinese / English force it."); Chinese = ResolveChinese(Language.Value); BindEntries(); Language.SettingChanged += delegate { Chinese = ResolveChinese(Language.Value); BindEntries(); ConfigLabels.RefreshAll(); Log.LogInfo((object)("[M16A4] config language -> " + (Chinese ? "Chinese" : "English"))); }; try { Harmony val = new Harmony("com.peachh.M16A4"); MethodInfo methodInfo = AccessTools.Method(typeof(StatsManager), "LoadItemsFromFolder", (Type[])null, (Type[])null); if (methodInfo == null) { WeaponRegistrar.Dbg("StatsManager.LoadItemsFromFolder not found"); Log.LogError((object)"[M16A4] StatsManager.LoadItemsFromFolder not found - the mod cannot register its item."); return; } val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("OnItemsLoaded", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); WeaponRegistrar.Dbg("patched StatsManager.LoadItemsFromFolder"); MethodInfo methodInfo2 = AccessTools.Method(typeof(ItemGun), "Shoot", (Type[])null, (Type[])null); if (methodInfo2 == null) { WeaponRegistrar.Dbg("ItemGun.Shoot not found - burst fire disabled"); Log.LogWarning((object)"[M16A4] ItemGun.Shoot not found - burst fire disabled."); } else { val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(BurstPatch).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); WeaponRegistrar.Dbg("patched ItemGun.Shoot for burst fire"); } MethodInfo methodInfo3 = AccessTools.Method(typeof(ItemGun), "Start", (Type[])null, (Type[])null); if (methodInfo3 == null) { WeaponRegistrar.Dbg("ItemGun.Start not found - bundle guns keep stock tuning"); } else { val.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(GunTunePatch).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); WeaponRegistrar.Dbg("patched ItemGun.Start for bundle-gun tuning"); } MethodInfo methodInfo4 = AccessTools.Method(typeof(ItemGun), "MuzzleFlash", (Type[])null, (Type[])null); if (methodInfo4 == null) { WeaponRegistrar.Dbg("ItemGun.MuzzleFlash not found - flash toggle unavailable"); } else { val.Patch((MethodBase)methodInfo4, new HarmonyMethod(typeof(MuzzleFlashPatch).GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); WeaponRegistrar.Dbg("patched ItemGun.MuzzleFlash for the flash toggle"); } MethodInfo methodInfo5 = AccessTools.Method(typeof(ItemGun), "UpdateMaster", (Type[])null, (Type[])null); if (methodInfo5 == null) { WeaponRegistrar.Dbg("ItemGun.UpdateMaster not found - held pose keeps the prefab value"); } else { val.Patch((MethodBase)methodInfo5, new HarmonyMethod(typeof(HoldPosePatch).GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); WeaponRegistrar.Dbg("patched ItemGun.UpdateMaster for the held pose"); } ConfigLabels.Install(val); Log.LogInfo((object)"[M16A4] 0.1.1 loaded, waiting for the item table."); } catch (Exception ex) { WeaponRegistrar.Dbg("patch failed: " + ex); Log.LogError((object)("[M16A4] patching failed: " + ex)); } try { GameObject val2 = new GameObject("M16A4Runtime") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val2); val2.AddComponent<M16A4Runtime>(); } catch (Exception ex2) { WeaponRegistrar.Dbg("coroutine host attach failed: " + ex2); } } private static void OnItemsLoaded(StatsManager __instance) { WeaponRegistrar.Dbg("LoadItemsFromFolder postfix fired"); WeaponRegistrar.Install(__instance); } } internal class M16A4Runtime : MonoBehaviour { internal static M16A4Runtime Instance; private void Awake() { Instance = this; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } internal class WeaponTag : MonoBehaviour { } internal static class BurstPatch { private static readonly HashSet<int> Running = new HashSet<int>(); internal static bool IsOurs(ItemGun gun) { if ((Object)(object)gun == (Object)null) { return false; } if ((Object)(object)((Component)gun).GetComponent<WeaponTag>() != (Object)null) { return true; } if (!Plugin.BundleMode) { return false; } return ((Object)((Component)gun).gameObject).name.IndexOf("M16A4", StringComparison.OrdinalIgnoreCase) >= 0; } internal static void Postfix(ItemGun __instance, bool __result) { if (!__result || (Object)(object)__instance == (Object)null || Plugin.Burst == null || !Plugin.Burst.Value || !IsOurs(__instance)) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (Running.Add(instanceID)) { MuteImpact(__instance); M16A4Runtime instance = M16A4Runtime.Instance; if ((Object)(object)instance == (Object)null) { Running.Remove(instanceID); } else { ((MonoBehaviour)instance).StartCoroutine(Fire(__instance, instanceID)); } } } private static void MuteImpact(ItemGun gun) { PhysGrabObjectImpactDetector componentInChildren = ((Component)gun).GetComponentInChildren<PhysGrabObjectImpactDetector>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.OverrideImpactAudioDisable(0.22f); } } private static IEnumerator Fire(ItemGun gun, int id) { int shots = 3; float gap = 0.072f; try { for (int i = 1; i < shots; i++) { yield return (object)new WaitForSeconds(gap); if (!((Object)(object)gun == (Object)null)) { ItemBattery component = ((Component)gun).GetComponent<ItemBattery>(); if (!((Object)(object)component != (Object)null) || !(component.batteryLife <= 0f)) { Pull(gun); MuteImpact(gun); continue; } break; } break; } } finally { Running.Remove(id); } } private static void Pull(ItemGun gun) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer()) { PhotonView component = ((Component)gun).GetComponent<PhotonView>(); if ((Object)(object)component != (Object)null) { component.RPC("ShootRPC", (RpcTarget)0, Array.Empty<object>()); return; } } gun.ShootRPC(default(PhotonMessageInfo)); } } internal static class WeaponRegistrar { private static Item _item; private static GameObject _prefab; private static bool _buildFailed; private static int _builtKind = -1; private static readonly string DebugPath = Path.Combine(Paths.BepInExRootPath, "M16A4.debug.log"); public static bool IsRifle => true; public static string ItemKey { get { if (!IsRifle) { return "Item Microwave Hammer"; } return "Item M16A4"; } } public static string ItemResourcePath => "Items/" + ItemKey; public static bool Ready { get { if ((Object)(object)_prefab != (Object)null) { return (Object)(object)_item != (Object)null; } return false; } } private static Item ResolveItem() { if ((Object)(object)_item != (Object)null) { return _item; } try { StatsManager instance = StatsManager.instance; if ((Object)(object)instance != (Object)null && instance.itemDictionary != null && instance.itemDictionary.TryGetValue(ItemKey, out var value) && (Object)(object)value != (Object)null) { return value; } } catch { } return null; } public static void Dbg(string message) { if (Plugin.DebugLog == null || !Plugin.DebugLog.Value) { return; } try { File.AppendAllText(DebugPath, DateTime.Now.ToString("HH:mm:ss.fff") + " " + message + Environment.NewLine); } catch { } } public static void Install(StatsManager stats) { Dbg("Install() called, stats=" + (((Object)(object)stats == (Object)null) ? "null" : "ok") + ", rifle=" + IsRifle + ", bundle=" + Plugin.BundleMode); if ((Object)(object)stats == (Object)null || _buildFailed) { return; } if (Plugin.BundleMode) { Dbg("bundle owns registration - runtime clone disabled"); return; } try { int num = (IsRifle ? 1 : 0); if ((Object)(object)_item == (Object)null || (Object)(object)_prefab == (Object)null || _builtKind != num) { _item = null; _prefab = null; if (!Build(stats)) { return; } _builtKind = num; } stats.itemDictionary[ItemKey] = _item; Dbg("itemDictionary['" + ItemKey + "'] = " + _item.itemName); if (_item.prefab != null && ((PrefabRef<GameObject>)(object)_item.prefab).IsValid()) { Dbg("bundle content already registered this item - leaving REPOLib's PrefabRef alone"); return; } ((PrefabRef<GameObject>)(object)_item.prefab).SetPrefab(_prefab, ItemResourcePath); Dbg("prefab ref set -> '" + ItemResourcePath + "' valid=" + ((PrefabRef<GameObject>)(object)_item.prefab).IsValid()); TryRepolibRegister(_item); if (!((PrefabRef<GameObject>)(object)_item.prefab).IsValid()) { ((PrefabRef<GameObject>)(object)_item.prefab).SetPrefab(_prefab, ItemResourcePath); } } catch (Exception ex) { _buildFailed = true; Dbg("FAILED: " + ex); ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("[M16A4] registration failed: " + ex)); } } } private static bool TryRepolibRegister(Item item) { try { Type type = Type.GetType("REPOLib.Modules.Items, REPOLib"); if (type == null) { Dbg("REPOLib not installed - using built-in registration"); return false; } MethodInfo methodInfo = null; MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo methodInfo2 in methods) { if (!(methodInfo2.Name != "RegisterItem")) { ParameterInfo[] parameters = methodInfo2.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType == typeof(ItemAttributes)) { methodInfo = methodInfo2; break; } } } if (methodInfo == null) { Dbg("REPOLib: no RegisterItem(ItemAttributes) overload"); return false; } ItemAttributes val = (((Object)(object)_prefab != (Object)null) ? _prefab.GetComponent<ItemAttributes>() : null); if ((Object)(object)val == (Object)null) { Dbg("REPOLib: clone has no ItemAttributes"); return false; } if ((Object)(object)val.item == (Object)null) { val.item = item; } object obj = methodInfo.Invoke(null, new object[1] { val }); if (obj == null) { Dbg("REPOLib: RegisterItem returned null - see REPOLib's own log for the reason"); return false; } Dbg("REPOLib: RegisterItem(ItemAttributes) -> " + obj.GetType().FullName); return true; } catch (Exception ex) { Dbg("REPOLib register threw: " + ex.Message); return false; } } private static bool Build(StatsManager stats) { GameObject prefab; Item val = FindTemplate(out prefab); if ((Object)(object)val == (Object)null) { Dbg("no suitable template found - aborting"); ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[M16A4] no suitable template prefab found - aborting"); } _buildFailed = true; return false; } Dbg("template = '" + ((Object)val).name + "' / " + ((Object)prefab).name); Item item = CreateItem(val); GameObject val2 = ClonePrefab(prefab, item); if ((Object)(object)val2 == (Object)null) { _buildFailed = true; return false; } ApplyModel(val2); if (IsRifle) { TuneGun(val2, item); } else { TunePhysics(val2); } if ((Object)(object)val2.GetComponent<WeaponTag>() == (Object)null) { val2.AddComponent<WeaponTag>(); } _item = item; _prefab = val2; Dbg("build complete: item + prefab ready"); DumpHierarchy(val2.transform, 0, 2); return true; } private unsafe static void DumpHierarchy(Transform t, int depth, int maxDepth) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)t == (Object)null || depth > maxDepth) { return; } string text = new string(' ', depth * 2); GameObject gameObject = ((Component)t).gameObject; string text2 = ""; MeshFilter component = gameObject.GetComponent<MeshFilter>(); Vector3 val; if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { string[] obj = new string[7] { text2, " mesh='", ((Object)component.sharedMesh).name, "' v=", component.sharedMesh.vertexCount.ToString(), " b=", null }; Bounds bounds = component.sharedMesh.bounds; val = ((Bounds)(ref bounds)).size; obj[6] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); text2 = string.Concat(obj); } MeshRenderer component2 = gameObject.GetComponent<MeshRenderer>(); if ((Object)(object)component2 != (Object)null) { text2 = text2 + " MR(en=" + ((Renderer)component2).enabled + ",mats=" + ((((Renderer)component2).sharedMaterials != null) ? ((Renderer)component2).sharedMaterials.Length : 0) + ")"; if ((Object)(object)((Renderer)component2).sharedMaterial != (Object)null && (Object)(object)((Renderer)component2).sharedMaterial.shader != (Object)null) { text2 = text2 + " shader='" + ((Object)((Renderer)component2).sharedMaterial.shader).name + "'"; } } Renderer[] components = gameObject.GetComponents<Renderer>(); foreach (Renderer val2 in components) { if ((Object)(object)val2 != (Object)null && !(val2 is MeshRenderer)) { text2 = text2 + " [" + ((object)val2).GetType().Name + " en=" + val2.enabled + "]"; } } string[] obj2 = new string[12] { text, "+ ", ((Object)gameObject).name, " self=", gameObject.activeSelf.ToString(), " pos=", null, null, null, null, null, null }; val = t.localPosition; obj2[6] = ((Vector3)(ref val)).ToString("F3"); obj2[7] = " rot="; val = t.localEulerAngles; obj2[8] = ((Vector3)(ref val)).ToString("F1"); obj2[9] = " scl="; val = t.localScale; obj2[10] = ((Vector3)(ref val)).ToString("F3"); obj2[11] = text2; Dbg(string.Concat(obj2)); for (int j = 0; j < t.childCount; j++) { DumpHierarchy(t.GetChild(j), depth + 1, maxDepth); } } private static Item FindTemplate(out GameObject prefab) { prefab = null; Dictionary<string, Item> dictionary = StatsManager.instance?.itemDictionary; if (dictionary == null) { Dbg("itemDictionary is null"); return null; } if (!IsRifle) { return FindMeleeTemplate(dictionary, out prefab); } return FindGunTemplate(dictionary, out prefab); } private static Item FindMeleeTemplate(Dictionary<string, Item> dict, out GameObject prefab) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 prefab = null; Item val = null; GameObject val2 = null; foreach (KeyValuePair<string, Item> item in dict) { Item value = item.Value; if ((Object)(object)value == (Object)null || (int)value.itemType != 7) { continue; } GameObject val3; try { val3 = ((value.prefab != null) ? ((PrefabRef<GameObject>)(object)value.prefab).Prefab : null); } catch { continue; } if ((Object)(object)val3 == (Object)null || (Object)(object)val3.GetComponent<ItemMelee>() == (Object)null) { continue; } if ((Object)(object)val3.GetComponent("ItemMeleeWhip") != (Object)null) { Dbg("skipping whip template '" + ((Object)value).name + "'"); continue; } if (((Object)value).name.IndexOf("Sword", StringComparison.OrdinalIgnoreCase) >= 0) { prefab = val3; return value; } if ((Object)(object)val == (Object)null) { val = value; val2 = val3; } } prefab = val2; return val; } private static Item FindGunTemplate(Dictionary<string, Item> dict, out GameObject prefab) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 prefab = null; Item val = null; GameObject val2 = null; foreach (KeyValuePair<string, Item> item in dict) { Item value = item.Value; if ((Object)(object)value == (Object)null || (int)value.itemType != 9) { continue; } GameObject val3; try { val3 = ((value.prefab != null) ? ((PrefabRef<GameObject>)(object)value.prefab).Prefab : null); } catch { continue; } if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.GetComponent<ItemGun>() == (Object)null) && !((Object)(object)val3.GetComponent("ItemGunRevolver") != (Object)null) && !((Object)(object)val3.GetComponent("ItemGunLaser") != (Object)null) && !((Object)(object)val3.GetComponent("ItemGunTranq") != (Object)null)) { if (((Object)value).name.IndexOf("Shotgun", StringComparison.OrdinalIgnoreCase) >= 0) { prefab = val3; return value; } if ((Object)(object)val == (Object)null) { val = value; val2 = val3; } } } prefab = val2; return val; } private static Item CreateItem(Item template) { //IL_001b: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_008e: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) Item val = ScriptableObject.CreateInstance<Item>(); ((Object)val).name = ItemKey; ((Object)val).hideFlags = (HideFlags)32; val.status = (Status)1; val.disabled = false; val.itemName = "M16A4"; val.itemNameLocalized = null; val.description = "Select fire, three-round burst, or a very loud argument. Military surplus, condition unknown."; val.itemType = (itemType)(IsRifle ? 9 : 7); val.emojiIcon = (emojiIcon)(IsRifle ? 24 : 16); val.itemVolume = (itemVolume)0; val.itemSecretShopType = (itemSecretShopType)0; val.colorPreset = template.colorPreset; val.prefab = new PrefabRef(); if ((Object)(object)template.value != (Object)null) { val.value = template.value; } else { Value val2 = ScriptableObject.CreateInstance<Value>(); val2.valueMin = 40f; val2.valueMax = 120f; ((Object)val2).hideFlags = (HideFlags)32; val.value = val2; } val.maxAmount = 1; val.maxAmountInShop = 3; val.minPlayerCount = 1; val.maxPurchase = false; val.maxPurchaseAmount = 1; val.spawnRotationOffset = template.spawnRotationOffset; val.physicalItem = true; return val; } private static GameObject ClonePrefab(GameObject templatePrefab, Item item) { ItemAttributes[] componentsInChildren = templatePrefab.GetComponentsInChildren<ItemAttributes>(true); Item[] array = (Item[])(object)new Item[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { array[i] = componentsInChildren[i].item; componentsInChildren[i].item = item; } GameObject val = null; try { val = Object.Instantiate<GameObject>(templatePrefab); ((Object)val).name = ItemKey; ((Object)val).hideFlags = (HideFlags)61; val.SetActive(true); Object.DontDestroyOnLoad((Object)(object)val); } finally { for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j] != (Object)null) { componentsInChildren[j].item = array[j]; } } } if ((Object)(object)val != (Object)null) { ((PrefabRef<GameObject>)(object)item.prefab).SetPrefab(val, ItemResourcePath); ItemAttributes[] componentsInChildren2 = val.GetComponentsInChildren<ItemAttributes>(true); for (int k = 0; k < componentsInChildren2.Length; k++) { componentsInChildren2[k].item = item; } Dbg("prefab cloned -> '" + ((Object)val).name + "', ResourcePath='" + ((PrefabRef<GameObject>)(object)item.prefab).ResourcePath + "'"); } return val; } private unsafe static void ApplyModel(GameObject clone) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0067: 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) //IL_007d: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: 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_01b5: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: 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) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: 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_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due t