using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Peak.Afflictions; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ShootZombies")] [assembly: AssemblyDescription("Turns PEAK's blowgun into a configurable zombie-survival weapon mode with selectable gun models, lobby weapon grants, an in-game config panel, and host-synced multiplayer settings.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ShootZombies")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("927916ce-8113-4ce1-a65e-d4bd77e780b4")] [assembly: AssemblyFileVersion("1.3.6.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.6.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ShootZombies { public sealed class AkHeldLegacyVisualMarker : MonoBehaviour { } public sealed class AkInPlaceMarker : MonoBehaviour { public bool hasBaseRotation; public bool hasBaseTransform; public bool hasOriginalVisual; public Vector3 baseLocalPosition = Vector3.zero; public Quaternion baseLocalRotation = Quaternion.identity; public Vector3 baseLocalScale = Vector3.one; public Mesh originalMesh; public Material[] originalMaterials; } internal static class AkLightweightAssetLoader { private struct ObjVertexKey : IEquatable { public int PositionIndex; public int UvIndex; public int NormalIndex; public bool Equals(ObjVertexKey other) { if (PositionIndex == other.PositionIndex && UvIndex == other.UvIndex) { return NormalIndex == other.NormalIndex; } return false; } public override bool Equals(object obj) { if (!(obj is ObjVertexKey)) { return false; } return Equals((ObjVertexKey)obj); } public override int GetHashCode() { return ((17 * 31 + PositionIndex) * 31 + UvIndex) * 31 + NormalIndex; } } private struct ObjFaceVertex { public int PositionIndex; public int UvIndex; public int NormalIndex; } [CompilerGenerated] private sealed class d__18 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private string <>2__current; private int <>l__initialThreadId; private HashSet 5__2; private IEnumerator <>7__wrap2; private string 5__4; string IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__18(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>7__wrap2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = new HashSet(StringComparer.OrdinalIgnoreCase); <>7__wrap2 = GetSearchRoots().GetEnumerator(); <>1__state = -3; break; case 1: { <>1__state = -3; string path = Path.Combine(5__4, "AK_Resources"); if (Directory.Exists(path)) { string fullPath = GetFullPath(path); if (!string.IsNullOrWhiteSpace(fullPath) && 5__2.Add(fullPath)) { <>2__current = fullPath; <>1__state = 2; return true; } } goto IL_0120; } case 2: { <>1__state = -3; goto IL_0120; } IL_0120: 5__4 = null; break; } while (<>7__wrap2.MoveNext()) { string current = <>7__wrap2.Current; if (!string.IsNullOrWhiteSpace(current)) { 5__4 = GetFullPath(current); if (!string.IsNullOrWhiteSpace(5__4) && Directory.Exists(5__4) && 5__2.Add(5__4)) { <>2__current = 5__4; <>1__state = 1; return true; } } } <>m__Finally1(); <>7__wrap2 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 != null) { <>7__wrap2.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__18(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__19 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private string <>2__current; private int <>l__initialThreadId; private string 5__2; private string 5__3; string IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__19(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; string location = Assembly.GetExecutingAssembly().Location; string value = (string.IsNullOrWhiteSpace(location) ? string.Empty : (Path.GetDirectoryName(location) ?? string.Empty)); 5__2 = Paths.PluginPath ?? string.Empty; 5__3 = (string.IsNullOrWhiteSpace(5__2) ? string.Empty : (Directory.GetParent(5__2)?.FullName ?? string.Empty)); if (!string.IsNullOrWhiteSpace(value)) { <>2__current = value; <>1__state = 1; return true; } goto IL_00c1; } case 1: <>1__state = -1; goto IL_00c1; case 2: <>1__state = -1; goto IL_00ea; case 3: <>1__state = -1; goto IL_0113; case 4: { <>1__state = -1; return false; } IL_0113: <>2__current = Path.Combine(Environment.CurrentDirectory ?? string.Empty, "AK_Resources"); <>1__state = 4; return true; IL_00c1: if (!string.IsNullOrWhiteSpace(5__2)) { <>2__current = 5__2; <>1__state = 2; return true; } goto IL_00ea; IL_00ea: if (!string.IsNullOrWhiteSpace(5__3)) { <>2__current = 5__3; <>1__state = 3; return true; } goto IL_0113; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__19(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private const string ResourceFolderName = "AK_Resources"; private const string CanonicalModelFileName = "ak_model.obj"; private const string CanonicalTextureFileName = "ak_texture.png"; private const string CanonicalIconFileName = "ak_icon.png"; private static readonly string[] ModelFileNames = new string[3] { "ak_model.obj", "-3728671120793114700_Cube.obj", "Cube.obj" }; private static readonly string[] TextureFileNames = new string[3] { "ak_texture.png", "AK-47_type_II.png", "ak47.png" }; private static readonly string[] IconFileNames = new string[3] { "ak_icon.png", "AK-47_type_II_icon.png", "ak47_icon.png" }; private static readonly Vector3 MeshLocalPosition = new Vector3(0f, 0f, 0.11863899f); private static readonly Quaternion MeshLocalRotation = new Quaternion(1.1009293E-08f, -0.70710677f, -0.7071068f, -2.2351747E-08f); private static readonly Vector3 MeshLocalScale = new Vector3(0.3060086f, 0.18934934f, 0.18934931f); private static readonly Vector3 SpawnLocalPosition = new Vector3(0.002f, 0.036f, 0.5118f); private static readonly Quaternion SpawnLocalRotation = Quaternion.identity; private static readonly Vector3 SpawnLocalScale = new Vector3(0.7339988f, 0.7339988f, 0.7339988f); public static bool TryLoad(out GameObject prefab, out string diagnostic) { prefab = null; diagnostic = string.Empty; if (!TryResolveResourcePaths(out var modelPath, out var texturePath, out diagnostic)) { return false; } if (!TryLoadObjMesh(modelPath, out var mesh, out var summary)) { diagnostic = "OBJ load failed: " + modelPath + " (" + summary + ")"; return false; } string summary2; Material val = CreateMaterial(LoadTexture(texturePath, out summary2), texturePath); if ((Object)(object)val == (Object)null) { diagnostic = "Material creation failed for texture: " + texturePath; return false; } prefab = BuildPrefab(mesh, val); if ((Object)(object)prefab == (Object)null) { diagnostic = "Prefab build failed"; return false; } diagnostic = "model=" + Path.GetFileName(modelPath) + ", texture=" + Path.GetFileName(texturePath) + ", " + summary + ", " + summary2; return true; } public static bool TryLoadIconTexture(out Texture2D texture, out string diagnostic) { texture = null; diagnostic = string.Empty; List list = GetSearchDirectories().Distinct(StringComparer.OrdinalIgnoreCase).ToList(); foreach (string item in list) { string text = ResolveFirstExistingPath(item, IconFileNames); if (!string.IsNullOrWhiteSpace(text)) { texture = LoadTexture(text, out var summary); if ((Object)(object)texture != (Object)null) { diagnostic = "icon=" + Path.GetFileName(text) + ", " + summary; return true; } diagnostic = "icon decode failed: " + text + ", " + summary; return false; } } diagnostic = "searched=" + string.Join(" | ", list); return false; } private static bool TryResolveResourcePaths(out string modelPath, out string texturePath, out string diagnostic) { modelPath = string.Empty; texturePath = string.Empty; List list = GetSearchDirectories().Distinct(StringComparer.OrdinalIgnoreCase).ToList(); foreach (string item in list) { string text = ResolveFirstExistingPath(item, ModelFileNames); string text2 = ResolveFirstExistingPath(item, TextureFileNames); if (!string.IsNullOrWhiteSpace(text) && !string.IsNullOrWhiteSpace(text2)) { modelPath = text; texturePath = text2; diagnostic = "resolved at " + item; return true; } } diagnostic = "searched=" + string.Join(" | ", list); return false; } [IteratorStateMachine(typeof(d__18))] private static IEnumerable GetSearchDirectories() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__18(-2); } [IteratorStateMachine(typeof(d__19))] private static IEnumerable GetSearchRoots() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__19(-2); } private static string GetFullPath(string path) { try { return Path.GetFullPath(path); } catch { return string.Empty; } } private static string ResolveFirstExistingPath(string directory, IEnumerable fileNames) { if (string.IsNullOrWhiteSpace(directory) || !Directory.Exists(directory)) { return string.Empty; } foreach (string fileName in fileNames) { string text = Path.Combine(directory, fileName); if (File.Exists(text)) { return text; } } return string.Empty; } private static bool TryLoadObjMesh(string modelPath, out Mesh mesh, out string summary) { //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) mesh = null; summary = string.Empty; List list = new List(4096); List list2 = new List(4096); List list3 = new List(4096); List list4 = new List(4096); List list5 = new List(4096); List list6 = new List(4096); List list7 = new List(12288); Dictionary cache = new Dictionary(); bool flag = true; try { foreach (string item in File.ReadLines(modelPath)) { if (string.IsNullOrWhiteSpace(item) || item[0] == '#') { continue; } if (item.StartsWith("v ", StringComparison.Ordinal)) { if (TryParseVector3(item, out var vector)) { list.Add(vector); } } else if (item.StartsWith("vt ", StringComparison.Ordinal)) { if (TryParseVector2(item, out var vector2)) { list2.Add(vector2); } } else if (item.StartsWith("vn ", StringComparison.Ordinal)) { if (TryParseVector3(item, out var vector3)) { list3.Add(vector3); } } else { if (!item.StartsWith("f ", StringComparison.Ordinal)) { continue; } string[] array = item.Substring(2).Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length < 3) { continue; } List list8 = new List(array.Length); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { if (TryParseFaceVertex(array2[i], list.Count, list2.Count, list3.Count, out var vertex)) { list8.Add(vertex); if (vertex.NormalIndex < 0) { flag = false; } } } if (list8.Count >= 3) { for (int j = 1; j < list8.Count - 1; j++) { AddTriangleVertex(list8[0], list, list2, list3, list4, list5, list6, list7, cache); AddTriangleVertex(list8[j], list, list2, list3, list4, list5, list6, list7, cache); AddTriangleVertex(list8[j + 1], list, list2, list3, list4, list5, list6, list7, cache); } } } } if (list4.Count == 0 || list7.Count == 0) { summary = "no mesh data"; return false; } mesh = new Mesh(); ((Object)mesh).name = "AK_RuntimeMesh"; if (list4.Count > 65535) { mesh.indexFormat = (IndexFormat)1; } mesh.SetVertices(list4); if (list5.Count == list4.Count) { mesh.SetUVs(0, list5); } mesh.subMeshCount = 1; mesh.SetTriangles(list7, 0, true); if (flag && list6.Count == list4.Count) { mesh.SetNormals(list6); } else { mesh.RecalculateNormals(); } mesh.RecalculateBounds(); TryRecalculateTangents(mesh); summary = "verts=" + list4.Count + ", tris=" + list7.Count / 3; return true; } catch (Exception ex) { mesh = null; summary = ex.GetType().Name + ": " + ex.Message; return false; } } private static bool TryParseVector3(string line, out Vector3 vector) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) vector = Vector3.zero; string[] array = line.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length < 4) { return false; } if (float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { vector = new Vector3(result, result2, result3); return true; } return false; } private static bool TryParseVector2(string line, out Vector2 vector) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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) vector = Vector2.zero; string[] array = line.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length < 3) { return false; } if (float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { vector = new Vector2(result, result2); return true; } return false; } private static bool TryParseFaceVertex(string token, int positionCount, int uvCount, int normalCount, out ObjFaceVertex vertex) { vertex = default(ObjFaceVertex); if (string.IsNullOrWhiteSpace(token)) { return false; } string[] array = token.Split(new char[1] { '/' }); if (array.Length == 0) { return false; } vertex.PositionIndex = ResolveObjIndex(ParseObjIndex(array[0]), positionCount); vertex.UvIndex = ((array.Length >= 2 && !string.IsNullOrWhiteSpace(array[1])) ? ResolveObjIndex(ParseObjIndex(array[1]), uvCount) : (-1)); vertex.NormalIndex = ((array.Length >= 3 && !string.IsNullOrWhiteSpace(array[2])) ? ResolveObjIndex(ParseObjIndex(array[2]), normalCount) : (-1)); return vertex.PositionIndex >= 0; } private static int ParseObjIndex(string value) { int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result); return result; } private static int ResolveObjIndex(int rawIndex, int count) { if (rawIndex > 0) { return rawIndex - 1; } if (rawIndex < 0) { return count + rawIndex; } return -1; } private static void AddTriangleVertex(ObjFaceVertex faceVertex, List positions, List uvs, List normals, List outVertices, List outUvs, List outNormals, List outTriangles, Dictionary cache) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00ba: Unknown result type (might be due to invalid IL or missing references) ObjVertexKey key = default(ObjVertexKey); key.PositionIndex = faceVertex.PositionIndex; key.UvIndex = faceVertex.UvIndex; key.NormalIndex = faceVertex.NormalIndex; if (!cache.TryGetValue(key, out var value)) { value = (cache[key] = outVertices.Count); outVertices.Add(positions[faceVertex.PositionIndex]); outUvs.Add((faceVertex.UvIndex >= 0 && faceVertex.UvIndex < uvs.Count) ? uvs[faceVertex.UvIndex] : Vector2.zero); outNormals.Add((faceVertex.NormalIndex >= 0 && faceVertex.NormalIndex < normals.Count) ? normals[faceVertex.NormalIndex] : Vector3.zero); } outTriangles.Add(value); } private static void TryRecalculateTangents(Mesh mesh) { if ((Object)(object)mesh == (Object)null) { return; } try { typeof(Mesh).GetMethod("RecalculateTangents", BindingFlags.Instance | BindingFlags.Public, null, Type.EmptyTypes, null)?.Invoke(mesh, null); } catch { } } private static Texture2D LoadTexture(string texturePath, out string summary) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown summary = "texture=missing"; if (string.IsNullOrWhiteSpace(texturePath) || !File.Exists(texturePath)) { return null; } try { byte[] data = File.ReadAllBytes(texturePath); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Object)val).name = Path.GetFileNameWithoutExtension(texturePath); if (!TryLoadPngIntoTexture(val, data)) { Object.DestroyImmediate((Object)(object)val); summary = "texture=decode-failed"; return null; } ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).anisoLevel = 2; summary = "texture=" + ((Texture)val).width + "x" + ((Texture)val).height; return val; } catch (Exception ex) { summary = "texture-error=" + ex.GetType().Name; return null; } } private static bool TryLoadPngIntoTexture(Texture2D texture, byte[] data) { if ((Object)(object)texture == (Object)null || data == null || data.Length == 0) { return false; } try { MethodInfo method = typeof(Texture2D).GetMethod("LoadImage", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(byte[]) }, null); if (method != null) { if (!(method.Invoke(texture, new object[1] { data }) is bool result)) { return true; } return result; } } catch { } try { MethodInfo methodInfo = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule", throwOnError: false)?.GetMethod("LoadImage", BindingFlags.Static | BindingFlags.Public, null, new Type[3] { typeof(Texture2D), typeof(byte[]), typeof(bool) }, null); if (methodInfo != null) { if (!(methodInfo.Invoke(null, new object[3] { texture, data, false }) is bool result2)) { return true; } return result2; } } catch { } return false; } private static Material CreateMaterial(Texture2D texture, string texturePath) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0089: 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) Shader val = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Diffuse"); if ((Object)(object)val == (Object)null) { return null; } Material val2 = new Material(val); ((Object)val2).name = "M_AK_Runtime"; if (val2.HasProperty("_BaseMap")) { val2.SetTexture("_BaseMap", (Texture)(object)texture); } if (val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", (Texture)(object)texture); } if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", Color.white); } if (val2.HasProperty("_Color")) { val2.SetColor("_Color", Color.white); } if (val2.HasProperty("_Smoothness")) { val2.SetFloat("_Smoothness", 0.12f); } if (val2.HasProperty("_Glossiness")) { val2.SetFloat("_Glossiness", 0.12f); } if (val2.HasProperty("_Cull")) { val2.SetInt("_Cull", 2); } val2.enableInstancing = true; Plugin.LogDiagnosticOnce("ak-light-mat:" + Path.GetFileName(texturePath ?? string.Empty), "Created lightweight AK material with shader=" + (((Object)(object)val != (Object)null) ? ((Object)val).name : "null") + ", texture=" + (((Object)(object)texture != (Object)null) ? (((Texture)texture).width + "x" + ((Texture)texture).height) : "none")); return val2; } private static GameObject BuildPrefab(Mesh mesh, Material material) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006b: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mesh == (Object)null || (Object)(object)material == (Object)null) { return null; } GameObject val = new GameObject("AK"); GameObject val2 = new GameObject("Mesh"); val2.transform.SetParent(val.transform, false); val2.transform.localPosition = MeshLocalPosition; val2.transform.localRotation = MeshLocalRotation; val2.transform.localScale = MeshLocalScale; MeshFilter val3 = val2.AddComponent(); MeshRenderer val4 = val2.AddComponent(); val3.sharedMesh = mesh; ((Renderer)val4).sharedMaterials = (Material[])(object)new Material[1] { material }; ((Renderer)val4).enabled = false; ((Renderer)val4).forceRenderingOff = true; ((Renderer)val4).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)val4).receiveShadows = true; GameObject val5 = new GameObject("SpawnPos"); val5.transform.SetParent(val.transform, false); val5.transform.localPosition = SpawnLocalPosition; val5.transform.localRotation = SpawnLocalRotation; val5.transform.localScale = SpawnLocalScale; Object.DontDestroyOnLoad((Object)(object)val); return val; } } public sealed class AkLocalVisualMarker : MonoBehaviour { } public sealed class AkMuzzleMarker : MonoBehaviour { } public sealed class AkSimpleVisualMarker : MonoBehaviour { } internal static class AkUiPatchHelpers { private const BindingFlags ReflectionFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly FieldInfo InventoryPrefabField = typeof(InventoryItemUI).GetField("_itemPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo InventoryItemDataField = typeof(InventoryItemUI).GetField("_itemData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo ItemDataField = typeof(Item).GetField("data", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly PropertyInfo ItemDataProperty = typeof(Item).GetProperty("data", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly PropertyInfo SlotItemProperty = typeof(ItemSlot).GetProperty("item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo SlotItemField = typeof(ItemSlot).GetField("item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo SliceItemSlotField = typeof(BackpackWheelSlice).GetField("itemSlot", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly Dictionary InventoryItemDataItemPropertyCache = new Dictionary(); private static readonly Dictionary InventoryItemDataItemFieldCache = new Dictionary(); private static readonly Dictionary InventoryUiSourceKeyCache = new Dictionary(); private static readonly Dictionary SliceSourceKeyCache = new Dictionary(); private static readonly Rect FullUvRect = new Rect(0f, 0f, 1f, 1f); private static readonly HashSet TrackedInventoryUis = new HashSet(); private static readonly HashSet TrackedSlices = new HashSet(); private static readonly HashSet TrackedWheels = new HashSet(); private static readonly List StaleInventoryUis = new List(); private static readonly List StaleSlices = new List(); private static readonly List StaleWheels = new List(); internal static void ApplyAkIcon(RawImage image, Item item) { if (Plugin.IsWeaponFeatureEnabled() && !((Object)(object)image == (Object)null) && ItemPatch.IsBlowgunLike(item)) { ApplyAkIconForce(image); } } internal static void ApplyAkIconForce(RawImage image) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_007b: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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) if ((Object)(object)image == (Object)null) { return; } Texture2D akIconTexture = Plugin.GetAkIconTexture(); if (!((Object)(object)akIconTexture == (Object)null)) { Graphic val = (Graphic)image; if (!((Object)(object)image.texture == (Object)(object)akIconTexture) || !((Object)(object)val.material == (Object)null) || !(val.color == Color.white) || !(image.uvRect == FullUvRect) || !((Behaviour)image).enabled) { image.texture = (Texture)akIconTexture; val.color = Color.white; val.material = null; image.uvRect = FullUvRect; ((Behaviour)image).enabled = true; } } } internal static void ApplyAkText(TMP_Text label) { if (!((Object)(object)label == (Object)null) && !string.Equals(label.text, ItemPatch.DisplayName, StringComparison.Ordinal)) { label.text = ItemPatch.DisplayName; } } internal static void EnsureAkDisplayAndVisual(Item item) { if (Plugin.IsWeaponFeatureEnabled() && !((Object)(object)item == (Object)null) && ItemPatch.IsBlowgunLike(item)) { ItemPatch.ApplyAkDisplay(item); } } internal static void ApplyAkToInventoryUi(InventoryItemUI ui, Item knownItem = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown if ((Object)ui == (Object)null) { return; } TrackInventoryUi(ui); Item val = (((Object)(object)knownItem != (Object)null) ? knownItem : ResolveItemFromInventoryUi(ui)); int instanceID = ((Object)ui).GetInstanceID(); if (!Plugin.IsWeaponFeatureEnabled()) { return; } int itemSourceKey = GetItemSourceKey(val); if (itemSourceKey != 0 && InventoryUiSourceKeyCache.TryGetValue(instanceID, out var value) && value == itemSourceKey && IsInventoryUiAlreadyShowingAk(ui)) { return; } if ((Object)(object)val != (Object)null && ItemPatch.IsBlowgunLike(val)) { EnsureAkDisplayAndVisual(val); ApplyAkIconForce(ui.icon); ApplyAkText((TMP_Text)ui.nameText); InventoryUiSourceKeyCache[instanceID] = itemSourceKey; return; } InventoryUiSourceKeyCache[instanceID] = itemSourceKey; if ((Object)(object)val != (Object)null) { RestoreInventoryUi(ui, val); return; } if (itemSourceKey == 0 && IsInventoryUiAlreadyShowingAk(ui)) { ClearInventoryUi(ui); return; } TextMeshProUGUI nameText = ui.nameText; string value2 = ((((Object)(object)nameText != (Object)null) ? ((TMP_Text)nameText).text : null) ?? string.Empty).ToLowerInvariant(); RawImage icon = ui.icon; Texture val2 = (((Object)(object)icon != (Object)null) ? icon.texture : null); string text = (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : string.Empty).ToLowerInvariant(); if (ItemPatch.ContainsWeaponKeyword(value2) || text.Contains("dart") || text.Contains("blowgun") || ItemPatch.ContainsWeaponKeyword(text)) { ApplyAkIconForce(ui.icon); ApplyAkText((TMP_Text)ui.nameText); } } internal static Item ResolveItemFromInventoryUi(InventoryItemUI ui) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if ((Object)ui == (Object)null) { return null; } try { object obj = InventoryPrefabField?.GetValue(ui); Item val = (Item)((obj is Item) ? obj : null); if ((Object)(object)val != (Object)null) { return val; } object obj2 = InventoryItemDataField?.GetValue(ui); if (obj2 != null) { Item val2 = ResolveItemFromItemData(obj2); if ((Object)(object)val2 != (Object)null) { return val2; } } } catch { } return null; } internal static Item ResolveItemFromSlot(ItemSlot slot) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown if (slot == null || slot.IsEmpty()) { return null; } try { object obj = SlotItemProperty?.GetValue(slot); Item val = (Item)((obj is Item) ? obj : null); if ((Object)(object)val != (Object)null) { return val; } object obj2 = SlotItemField?.GetValue(slot); Item val2 = (Item)((obj2 is Item) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { return val2; } } catch { } return slot.prefab; } internal static void ApplyAkToSliceImage(BackpackWheelSlice slice, Item knownItem = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)slice == (Object)null) { return; } TrackSlice(slice); Item val = (((Object)(object)knownItem != (Object)null) ? knownItem : ResolveItemFromSlice(slice)); int instanceID = ((Object)slice).GetInstanceID(); if (!Plugin.IsWeaponFeatureEnabled()) { return; } int itemSourceKey = GetItemSourceKey(val); if (itemSourceKey == 0 || !SliceSourceKeyCache.TryGetValue(instanceID, out var value) || value != itemSourceKey || !IsSliceAlreadyShowingAk(slice)) { if (!((Object)(object)val == (Object)null) && ItemPatch.IsBlowgunLike(val)) { EnsureAkDisplayAndVisual(val); ApplyAkIconForce(slice.image); } else { RestoreSliceImage(slice, val); } SliceSourceKeyCache[instanceID] = itemSourceKey; } } internal static void ApplyAkToBackpackWheel(BackpackWheel wheel, Item knownItem = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)wheel == (Object)null) { return; } TrackWheel(wheel); Item val = knownItem; if ((Object)(object)val == (Object)null) { Character localCharacter = Character.localCharacter; object obj; if (localCharacter == null) { obj = null; } else { CharacterData data = localCharacter.data; obj = ((data != null) ? data.currentItem : null); } val = (Item)obj; } Character localCharacter2 = Character.localCharacter; if (Plugin.IsWeaponFeatureEnabled()) { if (!((Object)(object)val == (Object)null) && ItemPatch.IsBlowgunLike(val) && ItemPatch.IsLocallyHeldByPlayer(val, localCharacter2)) { ItemPatch.ApplyAkDisplayIfNeeded(val); ApplyAkIcon(wheel.currentlyHeldItem, val); } else { RestoreBackpackWheel(wheel, ((Object)(object)val != (Object)null && ItemPatch.IsBlowgunLike(val)) ? null : val); } } } internal static bool RefreshTrackedUi() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown CleanupStaleTrackedUi(); bool result = false; foreach (InventoryItemUI trackedInventoryUi in TrackedInventoryUis) { if (!((Object)trackedInventoryUi == (Object)null)) { ApplyAkToInventoryUi(trackedInventoryUi); result = true; } } foreach (BackpackWheelSlice trackedSlice in TrackedSlices) { if (!((Object)trackedSlice == (Object)null)) { ApplyAkToSliceImage(trackedSlice); result = true; } } foreach (BackpackWheel trackedWheel in TrackedWheels) { if (!((Object)trackedWheel == (Object)null)) { ApplyAkToBackpackWheel(trackedWheel); result = true; } } return result; } internal static void ClearInventoryUiCache(InventoryItemUI ui) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if (!((Object)ui == (Object)null)) { InventoryUiSourceKeyCache.Remove(((Object)ui).GetInstanceID()); } } internal static void ClearRuntimeCaches() { InventoryUiSourceKeyCache.Clear(); SliceSourceKeyCache.Clear(); TrackedInventoryUis.Clear(); TrackedSlices.Clear(); TrackedWheels.Clear(); StaleInventoryUis.Clear(); StaleSlices.Clear(); StaleWheels.Clear(); } private static Item ResolveItemFromItemData(object itemData) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown if (itemData == null) { return null; } Type type = itemData.GetType(); if (!InventoryItemDataItemPropertyCache.TryGetValue(type, out var value)) { value = type.GetProperty("item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); InventoryItemDataItemPropertyCache[type] = value; InventoryItemDataItemFieldCache[type] = type.GetField("item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } try { object obj = value?.GetValue(itemData) ?? InventoryItemDataItemFieldCache[type]?.GetValue(itemData); return (Item)((obj is Item) ? obj : null); } catch { return null; } } private static int GetItemSourceKey(Item item) { if (!((Object)(object)item == (Object)null)) { return ((Object)item).GetInstanceID(); } return 0; } internal static bool IsInventoryUiAlreadyShowingAk(InventoryItemUI ui) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)ui == (Object)null) { return false; } TextMeshProUGUI nameText = ui.nameText; if (!string.Equals((nameText != null) ? ((TMP_Text)nameText).text : null, ItemPatch.DisplayName, StringComparison.Ordinal)) { return false; } Texture2D akIconTexture = Plugin.GetAkIconTexture(); RawImage icon = ui.icon; if ((Object)(object)akIconTexture != (Object)null && !((Object)(object)icon == (Object)null)) { return (Object)(object)icon.texture == (Object)(object)akIconTexture; } return false; } private static bool IsSliceAlreadyShowingAk(BackpackWheelSlice slice) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)slice == (Object)null) { return false; } Texture2D akIconTexture = Plugin.GetAkIconTexture(); RawImage image = slice.image; if ((Object)(object)akIconTexture != (Object)null && !((Object)(object)image == (Object)null)) { return (Object)(object)image.texture == (Object)(object)akIconTexture; } return false; } private static void RestoreInventoryUi(InventoryItemUI ui, Item item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_006b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)ui == (Object)null) && !((Object)(object)item == (Object)null)) { Texture val = ResolveDefaultItemIcon(item); if (!((Object)(object)ui.icon == (Object)null)) { ui.icon.texture = val; ((Graphic)ui.icon).color = ResolveInventoryIconColor(ui, Color.white); ((Graphic)ui.icon).material = null; ui.icon.uvRect = FullUvRect; ((Behaviour)ui.icon).enabled = (Object)(object)val != (Object)null; } if (!((Object)(object)ui.nameText == (Object)null)) { ((TMP_Text)ui.nameText).text = ResolveDefaultItemName(item); } } } private static void ClearInventoryUi(InventoryItemUI ui) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if (!((Object)ui == (Object)null)) { if (!((Object)(object)ui.icon == (Object)null)) { ui.icon.texture = null; ((Behaviour)ui.icon).enabled = false; } if (!((Object)(object)ui.nameText == (Object)null)) { ((TMP_Text)ui.nameText).text = string.Empty; } } } private static void RestoreSliceImage(BackpackWheelSlice slice, Item item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (!((Object)slice == (Object)null) && !((Object)(object)slice.image == (Object)null)) { Texture val = ResolveDefaultItemIcon(item); slice.image.texture = val; ((Graphic)slice.image).color = ResolveSliceIconColor(slice, Color.white); ((Graphic)slice.image).material = null; slice.image.uvRect = FullUvRect; ((Behaviour)slice.image).enabled = (Object)(object)val != (Object)null; } } private static void RestoreBackpackWheel(BackpackWheel wheel, Item item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (!((Object)wheel == (Object)null)) { RawImage currentlyHeldItem = wheel.currentlyHeldItem; if (!((Object)(object)currentlyHeldItem == (Object)null)) { Texture val2 = (currentlyHeldItem.texture = ResolveDefaultItemIcon(item)); ((Graphic)currentlyHeldItem).color = ResolveItemIconColor(item, Color.white); ((Graphic)currentlyHeldItem).material = null; currentlyHeldItem.uvRect = FullUvRect; ((Behaviour)currentlyHeldItem).enabled = (Object)(object)val2 != (Object)null; } } } private static Texture ResolveDefaultItemIcon(Item item) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if ((Object)(object)item == (Object)null || item.UIData == null) { return null; } try { return (Texture)item.UIData.GetIcon(); } catch { return (Texture)item.UIData.icon; } } private static Color ResolveInventoryIconColor(InventoryItemUI ui, Color fallback) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0030: Unknown result type (might be due to invalid IL or missing references) if ((Object)ui == (Object)null) { return fallback; } try { Color color; return TryGetCookColor(InventoryItemDataField?.GetValue(ui), out color) ? color : fallback; } catch { return fallback; } } private static Color ResolveSliceIconColor(BackpackWheelSlice slice, Color fallback) { //IL_0019: 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) ItemSlot val = ResolveItemSlotFromSlice(slice); if (val == null || !TryGetCookColor(val.data, out var color)) { return fallback; } return color; } private static Color ResolveItemIconColor(Item item, Color fallback) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { return fallback; } try { Color color; return TryGetCookColor(ItemDataField?.GetValue(item) ?? ItemDataProperty?.GetValue(item), out color) ? color : fallback; } catch { return fallback; } } private static bool TryGetCookColor(object itemData, out Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) color = Color.white; ItemInstanceData val = (ItemInstanceData)((itemData is ItemInstanceData) ? itemData : null); IntItemData val2 = default(IntItemData); if (val != null && val.TryGetDataEntry((DataEntryKey)1, ref val2) && val2 != null && val2.Value > 0) { color = ItemCooking.GetCookColor(val2.Value); return true; } return false; } private static string ResolveDefaultItemName(Item item) { if ((Object)(object)item == (Object)null) { return string.Empty; } try { string itemName = item.GetItemName((ItemInstanceData)null); if (!string.IsNullOrWhiteSpace(itemName)) { return itemName; } } catch { } return item.UIData?.itemName ?? string.Empty; } internal static Item ResolveItemFromSlice(BackpackWheelSlice slice) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)slice == (Object)null) { return null; } try { PropertyInfo[] properties = ((object)slice).GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo propertyInfo in properties) { if (!(propertyInfo == null) && propertyInfo.GetIndexParameters().Length == 0) { object value = null; try { value = propertyInfo.GetValue(slice); } catch { } Item val = ExtractItem(value); if ((Object)(object)val != (Object)null) { return val; } } } FieldInfo[] fields = ((object)slice).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { object value2 = null; try { value2 = fieldInfo.GetValue(slice); } catch { } Item val2 = ExtractItem(value2); if ((Object)(object)val2 != (Object)null) { return val2; } } } catch { } return null; } private static ItemSlot ResolveItemSlotFromSlice(BackpackWheelSlice slice) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)slice == (Object)null || SliceItemSlotField == null) { return null; } try { object? value = SliceItemSlotField.GetValue(slice); return (ItemSlot)((value is ItemSlot) ? value : null); } catch { return null; } } private static void TrackInventoryUi(InventoryItemUI ui) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if (!((Object)ui == (Object)null) && !TrackedInventoryUis.Contains(ui)) { TrackedInventoryUis.Add(ui); } } private static void TrackSlice(BackpackWheelSlice slice) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if (!((Object)slice == (Object)null) && !TrackedSlices.Contains(slice)) { TrackedSlices.Add(slice); } } private static void TrackWheel(BackpackWheel wheel) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if (!((Object)wheel == (Object)null) && !TrackedWheels.Contains(wheel)) { TrackedWheels.Add(wheel); } } private static void CleanupStaleTrackedUi() { RemoveDestroyedTrackedObjects(TrackedInventoryUis, StaleInventoryUis); RemoveDestroyedTrackedObjects(TrackedSlices, StaleSlices); RemoveDestroyedTrackedObjects(TrackedWheels, StaleWheels); } private static void RemoveDestroyedTrackedObjects(HashSet source, List staleBuffer) where T : Object { if (source.Count == 0) { return; } staleBuffer.Clear(); foreach (T item in source) { if ((Object)(object)item == (Object)null) { staleBuffer.Add(item); } } for (int i = 0; i < staleBuffer.Count; i++) { source.Remove(staleBuffer[i]); } staleBuffer.Clear(); } private static Item ExtractItem(object value) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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) Item val = (Item)((value is Item) ? value : null); if ((Object)(object)val != (Object)null) { return val; } ItemSlot val2 = (ItemSlot)((value is ItemSlot) ? value : null); if (val2 != null) { return ResolveItemFromSlot(val2); } if (value == null) { return null; } Type type = value.GetType(); if (!(type.FullName ?? string.Empty).StartsWith("System.ValueTuple", StringComparison.Ordinal)) { return null; } try { FieldInfo field = type.GetField("Item1"); FieldInfo? field2 = type.GetField("Item2"); object obj = field?.GetValue(value); object obj2 = field2?.GetValue(value); if (obj is BackpackReference) { BackpackReference backpackRef = (BackpackReference)obj; if (obj2 is byte slotIndex) { return ResolveFromBackpackTuple(backpackRef, slotIndex); } if (obj2 is int) { int num = (int)obj2; return ResolveFromBackpackTuple(backpackRef, (byte)Mathf.Clamp(num, 0, 255)); } } } catch { } return null; } private static Item ResolveFromBackpackTuple(BackpackReference backpackRef, byte slotIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { if ((object)backpackRef == null) { return null; } object data = ((BackpackReference)(ref backpackRef)).GetData(); if (data == null) { return null; } if (!((data.GetType().GetProperty("itemSlots", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(data) ?? data.GetType().GetField("itemSlots", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(data)) is ItemSlot[] array) || slotIndex >= array.Length) { return null; } return ResolveItemFromSlot(array[slotIndex]); } catch { } return null; } } [HarmonyPatch(typeof(BackpackWheel), "UpdateCookedAmount")] public static class BackpackWheelCookColorPatch { [HarmonyPostfix] public static void UpdateCookedAmountPostfix(BackpackWheel __instance, Item item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if ((Object)__instance == (Object)null) { return; } try { if (!Plugin.IsWeaponFeatureEnabled()) { return; } object obj; if (!((Object)(object)item != (Object)null)) { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { obj = null; } else { CharacterData data = localCharacter.data; obj = (((Object)(object)data != (Object)null) ? data.currentItem : null); } } else { obj = item; } Item val = (Item)obj; if (!((Object)(object)val == (Object)null) && ItemPatch.IsBlowgunLike(val)) { AkUiPatchHelpers.ApplyAkIconForce(__instance.currentlyHeldItem); } } catch { } } } [HarmonyPatch(typeof(BackpackWheel), "InitWheel")] public static class BackpackWheelPatch { [HarmonyPostfix] public static void InitWheelPostfix(BackpackWheel __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)__instance == (Object)null) { return; } try { if (Plugin.IsWeaponFeatureEnabled()) { AkUiPatchHelpers.ApplyAkToBackpackWheel(__instance); BackpackWheelSlice[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { AkUiPatchHelpers.ApplyAkToSliceImage(componentsInChildren[i]); } } } catch (Exception ex) { Plugin.Log.LogError((object)("[ShootZombies] BackpackWheelPatch failed: " + ex)); } } } [HarmonyPatch(typeof(BackpackWheelSlice), "SetItemIcon")] public static class BackpackWheelSetItemIconPatch { [HarmonyPostfix] public static void SetItemIconPostfix(BackpackWheelSlice __instance, Item iconHolder, ItemInstanceData itemInstanceData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)__instance == (Object)null) { return; } try { if (Plugin.IsWeaponFeatureEnabled()) { Item val = (((Object)(object)iconHolder != (Object)null) ? iconHolder : AkUiPatchHelpers.ResolveItemFromSlice(__instance)); if (!((Object)(object)val == (Object)null) && ItemPatch.IsBlowgunLike(val)) { AkUiPatchHelpers.ApplyAkToSliceImage(__instance, val); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[ShootZombies] BackpackWheelSetItemIconPatch failed: " + ex.Message)); } } } [HarmonyPatch(typeof(BackpackWheelSlice), "SharedInit")] public static class BackpackWheelSharedInitPatch { [HarmonyPostfix] public static void SharedInitPostfix(BackpackWheelSlice __instance, BackpackReference bpRef, BackpackWheel wheel) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)__instance == (Object)null) { return; } try { if (Plugin.IsWeaponFeatureEnabled()) { AkUiPatchHelpers.ApplyAkToSliceImage(__instance); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[ShootZombies] BackpackWheelSharedInitPatch failed: " + ex.Message)); } } } [HarmonyPatch(typeof(BackpackWheelSlice), "UpdateCookedAmount")] public static class BackpackWheelSliceCookColorPatch { [HarmonyPostfix] public static void UpdateCookedAmountPostfix(BackpackWheelSlice __instance, Item item, ItemInstanceData itemInstanceData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)__instance == (Object)null) { return; } try { if (Plugin.IsWeaponFeatureEnabled()) { Item val = (((Object)(object)item != (Object)null) ? item : AkUiPatchHelpers.ResolveItemFromSlice(__instance)); if (!((Object)(object)val == (Object)null) && ItemPatch.IsBlowgunLike(val)) { AkUiPatchHelpers.ApplyAkIconForce(__instance.image); } } } catch { } } } [HarmonyPatch(typeof(BackpackWheelSlice), "InitItemSlot")] public static class BackpackWheelSlicePatch { [HarmonyPostfix] public static void InitItemSlotPostfix(BackpackWheelSlice __instance, (BackpackReference, byte) slot, BackpackWheel wheel) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)__instance == (Object)null) { return; } try { if (Plugin.IsWeaponFeatureEnabled()) { ItemSlot val = ((BackpackReference)(ref slot.Item1)).GetData().itemSlots[slot.Item2]; if (val != null && !val.IsEmpty() && ItemPatch.IsBlowgunLike(val.prefab)) { Item val2 = AkUiPatchHelpers.ResolveItemFromSlot(val); Item val3 = (((Object)(object)val2 != (Object)null) ? val2 : val.prefab); ItemPatch.ApplyAkDisplayIfNeeded(val3); ItemPatch.ApplyAkDisplayIfNeeded(val.prefab); AkUiPatchHelpers.ApplyAkToSliceImage(__instance, val3); } } } catch (Exception ex) { Plugin.Log.LogError((object)("[ShootZombies] BackpackWheelSlicePatch failed: " + ex)); } } } [HarmonyPatch(typeof(BackpackWheelSlice), "InitStashSlot")] public static class BackpackWheelStashSlicePatch { [HarmonyPostfix] public static void InitStashSlotPostfix(BackpackWheelSlice __instance, BackpackReference bpRef, BackpackWheel wheel) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown if ((Object)__instance == (Object)null) { return; } try { if (!Plugin.IsWeaponFeatureEnabled()) { return; } Item val = AkUiPatchHelpers.ResolveItemFromSlice(__instance); if ((Object)(object)val == (Object)null) { Character localCharacter = Character.localCharacter; object obj; if ((Object)(object)localCharacter == (Object)null) { obj = null; } else { CharacterData data = localCharacter.data; obj = (((Object)(object)data != (Object)null) ? data.currentItem : null); } val = (Item)obj; } if (!((Object)(object)val == (Object)null) && ItemPatch.IsBlowgunLike(val)) { AkUiPatchHelpers.ApplyAkToSliceImage(__instance, val); } } catch (Exception ex) { Plugin.Log.LogError((object)("[ShootZombies] BackpackWheelStashSlicePatch failed: " + ex)); } } } [HarmonyPatch] public class BlowgunChargeSoundPatch { private static MethodInfo _targetMethod; private static FieldInfo _castProgressField; private static float _lastCastProgress; private static bool _hasPlayedGunshot; private static MethodBase TargetMethod() { if (_targetMethod == null) { Type type = typeof(Item).Assembly.GetType("SFX_Instance"); if (type != null) { _targetMethod = type.GetMethod("Play", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(Vector3) }, null); if (_targetMethod == null) { _targetMethod = type.GetMethods(BindingFlags.Instance | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "Play" && m.GetParameters().Length == 1); } } } return _targetMethod; } private static bool Prefix(object __instance) { try { if (!Plugin.IsWeaponFeatureEnabled()) { return true; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return true; } if ((Object)(object)localCharacter.player == (Object)null) { return true; } CharacterData data = localCharacter.data; Item val = (((Object)(object)data != (Object)null) ? data.currentItem : null); if ((Object)(object)val == (Object)null || !ItemPatch.IsBlowgunLike(val)) { return true; } if (_castProgressField == null) { _castProgressField = ((object)val).GetType().GetField("k__BackingField", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_castProgressField == null) { return true; } float num = (float)_castProgressField.GetValue(val); bool flag = _lastCastProgress >= 0.99f; bool flag2 = num >= 0.99f; _lastCastProgress = num; if (!flag2) { _hasPlayedGunshot = false; return false; } if (!flag && flag2 && !_hasPlayedGunshot) { _hasPlayedGunshot = true; return false; } return false; } catch (Exception) { } return true; } } [HarmonyPatch] public class BlowgunInfiniteUsePatch { private const int BlowgunItemId = 70; private static Type _actionRaycastDartType; private static Type _actionConsumeType; private static Type _actionConsumeAndSpawnType; private static bool _itemDataAccessorsResolved; private static MethodInfo _getDataGenericMethod; private static Type _optionableIntItemDataType; private static FieldInfo _optionableIntHasDataField; private static FieldInfo _optionableIntValueField; private static MethodBase TargetMethod() { MethodInfo[] methods = typeof(Item).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name.Contains("Use") || methodInfo.Name.Contains("Fire") || methodInfo.Name.Contains("Shoot")) { return methodInfo; } } return null; } private static void Postfix(Item __instance) { try { if (Plugin.IsWeaponFeatureEnabled() && IsBlowgunItem(__instance)) { SetBlowgunUseCount(__instance, 9999); NormalizeEnabledBlowgunRuntimeState(__instance); Type type = ((object)__instance).GetType(); float num = Plugin.FireInterval?.Value ?? 0.4f; FieldInfo field = type.GetField("usingTimePrimary", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(__instance, num); } } } catch (Exception) { } } internal static void RestoreVanillaSingleUseOnAllBlowguns() { try { Item[] array = Resources.FindObjectsOfTypeAll(); for (int i = 0; i < array.Length; i++) { RestoreVanillaSingleUse(array[i]); } } catch (Exception) { } } internal static void EnsureInfiniteUse(Item item) { try { if (Plugin.IsWeaponFeatureEnabled() && IsBlowgunItem(item)) { SetBlowgunUseCount(item, 9999); NormalizeEnabledBlowgunRuntimeState(item); } } catch (Exception) { } } internal static void RestoreVanillaSingleUse(Item item) { try { if (IsBlowgunItem(item)) { SetBlowgunUseCount(item, 1); NormalizeRaycastDartComponents(item); NormalizeRaycastDartComponents(item.isSecretlyOtherItemPrefab); RestoreRaycastDartAction(item); RestoreRaycastDartAction(item.isSecretlyOtherItemPrefab); } } catch (Exception) { } } internal static bool IsBlowgunItem(Item item) { if ((Object)(object)item == (Object)null) { return false; } try { if (item.itemID == 70) { return true; } if ((Object)(object)item.isSecretlyOtherItemPrefab != (Object)null && item.isSecretlyOtherItemPrefab.itemID == 70) { return true; } return false; } catch { return false; } } internal static void NormalizeEnabledBlowgunRuntimeState(Item item) { try { if (Plugin.IsWeaponFeatureEnabled() && IsBlowgunItem(item)) { NormalizeRaycastDartComponents(item); NormalizeRaycastDartComponents(item.isSecretlyOtherItemPrefab); DisableConsumableActions(item); } } catch { } } internal static void NormalizeDartRpcComponents(Item item) { try { if (!((Object)(object)item == (Object)null) && ItemPatch.IsBlowgunLike(item)) { NormalizeRaycastDartComponents(item); NormalizeRaycastDartComponents(item.isSecretlyOtherItemPrefab); } } catch { } } private static void NormalizeRaycastDartComponents(Item item) { try { if ((Object)(object)item == (Object)null) { return; } if (_actionRaycastDartType == null) { _actionRaycastDartType = typeof(Item).Assembly.GetType("Action_RaycastDart"); } if (_actionRaycastDartType == null) { return; } Component[] componentsInChildren = ((Component)item).GetComponentsInChildren(_actionRaycastDartType, true); if (componentsInChildren == null || componentsInChildren.Length <= 1) { return; } for (int i = 1; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } } } catch { } } private static void DisableConsumableActions(Item item) { try { if (!((Object)(object)item == (Object)null)) { if (_actionConsumeType == null) { _actionConsumeType = typeof(Item).Assembly.GetType("Action_Consume"); } if (_actionConsumeAndSpawnType == null) { _actionConsumeAndSpawnType = typeof(Item).Assembly.GetType("Action_ConsumeAndSpawn"); } DestroyActionsByType(item, _actionConsumeType); DestroyActionsByType(item, _actionConsumeAndSpawnType); } } catch { } } private static void DestroyActionsByType(Item item, Type actionType) { if ((Object)(object)item == (Object)null || actionType == null) { return; } Component[] componentsInChildren = ((Component)item).GetComponentsInChildren(actionType, true); foreach (Component val in componentsInChildren) { if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } } } private static void RestoreRaycastDartAction(Item item) { try { if ((Object)(object)item == (Object)null) { return; } if (_actionRaycastDartType == null) { _actionRaycastDartType = typeof(Item).Assembly.GetType("Action_RaycastDart"); } if (!(_actionRaycastDartType == null)) { Component val = ((Component)item).GetComponentInChildren(_actionRaycastDartType, true); if ((Object)(object)val == (Object)null) { val = ((Component)item).GetComponent(_actionRaycastDartType); } Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null); if ((Object)(object)val2 != (Object)null) { val2.enabled = true; } } } catch { } } private static void SetBlowgunUseCount(Item item, int value) { if ((Object)(object)item == (Object)null || !TryResolveItemDataAccessors()) { return; } MethodInfo methodInfo = _getDataGenericMethod.MakeGenericMethod(_optionableIntItemDataType); ParameterInfo[] parameters = methodInfo.GetParameters(); object[] array = new object[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { if (parameters[i].ParameterType == typeof(DataEntryKey)) { array[i] = (object)(DataEntryKey)2; } } object obj = methodInfo.Invoke(item, array); if (obj != null) { _optionableIntHasDataField?.SetValue(obj, true); _optionableIntValueField?.SetValue(obj, value); } } private static bool TryResolveItemDataAccessors() { if (_itemDataAccessorsResolved) { if (_getDataGenericMethod != null && _optionableIntItemDataType != null) { return _optionableIntValueField != null; } return false; } _itemDataAccessorsResolved = true; MethodInfo[] methods = typeof(Item).GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == "GetData" && methodInfo.IsGenericMethod) { _getDataGenericMethod = methodInfo; break; } } Type[] types = typeof(Item).Assembly.GetTypes(); foreach (Type type in types) { if (type.Name == "OptionableIntItemData") { _optionableIntItemDataType = type; break; } } if (_optionableIntItemDataType != null) { _optionableIntHasDataField = _optionableIntItemDataType.GetField("HasData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _optionableIntValueField = _optionableIntItemDataType.GetField("Value", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_getDataGenericMethod != null && _optionableIntItemDataType != null) { return _optionableIntValueField != null; } return false; } } [HarmonyPatch] public static class BlowgunItemRuntimeNormalizePatch { [CompilerGenerated] private sealed class d__1 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; private MethodInfo[] <>7__wrap1; private int <>7__wrap2; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_006e; } <>1__state = -1; <>7__wrap1 = typeof(Item).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); <>7__wrap2 = 0; goto IL_007c; IL_006e: <>7__wrap2++; goto IL_007c; IL_007c: if (<>7__wrap2 < <>7__wrap1.Length) { MethodInfo methodInfo = <>7__wrap1[<>7__wrap2]; if (TargetMethodNames.Contains(methodInfo.Name)) { <>2__current = methodInfo; <>1__state = 1; return true; } goto IL_006e; } <>7__wrap1 = null; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__1(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly HashSet TargetMethodNames = new HashSet(StringComparer.Ordinal) { "Awake", "OnEnable", "Start", "OnInstanceDataSet", "SetState" }; [IteratorStateMachine(typeof(d__1))] private static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(-2); } private static void Postfix(Item __instance) { BlowgunInfiniteUsePatch.NormalizeDartRpcComponents(__instance); if (!Plugin.IsWeaponFeatureEnabled()) { BlowgunInfiniteUsePatch.RestoreVanillaSingleUse(__instance); return; } BlowgunInfiniteUsePatch.EnsureInfiniteUse(__instance); Plugin.TryProtectWeaponItemRuntime(__instance); } } [HarmonyPatch(typeof(ItemCooking), "Wreck")] public class BlowgunWreckPatch { private static bool Prefix(ItemCooking __instance) { try { if (!Plugin.IsWeaponFeatureEnabled()) { return true; } Item component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { string name = component.GetName(); if ((name != null && name.Contains("吹箭筒")) || (name != null && name.Contains("Blowgun")) || (name != null && name.Contains("HealingDart")) || (name != null && name.Contains("Dart"))) { return false; } } } catch { } return true; } } [HarmonyPatch] public static class DartImpactPatch { private static MethodBase _targetMethod; public static MethodBase TargetMethod() { if (_targetMethod != null) { return _targetMethod; } try { MethodInfo methodInfo = typeof(Item).Assembly.GetType("Action_RaycastDart")?.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault(delegate(MethodInfo m) { if (!string.Equals(m.Name, "RPC_DartImpact", StringComparison.Ordinal)) { return false; } ParameterInfo[] parameters = m.GetParameters(); if (parameters.Length != 3 && parameters.Length != 4) { return false; } return parameters[0].ParameterType == typeof(int) && parameters[1].ParameterType == typeof(Vector3) && parameters[2].ParameterType == typeof(Vector3); }); if (methodInfo != null) { _targetMethod = methodInfo; return _targetMethod; } } catch (Exception ex) { Plugin.Log.LogError((object)("[DartImpactPatch] TargetMethod error: " + ex)); } Plugin.Log.LogWarning((object)"[DartImpactPatch] TargetMethod returning null - RPC_DartImpact method not found"); return null; } [HarmonyPrefix] public static bool DartImpactPrefix(MonoBehaviour __instance, int characterID, Vector3 origin, Vector3 endpoint) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //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_006c: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) try { Item componentInParent = ((Component)__instance).GetComponentInParent(); if (!Plugin.IsWeaponFeatureEnabled() || (Object)(object)componentInParent == (Object)null || !ItemPatch.IsBlowgunLike(componentInParent)) { return true; } if (characterID > 0) { PhotonView val = PhotonView.Find(characterID); if ((Object)(object)val != (Object)null) { Character componentInParent2 = ((Component)val).gameObject.GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null && (componentInParent2.isZombie || componentInParent2.isBot)) { Plugin.HandleZombieDartImpactVisual((Component)__instance, endpoint); Plugin.Instance?.HitZombie(componentInParent2, origin); return false; } if ((Object)(object)componentInParent2 != (Object)null && !componentInParent2.isZombie && !componentInParent2.isBot) { return false; } } } Plugin.HandleZombieDartImpactVisual((Component)__instance, endpoint); return false; } catch (Exception ex) { Plugin.Log.LogError((object)("[DartImpactPatch] Error: " + ex)); } return true; } } [HarmonyPatch] public static class LocalDartImpactPatch { private static MethodBase _targetMethod; public static MethodBase TargetMethod() { if (_targetMethod != null) { return _targetMethod; } try { MethodInfo methodInfo = typeof(Item).Assembly.GetType("Action_RaycastDart")?.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => string.Equals(m.Name, "DartImpact", StringComparison.Ordinal) && m.GetParameters().Length == 3 && m.GetParameters()[0].ParameterType == typeof(Character) && m.GetParameters()[1].ParameterType == typeof(Vector3) && m.GetParameters()[2].ParameterType == typeof(Vector3)); if (methodInfo != null) { _targetMethod = methodInfo; return _targetMethod; } } catch (Exception ex) { Plugin.Log.LogError((object)("[LocalDartImpactPatch] TargetMethod error: " + ex)); } Plugin.Log.LogWarning((object)"[LocalDartImpactPatch] TargetMethod returning null - DartImpact method not found"); return null; } [HarmonyPrefix] public static bool DartImpactPrefix(MonoBehaviour __instance, Character hitCharacter, Vector3 origin, Vector3 endpoint) { //IL_0031: 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_003c: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown try { Item componentInParent = ((Component)__instance).GetComponentInParent(); if (!Plugin.IsWeaponFeatureEnabled() || (Object)(object)componentInParent == (Object)null || !ItemPatch.IsBlowgunLike(componentInParent)) { return true; } if ((Object)(object)hitCharacter == (Object)null) { Plugin.HandleZombieDartImpactVisual((Component)__instance, endpoint); return false; } if (hitCharacter.isZombie || hitCharacter.isBot) { Plugin.HandleZombieDartImpactVisual((Component)__instance, endpoint); Plugin.Instance?.HitZombie(hitCharacter, origin); return false; } Plugin.HandleZombieDartImpactVisual((Component)__instance, endpoint); return false; } catch (Exception ex) { Plugin.Log.LogError((object)("[LocalDartImpactPatch] Error: " + ex)); } return true; } } [HarmonyPatch] public static class DisableZombieSleepPatch { private const float DefaultTargetSearchInterval = 10f; private const float DefaultSamePlayerBiteCooldown = 5f; private const float DefaultPostBiteRecoveryTime = 3f; private const int LungeRecoveryState = 5; private const float PostBiteRecoverySyncThreshold = 0.45999998f; internal const float PostBiteRecoveryFallWindow = 0.45f; private const float CloseRangeLungeDistanceScale = 0.35f; private const float CloseRangeLungeDistanceMin = 2.75f; private const float CloseRangeLungeDistanceMax = 4.25f; private const float MinimumChaseBeforeLunge = 0.65f; private const float MaximumLungeVerticalDelta = 2.25f; private static readonly MethodInfo CharacterFallMethod = AccessTools.Method(typeof(Character), "Fall", new Type[2] { typeof(float), typeof(float) }, (Type[])null); private static readonly MethodInfo StartChasingMethod = AccessTools.Method(typeof(MushroomZombie), "StartChasing", Type.EmptyTypes, (Type[])null); private static readonly MethodInfo StartLungingMethod = AccessTools.Method(typeof(MushroomZombie), "StartLunging", Type.EmptyTypes, (Type[])null); private static readonly MethodInfo CanSeeTargetMethod = AccessTools.Method(typeof(MushroomZombie), "CanSeeTarget", new Type[1] { typeof(Character) }, (Type[])null); private static readonly FieldInfo LungeRecoveryTimerField = AccessTools.Field(typeof(MushroomZombie), "timeSpentRecoveringFromLunge"); private static readonly FieldInfo TimeSpentChasingField = AccessTools.Field(typeof(MushroomZombie), "timeSpentChasing"); private static readonly Dictionary PostBiteRecoveryUntilByZombieViewId = new Dictionary(); private static bool UseVanillaBehavior() { return Plugin.IsVanillaZombieBehaviorDifficultyRuntime(); } private static float GetTargetSearchInterval() { return Plugin.GetZombieTargetSearchIntervalRuntime(); } private static float GetSamePlayerBiteCooldown() { return Plugin.GetZombieSamePlayerBiteCooldownRuntime(); } private static float GetPostBiteRecoveryTime() { return Plugin.GetZombieBiteRecoveryTimeRuntime(); } private static int GetZombieViewId(MushroomZombie zombie) { if ((Object)(object)zombie == (Object)null || (Object)(object)((MonoBehaviourPun)zombie).photonView == (Object)null) { return -1; } return ((MonoBehaviourPun)zombie).photonView.ViewID; } private static void ResetLungeRecoveryTimer(MushroomZombie zombie) { if ((Object)(object)zombie != (Object)null && LungeRecoveryTimerField != null) { LungeRecoveryTimerField.SetValue(zombie, 0f); } } private static void ClearPostBiteRecoveryOverride(MushroomZombie zombie) { int zombieViewId = GetZombieViewId(zombie); if (zombieViewId >= 0) { PostBiteRecoveryUntilByZombieViewId.Remove(zombieViewId); } ResetLungeRecoveryTimer(zombie); } private static void SetPostBiteRecoveryOverride(MushroomZombie zombie, float duration) { int zombieViewId = GetZombieViewId(zombie); if (zombieViewId >= 0) { ResetLungeRecoveryTimer(zombie); if (duration <= 0f) { PostBiteRecoveryUntilByZombieViewId.Remove(zombieViewId); } else { PostBiteRecoveryUntilByZombieViewId[zombieViewId] = Time.time + duration; } } } private static bool TryGetPostBiteRecoveryOverride(MushroomZombie zombie, out float recoverAtTime) { recoverAtTime = 0f; int zombieViewId = GetZombieViewId(zombie); if (zombieViewId >= 0) { return PostBiteRecoveryUntilByZombieViewId.TryGetValue(zombieViewId, out recoverAtTime); } return false; } private static float GetCloseRangeLungeDistance(MushroomZombie zombie) { if ((Object)(object)zombie == (Object)null) { return 2.75f; } return Mathf.Clamp(zombie.zombieLungeDistance * 0.35f, 2.75f, 4.25f); } private static float GetTimeSpentChasing(MushroomZombie zombie) { if ((Object)(object)zombie == (Object)null || TimeSpentChasingField == null) { return 0f; } object value = TimeSpentChasingField.GetValue(zombie); if (value is float) { return (float)value; } return 0f; } private static bool CanSeeTarget(MushroomZombie zombie, Character target) { if ((Object)(object)zombie == (Object)null || (Object)(object)target == (Object)null || CanSeeTargetMethod == null) { return false; } object obj = CanSeeTargetMethod.Invoke(zombie, new object[1] { target }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } internal static void ResetRuntimeState() { PostBiteRecoveryUntilByZombieViewId.Clear(); } [HarmonyPatch(typeof(MushroomZombie), "Start")] [HarmonyPostfix] private static void MushroomZombieStartPostfix(MushroomZombie __instance) { if (!((Object)(object)__instance == (Object)null)) { ZombieSpawner.InitializeSpawnedZombieRuntime(((Component)__instance).gameObject); } } [HarmonyPatch(typeof(MushroomZombie), "TryLookForTarget")] [HarmonyPrefix] private static bool TryLookForTargetPrefix(MushroomZombie __instance) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || (Object)(object)((MonoBehaviourPun)__instance).photonView == (Object)null || !((MonoBehaviourPun)__instance).photonView.IsMine) { return true; } float targetSearchInterval = GetTargetSearchInterval(); if (__instance.sinceLookForTarget < targetSearchInterval) { return false; } Character component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null) { __instance.sinceLookForTarget = 0f; return false; } Character val = null; float num = float.MaxValue; foreach (Character allCharacter in Character.AllCharacters) { if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter == (Object)(object)component) && !allCharacter.isBot && !allCharacter.isZombie && !((Object)(object)allCharacter.data == (Object)null) && !allCharacter.data.dead && !allCharacter.data.fullyPassedOut) { float num2 = Vector3.Distance(allCharacter.Center, component.Center); if ((Object)(object)val == (Object)null || num2 < num) { val = allCharacter; num = num2; } } } int num3 = (((Object)(object)val == (Object)null) ? (-1) : ((MonoBehaviourPun)val).photonView.ViewID); ((MonoBehaviourPun)__instance).photonView.RPC("RPCA_SetCurrentTarget", (RpcTarget)0, new object[2] { num3, 0f }); __instance.sinceLookForTarget = 0f; return false; } [HarmonyPatch(typeof(MushroomZombie), "TryLunge")] [HarmonyPrefix] private static bool TryLungePrefix(MushroomZombie __instance) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_0098: 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_00b2: 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_00c4: Unknown result type (might be due to invalid IL or missing references) if (UseVanillaBehavior()) { return true; } if ((Object)(object)__instance == (Object)null || StartLungingMethod == null) { return true; } Character currentTarget = __instance.currentTarget; Character component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)currentTarget == (Object)null) { return false; } if ((int)__instance.currentState != 3 || !component.data.isGrounded || !component.input.sprintIsPressed || !CanSeeTarget(__instance, currentTarget)) { return false; } if (GetTimeSpentChasing(__instance) < Mathf.Max(__instance.chaseTimeBeforeSprint, 0.65f)) { return false; } Vector3 center = component.Center; Vector3 center2 = currentTarget.Center; center.y = 0f; center2.y = 0f; float num = Vector3.Distance(center, center2); float num2 = Mathf.Abs(currentTarget.Center.y - component.Center.y); if (num > GetCloseRangeLungeDistance(__instance) || num2 > 2.25f) { return false; } StartLungingMethod.Invoke(__instance, null); return false; } [HarmonyPatch(typeof(MushroomZombie), "OnBitCharacter")] [HarmonyPostfix] private static void OnBitCharacterPostfix(MushroomZombie __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((MonoBehaviourPun)__instance).photonView == (Object)null)) { Character component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)((MonoBehaviourPun)component).photonView == (Object)null)) { float postBiteRecoveryTime = GetPostBiteRecoveryTime(); SetPostBiteRecoveryOverride(__instance, postBiteRecoveryTime); float num = Mathf.Min(0.45f, postBiteRecoveryTime); component.data.fallSeconds = num; ((MonoBehaviourPun)component).photonView.RPC("RPCA_Fall", (RpcTarget)0, new object[1] { num }); ((MonoBehaviourPun)__instance).photonView.RPC("RPC_SyncState", (RpcTarget)0, new object[4] { 5, false, num, component.data.passedOut }); } } } [HarmonyPatch(typeof(MushroomZombie), "RPC_SyncState")] [HarmonyPostfix] private static void RpcSyncStatePostfix(MushroomZombie __instance, int state, bool isSprinting, float fallSeconds, bool passedOut) { if ((Object)(object)__instance == (Object)null) { return; } if (state == 5) { if (fallSeconds <= 0.45999998f) { SetPostBiteRecoveryOverride(__instance, GetPostBiteRecoveryTime()); } else { ClearPostBiteRecoveryOverride(__instance); } } else { ClearPostBiteRecoveryOverride(__instance); } } [HarmonyPatch(typeof(MushroomZombie), "DoLungeRecovery")] [HarmonyPrefix] private static bool DoLungeRecoveryPrefix(MushroomZombie __instance) { if ((Object)(object)__instance == (Object)null) { return true; } if (!TryGetPostBiteRecoveryOverride(__instance, out var recoverAtTime)) { return true; } Character component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null) { ClearPostBiteRecoveryOverride(__instance); return true; } if (component.data.fallSeconds > 0f || component.data.passedOut || component.data.fullyPassedOut) { return false; } if (Time.time < recoverAtTime) { return false; } ClearPostBiteRecoveryOverride(__instance); if (StartChasingMethod == null) { return true; } StartChasingMethod.Invoke(__instance, null); return false; } [HarmonyPatch(typeof(MushroomZombieBiteCollider), "OnTriggerEnter")] [HarmonyPrefix] private static bool BiteColliderPrefix(MushroomZombieBiteCollider __instance, Collider other) { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown if (UseVanillaBehavior()) { return true; } if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.parentZombie == (Object)null) { return false; } float samePlayerBiteCooldown = GetSamePlayerBiteCooldown(); Character val = default(Character); if (Time.time - __instance.lastBitLocalCharacter < samePlayerBiteCooldown || !CharacterRagdoll.TryGetCharacterFromCollider(other, ref val) || !val.IsLocal) { return false; } __instance.lastBitLocalCharacter = Time.time; if (val.data.isSkeleton) { val.refs.afflictions.AddStatus((STATUSTYPE)0, __instance.parentZombie.biteInitialInjury / 8f * 2f, false, true, true); } else { val.refs.afflictions.AddStatus((STATUSTYPE)0, __instance.parentZombie.biteInitialInjury, false, true, true); } val.refs.afflictions.AddStatus((STATUSTYPE)10, __instance.parentZombie.biteInitialSpores, false, true, true); Affliction_ZombieBite val2 = new Affliction_ZombieBite(__instance.parentZombie.totalBiteSporesTime, __instance.parentZombie.biteDelayBeforeSpores, __instance.parentZombie.biteSporesPerSecond); val.refs.afflictions.AddAffliction((Affliction)(object)val2, false); CharacterFallMethod?.Invoke(val, new object[2] { __instance.parentZombie.biteStunTime, 0f }); __instance.parentZombie.OnBitCharacter(val); return false; } } [HarmonyPatch(typeof(UI_UseItemProgress), "UpdateFillAmount")] public static class HideUseItemProgressPatch { private static bool Prefix(UI_UseItemProgress __instance, ref bool __result) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown try { if (!Plugin.IsWeaponFeatureEnabled()) { return true; } Character localCharacter = Character.localCharacter; object obj; if ((Object)(object)localCharacter == (Object)null) { obj = null; } else { CharacterData data = localCharacter.data; obj = (((Object)(object)data != (Object)null) ? data.currentItem : null); } if (BlowgunInfiniteUsePatch.IsBlowgunItem((Item)obj)) { if ((Object)(object)__instance.fill != (Object)null) { __instance.fill.fillAmount = 0f; } __result = false; return false; } } catch { } return true; } internal static void RestoreVanillaUseProgressOnAllUi() { try { UI_UseItemProgress[] array = Object.FindObjectsByType((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { RestoreVanillaUseProgressUi(array[i]); } } catch { } } private static void RestoreVanillaUseProgressUi(UI_UseItemProgress ui) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)ui == (Object)null) { return; } try { Character localCharacter = Character.localCharacter; object obj; if (localCharacter == null) { obj = null; } else { CharacterData data = localCharacter.data; obj = ((data != null) ? data.currentItem : null); } Item val = (Item)obj; float num = (((Object)(object)val != (Object)null) ? val.progress : 0f); bool flag = num > 0f; if ((Object)(object)ui.fill != (Object)null) { ui.fill.fillAmount = (flag ? num : 0f); ((Behaviour)ui.fill).enabled = true; } if ((Object)(object)ui.empty != (Object)null) { ((Behaviour)ui.empty).enabled = true; } } catch { } } } [HarmonyPatch(typeof(InventoryItemUI), "UpdateCookedAmount")] public static class InventoryItemUiCookColorPatch { [HarmonyPostfix] public static void UpdateCookedAmountPostfix(InventoryItemUI __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)__instance == (Object)null) { return; } try { if (Plugin.IsWeaponFeatureEnabled()) { AkUiPatchHelpers.ApplyAkToInventoryUi(__instance); } } catch { } } } [HarmonyPatch(typeof(InventoryItemUI), "UpdateNameText")] public static class InventoryItemUiNamePatch { [HarmonyPostfix] public static void UpdateNameTextPostfix(InventoryItemUI __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)__instance == (Object)null) { return; } try { if (Plugin.IsWeaponFeatureEnabled()) { AkUiPatchHelpers.ApplyAkToInventoryUi(__instance); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[ShootZombies] InventoryItemUiNamePatch failed: " + ex.Message)); } } } [HarmonyPatch(typeof(InventoryItemUI), "SetItem")] public static class InventoryItemUiPatch { private readonly struct SetItemState : IEquatable { private readonly int _prefabInstanceId; private readonly int _prefabItemId; private readonly int _resolvedItemInstanceId; private readonly int _itemDataIdentity; private readonly string _displayName; private readonly bool _isBlowgunLike; public SetItemState(ItemSlot slot, Item resolvedItem, bool isBlowgunLike) { Item val = slot?.prefab; _prefabInstanceId = (((Object)(object)val != (Object)null) ? ((Object)val).GetInstanceID() : 0); _prefabItemId = (((Object)(object)val != (Object)null) ? val.itemID : 0); _resolvedItemInstanceId = (((Object)(object)resolvedItem != (Object)null) ? ((Object)resolvedItem).GetInstanceID() : 0); _itemDataIdentity = ((slot?.data != null) ? RuntimeHelpers.GetHashCode(slot.data) : 0); _displayName = ItemPatch.DisplayName ?? string.Empty; _isBlowgunLike = isBlowgunLike; } public bool Equals(SetItemState other) { if (_prefabInstanceId == other._prefabInstanceId && _prefabItemId == other._prefabItemId && _resolvedItemInstanceId == other._resolvedItemInstanceId && _itemDataIdentity == other._itemDataIdentity && string.Equals(_displayName, other._displayName, StringComparison.Ordinal)) { return _isBlowgunLike == other._isBlowgunLike; } return false; } } private static readonly Dictionary LastStateByUiId = new Dictionary(); [HarmonyPostfix] public static void SetItemPostfix(InventoryItemUI __instance, ItemSlot slot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)__instance == (Object)null) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (!Plugin.IsWeaponFeatureEnabled()) { LastStateByUiId.Remove(instanceID); AkUiPatchHelpers.ClearInventoryUiCache(__instance); return; } if (slot == null || slot.IsEmpty()) { LastStateByUiId.Remove(instanceID); AkUiPatchHelpers.ClearInventoryUiCache(__instance); return; } try { Item val = AkUiPatchHelpers.ResolveItemFromSlot(slot); Item val2 = (((Object)(object)val != (Object)null) ? val : slot.prefab); bool flag = ItemPatch.IsBlowgunLike(val2); SetItemState setItemState = new SetItemState(slot, val2, flag); if (LastStateByUiId.TryGetValue(instanceID, out var value) && value.Equals(setItemState) && (!flag || AkUiPatchHelpers.IsInventoryUiAlreadyShowingAk(__instance))) { return; } LastStateByUiId[instanceID] = setItemState; if (flag) { ItemPatch.ApplyAkDisplayIfNeeded(val2); if ((Object)(object)slot.prefab != (Object)null) { ItemPatch.ApplyAkDisplayIfNeeded(slot.prefab); } AkUiPatchHelpers.ApplyAkToInventoryUi(__instance, val2); } } catch (Exception ex) { Plugin.Log.LogError((object)("[ShootZombies] InventoryItemUiPatch failed: " + ex)); } } internal static void ClearCaches() { LastStateByUiId.Clear(); } } [HarmonyPatch] public static class ItemPatch { private struct SourceVisualCandidate { public Mesh Mesh; public Material[] Materials; public Transform Transform; public int VertexCount; public int Score; public string Path; public string MeshName; } [CompilerGenerated] private sealed class d__167 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private Collider <>2__current; private int <>l__initialThreadId; private Item item; public Item <>3__item; private Collider[] <>7__wrap1; private int <>7__wrap2; Collider IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__167(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_007a; } <>1__state = -1; if ((Object)(object)item == (Object)null) { return false; } Collider[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); <>7__wrap1 = componentsInChildren; <>7__wrap2 = 0; goto IL_0088; IL_007a: <>7__wrap2++; goto IL_0088; IL_0088: if (<>7__wrap2 < <>7__wrap1.Length) { Collider val = <>7__wrap1[<>7__wrap2]; if (!((Object)(object)val == (Object)null) && !IsCustomWeaponCollider(val)) { <>2__current = val; <>1__state = 1; return true; } goto IL_007a; } <>7__wrap1 = null; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__167 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__167(0); } d__.item = <>3__item; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private const string LocalVisualName = "AK_VisualRoot"; private const string VisualCloneName = "AK_LocalVisualClone"; private const string SimpleVisualName = "AK47Model"; private const string MuzzleMarkerName = "AK_MuzzleMarker"; private const string WorldColliderName = "AK_WorldCollider"; private const string HeldLegacyVisualName = "AK47_HeldLegacyModel"; private const string InPlaceVisualRootName = "AK_InPlaceVisualRoot"; private const string HeldDebugSphereName = "AK_HeldDebugSphere"; private static readonly Quaternion HeldLegacyRotationOffset = Quaternion.identity; private static readonly Vector3 HeldLegacyPositionOffset = new Vector3(-0.01f, 0.01f, 0f); private static readonly Quaternion InPlaceYawOffset = Quaternion.Euler(0f, 0f, 0f); private static readonly string[] SelectableWeaponKeywords = new string[4] { "ak47", "mpx", "hk416", "hk417" }; private const float RuntimeVisualBaseScaleMultiplier = 1.275f; private static readonly string[] ItemKeywords = new string[5] { "healingdart", "blowgun", "dart", "吹箭筒", "ak47" }; private static readonly string[] ExcludedVisualKeywords = new string[9] { "hand", "arm", "finger", "collider", "trigger", "vfx", "effect", "spawn", "holiday" }; private static readonly Dictionary HiddenRendererCache = new Dictionary(); private static readonly HashSet InPlaceSwappedItemIds = new HashSet(); private static readonly Dictionary PendingSetStateValueByItemId = new Dictionary(); private static readonly Dictionary PendingSetStateHolderByItemId = new Dictionary(); private const bool UseDebugAnchorSphereVisual = false; private static Mesh _debugCubeMesh; private static Material[] _debugCubeMaterials; private static Mesh _debugSphereMesh; private static Material[] _debugSphereMaterials; private static Material[] _meshOnlyTestMaterials; private static Material[] _cachedDirectAkSharedMaterials; private static int _cachedDirectAkSharedMaterialsHash; private static string _cachedCombinedWeaponSelection = string.Empty; private const bool PreferInPlaceMeshSwap = true; private const bool PreferLegacyHeldVisualForLocalPlayer = false; private const bool EnableHeldDebugSphereVisual = false; private static readonly string[] MainRendererFieldNames = new string[6] { "k__BackingField", "mainRenderer", "_mainRenderer", "k__BackingField", "MainRenderer", "_MainRenderer" }; private static readonly string[] MainRendererPropertyNames = new string[2] { "mainRenderer", "MainRenderer" }; private static readonly string[] AddtlRendererFieldNames = new string[6] { "k__BackingField", "addtlRenderers", "_addtlRenderers", "k__BackingField", "AddtlRenderers", "_AddtlRenderers" }; internal static string DisplayName => Plugin.GetCurrentWeaponDisplayName(); private static Quaternion GetDirectAkRotationOverride() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Plugin.GetDirectAkRotationOverride(); } private static float GetDirectAkScaleMultiplier(string selection = null) { return Plugin.GetEffectiveWeaponModelScale(string.IsNullOrWhiteSpace(selection) ? Plugin.GetCurrentWeaponSelection() : selection); } private static Vector3 GetDirectAkPositionOverride(string selection = null) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return Plugin.GetDirectAkPositionOverride(string.IsNullOrWhiteSpace(selection) ? Plugin.GetCurrentWeaponSelection() : selection); } private static string DescribeItemForDiagnostics(Item item) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected I4, but got Unknown if ((Object)(object)item == (Object)null) { return "item=null"; } string text = ((((Object)((Component)item).gameObject).name ?? string.Empty) + "/" + (((Object)((Component)item).transform).name ?? string.Empty)).Trim(new char[1] { '/' }); string text2 = (((Object)(object)item.holderCharacter != (Object)null) ? ((Object)item.holderCharacter).name : null) ?? "null"; string text3 = item.UIData?.itemName ?? "null"; return $"name={text}, itemID={item.itemID}, state={(int)item.itemState}, holder={text2}, uiName={text3}"; } private static string DescribeRendererCandidatesForDiagnostics(Item item, int maxEntries = 6) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown if ((Object)(object)item == (Object)null) { return "no-item"; } List list = new List(); Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { Mesh rendererMesh = GetRendererMesh(val); string item2 = string.Format("{0}|renderer={1}|mesh={2}|verts={3}", GetTransformPath(((Component)val).transform), ((Object)val).name, ((Object)rendererMesh != (Object)null) ? ((Object)rendererMesh).name : "null", ((Object)rendererMesh != (Object)null) ? rendererMesh.vertexCount : 0); list.Add(item2); if (list.Count >= maxEntries) { break; } } } if (list.Count == 0) { return "no-renderers"; } return string.Join(" || ", list); } [HarmonyPatch(typeof(Item), "OnDestroy")] [HarmonyPrefix] public static void ItemOnDestroyPrefix(Item __instance) { CleanupItem(__instance); } [HarmonyPatch(typeof(Item), "OnEnable")] [HarmonyPostfix] public static void ItemOnEnablePostfix(Item __instance) { TryRefreshItem(__instance, forceRefresh: false); } [HarmonyPatch(typeof(Item), "Start")] [HarmonyPostfix] public static void ItemStartPostfix(Item __instance) { TryRefreshItem(__instance, forceRefresh: false); } [HarmonyPatch(typeof(Item), "SetState")] [HarmonyPrefix] public static void ItemSetStatePrefix(Item __instance) { CachePendingSetStateContext(__instance); } [HarmonyPatch(typeof(Item), "SetState")] [HarmonyPostfix] public static void ItemSetStatePostfix(Item __instance) { NotifyDroppedWeaponIfNeeded(__instance); TryRefreshItem(__instance, forceRefresh: false); try { ItemUIDataPatch.ForceRefreshVisibleUi(); } catch { } } private static void CachePendingSetStateContext(Item item) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown if (!((Object)(object)item == (Object)null)) { int instanceID = ((Object)item).GetInstanceID(); PendingSetStateValueByItemId[instanceID] = (int)item.itemState; Character itemHolderCharacter = GetItemHolderCharacter(item); if ((Object)(object)itemHolderCharacter == (Object)null) { PendingSetStateHolderByItemId.Remove(instanceID); } else { PendingSetStateHolderByItemId[instanceID] = itemHolderCharacter; } } } private static void NotifyDroppedWeaponIfNeeded(Item item) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Invalid comparison between Unknown and I4 if ((Object)(object)item == (Object)null || !IsBlowgunLike(item)) { return; } int instanceID = ((Object)item).GetInstanceID(); Character value = null; PendingSetStateValueByItemId.TryGetValue(instanceID, out var value2); PendingSetStateHolderByItemId.TryGetValue(instanceID, out value); PendingSetStateValueByItemId.Remove(instanceID); PendingSetStateHolderByItemId.Remove(instanceID); if (value2 == 1 && !((Object)(object)value == (Object)null) && !value.isBot && !value.isZombie) { Character itemHolderCharacter = GetItemHolderCharacter(item); if ((int)item.itemState != 1 && ((Object)(object)itemHolderCharacter == (Object)null || !((Object)(object)itemHolderCharacter == (Object)(object)value) || IsDroppedWorldItem(item))) { Plugin.NotifyWeaponDropped(value); } } } private static Character GetItemHolderCharacter(Item item) { if ((Object)(object)item == (Object)null) { return null; } if (!((Object)(object)item.trueHolderCharacter != (Object)null)) { return item.holderCharacter; } return item.trueHolderCharacter; } [HarmonyPatch(typeof(Item), "GetName")] [HarmonyPostfix] public static void GetNamePostfix(Item __instance, ref string __result) { if (Plugin.IsWeaponFeatureEnabled() && IsBlowgunLike(__instance, __result)) { __result = Plugin.GetItemWeaponDisplayName(__instance); } } [HarmonyPatch(typeof(Item), "GetItemName")] [HarmonyPostfix] public static void GetItemNamePostfix(Item __instance, ref string __result) { if (Plugin.IsWeaponFeatureEnabled() && IsBlowgunLike(__instance, __result)) { __result = Plugin.GetItemWeaponDisplayName(__instance); } } public static int EnsureAkVisualOnAllItems(bool forceRefresh = false) { int num = 0; Item[] array = Object.FindObjectsByType((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { if (EnsureAkVisual(array[i], forceRefresh)) { num++; } } return num; } public static bool EnsureAkMeshSwap(Item item, bool forceRefreshMarker = false) { return EnsureAkVisual(item, forceRefreshMarker); } public static bool EnsureAkVisual(Item item, bool forceRefreshMarker = false) { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown if (!ShouldProcessRuntimeItem(item)) { return false; } if (!Plugin.IsWeaponFeatureEnabled()) { return false; } if (!IsBlowgunLike(item)) { RestoreOriginalVisual(item); CleanupSimpleAkVisual(item); DestroyLegacyHeldVisual(item, restoreRenderers: true); return false; } BlowgunInfiniteUsePatch.EnsureInfiniteUse(item); ApplyAkDisplay(item); Transform val = ResolveTargetVisualRoot(item); bool flag = HasReplacementVisualSource(item); if ((Object)(object)val == (Object)null || !flag) { Plugin.LogDiagnosticOnce("ak-ensure-abort:" + ((Object)item).GetInstanceID(), $"EnsureAkVisual aborted: {DescribeItemForDiagnostics(item)}, targetRoot={GetTransformPath(val)}, hasReplacementSource={flag}, prefab={Plugin.DescribeAkVisualPrefabForDiagnostics(Plugin.GetWeaponSelectionForItem(item))}"); RestoreOriginalVisual(item); CleanupSimpleAkVisual(item); DestroyLegacyHeldVisual(item, restoreRenderers: true); return false; } if (forceRefreshMarker) { RestoreOriginalVisual(item); CleanupSimpleAkVisual(item); } DestroyLegacyHeldVisual(item, restoreRenderers: false); RestoreInPlaceVisual(item); InPlaceSwappedItemIds.Remove(((Object)item).GetInstanceID()); if (ShouldUseSeparateLocalFirstPersonVisual(item)) { AkLocalVisualMarker componentInChildren = ((Component)item).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { Object.Destroy((Object)((Component)componentInChildren).gameObject); } CleanupSimpleAkVisual(item); HideOriginalRenderers(item, val); SyncWeaponColliderState(item, null); return true; } Transform orCreateSimpleAkVisual = GetOrCreateSimpleAkVisual(item, val, forceRefreshMarker); if ((Object)(object)orCreateSimpleAkVisual == (Object)null) { Plugin.LogDiagnosticOnce("ak-ensure-create-fail:" + ((Object)item).GetInstanceID(), "GetOrCreateSimpleAkVisual failed: " + DescribeItemForDiagnostics(item) + ", targetRoot=" + GetTransformPath(val) + ", prefab=" + Plugin.DescribeAkVisualPrefabForDiagnostics(Plugin.GetWeaponSelectionForItem(item))); RestoreOriginalVisual(item); return false; } if (ShouldShowSimpleAkVisual(item)) { HideOriginalRenderers(item, val); SetCustomVisualRenderersVisible(orCreateSimpleAkVisual, visible: true); SyncWeaponColliderState(item, null); } else { SetCustomVisualRenderersVisible(orCreateSimpleAkVisual, visible: false); RestoreOriginalVisual(item); } InPlaceSwappedItemIds.Remove(((Object)item).GetInstanceID()); return true; } public static void ApplyAkDisplay(Item item) { if (!((Object)(object)item == (Object)null)) { Plugin.TryProtectWeaponItemRuntime(item); ApplyUiData(item, item.UIData); if ((Object)(object)item.isSecretlyOtherItemPrefab != (Object)null) { ApplyUiData(item, item.isSecretlyOtherItemPrefab.UIData); } } } internal static void ApplyAkDisplayIfNeeded(Item item) { if (Plugin.IsWeaponFeatureEnabled() && !((Object)(object)item == (Object)null) && IsBlowgunLike(item)) { ApplyAkDisplay(item); } } public static bool IsBlowgunLike(Item item, string knownDisplayName = null) { if ((Object)(object)item == (Object)null) { return false; } if ((Object)(object)((Component)item).GetComponentInChildren(true) != (Object)null) { return true; } if ((Object)(object)((Component)item).GetComponentInChildren(true) != (Object)null) { return true; } if ((Object)(object)((Component)item).GetComponentInChildren(true) != (Object)null) { return true; } if (BlowgunInfiniteUsePatch.IsBlowgunItem(item)) { return true; } if (!ContainsKeyword(knownDisplayName) && !ContainsKeyword(((Object)((Component)item).gameObject).name) && !ContainsKeyword(item.UIData?.itemName)) { return ContainsKeyword(item.isSecretlyOtherItemPrefab?.UIData?.itemName); } return true; } internal static bool ContainsWeaponKeyword(string value) { return ContainsKeyword(value); } public static Transform TryGetMuzzleMarker(Item item) { if ((Object)(object)item == (Object)null) { return null; } AkMuzzleMarker componentInChildren = ((Component)item).GetComponentInChildren(true); if (!((Object)(object)componentInChildren != (Object)null)) { return null; } return ((Component)componentInChildren).transform; } internal static Transform ResolveTargetVisualRootForItem(Item item) { return ResolveTargetVisualRoot(item); } internal static bool IsLocallyHeldByPlayer(Item item, Character character = null) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 if ((Object)(object)item == (Object)null) { return false; } if ((int)item.itemState != 1) { return false; } character = (((Object)(object)character != (Object)null) ? character : Character.localCharacter); if ((Object)(object)character == (Object)null) { return false; } if (!((Object)(object)item.holderCharacter == (Object)(object)character)) { return (Object)(object)item.trueHolderCharacter == (Object)(object)character; } return true; } private static bool ShouldUseSeparateLocalFirstPersonVisual(Item item) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 if (!Plugin.IsLocalWeaponVisualFollowerEnabled()) { return false; } if (IsLocallyHeldByPlayer(item)) { return true; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || !IsBlowgunLike(item)) { return false; } if ((Object)(object)item.holderCharacter == (Object)(object)localCharacter || (Object)(object)item.trueHolderCharacter == (Object)(object)localCharacter) { return (int)item.itemState == 1; } CharacterData data = localCharacter.data; if ((Object)(object)((data != null) ? data.currentItem : null) == (Object)(object)item && (int)item.itemState == 1) { return true; } return false; } internal static bool HasLegacyHeldVisual(Item item) { if ((Object)(object)item != (Object)null) { return (Object)(object)((Component)item).GetComponentInChildren(true) != (Object)null; } return false; } private static bool ShouldProcessRuntimeItem(Item item) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0030: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { return false; } GameObject gameObject = ((Component)item).gameObject; if ((Object)(object)gameObject == (Object)null) { return false; } if ((((Object)gameObject).hideFlags & 0x34) != 0) { return false; } Scene scene = gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return ((Scene)(ref scene)).isLoaded; } return false; } private static bool ShouldShowSimpleAkVisual(Item item) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 if ((Object)(object)item == (Object)null) { return false; } if (ShouldUseSeparateLocalFirstPersonVisual(item)) { return false; } if ((int)item.itemState == 1) { return true; } return (Object)(object)(((Object)(object)item.trueHolderCharacter != (Object)null) ? item.trueHolderCharacter : item.holderCharacter) == (Object)null; } private static bool ShouldUseInPlaceWeaponVisual(Item item) { if ((Object)(object)item == (Object)null) { return false; } return !IsDroppedWorldItem(item); } private static bool IsDroppedWorldItem(Item item) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((Object)(object)item == (Object)null) { return false; } if (ShouldUseSeparateLocalFirstPersonVisual(item) || (int)item.itemState == 1) { return false; } return (Object)(object)(((Object)(object)item.trueHolderCharacter != (Object)null) ? item.trueHolderCharacter : item.holderCharacter) == (Object)null; } private static void SetCustomVisualRenderersVisible(Transform root, bool visible) { if ((Object)(object)root == (Object)null) { return; } Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { val.enabled = visible; val.forceRenderingOff = !visible; val.allowOcclusionWhenDynamic = false; } } } internal static void NormalizeVisualScaleAgainstReference(Transform visualRoot, Transform referenceRoot, string context) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: 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) if ((Object)(object)visualRoot == (Object)null || !TryGetCombinedRenderableBounds(visualRoot, out var bounds)) { return; } float boundsLongestSize = GetBoundsLongestSize(bounds); if (!IsFiniteFloat(boundsLongestSize) || boundsLongestSize < 0.0005f) { return; } Bounds bounds2; bool num = TryGetReferenceRenderableBounds(referenceRoot, visualRoot, out bounds2); float num2 = (num ? GetBoundsLongestSize(bounds2) : 0f); float num3 = 0f; string text = "none"; if (num && IsFiniteFloat(num2) && num2 > 0.02f && boundsLongestSize < num2 * 0.22f) { num3 = num2 * 0.92f; text = "reference"; } else if (boundsLongestSize < 0.04f) { num3 = 0.42f; text = "fallback"; } if (!IsFiniteFloat(num3) || num3 <= boundsLongestSize) { return; } float num4 = Mathf.Clamp(num3 / boundsLongestSize, 1f, 256f); if (!IsFiniteFloat(num4) || num4 <= 1.05f) { return; } Vector3 localScale = visualRoot.localScale; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Abs(localScale.x * num4), Mathf.Abs(localScale.y * num4), Mathf.Abs(localScale.z * num4)); if (IsValidNormalizedScale(val)) { visualRoot.localScale = val; float num5 = num3; if (TryGetCombinedRenderableBounds(visualRoot, out var bounds3)) { num5 = GetBoundsLongestSize(bounds3); } Plugin.LogDiagnosticOnce("ak-visual-scale:" + context + ":" + ((Object)visualRoot).GetInstanceID(), $"Normalized weapon visual scale: context={context}, visual={GetTransformPath(visualRoot)}, reference={GetTransformPath(referenceRoot)}, oldSize={boundsLongestSize:0.####}, referenceSize={num2:0.####}, targetSize={num3:0.####}, newSize={num5:0.####}, scaleRatio={num4:0.###}, reason={text}, newLocalScale={visualRoot.localScale}"); } } private static bool TryGetReferenceRenderableBounds(Transform referenceRoot, Transform visualRoot, out Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); if ((Object)(object)referenceRoot == (Object)null) { return false; } if (TryGetOriginalWeaponRenderableBounds(referenceRoot, out bounds)) { return true; } return TryGetCombinedRenderableBounds(referenceRoot, out bounds, visualRoot); } private static bool TryGetOriginalWeaponRenderableBounds(Transform targetVisualRoot, out Bounds bounds) { //IL_0001: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); if ((Object)(object)targetVisualRoot == (Object)null) { return false; } Renderer[] componentsInChildren = ((Component)targetVisualRoot).GetComponentsInChildren(true); bool flag = false; Renderer[] array = componentsInChildren; foreach (Renderer renderer in array) { if (IsOriginalWeaponRenderer(renderer, targetVisualRoot) && TryGetRendererWorldBounds(renderer, out var bounds2)) { if (!flag) { bounds = bounds2; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(bounds2); } } } return flag; } private static bool TryGetCombinedRenderableBounds(Transform root, out Bounds bounds, Transform excludedSubtree = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); if ((Object)(object)root == (Object)null) { return false; } Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); bool flag = false; Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if ((Object)(object)val == (Object)null || !IsMeshBackedRenderer(val)) { continue; } Transform transform = ((Component)val).transform; if ((!((Object)(object)excludedSubtree != (Object)null) || (!((Object)(object)transform == (Object)(object)excludedSubtree) && !transform.IsChildOf(excludedSubtree))) && TryGetRendererWorldBounds(val, out var bounds2)) { if (!flag) { bounds = bounds2; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(bounds2); } } } return flag; } private static bool TryGetRendererWorldBounds(Renderer renderer, out Bounds bounds) { //IL_0001: 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_001a: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); Mesh rendererMesh = GetRendererMesh(renderer); if ((Object)rendererMesh == (Object)null) { return false; } return TryTransformBounds(rendererMesh.bounds, ((Component)renderer).transform.localToWorldMatrix, out bounds); } private static bool TryTransformBounds(Bounds sourceBounds, Matrix4x4 matrix, out Bounds bounds) { //IL_0001: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_00fc: 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_0113: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); Vector3 center = ((Bounds)(ref sourceBounds)).center; Vector3 extents = ((Bounds)(ref sourceBounds)).extents; Vector3 val = ((Matrix4x4)(ref matrix)).MultiplyPoint3x4(center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z)); if (!IsFiniteVector3(val)) { return false; } bounds = new Bounds(val, Vector3.zero); Vector3[] array = (Vector3[])(object)new Vector3[7] { center + new Vector3(0f - extents.x, 0f - extents.y, extents.z), center + new Vector3(0f - extents.x, extents.y, 0f - extents.z), center + new Vector3(0f - extents.x, extents.y, extents.z), center + new Vector3(extents.x, 0f - extents.y, 0f - extents.z), center + new Vector3(extents.x, 0f - extents.y, extents.z), center + new Vector3(extents.x, extents.y, 0f - extents.z), center + new Vector3(extents.x, extents.y, extents.z) }; for (int i = 0; i < array.Length; i++) { Vector3 val2 = ((Matrix4x4)(ref matrix)).MultiplyPoint3x4(array[i]); if (!IsFiniteVector3(val2)) { return false; } ((Bounds)(ref bounds)).Encapsulate(val2); } return true; } private static float GetBoundsLongestSize(Bounds bounds) { //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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 size = ((Bounds)(ref bounds)).size; return Mathf.Max(new float[3] { size.x, size.y, size.z }); } private static bool IsFiniteVector3(Vector3 value) { //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) if (IsFiniteFloat(value.x) && IsFiniteFloat(value.y)) { return IsFiniteFloat(value.z); } return false; } private static bool IsValidNormalizedScale(Vector3 value) { //IL_0000: 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_0017: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!IsFiniteVector3(value)) { return false; } if (value.x < 0.0001f || value.y < 0.0001f || value.z < 0.0001f) { return false; } if (value.x > 256f || value.y > 256f || value.z > 256f) { return false; } return true; } internal static bool TryResolveBaseAkVisual(out Mesh mesh, out Material[] materials, out Vector3 localScale, out Quaternion localRotation, out Vector3 localPosition, out string debugInfo) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) mesh = null; materials = null; localScale = Vector3.one; localRotation = Quaternion.identity; localPosition = Vector3.zero; debugInfo = "unresolved"; if (!TryGetBestSourceVisual(out var best) || (Object)(object)best.Mesh == (Object)null) { return false; } mesh = best.Mesh; materials = best.Materials; if ((Object)(object)best.Transform != (Object)null) { TryGetTransformPoseRelativeToAkRoot(best.Transform, out var localPosition2, out var localRotation2, out var localScale2); localScale = SanitizeLocalScale(localScale2, Vector3.one); localRotation = SanitizeLocalRotation(localRotation2); localPosition = SanitizeLocalPosition(localPosition2, Vector3.zero); } debugInfo = $"path={best.Path}, mesh={best.MeshName}, verts={best.VertexCount}, score={best.Score}, subMeshes={Mathf.Max(best.Mesh.subMeshCount, 1)}, mats={((best.Materials != null) ? best.Materials.Length : 0)}, pos={localPosition}, rot={((Quaternion)(ref localRotation)).eulerAngles}, scale={localScale}"; return true; } private static bool HasReplacementVisualSource(Item item) { return Plugin.HasAkVisualPrefab(Plugin.GetWeaponSelectionForItem(item)); } private static bool TryResolveBundleMeshOnlyVisual(out Mesh mesh, out Material[] materials, out Vector3 localScale, out Quaternion localRotation, out Vector3 localPosition, out string debugInfo) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) mesh = null; materials = null; localScale = Vector3.one; localRotation = Quaternion.identity; localPosition = Vector3.zero; debugInfo = "bundle-mesh-only-unresolved"; GameObject akVisualPrefab = Plugin.GetAkVisualPrefab(); if ((Object)(object)akVisualPrefab == (Object)null) { return false; } Transform val = akVisualPrefab.transform.Find("AK/Mesh") ?? akVisualPrefab.transform.Find("Mesh"); if ((Object)(object)val == (Object)null && TryGetBestSourceVisual(out var best)) { val = best.Transform; mesh = best.Mesh; debugInfo = "bundle-mesh-only fallback path=" + best.Path; } if ((Object)(object)val == (Object)null) { return false; } if ((Object)(object)mesh == (Object)null) { MeshFilter component = ((Component)val).GetComponent(); mesh = (((Object)(object)component != (Object)null) ? component.sharedMesh : null); } if ((Object)(object)mesh == (Object)null) { return false; } MeshRenderer component2 = ((Component)val).GetComponent(); TryGetTransformPoseRelativeToAkRoot(val, out localPosition, out localRotation, out localScale); localScale = SanitizeLocalScale(localScale, Vector3.one); localRotation = SanitizeLocalRotation(localRotation); localPosition = SanitizeLocalPosition(localPosition, Vector3.zero); Material[] array = (((Object)(object)component2 != (Object)null) ? ((Renderer)component2).sharedMaterials : null); bool flag = array != null && array.Length != 0 && array.Any((Material material) => (Object)(object)material != (Object)null); materials = GetMeshOnlyTestMaterials(Mathf.Max(mesh.subMeshCount, 1)); debugInfo = $"bundle-mesh-only path={GetTransformPath(val)}, mesh={((Object)mesh).name}, verts={mesh.vertexCount}, subMeshes={Mathf.Max(mesh.subMeshCount, 1)}, sourceMats={(flag ? array.Length : 0)}, runtimeMats=test/{materials.Length}, pos={localPosition}, rot={((Quaternion)(ref localRotation)).eulerAngles}, scale={localScale}"; return true; } private static Material[] GetMeshOnlyTestMaterials(int subMeshCount) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) subMeshCount = Mathf.Max(subMeshCount, 1); if (_meshOnlyTestMaterials == null || _meshOnlyTestMaterials.Length != subMeshCount || _meshOnlyTestMaterials.Any((Material material) => (Object)(object)material == (Object)null)) { Material[] array = (Material[])(object)new Material[subMeshCount]; for (int i = 0; i < subMeshCount; i++) { Material val = CreateRuntimeMaterial(null, null); ApplyColor(val, new Color(0.82f, 0.82f, 0.82f, 1f)); NormalizeMaterialForVisibility(val); array[i] = val; } _meshOnlyTestMaterials = array; } return _meshOnlyTestMaterials; } private static bool TryResolveDebugCubeVisual(out Mesh mesh, out Material[] materials, out Vector3 localScale, out Quaternion localRotation, out Vector3 localPosition, out string debugInfo) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) mesh = GetDebugCubeMesh(); materials = GetDebugCubeMaterials(); localScale = Vector3.one * 0.25f; localRotation = Quaternion.identity; localPosition = Vector3.zero; debugInfo = "debug-cube"; if ((Object)(object)mesh != (Object)null && materials != null) { return materials.Length != 0; } return false; } private static Mesh GetDebugCubeMesh() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown if ((Object)(object)_debugCubeMesh != (Object)null) { return _debugCubeMesh; } GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); try { MeshFilter component = val.GetComponent(); if ((Object)(object)component != (Object)null) { _debugCubeMesh = component.sharedMesh; } } finally { Object.Destroy((Object)val); } return _debugCubeMesh; } private static Material[] GetDebugCubeMaterials() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if (_debugCubeMaterials != null && _debugCubeMaterials.Length != 0 && _debugCubeMaterials.All((Material material) => (Object)(object)material != (Object)null)) { return _debugCubeMaterials; } Material val = CreateRuntimeMaterial(null, null); ApplyColor(val, new Color(1f, 0.25f, 0.05f, 1f)); if (val.HasProperty("_EmissionColor")) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", new Color(0.35f, 0.08f, 0.02f, 1f)); } NormalizeMaterialForVisibility(val); _debugCubeMaterials = (Material[])(object)new Material[1] { val }; return _debugCubeMaterials; } private static bool TryResolveDebugSphereVisual(out Mesh mesh, out Material[] materials, out Vector3 localScale, out Quaternion localRotation, out Vector3 localPosition, out string debugInfo) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) mesh = GetDebugSphereMesh(); materials = GetDebugSphereMaterials(); localScale = Vector3.one * 0.08f; localRotation = Quaternion.identity; localPosition = Vector3.zero; debugInfo = "debug-anchor-sphere"; if ((Object)(object)mesh != (Object)null && materials != null) { return materials.Length != 0; } return false; } private static Mesh GetDebugSphereMesh() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown if ((Object)(object)_debugSphereMesh != (Object)null) { return _debugSphereMesh; } GameObject val = GameObject.CreatePrimitive((PrimitiveType)0); try { MeshFilter component = val.GetComponent(); if ((Object)(object)component != (Object)null) { _debugSphereMesh = component.sharedMesh; } } finally { Object.Destroy((Object)val); } return _debugSphereMesh; } private static Material[] GetDebugSphereMaterials() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if (_debugSphereMaterials != null && _debugSphereMaterials.Length != 0 && _debugSphereMaterials.All((Material material) => (Object)(object)material != (Object)null)) { return _debugSphereMaterials; } Material val = CreateRuntimeMaterial(null, null); ApplyColor(val, new Color(1f, 0.08f, 0.08f, 1f)); if (val.HasProperty("_EmissionColor")) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", new Color(0.55f, 0.02f, 0.02f, 1f)); } NormalizeMaterialForVisibility(val); _debugSphereMaterials = (Material[])(object)new Material[1] { val }; return _debugSphereMaterials; } private static void EnsureHeldDebugSphere(Transform visualRoot) { } private static void CleanupHeldDebugSphere(Transform visualRoot) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (!((Object)(object)visualRoot == (Object)null)) { Transform val = visualRoot.Find("AK_HeldDebugSphere"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)((Component)val).gameObject); } } } private static Vector3 ResolveHeldDebugSphereLocalPosition(Transform visualRoot) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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) if ((Object)(object)visualRoot == (Object)null || !TryGetCombinedRenderableBounds(visualRoot, out var bounds)) { return Vector3.zero; } return SanitizeLocalPosition(visualRoot.InverseTransformPoint(((Bounds)(ref bounds)).center), Vector3.zero); } private static Vector3 ResolveHeldDebugSphereLocalScale(Transform visualRoot, float desiredWorldDiameter) { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) if ((Object)(object)visualRoot == (Object)null) { return Vector3.one * desiredWorldDiameter; } Vector3 lossyScale = visualRoot.lossyScale; return SanitizeLocalScale(new Vector3(desiredWorldDiameter / Mathf.Max(Mathf.Abs(lossyScale.x), 0.0001f), desiredWorldDiameter / Mathf.Max(Mathf.Abs(lossyScale.y), 0.0001f), desiredWorldDiameter / Mathf.Max(Mathf.Abs(lossyScale.z), 0.0001f)), Vector3.one * desiredWorldDiameter); } internal static bool TryResolvePreferredAkVisual(out Mesh mesh, out Material[] materials, out Vector3 localScale, out Quaternion localRotation, out Vector3 localPosition, out string debugInfo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_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_0062: 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_006c: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) Vector3 directAkPositionOverride = GetDirectAkPositionOverride(); if (!TryResolveBaseAkVisual(out mesh, out materials, out var localScale2, out var localRotation2, out var localPosition2, out debugInfo)) { localScale = Vector3.one * 1.6f; localRotation = HeldLegacyRotationOffset; localPosition = directAkPositionOverride; return false; } localScale = SanitizeLocalScale(Vector3.Scale(localScale2, Vector3.one * 1.6f), Vector3.one * 1.6f); localRotation = SanitizeLocalRotation(localRotation2 * HeldLegacyRotationOffset); localPosition = SanitizeLocalPosition(localPosition2 + directAkPositionOverride, directAkPositionOverride); debugInfo += $", heldPos={localPosition}, heldRot={((Quaternion)(ref localRotation)).eulerAngles}, heldScale={localScale}"; return true; } private static bool TryResolveDirectAkVisual(out Mesh mesh, out Material[] materials, out Vector3 localScale, out Quaternion localRotation, out Vector3 localPosition, out string debugInfo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) Vector3 directAkPositionOverride = GetDirectAkPositionOverride(); mesh = null; materials = null; localScale = Vector3.one; localRotation = HeldLegacyRotationOffset; localPosition = directAkPositionOverride; debugInfo = "direct-ak-unresolved"; GameObject akVisualPrefab = Plugin.GetAkVisualPrefab(); if ((Object)(object)akVisualPrefab == (Object)null) { Plugin.LogDiagnosticOnce("ak-direct-prefab-null", "TryResolveDirectAkVisual aborted because AK visual prefab is null"); return false; } Transform val = akVisualPrefab.transform.Find("AK/Mesh") ?? akVisualPrefab.transform.Find("Mesh"); bool flag = (Object)(object)val != (Object)null && ShouldRejectDirectAkSource(val); MeshFilter val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); MeshRenderer val3 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null || ShouldRejectDirectAkSource(val)) { val2 = null; val3 = null; MeshFilter[] componentsInChildren = akVisualPrefab.GetComponentsInChildren(true); int num = int.MinValue; MeshFilter[] array = componentsInChildren; foreach (MeshFilter val4 in array) { if ((Object)(object)val4 == (Object)null || (Object)(object)val4.sharedMesh == (Object)null) { continue; } MeshRenderer component = ((Component)val4).GetComponent(); if (!((Object)(object)component == (Object)null) && !ShouldRejectDirectAkSource(((Component)val4).transform)) { int num2 = val4.sharedMesh.vertexCount; string text = GetTransformPath(((Component)val4).transform).ToLowerInvariant(); if (text.Contains("/ak/")) { num2 += 4000; } if (text.EndsWith("/mesh")) { num2 += 6000; } if (text.Contains("cube")) { num2 += 2500; } if (num2 > num) { num = num2; val2 = val4; val3 = component; } } } } if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) { Plugin.LogDiagnosticOnce("ak-direct-fail:" + ((Object)akVisualPrefab).GetInstanceID(), $"TryResolveDirectAkVisual failed: preferredNode={GetTransformPath(val)}, preferredRejected={flag}, prefab={Plugin.DescribeAkVisualPrefabForDiagnostics()}"); return false; } mesh = val2.sharedMesh; materials = NormalizeMaterialArray(((Renderer)val3).sharedMaterials, Mathf.Max(mesh.subMeshCount, 1)); localScale = Vector3.one * GetDirectAkScaleMultiplier(); localRotation = GetDirectAkRotationOverride(); localPosition = directAkPositionOverride; object[] array2 = new object[7] { GetTransformPath(((Component)val2).transform), ((Object)mesh).name, mesh.vertexCount, null, null, null, null }; Material[] array3 = materials; array2[3] = ((array3 != null) ? array3.Length : 0); array2[4] = localPosition; array2[5] = ((Quaternion)(ref localRotation)).eulerAngles; array2[6] = localScale; debugInfo = string.Format("direct path={0}, mesh={1}, verts={2}, mats={3}, pos={4}, rot={5}, scale={6}", array2); Plugin.LogDiagnosticOnce("ak-direct-success:" + GetTransformPath(((Component)val2).transform), $"TryResolveDirectAkVisual selected source={GetTransformPath(((Component)val2).transform)}, mesh={((Object)mesh).name}, verts={mesh.vertexCount}, mats={((materials != null) ? materials.Length : 0)}, heldPos={localPosition}, heldRot={((Quaternion)(ref localRotation)).eulerAngles}, heldScale={localScale}"); return true; } private static bool TryResolveSimpleVisualSource(out Mesh mesh, out Material[] materials, out Vector3 localScale, out Quaternion localRotation, out Vector3 localPosition, out string debugInfo) { //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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002d: 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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if (TryResolveBaseAkVisual(out mesh, out materials, out var localScale2, out var localRotation2, out var localPosition2, out var debugInfo2) && (Object)(object)mesh != (Object)null) { localScale = SanitizeLocalScale(localScale2, Vector3.one); localRotation = SanitizeLocalRotation(localRotation2); localPosition = SanitizeLocalPosition(localPosition2, Vector3.zero); debugInfo = "simple-base->" + debugInfo2; return true; } if (TryResolveDirectAkVisual(out mesh, out materials, out var localScale3, out var _, out var _, out var debugInfo3) && (Object)(object)mesh != (Object)null) { localScale = SanitizeLocalScale(localScale3, Vector3.one); localRotation = Quaternion.identity; localPosition = Vector3.zero; debugInfo = "simple-direct-fallback->" + debugInfo3 + ", forcedPos=(0.00, 0.00, 0.00), forcedRot=(0.00, 0.00, 0.00)"; return true; } localScale = Vector3.one; localRotation = Quaternion.identity; localPosition = Vector3.zero; debugInfo = "simple-unresolved"; return false; } private static bool ShouldUseHeldSimpleVisualPose(Item item) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 if ((Object)(object)item == (Object)null) { return false; } if ((int)item.itemState == 1) { return true; } if ((Object)(object)item.holderCharacter == (Object)null) { return (Object)(object)item.trueHolderCharacter != (Object)null; } return true; } private static bool TryResolveRuntimeSimpleVisualSource(Item item, out Mesh mesh, out Material[] materials, out Vector3 localScale, out Quaternion localRotation, out Vector3 localPosition, out string debugInfo) { if (ShouldUseHeldSimpleVisualPose(item) && TryResolvePreferredAkVisual(out mesh, out materials, out localScale, out localRotation, out localPosition, out var debugInfo2) && (Object)(object)mesh != (Object)null) { debugInfo = "simple-held->" + debugInfo2; return true; } return TryResolveSimpleVisualSource(out mesh, out materials, out localScale, out localRotation, out localPosition, out debugInfo); } private static bool ShouldRejectDirectAkSource(Transform transform) { if ((Object)(object)transform == (Object)null) { return true; } string text = GetTransformPath(transform).ToLowerInvariant(); if (!text.Contains("/hand") && !text.Contains("/arm") && !text.Contains("finger") && !text.Contains("holiday") && !text.Contains("vfx") && !text.Contains("effect") && !text.Contains("spawn")) { return text.Contains("muzzle"); } return true; } private static Material[] BuildDirectAkMaterials(Material[] sourceMaterials, int subMeshCount) { subMeshCount = Mathf.Max(subMeshCount, 1); Material[] array = NormalizeMaterialArray(sourceMaterials, subMeshCount); Material[] array2 = (Material[])(object)new Material[subMeshCount]; Material val = ((IEnumerable)array).FirstOrDefault((Func)((Material material) => (Object)(object)material != (Object)null)); for (int i = 0; i < subMeshCount; i++) { Material val2 = ((i < array.Length) ? array[i] : null); if ((Object)(object)val2 == (Object)null) { val2 = val; } array2[i] = CreateDirectVisibleMaterial(val2); NormalizeMaterialForVisibility(array2[i]); } return array2; } private static Material CreateDirectVisibleMaterial(Material source) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown Shader val = ResolvePreferredVisibleShader(); Material val2 = new Material(((Object)(object)val != (Object)null) ? val : ResolveFallbackShader()); if ((Object)(object)source != (Object)null) { CopySourceMaterialProperties(source, val2, preserveDestinationColor: false); NormalizeMaterial(val2, source); } else { NormalizeMaterial(val2, null); } return val2; } internal static bool TryResolveHeldPoseRelativeToBase(out Vector3 localPosition, out Quaternion localRotation, out Vector3 localScale) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0069: 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_0070: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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) Vector3 directAkPositionOverride = GetDirectAkPositionOverride(); localPosition = Vector3.zero; localRotation = Quaternion.identity; localScale = Vector3.one; if (!TryResolveBaseAkVisual(out var mesh, out var materials, out var localScale2, out var localRotation2, out var localPosition2, out var debugInfo)) { return false; } if (!TryResolvePreferredAkVisual(out mesh, out materials, out var localScale3, out var localRotation3, out var localPosition3, out debugInfo)) { return false; } Matrix4x4 val = Matrix4x4.TRS(localPosition2, localRotation2, localScale2); DecomposeMatrix(((Matrix4x4)(ref val)).inverse * Matrix4x4.TRS(localPosition3, localRotation3, localScale3), out localPosition, out localRotation, out localScale); localPosition = SanitizeLocalPosition(localPosition, directAkPositionOverride); localRotation = SanitizeLocalRotation(localRotation); localScale = SanitizeLocalScale(localScale, Vector3.one * 1.6f); return true; } internal static Material[] BuildAkVisibleMaterials(Material[] preferredMaterials, int subMeshCount) { return BuildVisibleMaterials(preferredMaterials, null, subMeshCount); } private static int ComputeMaterialArrayHash(Material[] materials, int subMeshCount) { int num = subMeshCount; Material[] array = NormalizeMaterialArray(materials, subMeshCount); for (int i = 0; i < array.Length; i++) { num = num * 31 + (((Object)(object)array[i] != (Object)null) ? ((Object)array[i]).GetInstanceID() : 0); } return num; } private static Material[] GetSharedDirectAkMaterials(Material[] sourceMaterials, int subMeshCount) { int num = ComputeMaterialArrayHash(sourceMaterials, subMeshCount); if (_cachedDirectAkSharedMaterials == null || _cachedDirectAkSharedMaterials.Length != subMeshCount || _cachedDirectAkSharedMaterialsHash != num || _cachedDirectAkSharedMaterials.Any((Material material) => (Object)(object)material == (Object)null)) { _cachedDirectAkSharedMaterials = BuildDirectAkMaterials(sourceMaterials, subMeshCount); _cachedDirectAkSharedMaterialsHash = num; } if (_cachedDirectAkSharedMaterials == null) { return Array.Empty(); } return _cachedDirectAkSharedMaterials.ToArray(); } internal static void NormalizeAkRenderer(Renderer renderer) { NormalizeRendererMaterials(renderer); } private static void ConfigureRuntimeWeaponRenderer(Renderer renderer) { if (!((Object)(object)renderer == (Object)null)) { renderer.allowOcclusionWhenDynamic = false; renderer.shadowCastingMode = (ShadowCastingMode)0; renderer.receiveShadows = false; renderer.lightProbeUsage = (LightProbeUsage)0; renderer.reflectionProbeUsage = (ReflectionProbeUsage)0; } } internal static Transform CreatePreparedAkClone(Item item, Transform parent, Transform targetVisualRoot, string cloneName) { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)parent == (Object)null) { return null; } GameObject val = (((Object)(object)item != (Object)null) ? Plugin.GetAkVisualPrefab(Plugin.GetWeaponSelectionForItem(item)) : Plugin.GetAkVisualPrefab()); if (!((Object)(object)val == (Object)null)) { GameObject obj = Object.Instantiate(val, parent, false); ((Object)obj).name = cloneName; StripNonVisualComponents(obj); PrepareRenderers(obj, targetVisualRoot); ApplyConfiguredPrefabRootPose(obj.transform); NormalizeVisualScaleAgainstReference(obj.transform, targetVisualRoot, cloneName); ApplyConfiguredWorldVisualScale(obj.transform, ((Object)(object)item != (Object)null) ? Plugin.GetWeaponSelectionForItem(item) : null); SetLayerRecursively(obj.transform, ((Component)parent).gameObject.layer); SetHierarchyActive(obj.transform, active: true); return obj.transform; } if (TryResolvePreferredAkVisual(out var mesh, out var materials, out var localScale, out var localRotation, out var localPosition, out var _) && (Object)(object)mesh != (Object)null) { GameObject val2 = new GameObject(cloneName); val2.transform.SetParent(parent, false); val2.transform.localPosition = localPosition; val2.transform.localRotation = localRotation; val2.transform.localScale = localScale; MeshFilter val3 = val2.AddComponent(); MeshRenderer obj2 = val2.AddComponent(); val3.sharedMesh = mesh; ((Renderer)obj2).sharedMaterials = GetSharedDirectAkMaterials(materials, Mathf.Max(mesh.subMeshCount, 1)); NormalizeAkRenderer((Renderer)obj2); NormalizeVisualScaleAgainstReference(val2.transform, targetVisualRoot, cloneName + "-mesh"); ApplyConfiguredWorldVisualScale(val2.transform, ((Object)(object)item != (Object)null) ? Plugin.GetWeaponSelectionForItem(item) : null); SetLayerRecursively(val2.transform, ((Component)parent).gameObject.layer); return val2.transform; } return null; } internal static Transform CreatePreparedAkClone(Transform parent, Transform targetVisualRoot, string cloneName) { return CreatePreparedAkClone(null, parent, targetVisualRoot, cloneName); } private static void ApplyConfiguredPrefabRootPose(Transform cloneRoot) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)cloneRoot == (Object)null)) { cloneRoot.localPosition = GetDirectAkPositionOverride(); cloneRoot.localRotation = GetDirectAkRotationOverride(); cloneRoot.localScale = Vector3.one; } } private static void ApplyConfiguredWorldVisualScale(Transform cloneRoot, string selection = null) { //IL_0022: 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_002d: 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 (!((Object)(object)cloneRoot == (Object)null)) { float num = Mathf.Max(GetDirectAkScaleMultiplier(selection) * 1.275f, 0.001f); cloneRoot.localScale = Vector3.Scale(cloneRoot.localScale, Vector3.one * num); } } private static void SetHierarchyActive(Transform root, bool active) { //IL_0030: 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_0040: Expected O, but got Unknown //IL_0040: Expected O, but got Unknown if ((Object)(object)root == (Object)null) { return; } ((Component)root).gameObject.SetActive(active); Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)val == (Object)root)) { ((Component)val).gameObject.SetActive(active); } } } internal static void PrepareAkVisualRenderers(GameObject root, Transform targetVisualRoot) { PrepareRenderers(root, targetVisualRoot); } private static void TryRefreshItem(Item item, bool forceRefresh) { if (!ShouldProcessRuntimeItem(item) || !Plugin.IsWeaponFeatureEnabled() || !IsBlowgunLike(item)) { return; } try { EnsureAkVisual(item, forceRefresh); } catch (Exception ex) { Plugin.Log.LogError((object)("[ShootZombies] ItemPatch refresh failed: " + ex)); } } private static void ApplyUiData(Item item, ItemUIData uiData) { if (uiData == null) { return; } Plugin.CaptureWeaponItemUiDisplayState(uiData); string weaponSelectionForItem = Plugin.GetWeaponSelectionForItem(item); uiData.itemName = Plugin.GetWeaponDisplayName(weaponSelectionForItem); Texture2D akIconTexture = Plugin.GetAkIconTexture(weaponSelectionForItem); if ((Object)(object)akIconTexture != (Object)null) { uiData.icon = akIconTexture; if (uiData.hasAltIcon) { uiData.altIcon = akIconTexture; } } Plugin.ApplyWeaponItemInteractionRestrictions(uiData); } private static Transform ResolveTargetVisualRoot(Item item) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 if ((Object)(object)item == (Object)null) { return null; } if ((int)item.itemState == 1) { Transform transform = ((Component)item).transform; Plugin.LogDiagnosticOnce("ak-target-root:" + ((Object)item).GetInstanceID(), "ResolveTargetVisualRoot using held item root: " + DescribeItemForDiagnostics(item) + ", root=" + GetTransformPath(transform)); return transform; } if (IsDroppedWorldItem(item)) { Transform transform2 = ((Component)item).transform; Plugin.LogDiagnosticOnce("ak-target-root:" + ((Object)item).GetInstanceID(), "ResolveTargetVisualRoot using dropped item root: " + DescribeItemForDiagnostics(item) + ", root=" + GetTransformPath(transform2)); return transform2; } Transform val = ((Component)item).transform.Find("Blowgun"); if ((Object)(object)val != (Object)null) { Plugin.LogDiagnosticOnce("ak-target-root:" + ((Object)item).GetInstanceID(), "ResolveTargetVisualRoot via Find(\"Blowgun\"): " + DescribeItemForDiagnostics(item) + ", root=" + GetTransformPath(val)); return val; } Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (IsRenderableWeaponPiece(val2)) { Plugin.LogDiagnosticOnce("ak-target-root:" + ((Object)item).GetInstanceID(), "ResolveTargetVisualRoot via renderer scan: " + DescribeItemForDiagnostics(item) + ", root=" + GetTransformPath(((Component)val2).transform) + ", rendererCandidates=" + DescribeRendererCandidatesForDiagnostics(item)); return ((Component)val2).transform; } } Plugin.LogDiagnosticOnce("ak-target-root:" + ((Object)item).GetInstanceID(), "ResolveTargetVisualRoot fell back to item root: " + DescribeItemForDiagnostics(item) + ", root=" + GetTransformPath(((Component)item).transform) + ", rendererCandidates=" + DescribeRendererCandidatesForDiagnostics(item)); return ((Component)item).transform; } private static Transform ResolveHeldLegacyParent(Item item) { if ((Object)(object)item == (Object)null) { return null; } Transform val = ((Component)item).transform.Find("Blowgun"); if ((Object)(object)val != (Object)null) { Plugin.LogDiagnosticOnce("ak-held-parent:" + ((Object)item).GetInstanceID(), "ResolveHeldLegacyParent via Find(\"Blowgun\"): " + DescribeItemForDiagnostics(item) + ", parent=" + GetTransformPath(val) + ", itemRoot=" + GetTransformPath(((Component)item).transform)); return val; } Transform val2 = ResolveTargetVisualRoot(item); if ((Object)(object)val2 != (Object)null) { Plugin.LogDiagnosticOnce("ak-held-parent:" + ((Object)item).GetInstanceID(), "ResolveHeldLegacyParent fallback to target root: " + DescribeItemForDiagnostics(item) + ", parent=" + GetTransformPath(val2) + ", itemRoot=" + GetTransformPath(((Component)item).transform)); return val2; } Plugin.LogDiagnosticOnce("ak-held-parent:" + ((Object)item).GetInstanceID(), "ResolveHeldLegacyParent fell back to item root: " + DescribeItemForDiagnostics(item) + ", parent=" + GetTransformPath(((Component)item).transform)); return ((Component)item).transform; } private static bool IsRenderableWeaponPiece(Renderer renderer) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown if ((Object)(object)renderer == (Object)null) { return false; } string text = ((((Object)renderer).name ?? string.Empty) + "/" + (((Object)((Component)renderer).transform).name ?? string.Empty)).ToLowerInvariant(); string[] excludedVisualKeywords = ExcludedVisualKeywords; foreach (string value in excludedVisualKeywords) { if (text.Contains(value)) { return false; } } Mesh rendererMesh = GetRendererMesh(renderer); if ((Object)rendererMesh != (Object)null) { return rendererMesh.vertexCount > 24; } return false; } private static bool IsMeshBackedRenderer(Renderer renderer) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown return (Object)GetRendererMesh(renderer) != (Object)null; } private static bool HasAnyPreferredRenderer(Renderer[] renderers) { if (renderers == null) { return false; } for (int i = 0; i < renderers.Length; i++) { if (IsRenderableWeaponPiece(renderers[i])) { return true; } } return false; } private static Transform GetOrCreateLocalVisualRoot(Transform itemRoot, Transform targetVisualRoot) { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) AkLocalVisualMarker componentInChildren = ((Component)itemRoot).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { Transform transform = ((Component)componentInChildren).transform; SyncVisualRootToTarget(transform, targetVisualRoot); return transform; } GameObject val = new GameObject("AK_VisualRoot"); val.transform.SetParent(itemRoot, false); val.AddComponent(); SyncVisualRootToTarget(val.transform, targetVisualRoot); SetLayerRecursively(val.transform, ((Component)itemRoot).gameObject.layer); return val.transform; } private static void RefreshLocalVisual(Transform localVisualRoot, Transform targetVisualRoot, Item item, bool forceRefresh) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown if (!((Object)(object)localVisualRoot == (Object)null)) { SyncVisualRootToTarget(localVisualRoot, targetVisualRoot); Transform val = localVisualRoot.Find("AK_LocalVisualClone"); if (forceRefresh && (Object)(object)val != (Object)null) { Object.Destroy((Object)((Component)val).gameObject); val = null; } if ((Object)(object)val == (Object)null) { val = BuildVisualClone(item, localVisualRoot, targetVisualRoot); } EnsureVisualRenderersActive(val, visible: true); Transform val2 = (((Object)(object)targetVisualRoot != (Object)null) ? targetVisualRoot : (((Object)localVisualRoot.parent != (Object)null) ? localVisualRoot.parent : localVisualRoot)); int layer = (IsLocallyHeldByPlayer(item) ? ResolveBestVisibleLayerForLocalHeldItem(item, val2) : ResolveReferenceLayer(item, val2)); SetLayerRecursively(localVisualRoot, layer); Renderer val3 = SelectPreferredRenderer(((Component)val).GetComponentsInChildren(true), val); if ((Object)(object)val3 != (Object)null) { EnsureMuzzleMarkerForItem(item, val3); } EnsureMuzzleMarker(localVisualRoot, val); } } private static void BindVisualCloneToItem(Item item, Transform visualRoot) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown if ((Object)(object)item == (Object)null || (Object)(object)visualRoot == (Object)null) { return; } MeshRenderer[] array = (from r in ((Component)visualRoot).GetComponentsInChildren(true) where (Object)(object)r != (Object)null && (Object)(object)GetRendererMesh((Renderer)r) != (Object)null select r).ToArray(); SkinnedMeshRenderer[] array2 = (from r in ((Component)visualRoot).GetComponentsInChildren(true) where (Object)(object)r != (Object)null && (Object)(object)r.sharedMesh != (Object)null select r).ToArray(); if ((array == null || array.Length == 0) && (array2 == null || array2.Length == 0)) { return; } foreach (Renderer item2 in array.Cast().Concat((IEnumerable)(object)array2)) { item2.enabled = true; item2.forceRenderingOff = false; item2.allowOcclusionWhenDynamic = false; SkinnedMeshRenderer val = (SkinnedMeshRenderer)((item2 is SkinnedMeshRenderer) ? item2 : null); if ((Object)(object)val != (Object)null) { val.updateWhenOffscreen = true; } } BindItemRendererFields(item, array, array2); Renderer val2 = SelectPreferredRenderer(array.Cast().Concat((IEnumerable)(object)array2), visualRoot); if ((Object)(object)val2 != (Object)null) { EnsureMuzzleMarkerForItem(item, val2); } } private static Transform BuildVisualClone(Item item, Transform localVisualRoot, Transform targetVisualRoot) { return CreatePreparedAkClone(item, localVisualRoot, targetVisualRoot, "AK_LocalVisualClone"); } internal static void StripNonVisualComponents(GameObject root) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown foreach (Component item in root.GetComponentsInChildren(true).Reverse()) { if (!((Object)item == (Object)null) && !(item is Transform) && !(item is MeshFilter) && !(item is MeshRenderer) && !(item is SkinnedMeshRenderer)) { Object.Destroy((Object)item); } } } private static void PrepareRenderers(GameObject root, Transform targetVisualRoot) { Material[] fallbackMaterials = ResolveTemplateMaterials(targetVisualRoot).ToArray(); Renderer[] componentsInChildren = root.GetComponentsInChildren(true); bool flag = HasAnyPreferredRenderer(componentsInChildren); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (!IsRenderableWeaponPiece(val) && (flag || !IsMeshBackedRenderer(val))) { val.enabled = false; continue; } val.enabled = true; val.forceRenderingOff = false; ConfigureRuntimeWeaponRenderer(val); Material[] sharedMaterials = val.sharedMaterials; Mesh rendererMesh = GetRendererMesh(val); int subMeshCount = Math.Max(((Object)(object)rendererMesh != (Object)null) ? rendererMesh.subMeshCount : 0, 1); val.sharedMaterials = BuildVisibleMaterials(sharedMaterials, fallbackMaterials, subMeshCount); NormalizeRendererMaterials(val); } } private static void EnsureVisualRenderersActive(Transform visualClone, bool visible) { if ((Object)(object)visualClone == (Object)null) { return; } Renderer[] componentsInChildren = ((Component)visualClone).GetComponentsInChildren(true); bool flag = HasAnyPreferredRenderer(componentsInChildren); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (!((Object)(object)val == (Object)null)) { if (!IsRenderableWeaponPiece(val) && (flag || !IsMeshBackedRenderer(val))) { val.enabled = false; continue; } val.enabled = visible; val.forceRenderingOff = !visible; val.allowOcclusionWhenDynamic = false; } } } private static Transform FindBestAnchor(Transform root) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); bool flag = HasAnyPreferredRenderer(componentsInChildren); Renderer val = null; int num = int.MinValue; Renderer[] array = componentsInChildren; foreach (Renderer val2 in array) { if (!IsRenderableWeaponPiece(val2) && (flag || !IsMeshBackedRenderer(val2))) { continue; } Mesh rendererMesh = GetRendererMesh(val2); if (!((Object)rendererMesh == (Object)null)) { int num2 = ScoreRenderer(val2, rendererMesh); if (num2 > num) { num = num2; val = val2; } } } if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).transform; } private static int ScoreRenderer(Renderer renderer, Mesh mesh) { int num = mesh.vertexCount; string text = ((((Object)renderer).name ?? string.Empty) + "/" + (((Object)((Component)renderer).transform).name ?? string.Empty)).ToLowerInvariant(); if (text.Contains("ak") || text.Contains("gun") || text.Contains("rifle") || text.Contains("weapon")) { num += 2000; } if (text.Contains("body") || text.Contains("mesh")) { num += 1000; } if (renderer is SkinnedMeshRenderer) { num -= 500; } return num; } private static void AlignCloneToAnchor(Transform cloneRoot, Transform anchor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0055: 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_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_0079: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 val = cloneRoot.parent.worldToLocalMatrix * anchor.localToWorldMatrix; DecomposeMatrix(Matrix4x4.TRS(new Vector3(-0.01f, -0.01f, 0f), Quaternion.Euler(0f, 0f, -12f), Vector3.one * 1.6f) * ((Matrix4x4)(ref val)).inverse, out var position, out var rotation, out var scale); cloneRoot.localPosition = position; cloneRoot.localRotation = rotation; cloneRoot.localScale = scale; } private static void EnsureMuzzleMarker(Transform localVisualRoot, Transform visualClone) { //IL_0026: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) if (!((Object)(object)localVisualRoot == (Object)null)) { Transform val = localVisualRoot.Find("AK_MuzzleMarker"); if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("AK_MuzzleMarker"); val2.transform.SetParent(localVisualRoot, false); val2.AddComponent(); val = val2.transform; } Renderer val3 = FindBestMuzzleRenderer(visualClone); if ((Object)(object)val3 == (Object)null) { val.localPosition = Vector3.forward * 0.6f; val.localRotation = Quaternion.identity; return; } Bounds bounds = val3.bounds; Vector3 position = ((Bounds)(ref bounds)).center + ((Component)val3).transform.forward * Mathf.Max(((Bounds)(ref bounds)).extents.z, 0.06f); val.position = position; val.rotation = ((Component)val3).transform.rotation; } } private static Renderer FindBestMuzzleRenderer(Transform visualClone) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)visualClone == (Object)null) { return null; } Renderer[] componentsInChildren = ((Component)visualClone).GetComponentsInChildren(true); bool flag = HasAnyPreferredRenderer(componentsInChildren); Renderer result = null; float num = float.MinValue; Renderer[] array = componentsInChildren; foreach (Renderer val in array) { bool flag2 = IsRenderableWeaponPiece(val) || (!flag && IsMeshBackedRenderer(val)); if (val.enabled && flag2) { Bounds bounds = val.bounds; Vector3 size = ((Bounds)(ref bounds)).size; float num2 = ((Vector3)(ref size)).magnitude + ((Bounds)(ref bounds)).center.z; if (num2 > num) { num = num2; result = val; } } } return result; } private static Material CreateRuntimeMaterial(Material source, Material template) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown Material val = null; bool num = (Object)(object)template != (Object)null && (Object)(object)template.shader != (Object)null && template.shader.isSupported && !string.IsNullOrWhiteSpace(((Object)template.shader).name) && ((Object)template.shader).name.StartsWith("W/", StringComparison.OrdinalIgnoreCase); bool flag = (Object)(object)source == (Object)null || (Object)(object)source.shader == (Object)null || !source.shader.isSupported || string.IsNullOrWhiteSpace(((Object)source.shader).name) || string.Equals(((Object)source.shader).name, "Standard", StringComparison.OrdinalIgnoreCase) || string.Equals(((Object)source.shader).name, "Standard (Specular setup)", StringComparison.OrdinalIgnoreCase) || string.Equals(((Object)source.shader).name, "Standard (Roughness setup)", StringComparison.OrdinalIgnoreCase); if (num && flag) { val = new Material(template); CopySourceMaterialProperties(((Object)(object)source != (Object)null) ? source : template, val, preserveDestinationColor: false); NormalizeMaterial(val, template); return val; } if ((Object)(object)source != (Object)null) { val = new Material(source); CopySourceMaterialProperties(source, val, preserveDestinationColor: false); NormalizeMaterial(val, source); return val; } if ((Object)(object)template != (Object)null && !HasUsableTexture(source)) { val = new Material(template); CopySourceMaterialProperties(((Object)(object)source != (Object)null) ? source : template, val, preserveDestinationColor: false); } else if ((Object)(object)template != (Object)null) { val = new Material(template); CopySourceMaterialProperties(template, val, preserveDestinationColor: false); } else { val = new Material(ResolveFallbackShader()); } NormalizeMaterial(val, ((Object)(object)template != (Object)null) ? template : source); return val; } private static Shader ResolveFallbackShader() { return Shader.Find("Unlit/Texture") ?? Shader.Find("W/Peak_Standard") ?? Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Diffuse") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Hidden/InternalErrorShader"); } private static void NormalizeMaterial(Material material, Material referenceMaterial) { //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) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)material == (Object)null)) { Shader shader = ResolveFallbackShader(); string value = (((Object)(object)material.shader != (Object)null) ? ((Object)material.shader).name : string.Empty); if (((Object)(object)material.shader == (Object)null || !material.shader.isSupported || string.IsNullOrWhiteSpace(value)) && (Object)(object)referenceMaterial != (Object)null && (Object)(object)referenceMaterial.shader != (Object)null && referenceMaterial.shader.isSupported && !string.IsNullOrWhiteSpace(((Object)referenceMaterial.shader).name)) { material.shader = referenceMaterial.shader; } if ((Object)(object)material.shader == (Object)null || !material.shader.isSupported) { material.shader = shader; } Color color = ResolveMaterialColor(material); color.a = 1f; ApplyColor(material, color); if (material.HasProperty("_BaseColor")) { Color color2 = material.GetColor("_BaseColor"); color2.a = 1f; color2.r = Mathf.Max(color2.r, 0.82f); color2.g = Mathf.Max(color2.g, 0.82f); color2.b = Mathf.Max(color2.b, 0.82f); material.SetColor("_BaseColor", color2); } if (material.HasProperty("_Color")) { Color color3 = material.color; color3.a = 1f; color3.r = Mathf.Max(color3.r, 0.82f); color3.g = Mathf.Max(color3.g, 0.82f); color3.b = Mathf.Max(color3.b, 0.82f); material.color = color3; } if (material.HasProperty("_EmissionColor")) { material.EnableKeyword("_EMISSION"); material.SetColor("_EmissionColor", new Color(0.08f, 0.08f, 0.08f, 1f)); } if (material.HasProperty("_Surface")) { material.SetFloat("_Surface", 0f); } if (material.HasProperty("_AlphaClip")) { material.SetFloat("_AlphaClip", 0f); } if (material.HasProperty("_Cutoff")) { material.SetFloat("_Cutoff", 0f); } if (material.HasProperty("_Cull")) { material.SetInt("_Cull", 0); } material.renderQueue = (((Object)(object)referenceMaterial != (Object)null) ? referenceMaterial.renderQueue : (-1)); } } private static List ResolveTemplateMaterials(Transform targetVisualRoot) { List list = new List(); if ((Object)(object)targetVisualRoot == (Object)null) { return list; } Renderer[] componentsInChildren = ((Component)targetVisualRoot).GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (!IsOriginalWeaponRenderer(val, targetVisualRoot)) { continue; } Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials == null) { continue; } Material[] array2 = sharedMaterials; foreach (Material val2 in array2) { if ((Object)(object)val2 != (Object)null) { list.Add(val2); } } } if (list.Count == 0) { Item componentInParent = ((Component)targetVisualRoot).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { AddTemplateMaterials(componentInParent.mainRenderer, list); Renderer[] addtlRenderers = componentInParent.addtlRenderers; if (addtlRenderers == null) { return list; } componentsInChildren = addtlRenderers; for (int k = 0; k < componentsInChildren.Length; k++) { AddTemplateMaterials(componentsInChildren[k], list); } } } return list; } private static void AddTemplateMaterials(Renderer renderer, List output) { if ((Object)(object)renderer == (Object)null) { return; } Material[] sharedMaterials = renderer.sharedMaterials; if (sharedMaterials == null) { return; } Material[] array = sharedMaterials; foreach (Material val in array) { if ((Object)(object)val != (Object)null) { output.Add(val); } } } private static void CopySourceMaterialProperties(Material source, Material destination, bool preserveDestinationColor) { //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null || (Object)(object)destination == (Object)null) { return; } Texture val = ResolvePrimaryTexture(source); if ((Object)(object)val != (Object)null) { bool flag = false; if (destination.HasProperty("_MainTex")) { destination.SetTexture("_MainTex", val); CopyTextureScaleAndOffset(source, destination, "_MainTex", "_MainTex"); flag = true; } if (destination.HasProperty("_BaseMap")) { destination.SetTexture("_BaseMap", val); CopyTextureScaleAndOffset(source, destination, "_BaseMap", "_BaseMap"); flag = true; } if (!flag) { AssignPrimaryTextureToDestination(source, destination, val); } } CopyTextureByAlias(source, destination, "_BaseMap", "_MainTex"); CopyTextureByAlias(source, destination, "_MainTex", "_BaseMap"); CopyTextureByAlias(source, destination, "_BumpMap", "_NormalMap"); CopyTextureByAlias(source, destination, "_NormalMap", "_BumpMap"); CopyTextureByAlias(source, destination, "_MetallicGlossMap", "_MetallicTex"); CopyTextureByAlias(source, destination, "_MetallicTex", "_MetallicGlossMap"); CopyTextureIfPresent(source, destination, "_BumpMap"); CopyTextureIfPresent(source, destination, "_NormalMap"); CopyTextureIfPresent(source, destination, "_EmissionMap"); CopyTextureIfPresent(source, destination, "_MetallicGlossMap"); CopyTextureIfPresent(source, destination, "_OcclusionMap"); string[] texturePropertyNames = source.GetTexturePropertyNames(); if (texturePropertyNames != null) { string[] array = texturePropertyNames; foreach (string propertyName in array) { CopyTextureIfPresent(source, destination, propertyName); } } if (!preserveDestinationColor) { Color color = ResolveMaterialColor(source); color.a = 1f; ApplyColor(destination, color); } else { Color color2 = ResolveMaterialColor(destination); color2.a = 1f; ApplyColor(destination, color2); } CopyColorIfPresent(source, destination, "_EmissionColor"); CopyFloatIfPresent(source, destination, "_Metallic"); CopyFloatIfPresent(source, destination, "_Smoothness"); CopyFloatIfPresent(source, destination, "_Glossiness"); CopyFloatIfPresent(source, destination, "_BumpScale"); CopyFloatIfPresent(source, destination, "_Cutoff"); if (source.IsKeywordEnabled("_EMISSION")) { destination.EnableKeyword("_EMISSION"); } } private static void CopyTextureIfPresent(Material source, Material destination, string propertyName) { if (source.HasProperty(propertyName) && destination.HasProperty(propertyName)) { Texture texture = source.GetTexture(propertyName); if ((Object)(object)texture != (Object)null) { destination.SetTexture(propertyName, texture); CopyTextureScaleAndOffset(source, destination, propertyName, propertyName); } } } private static void CopyTextureByAlias(Material source, Material destination, string sourceProperty, string destinationProperty) { if (source.HasProperty(sourceProperty) && destination.HasProperty(destinationProperty)) { Texture texture = source.GetTexture(sourceProperty); if (!((Object)(object)texture == (Object)null)) { destination.SetTexture(destinationProperty, texture); CopyTextureScaleAndOffset(source, destination, sourceProperty, destinationProperty); } } } private static void AssignPrimaryTextureToDestination(Material source, Material destination, Texture texture) { if ((Object)(object)texture == (Object)null || (Object)(object)destination == (Object)null) { return; } string[] texturePropertyNames = destination.GetTexturePropertyNames(); if (texturePropertyNames == null || texturePropertyNames.Length == 0) { return; } string text = texturePropertyNames.FirstOrDefault((string name) => !string.IsNullOrEmpty(name) && (name.IndexOf("base", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("albedo", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("diff", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("main", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("color", StringComparison.OrdinalIgnoreCase) >= 0)); if (string.IsNullOrEmpty(text)) { text = texturePropertyNames.FirstOrDefault((string name) => !string.IsNullOrEmpty(name) && name.IndexOf("normal", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("bump", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("metal", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("occlusion", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("emission", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("detail", StringComparison.OrdinalIgnoreCase) < 0) ?? texturePropertyNames[0]; } if (string.IsNullOrEmpty(text) || !destination.HasProperty(text)) { return; } destination.SetTexture(text, texture); if ((Object)(object)source != (Object)null) { string text2 = ((source.HasProperty(text) && (Object)(object)source.GetTexture(text) != (Object)null) ? text : ResolveSourceScaleProperty(source)); if (!string.IsNullOrEmpty(text2)) { CopyTextureScaleAndOffset(source, destination, text2, text); } } } private static string ResolveSourceScaleProperty(Material source) { if ((Object)(object)source == (Object)null) { return null; } string[] array = new string[3] { "_BaseMap", "_MainTex", "_AlbedoMap" }; foreach (string text in array) { if (source.HasProperty(text) && (Object)(object)source.GetTexture(text) != (Object)null) { return text; } } return null; } private static void CopyTextureScaleAndOffset(Material source, Material destination, string sourceProperty, string destinationProperty) { //IL_0016: 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) if (source.HasProperty(sourceProperty) && destination.HasProperty(destinationProperty)) { destination.SetTextureScale(destinationProperty, source.GetTextureScale(sourceProperty)); destination.SetTextureOffset(destinationProperty, source.GetTextureOffset(sourceProperty)); } } private static Texture ResolvePrimaryTexture(Material material) { if ((Object)(object)material == (Object)null) { return null; } string[] array = new string[6] { "_BaseMap", "_MainTex", "_BaseColorMap", "_AlbedoMap", "_Albedo", "_DiffuseMap" }; foreach (string text in array) { if (material.HasProperty(text)) { Texture texture = material.GetTexture(text); if ((Object)(object)texture != (Object)null) { return texture; } } } string[] texturePropertyNames = material.GetTexturePropertyNames(); if (texturePropertyNames == null) { return null; } array = texturePropertyNames; foreach (string text2 in array) { if (material.HasProperty(text2)) { Texture texture2 = material.GetTexture(text2); if ((Object)(object)texture2 != (Object)null) { return texture2; } } } return null; } private static bool HasUsableTexture(Material material) { if ((Object)(object)material != (Object)null) { return (Object)(object)ResolvePrimaryTexture(material) != (Object)null; } return false; } private static bool HasUsableTexture(Material[] materials) { if (materials == null || materials.Length == 0) { return false; } foreach (Material val in materials) { if ((Object)(object)val != (Object)null && (Object)(object)ResolvePrimaryTexture(val) != (Object)null) { return true; } } return false; } private static void CopyFloatIfPresent(Material source, Material destination, string propertyName) { if (source.HasProperty(propertyName) && destination.HasProperty(propertyName)) { destination.SetFloat(propertyName, source.GetFloat(propertyName)); } } private static void CopyColorIfPresent(Material source, Material destination, string propertyName) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (source.HasProperty(propertyName) && destination.HasProperty(propertyName)) { destination.SetColor(propertyName, source.GetColor(propertyName)); } } private static Color ResolveMaterialColor(Material material) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)material == (Object)null) { return Color.white; } if (material.HasProperty("_BaseColor")) { return material.GetColor("_BaseColor"); } if (material.HasProperty("_Color")) { return material.GetColor("_Color"); } return Color.white; } private static void ApplyColor(Material material, Color color) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)material == (Object)null)) { if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", color); } if (material.HasProperty("_Color")) { material.SetColor("_Color", color); } } } private static void HideOriginalRenderers(Item item, Transform targetVisualRoot) { if ((Object)(object)item == (Object)null || (Object)(object)targetVisualRoot == (Object)null) { return; } List list = new List(); Renderer[] componentsInChildren = ((Component)targetVisualRoot).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && IsOriginalWeaponRenderer(val, targetVisualRoot)) { val.enabled = false; val.forceRenderingOff = true; list.Add(val); } } HiddenRendererCache[((Object)item).GetInstanceID()] = list.ToArray(); Plugin.LogDiagnosticOnce("ak-hide-original:" + ((Object)item).GetInstanceID(), $"HideOriginalRenderers processed {DescribeItemForDiagnostics(item)}, targetRoot={GetTransformPath(targetVisualRoot)}, hiddenCount={list.Count}, hidden={DescribeRendererCollectionForDiagnostics(list)}"); } private static bool IsOriginalWeaponRenderer(Renderer renderer, Transform targetVisualRoot) { if ((Object)(object)renderer == (Object)null) { return false; } if ((Object)(object)((Component)renderer).GetComponentInParent() != (Object)null) { return false; } if ((Object)(object)((Component)renderer).GetComponentInParent() != (Object)null) { return false; } if ((Object)(object)((Component)renderer).GetComponentInParent() != (Object)null) { return false; } if (HasNamedAncestor(((Component)renderer).transform, "AK_InPlaceVisualRoot")) { return false; } if (!((Component)renderer).transform.IsChildOf(targetVisualRoot)) { return false; } string text = ((((Object)renderer).name ?? string.Empty) + "/" + (((Object)((Component)renderer).transform).name ?? string.Empty)).ToLowerInvariant(); if (!text.Contains("hand") && !text.Contains("arm")) { return !text.Contains("finger"); } return false; } private static void RestoreOriginalVisual(Item item) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if ((Object)(object)item == (Object)null) { return; } RestoreInPlaceVisual(item); AkLocalVisualMarker componentInChildren = ((Component)item).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { Object.Destroy((Object)((Component)componentInChildren).gameObject); } if (HiddenRendererCache.TryGetValue(((Object)item).GetInstanceID(), out var value)) { Renderer[] array = value; foreach (Renderer val in array) { if (!((Object)(object)val == (Object)null)) { val.enabled = true; val.forceRenderingOff = false; val.allowOcclusionWhenDynamic = false; } } } HiddenRendererCache.Remove(((Object)item).GetInstanceID()); CleanupAllWeaponWorldColliders(item); SetOriginalItemCollidersEnabled(item, enabled: true); } private static void CleanupItem(Item item) { if (!((Object)(object)item == (Object)null)) { RestoreInPlaceVisual(item); CleanupSimpleAkVisual(item); DestroyLegacyHeldVisual(item, restoreRenderers: false); CleanupAllWeaponWorldColliders(item); SetOriginalItemCollidersEnabled(item, enabled: true); InPlaceSwappedItemIds.Remove(((Object)item).GetInstanceID()); HiddenRendererCache.Remove(((Object)item).GetInstanceID()); PendingSetStateValueByItemId.Remove(((Object)item).GetInstanceID()); PendingSetStateHolderByItemId.Remove(((Object)item).GetInstanceID()); } } private static void RestoreInPlaceVisual(Item item) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown if ((Object)(object)item == (Object)null) { return; } Transform[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && string.Equals(((Object)val).name, "AK_InPlaceVisualRoot", StringComparison.Ordinal)) { Object.Destroy((Object)((Component)val).gameObject); } } AkInPlaceMarker[] componentsInChildren2 = ((Component)item).GetComponentsInChildren(true); foreach (AkInPlaceMarker akInPlaceMarker in componentsInChildren2) { if ((Object)(object)akInPlaceMarker == (Object)null) { continue; } Transform transform = ((Component)akInPlaceMarker).transform; if (akInPlaceMarker.hasBaseTransform) { transform.localPosition = akInPlaceMarker.baseLocalPosition; transform.localRotation = akInPlaceMarker.baseLocalRotation; transform.localScale = akInPlaceMarker.baseLocalScale; } MeshFilter component = ((Component)akInPlaceMarker).GetComponent(); if ((Object)(object)component != (Object)null && akInPlaceMarker.hasOriginalVisual) { component.sharedMesh = akInPlaceMarker.originalMesh; } MeshRenderer component2 = ((Component)akInPlaceMarker).GetComponent(); if ((Object)(object)component2 != (Object)null) { if (akInPlaceMarker.hasOriginalVisual) { ((Renderer)component2).sharedMaterials = akInPlaceMarker.originalMaterials ?? Array.Empty(); } ((Renderer)component2).enabled = true; ((Renderer)component2).forceRenderingOff = false; ((Renderer)component2).allowOcclusionWhenDynamic = false; } Object.Destroy((Object)akInPlaceMarker); } InPlaceSwappedItemIds.Remove(((Object)item).GetInstanceID()); } private static void CleanupSimpleAkVisual(Item item) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if (!((Object)(object)item == (Object)null)) { Transform val = FindSimpleAkVisualRoot(item); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)((Component)val).gameObject); } } } private static Transform FindSimpleAkVisualRoot(Item item) { if ((Object)(object)item == (Object)null) { return null; } AkSimpleVisualMarker componentInChildren = ((Component)item).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { return ((Component)componentInChildren).transform; } return ((IEnumerable)((Component)item).GetComponentsInChildren(true)).FirstOrDefault((Func)((Transform t) => (Object)(object)t != (Object)null && string.Equals(((Object)t).name, "AK47Model", StringComparison.Ordinal))); } private static Transform TryCreatePreparedSimpleAkVisual(Item item, Transform targetVisualRoot) { if ((Object)(object)item == (Object)null) { return null; } Transform val = targetVisualRoot; if ((Object)(object)val == (Object)null) { val = ((Component)item).transform; } Transform val2 = CreatePreparedAkClone(item, val, targetVisualRoot, "AK47Model"); if ((Object)(object)val2 == (Object)null) { return null; } if ((Object)(object)((Component)val2).GetComponent() == (Object)null) { ((Component)val2).gameObject.AddComponent(); } EnsureVisualRenderersActive(val2, visible: true); return val2; } private static bool ShouldPreferBakedSimpleVisual(Item item) { return (Object)(object)item != (Object)null; } private static bool ShouldIncludeBakedSimpleSourceRenderer(Renderer sourceRenderer) { if ((Object)(object)sourceRenderer == (Object)null || !IsMeshBackedRenderer(sourceRenderer)) { return false; } if ((Object)(object)GetRendererMesh(sourceRenderer) == (Object)null) { return false; } if (ShouldRejectDirectAkSource(((Component)sourceRenderer).transform)) { return false; } string text = ((((Object)sourceRenderer).name ?? string.Empty) + "/" + GetTransformPath(((Component)sourceRenderer).transform)).ToLowerInvariant(); if (ExcludedVisualKeywords.Any((string keyword) => !string.IsNullOrWhiteSpace(keyword) && text.Contains(keyword))) { return false; } return true; } private static Transform TryCreateBakedSimpleAkVisual(Item item, Transform targetVisualRoot) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { return null; } string weaponSelectionForItem = Plugin.GetWeaponSelectionForItem(item); GameObject akVisualPrefab = Plugin.GetAkVisualPrefab(weaponSelectionForItem); if ((Object)(object)akVisualPrefab == (Object)null) { return null; } Transform val = targetVisualRoot; if ((Object)(object)val == (Object)null) { val = ((Component)item).transform; } GameObject val2 = new GameObject("AK47Model"); val2.transform.SetParent(val, false); val2.transform.localPosition = GetDirectAkPositionOverride(weaponSelectionForItem); val2.transform.localRotation = GetDirectAkRotationOverride(); val2.transform.localScale = Vector3.one; val2.AddComponent(); Material[] fallbackMaterials = ResolveTemplateMaterials(val).ToArray(); int num = 0; Renderer[] componentsInChildren = akVisualPrefab.GetComponentsInChildren(true); foreach (Renderer val3 in componentsInChildren) { if (!ShouldIncludeBakedSimpleSourceRenderer(val3)) { continue; } Mesh rendererMesh = GetRendererMesh(val3); if (!((Object)(object)rendererMesh == (Object)null) && rendererMesh.vertexCount > 0) { GameObject val4 = new GameObject(string.IsNullOrWhiteSpace(((Object)val3).name) ? ("AK47MeshPart_" + num) : ((Object)val3).name); val4.transform.SetParent(val2.transform, false); if (!TryGetTransformPoseRelativeToAkRoot(((Component)val3).transform, out var localPosition, out var localRotation, out var localScale)) { localPosition = ((Component)val3).transform.localPosition; localRotation = ((Component)val3).transform.localRotation; localScale = ((Component)val3).transform.localScale; } val4.transform.localPosition = SanitizeLocalPosition(localPosition, Vector3.zero); val4.transform.localRotation = SanitizeLocalRotation(localRotation); val4.transform.localScale = SanitizeLocalScale(localScale, Vector3.one); MeshFilter val5 = val4.AddComponent(); MeshRenderer obj = val4.AddComponent(); val5.sharedMesh = rendererMesh; ((Renderer)obj).sharedMaterials = BuildVisibleMaterials(val3.sharedMaterials, fallbackMaterials, Math.Max(rendererMesh.subMeshCount, 1)); ConfigureRuntimeWeaponRenderer((Renderer)obj); NormalizeRendererMaterials((Renderer)obj); ((Renderer)obj).enabled = true; ((Renderer)obj).forceRenderingOff = false; num++; } } if (num == 0) { Object.Destroy((Object)val2); return null; } NormalizeVisualScaleAgainstReference(val2.transform, val, "AK47Model-baked"); ApplyConfiguredWorldVisualScale(val2.transform, weaponSelectionForItem); SetLayerRecursively(val2.transform, ((Component)val).gameObject.layer); SetHierarchyActive(val2.transform, active: true); EnsureVisualRenderersActive(val2.transform, visible: true); Plugin.LogDiagnosticOnce("ak-simple-baked-create-success:" + ((Object)item).GetInstanceID(), "Created baked simple replacement visual: " + DescribeItemForDiagnostics(item) + ", parent=" + GetTransformPath(val) + ", visual=" + GetTransformPath(val2.transform) + ", renderers=" + DescribeRendererCollectionForDiagnostics(((Component)val2.transform).GetComponentsInChildren(true)) + ", bounds=" + DescribeBoundsForDiagnostics(val2.transform) + ", selection=" + weaponSelectionForItem + ", prefab=" + Plugin.DescribeAkVisualPrefabForDiagnostics(weaponSelectionForItem)); return val2.transform; } private static Transform GetOrCreateSimpleAkVisual(Item item, Transform targetVisualRoot, bool forceRefreshMarker) { //IL_0030: 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_0040: Expected O, but got Unknown //IL_0040: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Expected O, but got Unknown //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Expected O, but got Unknown //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { return null; } Transform val = FindSimpleAkVisualRoot(item); if ((Object)(object)val != (Object)null && (Object)(object)targetVisualRoot != (Object)null && (Object)val.parent != (Object)targetVisualRoot) { Plugin.LogDiagnosticOnce("ak-simple-recreate-parent:" + ((Object)item).GetInstanceID() + ":" + ((Object)val).GetInstanceID(), "Recreating simple visual because parent changed: " + DescribeItemForDiagnostics(item) + ", existingParent=" + GetTransformPath(val.parent) + ", targetParent=" + GetTransformPath(targetVisualRoot) + ", existingRenderers=" + DescribeRendererCollectionForDiagnostics(((Component)val).GetComponentsInChildren(true))); Object.Destroy((Object)((Component)val).gameObject); val = null; forceRefreshMarker = true; } if ((Object)(object)val != (Object)null && !forceRefreshMarker && HasReplacementVisualSource(item) && CountMeshBackedRenderers(val) == 0) { Plugin.LogDiagnosticOnce("ak-simple-recreate-empty:" + ((Object)item).GetInstanceID() + ":" + ((Object)val).GetInstanceID(), "Recreating simple visual because it has no mesh-backed renderers: " + DescribeItemForDiagnostics(item) + ", visual=" + GetTransformPath(val) + ", renderers=" + DescribeRendererCollectionForDiagnostics(((Component)val).GetComponentsInChildren(true))); Object.Destroy((Object)((Component)val).gameObject); val = null; forceRefreshMarker = true; } if (forceRefreshMarker && (Object)(object)val != (Object)null) { Plugin.LogDiagnosticOnce("ak-simple-force-refresh:" + ((Object)item).GetInstanceID() + ":" + ((Object)val).GetInstanceID(), "Destroying simple visual for force refresh: " + DescribeItemForDiagnostics(item) + ", visual=" + GetTransformPath(val) + ", renderers=" + DescribeRendererCollectionForDiagnostics(((Component)val).GetComponentsInChildren(true))); Object.Destroy((Object)((Component)val).gameObject); val = null; } if ((Object)(object)val != (Object)null && !forceRefreshMarker) { Plugin.LogDiagnosticOnce("ak-simple-reuse:" + ((Object)item).GetInstanceID() + ":" + ((Object)val).GetInstanceID(), "Reusing existing simple visual: " + DescribeItemForDiagnostics(item) + ", visual=" + GetTransformPath(val) + ", parent=" + GetTransformPath(val.parent) + ", bounds=" + DescribeBoundsForDiagnostics(val) + ", renderers=" + DescribeRendererCollectionForDiagnostics(((Component)val).GetComponentsInChildren(true))); } if ((Object)(object)val == (Object)null) { bool flag = false; Transform val2 = targetVisualRoot; if ((Object)(object)val2 == (Object)null) { val2 = ((Component)item).transform; } if (!flag) { val = TryCreatePreparedSimpleAkVisual(item, val2); } if ((Object)(object)val == (Object)null) { string debugInfo = string.Empty; Mesh mesh = null; Material[] materials = null; Vector3 localScale = Vector3.one; Quaternion localRotation = Quaternion.identity; Vector3 localPosition = Vector3.zero; if (!flag || !TryResolveDebugSphereVisual(out mesh, out materials, out localScale, out localRotation, out localPosition, out debugInfo) || (Object)(object)mesh == (Object)null) { Plugin.LogDiagnosticOnce("ak-simple-create-fail:" + ((Object)item).GetInstanceID(), $"Simple visual creation failed: {DescribeItemForDiagnostics(item)}, targetRoot={GetTransformPath(targetVisualRoot)}, debugMode={flag}, debugInfo={debugInfo}, selection={Plugin.GetWeaponSelectionForItem(item)}, prefab={Plugin.DescribeAkVisualPrefabForDiagnostics(Plugin.GetWeaponSelectionForItem(item))}"); return null; } GameObject val3 = new GameObject("AK47Model"); val3.transform.SetParent(val2, false); val3.transform.localPosition = localPosition; val3.transform.localRotation = localRotation; val3.transform.localScale = localScale; val3.AddComponent(); MeshFilter val4 = val3.AddComponent(); MeshRenderer obj = val3.AddComponent(); val4.sharedMesh = mesh; ((Renderer)obj).sharedMaterials = BuildVisibleMaterials(subMeshCount: Mathf.Max(mesh.subMeshCount, 1), preferredMaterials: materials, fallbackMaterials: ResolveTemplateMaterials(val2).ToArray()); ((Renderer)obj).enabled = true; ((Renderer)obj).forceRenderingOff = false; ConfigureRuntimeWeaponRenderer((Renderer)obj); NormalizeVisualScaleAgainstReference(val3.transform, val2, "AK47Model-direct"); ApplyConfiguredWorldVisualScale(val3.transform, Plugin.GetWeaponSelectionForItem(item)); SetLayerRecursively(layer: IsLocallyHeldByPlayer(item) ? ResolveBestVisibleLayerForLocalHeldItem(item, val2) : ResolveReferenceLayer(item, val2), root: val3.transform); val = val3.transform; Plugin.LogDiagnosticOnce("ak-simple-create-success:" + ((Object)item).GetInstanceID(), $"Created simple debug visual: {DescribeItemForDiagnostics(item)}, parent={GetTransformPath(val2)}, visual={GetTransformPath(val)}, debugInfo={debugInfo}, mesh={((Object)mesh).name}, pos={localPosition}, rot={((Quaternion)(ref localRotation)).eulerAngles}, scale={localScale}"); } else if (!flag) { Plugin.LogDiagnosticOnce("ak-simple-create-clone-success:" + ((Object)item).GetInstanceID(), "Created simple replacement visual from selected prefab clone: " + DescribeItemForDiagnostics(item) + ", parent=" + GetTransformPath(val2) + ", visual=" + GetTransformPath(val) + ", selection=" + Plugin.GetWeaponSelectionForItem(item) + ", prefab=" + Plugin.DescribeAkVisualPrefabForDiagnostics(Plugin.GetWeaponSelectionForItem(item))); } } Renderer val5 = SelectPreferredRenderer(((Component)val).GetComponentsInChildren(true), val); if ((Object)(object)val5 == (Object)null) { bool flag2 = ShouldShowSimpleAkVisual(item); SetCustomVisualRenderersVisible(val, flag2); SyncWeaponColliderState(item, null); LogWorldVisualState(item, val, flag2 ? "simple-no-preferred-renderer-visible" : "simple-no-preferred-renderer-hidden", targetVisualRoot); return val; } bool flag3 = ShouldShowSimpleAkVisual(item); SetCustomVisualRenderersVisible(val, flag3); if (!flag3) { SyncWeaponColliderState(item, null); LogWorldVisualState(item, val, "simple-hidden", targetVisualRoot); return val; } val5.enabled = true; val5.forceRenderingOff = false; val5.allowOcclusionWhenDynamic = false; int layer2 = (IsLocallyHeldByPlayer(item) ? ResolveBestVisibleLayerForLocalHeldItem(item, targetVisualRoot) : ResolveReferenceLayer(item, targetVisualRoot)); SetLayerRecursively(val, layer2); EnsureMuzzleMarkerForItem(item, val5); SyncWeaponColliderState(item, null); LogWorldVisualState(item, val, "simple-final", targetVisualRoot); return val; } private static bool ShouldUseWorldWeaponCollider(Item item) { return IsDroppedWorldItem(item); } private static void SyncWeaponColliderState(Item item, Transform weaponVisualRoot) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected I4, but got Unknown if (!((Object)(object)item == (Object)null)) { CleanupAllWeaponWorldColliders(item); SetOriginalItemCollidersEnabled(item, enabled: true); Plugin.LogDiagnosticOnce("ak-collider-state:" + ((Object)item).GetInstanceID() + ":" + (int)item.itemState + ":original-only", "Synced weapon collider state: " + DescribeItemForDiagnostics(item) + ", requestedCustom=False, usingCustom=False, mode=original-item, visualRoot=" + GetTransformPath(weaponVisualRoot)); } } private static bool EnsureWorldWeaponCollider(Item item, Transform visualRoot) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_00fa: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0158: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null || (Object)(object)visualRoot == (Object)null) { return false; } if (!ShouldUseWorldWeaponCollider(item)) { CleanupAllWeaponWorldColliders(item); return false; } Transform transform = ((Component)item).transform; if ((Object)(object)transform == (Object)null) { return false; } if (!TryGetCombinedRenderableBounds(visualRoot, out var bounds) || !TryTransformWorldBoundsToLocalBounds(transform, bounds, out var localBounds)) { Plugin.LogDiagnosticOnce("ak-world-collider-fail:" + ((Object)item).GetInstanceID(), $"Failed to build world collider from render bounds, keeping original colliders: {DescribeItemForDiagnostics(item)}, visualRoot={GetTransformPath(visualRoot)}, boundsValid={TryGetCombinedRenderableBounds(visualRoot, out var _)}"); return false; } Transform val = ((IEnumerable)((Component)item).GetComponentsInChildren(true)).FirstOrDefault((Func)((Transform t) => (Object)(object)t != (Object)null && string.Equals(((Object)t).name, "AK_WorldCollider", StringComparison.Ordinal))); if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("AK_WorldCollider"); val2.transform.SetParent(transform, false); val = val2.transform; } else if ((Object)val.parent != (Object)transform) { val.SetParent(transform, false); } val.localRotation = Quaternion.identity; val.localScale = Vector3.one; val.localPosition = ((Bounds)(ref localBounds)).center; BoxCollider val3 = ((Component)val).GetComponent(); if ((Object)(object)val3 == (Object)null) { val3 = ((Component)val).gameObject.AddComponent(); } ((Collider)val3).isTrigger = false; ((Collider)val3).enabled = true; val3.center = Vector3.zero; val3.size = new Vector3(Mathf.Max(((Bounds)(ref localBounds)).size.x, 0.18f), Mathf.Max(((Bounds)(ref localBounds)).size.y, 0.18f), Mathf.Max(((Bounds)(ref localBounds)).size.z, 0.6f)); Plugin.LogDiagnosticOnce("ak-world-collider:" + ((Object)item).GetInstanceID() + ":" + ((Object)visualRoot).GetInstanceID(), $"Configured world collider: {DescribeItemForDiagnostics(item)}, visualRoot={GetTransformPath(visualRoot)}, collider={GetTransformPath(val)}, parentScale={transform.lossyScale}, localCenter={val.localPosition}, localSize={val3.size}, trigger={((Collider)val3).isTrigger}, bounds={DescribeBoundsForDiagnostics(visualRoot)}"); return true; } private static void CleanupWorldWeaponCollider(Transform visualRoot) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (!((Object)(object)visualRoot == (Object)null)) { Transform val = visualRoot.Find("AK_WorldCollider"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)((Component)val).gameObject); } } } private static void CleanupAllWeaponWorldColliders(Item item) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown if ((Object)(object)item == (Object)null) { return; } Transform[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && string.Equals(((Object)val).name, "AK_WorldCollider", StringComparison.Ordinal)) { Object.Destroy((Object)((Component)val).gameObject); } } } private static void SetOriginalItemCollidersEnabled(Item item, bool enabled) { if ((Object)(object)item == (Object)null) { return; } foreach (Collider item2 in EnumerateOriginalItemColliders(item)) { if (!((Object)(object)item2 == (Object)null)) { item2.enabled = enabled; } } } [IteratorStateMachine(typeof(d__167))] private static IEnumerable EnumerateOriginalItemColliders(Item item) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__167(-2) { <>3__item = item }; } private static bool IsCustomWeaponCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } if (string.Equals(((Object)collider).name, "AK_WorldCollider", StringComparison.Ordinal)) { return true; } Transform transform = ((Component)collider).transform; if ((Object)(object)((Component)collider).GetComponentInParent(true) != (Object)null) { return true; } if ((Object)(object)((Component)collider).GetComponentInParent(true) != (Object)null) { return true; } if ((Object)(object)((Component)collider).GetComponentInParent(true) != (Object)null) { return true; } if (HasNamedAncestor(transform, "AK_InPlaceVisualRoot")) { return true; } return string.Equals(((Object)transform).name, "AK_WorldCollider", StringComparison.Ordinal); } private static bool TryTransformWorldBoundsToLocalBounds(Transform localRoot, Bounds worldBounds, out Bounds localBounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c7: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_0192: 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_01a9: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) localBounds = default(Bounds); if ((Object)(object)localRoot == (Object)null) { return false; } Matrix4x4 worldToLocalMatrix = localRoot.worldToLocalMatrix; Vector3 center = ((Bounds)(ref worldBounds)).center; Vector3 extents = ((Bounds)(ref worldBounds)).extents; Vector3[] obj = new Vector3[8] { center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z), center + new Vector3(0f - extents.x, 0f - extents.y, extents.z), center + new Vector3(0f - extents.x, extents.y, 0f - extents.z), center + new Vector3(0f - extents.x, extents.y, extents.z), center + new Vector3(extents.x, 0f - extents.y, 0f - extents.z), center + new Vector3(extents.x, 0f - extents.y, extents.z), center + new Vector3(extents.x, extents.y, 0f - extents.z), center + new Vector3(extents.x, extents.y, extents.z) }; bool flag = false; Vector3[] array = (Vector3[])(object)obj; foreach (Vector3 val in array) { Vector3 val2 = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyPoint3x4(val); if (IsFiniteVector3(val2)) { if (!flag) { localBounds = new Bounds(val2, Vector3.zero); flag = true; } else { ((Bounds)(ref localBounds)).Encapsulate(val2); } } } return flag; } private static int CountMeshBackedRenderers(Transform root) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if ((Object)(object)root == (Object)null) { return 0; } int num = 0; Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && (Object)GetRendererMesh(val) != (Object)null) { num++; } } return num; } private static void DisableNonVisualComponents(GameObject root) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown if ((Object)(object)root == (Object)null) { return; } Component[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Component val in componentsInChildren) { if ((Object)val == (Object)null || val is Transform || val is MeshFilter || val is Renderer) { continue; } Behaviour val2 = (Behaviour)((val is Behaviour) ? val : null); if ((Object)(object)val2 != (Object)null) { val2.enabled = false; continue; } Collider val3 = (Collider)((val is Collider) ? val : null); if ((Object)(object)val3 != (Object)null) { val3.enabled = false; continue; } Rigidbody val4 = (Rigidbody)((val is Rigidbody) ? val : null); if ((Object)(object)val4 != (Object)null) { val4.isKinematic = true; val4.detectCollisions = false; } } } private static void PreparePrefabCloneRenderers(GameObject root, Transform targetVisualRoot) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown if ((Object)(object)root == (Object)null) { return; } Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } bool flag2 = (val.enabled = IsCloneWeaponRenderer(val)); bool flag3 = flag2; val.forceRenderingOff = !flag3; ConfigureRuntimeWeaponRenderer(val); if (flag3) { SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)((val is SkinnedMeshRenderer) ? val : null); if ((Object)(object)val2 != (Object)null) { val2.updateWhenOffscreen = true; } Material[] sharedMaterials = val.sharedMaterials; Mesh rendererMesh = GetRendererMesh(val); int subMeshCount = Math.Max(((Object)(object)rendererMesh != (Object)null) ? rendererMesh.subMeshCount : 0, 1); val.sharedMaterials = BuildVisibleMaterials(sharedMaterials, ResolveTemplateMaterials(targetVisualRoot).ToArray(), subMeshCount); } } } private static bool IsCloneWeaponRenderer(Renderer renderer) { if ((Object)(object)renderer == (Object)null || !IsMeshBackedRenderer(renderer)) { return false; } string text = GetTransformPath(((Component)renderer).transform).ToLowerInvariant(); if (text.Contains("/hand") || text.Contains("/arm") || text.Contains("finger") || text.Contains("holiday") || text.Contains("vfx") || text.Contains("effect") || text.Contains("spawn") || text.Contains("muzzle")) { return false; } return true; } private static bool TryApplyInPlaceWeaponVisual(Item item, Transform targetVisualRoot, bool forceRefreshMarker) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected I4, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected I4, but got Unknown if ((Object)(object)item == (Object)null) { return false; } DestroyLegacyHeldVisual(item, restoreRenderers: true); CleanupSimpleAkVisual(item); if (forceRefreshMarker || (Object)(object)FindInPlaceVisualRoot(item, targetVisualRoot) == (Object)null) { RestoreOriginalVisual(item); } if (!TryReplaceMeshOnExistingAnchor(item, targetVisualRoot, forceRefreshMarker, out var modelRoot, out var preferredRenderer)) { return false; } if ((Object)(object)modelRoot == (Object)null || (Object)(object)preferredRenderer == (Object)null) { return false; } DisableSiblingWeaponRenderers(((Component)item).transform, modelRoot); if ((int)item.itemState == 1) { EnsureHeldVisibility(item, modelRoot, "in-place"); EnsureHeldDebugSphere(modelRoot); } else { CleanupHeldDebugSphere(modelRoot); int layer = ResolveReferenceLayer(item, modelRoot); SetLayerRecursively(modelRoot, layer); SyncWeaponColliderState(item, modelRoot); LogWorldVisualState(item, modelRoot, "in-place-final", ((Component)item).transform); } InPlaceSwappedItemIds.Add(((Object)item).GetInstanceID()); Plugin.LogDiagnosticOnce("ak-inplace-route:" + ((Object)item).GetInstanceID() + ":" + (int)item.itemState, $"Applied in-place weapon visual: {DescribeItemForDiagnostics(item)}, modelRoot={GetTransformPath(modelRoot)}, renderer={GetTransformPath(((Component)preferredRenderer).transform)}, state={(int)item.itemState}"); return true; } private static Transform ResolveInPlaceVisualParent(Item item, Transform anchor) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if ((Object)(object)item != (Object)null) { return ((Component)item).transform; } if ((Object)(object)anchor != (Object)null) { if (!((Object)anchor.parent != (Object)null)) { return anchor; } return anchor.parent; } return null; } private static Transform FindInPlaceVisualRoot(Item item, Transform anchor) { if ((Object)(object)item != (Object)null) { Transform[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && string.Equals(((Object)val).name, "AK_InPlaceVisualRoot", StringComparison.Ordinal)) { return val; } } } if ((Object)(object)anchor == (Object)null) { return null; } return anchor.Find("AK_InPlaceVisualRoot"); } private static void ApplyConfiguredInPlaceRootPose(Transform visualRoot) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)visualRoot == (Object)null)) { visualRoot.localPosition = GetDirectAkPositionOverride(); visualRoot.localRotation = GetDirectAkRotationOverride(); visualRoot.localScale = Vector3.one; } } private static void SyncInPlaceVisualRootToAnchor(Transform visualRoot, Transform stableParent, Transform anchor) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0029: Expected O, but got Unknown //IL_004d: 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_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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!((Object)(object)visualRoot == (Object)null)) { if ((Object)(object)stableParent != (Object)null && (Object)visualRoot.parent != (Object)stableParent) { visualRoot.SetParent(stableParent, false); } if ((Object)(object)stableParent == (Object)null || (Object)(object)anchor == (Object)null) { ApplyConfiguredInPlaceRootPose(visualRoot); return; } DecomposeMatrix(stableParent.worldToLocalMatrix * anchor.localToWorldMatrix * Matrix4x4.TRS(GetDirectAkPositionOverride(), GetDirectAkRotationOverride(), Vector3.one), out var position, out var rotation, out var scale); visualRoot.localPosition = SanitizeLocalPosition(position, Vector3.zero); visualRoot.localRotation = SanitizeLocalRotation(rotation); visualRoot.localScale = SanitizeLocalScale(scale, Vector3.one); } } private static bool TryCreateOrRefreshInPlaceVisualRoot(Item item, Transform anchor, bool forceRefreshMarker, out Transform modelRoot, out Renderer preferredRenderer) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown //IL_0198: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected I4, but got Unknown modelRoot = null; preferredRenderer = null; if ((Object)(object)item == (Object)null || (Object)(object)anchor == (Object)null || !HasReplacementVisualSource(item)) { return false; } GameObject akVisualPrefab = Plugin.GetAkVisualPrefab(); if ((Object)(object)akVisualPrefab == (Object)null) { return false; } Transform val = ResolveInPlaceVisualParent(item, anchor); if ((Object)(object)val == (Object)null) { return false; } Transform val2 = FindInPlaceVisualRoot(item, anchor); bool flag = forceRefreshMarker; if ((Object)(object)val2 != (Object)null && CountMeshBackedRenderers(val2) == 0) { Object.Destroy((Object)((Component)val2).gameObject); val2 = null; flag = true; } if (flag && (Object)(object)val2 != (Object)null) { Object.Destroy((Object)((Component)val2).gameObject); val2 = null; } if ((Object)(object)val2 == (Object)null) { GameObject val3 = Object.Instantiate(akVisualPrefab); if ((Object)(object)val3 == (Object)null) { return false; } val3.transform.SetParent(val, false); val3.SetActive(true); ((Object)val3).name = "AK_InPlaceVisualRoot"; StripNonVisualComponents(val3); PrepareRenderers(val3, anchor); val2 = val3.transform; Plugin.LogDiagnosticOnce("ak-inplace-create:" + ((Object)item).GetInstanceID() + ":" + (int)item.itemState, "Created in-place visual root: " + DescribeItemForDiagnostics(item) + ", anchor=" + GetTransformPath(anchor) + ", parent=" + GetTransformPath(val) + ", root=" + GetTransformPath(val2) + ", prefab=" + Plugin.DescribeAkVisualPrefabForDiagnostics()); } else if ((Object)val2.parent != (Object)val) { val2.SetParent(val, false); } SetHierarchyActive(val2, active: true); SyncInPlaceVisualRootToAnchor(val2, val, anchor); NormalizeVisualScaleAgainstReference(val2, anchor, "in-place-root"); ApplyConfiguredWorldVisualScale(val2, Plugin.GetWeaponSelectionForItem(item)); SetLayerRecursively(val2, ((Component)val).gameObject.layer); SetHierarchyActive(val2, active: true); EnsureVisualRenderersActive(val2, visible: true); preferredRenderer = SelectPreferredRenderer(((Component)val2).GetComponentsInChildren(true), val2); if ((Object)(object)preferredRenderer == (Object)null) { return false; } EnsureMuzzleMarkerForItem(item, preferredRenderer); modelRoot = val2; return true; } private static bool TryReplaceMeshOnExistingAnchor(Item item, Transform targetVisualRoot, bool forceRefreshMarker, out Transform modelRoot, out Renderer preferredRenderer) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00ed: 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_0133: Expected I4, but got Unknown modelRoot = targetVisualRoot; preferredRenderer = null; if ((Object)(object)item == (Object)null || !HasReplacementVisualSource(item)) { return false; } if (!TryResolveTargetMeshAnchor(item, targetVisualRoot, out var anchor, out var meshFilter, out var meshRenderer)) { return false; } if ((Object)(object)anchor == (Object)null || (Object)(object)meshFilter == (Object)null || (Object)(object)meshRenderer == (Object)null) { return false; } AkInPlaceMarker akInPlaceMarker = ((Component)anchor).GetComponent(); if ((Object)(object)akInPlaceMarker == (Object)null) { akInPlaceMarker = ((Component)anchor).gameObject.AddComponent(); } if (!akInPlaceMarker.hasBaseTransform) { akInPlaceMarker.baseLocalPosition = anchor.localPosition; akInPlaceMarker.baseLocalRotation = anchor.localRotation; akInPlaceMarker.baseLocalScale = anchor.localScale; akInPlaceMarker.hasBaseTransform = true; akInPlaceMarker.hasBaseRotation = true; } if (!akInPlaceMarker.hasOriginalVisual) { akInPlaceMarker.originalMesh = meshFilter.sharedMesh; akInPlaceMarker.originalMaterials = (((Renderer)meshRenderer).sharedMaterials ?? Array.Empty()).ToArray(); akInPlaceMarker.hasOriginalVisual = true; } anchor.localPosition = akInPlaceMarker.baseLocalPosition; anchor.localRotation = akInPlaceMarker.baseLocalRotation; anchor.localScale = akInPlaceMarker.baseLocalScale; ((Component)anchor).gameObject.SetActive(true); if (!TryCreateOrRefreshInPlaceVisualRoot(item, anchor, forceRefreshMarker, out modelRoot, out preferredRenderer)) { return false; } Plugin.LogDiagnosticOnce("ak-inplace-swap:" + ((Object)item).GetInstanceID() + ":" + (int)item.itemState, "Applied in-place hierarchy visual: " + DescribeItemForDiagnostics(item) + ", anchor=" + GetTransformPath(anchor) + ", root=" + GetTransformPath(modelRoot) + ", preferred=" + GetTransformPath(((Component)preferredRenderer).transform) + ", rootBounds=" + DescribeBoundsForDiagnostics(modelRoot)); return true; } private static bool TryResolveTargetMeshAnchor(Item item, Transform targetVisualRoot, out Transform anchor, out MeshFilter meshFilter, out MeshRenderer meshRenderer) { anchor = targetVisualRoot; meshFilter = null; meshRenderer = null; if (TryResolveExactBlowgunAnchor(item, targetVisualRoot, out anchor, out meshFilter, out meshRenderer)) { return true; } int bestScore = int.MinValue; HashSet visited = new HashSet(); EvaluateTargetRendererCandidate(item?.mainRenderer, ref anchor, ref meshFilter, ref meshRenderer, ref bestScore, visited, 25000); if ((Object)(object)targetVisualRoot != (Object)null) { EvaluateTargetMeshCandidate(((Component)targetVisualRoot).GetComponent(), ref anchor, ref meshFilter, ref meshRenderer, ref bestScore, visited); MeshFilter[] componentsInChildren = ((Component)targetVisualRoot).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { EvaluateTargetMeshCandidate(componentsInChildren[i], ref anchor, ref meshFilter, ref meshRenderer, ref bestScore, visited); } } if ((Object)(object)item != (Object)null) { MeshFilter[] componentsInChildren2 = ((Component)item).GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren2.Length; j++) { EvaluateTargetMeshCandidate(componentsInChildren2[j], ref anchor, ref meshFilter, ref meshRenderer, ref bestScore, visited); } } if ((Object)(object)meshFilter != (Object)null) { return (Object)(object)meshRenderer != (Object)null; } return false; } private static bool TryResolveExactBlowgunAnchor(Item item, Transform targetVisualRoot, out Transform anchor, out MeshFilter meshFilter, out MeshRenderer meshRenderer) { anchor = null; meshFilter = null; meshRenderer = null; Transform val = (((Object)(object)item != (Object)null) ? ((Component)item).transform.Find("Blowgun") : null); if ((Object)(object)val == (Object)null) { val = targetVisualRoot; } if ((Object)(object)val == (Object)null) { return false; } meshFilter = ((Component)val).GetComponent(); meshRenderer = ((Component)val).GetComponent(); if ((Object)(object)meshFilter == (Object)null || (Object)(object)meshRenderer == (Object)null) { Transform val2 = val.Find("Mesh"); if ((Object)(object)val2 != (Object)null) { meshFilter = ((Component)val2).GetComponent(); meshRenderer = ((Component)val2).GetComponent(); if ((Object)(object)meshFilter != (Object)null && (Object)(object)meshRenderer != (Object)null) { val = val2; } } } if ((Object)(object)meshFilter == (Object)null || (Object)(object)meshRenderer == (Object)null || ShouldSkipTargetTransform(val)) { return false; } anchor = val; return true; } private static void EvaluateTargetRendererCandidate(Renderer candidateRenderer, ref Transform anchor, ref MeshFilter meshFilter, ref MeshRenderer meshRenderer, ref int bestScore, HashSet visited, int scoreBonus) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown MeshRenderer val = (MeshRenderer)((candidateRenderer is MeshRenderer) ? candidateRenderer : null); if (!((Object)(object)val == (Object)null)) { EvaluateTargetMeshCandidate(((Component)val).GetComponent(), ref anchor, ref meshFilter, ref meshRenderer, ref bestScore, visited, scoreBonus); } } private static void EvaluateTargetMeshCandidate(MeshFilter candidate, ref Transform anchor, ref MeshFilter meshFilter, ref MeshRenderer meshRenderer, ref int bestScore, HashSet visited, int scoreBonus = 0) { if ((Object)(object)candidate == (Object)null || (Object)(object)candidate.sharedMesh == (Object)null || (visited != null && !visited.Add(((Object)candidate).GetInstanceID()))) { return; } MeshRenderer component = ((Component)candidate).GetComponent(); if (!((Object)(object)component == (Object)null) && !ShouldSkipTargetTransform(((Component)candidate).transform)) { string text = ((((Object)candidate.sharedMesh).name ?? string.Empty) + "/" + (((Object)((Component)candidate).transform).name ?? string.Empty)).ToLowerInvariant(); int num = candidate.sharedMesh.vertexCount; if (text.Contains("blowgun") || text.Contains("healing") || text.Contains("dart") || text.Contains("weapon")) { num += 900; } string text2 = GetTransformPath(((Component)candidate).transform).ToLowerInvariant(); if (text2.Contains("/blowgun")) { num += 12000; } if (text2.EndsWith("/blowgun")) { num += 8000; } if (text.Contains("mesh") || text.Contains("body")) { num += 400; } if (text.Contains("vfx") || text.Contains("effect") || text.Contains("spawn") || text.Contains("trigger") || text.Contains("collider")) { num -= 12000; } if (text.Contains("cube") && candidate.sharedMesh.vertexCount <= 200) { num -= 6000; } if (((Renderer)component).enabled) { num += 250; } num += scoreBonus; if (num > bestScore) { bestScore = num; anchor = ((Component)candidate).transform; meshFilter = candidate; meshRenderer = component; } } } private static bool ShouldSkipTargetTransform(Transform transform) { if ((Object)(object)transform == (Object)null) { return true; } string text = (((Object)transform).name ?? string.Empty).ToLowerInvariant(); if (text.Contains("hand") || text.Contains("arm") || text.Contains("finger")) { return true; } if (text.Contains("vfx") || text.Contains("effect") || text.Contains("spawn") || text.Contains("trigger") || text.Contains("collider")) { return true; } return false; } private static bool TryGetBestSourceVisual(out SourceVisualCandidate best) { best = default(SourceVisualCandidate); GameObject akVisualPrefab = Plugin.GetAkVisualPrefab(); if ((Object)(object)akVisualPrefab == (Object)null) { return false; } bool flag = false; int num = int.MinValue; bool flag2 = false; int num2 = int.MinValue; SourceVisualCandidate sourceVisualCandidate = default(SourceVisualCandidate); MeshFilter[] componentsInChildren = akVisualPrefab.GetComponentsInChildren(true); foreach (MeshFilter val in componentsInChildren) { if ((Object)(object)val == (Object)null || (Object)(object)val.sharedMesh == (Object)null) { continue; } MeshRenderer component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { continue; } SourceVisualCandidate? sourceVisualCandidate2 = BuildSourceVisualCandidate(((Component)val).transform, val.sharedMesh, ((Renderer)component).sharedMaterials, isSkinnedRenderer: false); if (sourceVisualCandidate2.HasValue) { SourceVisualCandidate value = sourceVisualCandidate2.Value; if (value.Score > num) { num = value.Score; best = value; flag = true; } if (!IsLikelyPlaceholderSource(value) && value.Score > num2) { num2 = value.Score; sourceVisualCandidate = value; flag2 = true; } } } SkinnedMeshRenderer[] componentsInChildren2 = akVisualPrefab.GetComponentsInChildren(true); foreach (SkinnedMeshRenderer val2 in componentsInChildren2) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) { continue; } SourceVisualCandidate? sourceVisualCandidate3 = BuildSourceVisualCandidate(((Component)val2).transform, val2.sharedMesh, ((Renderer)val2).sharedMaterials, isSkinnedRenderer: true); if (sourceVisualCandidate3.HasValue) { SourceVisualCandidate value2 = sourceVisualCandidate3.Value; if (value2.Score > num) { num = value2.Score; best = value2; flag = true; } if (!IsLikelyPlaceholderSource(value2) && value2.Score > num2) { num2 = value2.Score; sourceVisualCandidate = value2; flag2 = true; } } } if (flag && flag2 && IsLikelyPlaceholderSource(best) && sourceVisualCandidate.VertexCount > 64 && (sourceVisualCandidate.Score >= best.Score - 10000 || best.VertexCount <= 2000)) { best = sourceVisualCandidate; } return flag; } private static SourceVisualCandidate? BuildSourceVisualCandidate(Transform sourceTransform, Mesh mesh, Material[] materials, bool isSkinnedRenderer) { if ((Object)(object)sourceTransform == (Object)null || (Object)(object)mesh == (Object)null) { return null; } int vertexCount = mesh.vertexCount; int num = vertexCount; string text = (((Object)mesh).name ?? string.Empty).ToLowerInvariant(); string text2 = (((Object)sourceTransform).name ?? string.Empty).ToLowerInvariant(); Material[] array = NormalizeMaterialArray(materials, Math.Max(mesh.subMeshCount, 1)); if (materials == null || materials.Length == 0) { num -= 2000; } num = ((!HasUsableTexture(array)) ? (num - 12000) : (num + 1800)); if (vertexCount <= 24) { num -= 6000; } if (text.Contains("cube") || text2.Contains("cube")) { num -= 12000; } if (text.Contains("plane") || text2.Contains("plane") || text.Contains("quad") || text2.Contains("quad")) { num -= 8000; } if (text2.Contains("vfx") || text2.Contains("effect") || text2.Contains("spawn")) { num -= 5000; } if (text.Contains("hand") || text2.Contains("hand") || text.Contains("arm") || text2.Contains("arm") || text.Contains("finger") || text2.Contains("finger")) { num -= 18000; } if (isSkinnedRenderer) { num -= 3000; } if (text.Contains("ak") || text2.Contains("ak") || text.Contains("weapon") || text2.Contains("weapon") || text.Contains("rifle") || text2.Contains("rifle") || text2.Contains("gun")) { num += 2500; } if (text == "mesh" || text2 == "mesh") { num += 5000; } SourceVisualCandidate value = default(SourceVisualCandidate); value.Mesh = mesh; value.Materials = ((array != null) ? array : Array.Empty()); value.Transform = sourceTransform; value.VertexCount = vertexCount; value.Score = num; value.Path = GetTransformPath(sourceTransform); value.MeshName = ((Object)mesh).name; return value; } private static bool IsLikelyPlaceholderSource(SourceVisualCandidate candidate) { string text = (candidate.MeshName ?? string.Empty).ToLowerInvariant(); string text2 = (candidate.Path ?? string.Empty).ToLowerInvariant(); if ((text.Contains("cube") || text2.Contains("/cube")) && candidate.VertexCount <= 3000) { return true; } if ((text.Contains("plane") || text.Contains("quad") || text2.Contains("/plane") || text2.Contains("/quad")) && candidate.VertexCount <= 3000) { return true; } return false; } private static void DisableSiblingWeaponRenderers(Transform targetVisualRoot, Transform preservedAnchor) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0042: Expected O, but got Unknown if ((Object)(object)targetVisualRoot == (Object)null) { return; } Renderer[] componentsInChildren = ((Component)targetVisualRoot).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && (!((Object)(object)preservedAnchor != (Object)null) || (!((Object)((Component)val).transform == (Object)preservedAnchor) && !((Component)val).transform.IsChildOf(preservedAnchor))) && IsOriginalWeaponRenderer(val, targetVisualRoot)) { val.enabled = false; val.forceRenderingOff = true; } } } private static void EnsureHeldVisibility(Item item, Transform modelRoot, string source, bool preserveExistingLayer = false) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown if ((Object)(object)item == (Object)null || (int)item.itemState != 1) { return; } Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); if ((Object)(object)modelRoot != (Object)null) { SetItemNonHandRenderersEnabled(item, enabled: false, modelRoot); EnsureVisualRenderersActive(modelRoot, visible: true); } List list = new List(); List list2 = new List(); int num = 0; int num2 = 0; Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if ((Object)(object)val == (Object)null) { continue; } bool flag = IsHandItemRenderer(val); if (((Object)(object)modelRoot != (Object)null && ((Object)(object)((Component)val).transform == (Object)(object)modelRoot || ((Component)val).transform.IsChildOf(modelRoot))) || flag) { val.enabled = true; val.forceRenderingOff = false; val.allowOcclusionWhenDynamic = false; SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)((val is SkinnedMeshRenderer) ? val : null); if ((Object)(object)val2 != (Object)null) { val2.updateWhenOffscreen = true; list2.Add(val2); } else { MeshRenderer val3 = (MeshRenderer)((val is MeshRenderer) ? val : null); if ((Object)(object)val3 != (Object)null) { list.Add(val3); } } num++; } else { val.enabled = false; val.forceRenderingOff = true; val.allowOcclusionWhenDynamic = false; num2++; } } if (list.Count == 0 && list2.Count == 0) { list = (from r in ((Component)item).GetComponentsInChildren(true) where (Object)(object)r != (Object)null select r).ToList(); list2 = (from r in ((Component)item).GetComponentsInChildren(true) where (Object)(object)r != (Object)null select r).ToList(); foreach (Renderer item2 in list.Cast().Concat((IEnumerable)list2)) { item2.enabled = true; item2.forceRenderingOff = false; item2.allowOcclusionWhenDynamic = false; } } Renderer val4 = SelectPreferredRenderer(list.Cast().Concat((IEnumerable)list2), modelRoot); if ((Object)(object)val4 == (Object)null) { val4 = list.Cast().FirstOrDefault() ?? list2.Cast().FirstOrDefault(); } if ((Object)(object)val4 == (Object)null) { return; } MeshRenderer val5 = (MeshRenderer)((val4 is MeshRenderer) ? val4 : null); if ((Object)(object)val5 != (Object)null) { list.Remove(val5); list.Insert(0, val5); } else { SkinnedMeshRenderer val6 = (SkinnedMeshRenderer)((val4 is SkinnedMeshRenderer) ? val4 : null); if ((Object)(object)val6 != (Object)null) { list2.Remove(val6); list2.Insert(0, val6); } } if ((Object)(object)modelRoot != (Object)null && !preserveExistingLayer) { int layer = ResolveReferenceLayer(item, modelRoot); if (IsLocallyHeldByPlayer(item)) { layer = ResolveBestVisibleLayerForLocalHeldItem(item, modelRoot); } SetLayerRecursively(modelRoot, layer); } Plugin.LogDiagnosticOnce("ak-held-visibility:" + ((Object)item).GetInstanceID() + ":" + source, $"EnsureHeldVisibility applied: {DescribeItemForDiagnostics(item)}, source={source}, modelRoot={GetTransformPath(modelRoot)}, enabledCount={num}, disabledCount={num2}, preferred={GetTransformPath(((Component)val4).transform)}, modelBounds={DescribeBoundsForDiagnostics(modelRoot)}"); BindItemRendererFields(item, list.ToArray(), list2.ToArray()); EnsureMuzzleMarkerForItem(item, val4); } private static void BindInPlaceRendererFields(Item item, MeshRenderer preferredRenderer, Transform modelRoot) { if (!((Object)(object)item == (Object)null) && !((Object)(object)preferredRenderer == (Object)null)) { List list = (from r in ((Component)item).GetComponentsInChildren(true) where (Object)(object)r != (Object)null && (((Renderer)r).enabled || (Object)(object)r == (Object)(object)preferredRenderer || IsHandItemRenderer((Renderer)r) || ((Object)(object)modelRoot != (Object)null && ((Component)r).transform.IsChildOf(modelRoot))) select r).ToList(); List list2 = (from r in ((Component)item).GetComponentsInChildren(true) where (Object)(object)r != (Object)null && (((Renderer)r).enabled || IsHandItemRenderer((Renderer)r) || ((Object)(object)modelRoot != (Object)null && ((Component)r).transform.IsChildOf(modelRoot))) select r).ToList(); list.Remove(preferredRenderer); list.Insert(0, preferredRenderer); BindItemRendererFields(item, list.ToArray(), list2.ToArray()); } } private static void EnsureLegacyHeldVisual(Item item, bool forceRefreshMarker, bool allowWhenSeparateLocalVisual = false) { if ((Object)(object)item == (Object)null) { return; } if (ShouldUseSeparateLocalFirstPersonVisual(item) && !allowWhenSeparateLocalVisual) { DestroyLegacyHeldVisual(item, restoreRenderers: false); return; } if (!IsLocallyHeldByPlayer(item)) { DestroyLegacyHeldVisual(item, restoreRenderers: true); return; } AkHeldLegacyVisualMarker akHeldLegacyVisualMarker = ((Component)item).GetComponentInChildren(true); if (forceRefreshMarker || (Object)(object)akHeldLegacyVisualMarker == (Object)null) { DestroyLegacyHeldVisual(item, restoreRenderers: false); akHeldLegacyVisualMarker = CreateLegacyHeldVisual(item); } if (!((Object)(object)akHeldLegacyVisualMarker == (Object)null)) { Transform transform = ((Component)akHeldLegacyVisualMarker).transform; EnsureLegacyHeldRenderersEnabled(transform); Renderer legacyHeldPreferredRenderer = GetLegacyHeldPreferredRenderer(transform); if (!((Object)(object)legacyHeldPreferredRenderer == (Object)null)) { int num = ResolveReferenceLayer(item, transform); num = ResolveBestVisibleLayerForLocalHeldItem(item, transform); SetLayerRecursively(transform, num); SetItemNonHandRenderersEnabled(item, enabled: false, transform); SyncWeaponColliderState(item, null); BindLegacyHeldRendererFields(item, legacyHeldPreferredRenderer, transform); EnsureMuzzleMarkerForItem(item, legacyHeldPreferredRenderer); EnsureHeldDebugSphere(transform); LogHeldVisualCameraState(item, transform, "ensure"); } } } private static AkHeldLegacyVisualMarker CreateLegacyHeldVisual(Item item) { //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Expected O, but got Unknown //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { return null; } Transform val = ResolveHeldLegacyParent(item); if ((Object)(object)val == (Object)null) { val = ((Component)item).transform; } Transform val2 = CreatePreparedAkClone(val, val, "AK47_HeldLegacyModel"); if ((Object)(object)val2 != (Object)null) { ApplyPreparedLegacyHeldClonePose(val2); ((Component)val2).gameObject.SetActive(true); EnsureVisualRenderersActive(val2, visible: true); AkHeldLegacyVisualMarker akHeldLegacyVisualMarker = ((Component)val2).GetComponent(); if ((Object)(object)akHeldLegacyVisualMarker == (Object)null) { akHeldLegacyVisualMarker = ((Component)val2).gameObject.AddComponent(); } Plugin.LogDiagnosticOnce("ak-held-legacy-create:" + ((Object)item).GetInstanceID(), "Created held legacy visual from prepared clone: " + DescribeItemForDiagnostics(item) + ", parent=" + GetTransformPath(val) + ", visual=" + GetTransformPath(val2) + ", bounds=" + DescribeBoundsForDiagnostics(val2) + ", renderers=" + DescribeRendererCollectionForDiagnostics(((Component)val2).GetComponentsInChildren(true))); LogHeldVisualCameraState(item, val2, "create"); return akHeldLegacyVisualMarker; } Transform val3 = ResolveHeldLegacyParent(item); if ((Object)(object)val3 == (Object)null) { val3 = ResolveTargetVisualRoot(item); } AkHeldLegacyVisualMarker akHeldLegacyVisualMarker2 = CreateAnchoredLegacyHeldVisual(item, val3); if ((Object)(object)akHeldLegacyVisualMarker2 != (Object)null) { Plugin.LogDiagnosticOnce("ak-held-legacy-create:" + ((Object)item).GetInstanceID(), "Created held legacy visual from anchored fallback: " + DescribeItemForDiagnostics(item) + ", visual=" + GetTransformPath(((Component)akHeldLegacyVisualMarker2).transform) + ", bounds=" + DescribeBoundsForDiagnostics(((Component)akHeldLegacyVisualMarker2).transform)); LogHeldVisualCameraState(item, ((Component)akHeldLegacyVisualMarker2).transform, "fallback"); return akHeldLegacyVisualMarker2; } if (!TryResolveLegacyHeldSource(out var mesh, out var materials, out var localScale, out var localRotation, out var localPosition, out var _)) { return null; } Transform val4 = ResolveHeldLegacyParent(item); if ((Object)(object)val4 == (Object)null) { val4 = ((Component)item).transform; } GameObject val5 = new GameObject("AK47_HeldLegacyModel"); val5.transform.SetParent(val4, false); val5.transform.localScale = localScale; val5.transform.localRotation = localRotation; val5.transform.localPosition = localPosition; AkHeldLegacyVisualMarker result = val5.AddComponent(); MeshFilter val6 = val5.AddComponent(); MeshRenderer obj = val5.AddComponent(); val6.sharedMesh = mesh; ((Renderer)obj).sharedMaterials = BuildAkVisibleMaterials(materials, Mathf.Max(mesh.subMeshCount, 1)); NormalizeAkRenderer((Renderer)obj); Plugin.LogDiagnosticOnce("ak-held-legacy-create:" + ((Object)item).GetInstanceID(), $"Created held legacy visual from mesh fallback: {DescribeItemForDiagnostics(item)}, parent={GetTransformPath(val4)}, visual={GetTransformPath(val5.transform)}, pos={localPosition}, rot={((Quaternion)(ref localRotation)).eulerAngles}, scale={localScale}"); LogHeldVisualCameraState(item, val5.transform, "mesh-fallback"); return result; } private static void ApplyPreparedLegacyHeldClonePose(Transform legacyRoot) { //IL_000b: 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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_0030: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00e2: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)legacyRoot == (Object)null)) { Vector3 localPosition = legacyRoot.localPosition; Quaternion localRotation = legacyRoot.localRotation; Vector3 localScale = legacyRoot.localScale; if (TryResolveHeldPoseRelativeToBase(out var localPosition2, out var localRotation2, out var localScale2)) { legacyRoot.localPosition = SanitizeLocalPosition(localPosition + localPosition2, localPosition); legacyRoot.localRotation = SanitizeLocalRotation(localRotation * localRotation2); legacyRoot.localScale = SanitizeLocalScale(Vector3.Scale(localScale, localScale2), localScale); string key = "ak-held-legacy-pose:" + GetTransformPath(legacyRoot); object[] obj = new object[10] { GetTransformPath(legacyRoot), localPosition, ((Quaternion)(ref localRotation)).eulerAngles, localScale, localPosition2, ((Quaternion)(ref localRotation2)).eulerAngles, localScale2, legacyRoot.localPosition, null, null }; Quaternion localRotation3 = legacyRoot.localRotation; obj[8] = ((Quaternion)(ref localRotation3)).eulerAngles; obj[9] = legacyRoot.localScale; Plugin.LogDiagnosticOnce(key, string.Format("Applied prepared held pose delta: root={0}, basePos={1}, baseRot={2}, baseScale={3}, deltaPos={4}, deltaRot={5}, deltaScale={6}, finalPos={7}, finalRot={8}, finalScale={9}", obj)); } else { Plugin.LogDiagnosticOnce("ak-held-legacy-pose:" + GetTransformPath(legacyRoot), $"Held pose delta unavailable, keeping prepared clone pose: root={GetTransformPath(legacyRoot)}, pos={localPosition}, rot={((Quaternion)(ref localRotation)).eulerAngles}, scale={localScale}"); } } } private static AkHeldLegacyVisualMarker CreateAnchoredLegacyHeldVisual(Item item, Transform targetVisualRoot) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown if ((Object)(object)item == (Object)null) { return null; } if (!TryResolveBaseAkVisual(out var mesh, out var materials, out var _, out var _, out var _, out var _) || (Object)(object)mesh == (Object)null) { return null; } if (!TryResolveTargetMeshAnchor(item, targetVisualRoot, out var anchor, out var _, out var meshRenderer) || (Object)(object)anchor == (Object)null) { return null; } GameObject val = new GameObject("AK47_HeldLegacyModel"); val.transform.SetParent(anchor, false); if (TryResolveHeldPoseRelativeToBase(out var localPosition2, out var localRotation2, out var localScale2)) { val.transform.localPosition = localPosition2; val.transform.localRotation = localRotation2; val.transform.localScale = localScale2; } else { val.transform.localPosition = GetDirectAkPositionOverride(); val.transform.localRotation = HeldLegacyRotationOffset; val.transform.localScale = Vector3.one * Mathf.Max(1f, GetDirectAkScaleMultiplier(Plugin.GetWeaponSelectionForItem(item))); } AkHeldLegacyVisualMarker result = val.AddComponent(); MeshFilter val2 = val.AddComponent(); MeshRenderer obj = val.AddComponent(); val2.sharedMesh = mesh; ((Renderer)obj).sharedMaterials = BuildVisibleMaterials(materials, ((Object)(object)meshRenderer != (Object)null) ? ((Renderer)meshRenderer).sharedMaterials : null, Mathf.Max(mesh.subMeshCount, 1)); NormalizeAkRenderer((Renderer)obj); SetLayerRecursively(val.transform, ((Component)anchor).gameObject.layer); return result; } private static void ApplyLegacyHeldFallbackPose(Transform legacyRoot) { //IL_001d: 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_002b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)legacyRoot == (Object)null) && TryResolvePreferredAkVisual(out var _, out var _, out var localScale, out var localRotation, out var localPosition, out var _)) { legacyRoot.localPosition = localPosition; legacyRoot.localRotation = localRotation; legacyRoot.localScale = localScale; } } private static bool TryResolveLegacyHeldSource(out Mesh mesh, out Material[] materials, out Vector3 localScale, out Quaternion localRotation, out Vector3 localPosition, out string debugInfo) { return TryResolvePreferredAkVisual(out mesh, out materials, out localScale, out localRotation, out localPosition, out debugInfo); } private static Renderer GetLegacyHeldPreferredRenderer(Transform legacyRoot) { if ((Object)(object)legacyRoot == (Object)null) { return null; } Renderer[] componentsInChildren = ((Component)legacyRoot).GetComponentsInChildren(true); return SelectPreferredRenderer(componentsInChildren, legacyRoot) ?? ((IEnumerable)componentsInChildren).FirstOrDefault((Func)((Renderer r) => IsMeshBackedRenderer(r))); } private static void EnsureLegacyHeldRenderersEnabled(Transform legacyRoot) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown if ((Object)(object)legacyRoot == (Object)null) { return; } Renderer[] componentsInChildren = ((Component)legacyRoot).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } bool flag2 = (val.enabled = IsMeshBackedRenderer(val)); bool flag3 = flag2; val.forceRenderingOff = !flag3; ConfigureRuntimeWeaponRenderer(val); if (flag3) { SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)((val is SkinnedMeshRenderer) ? val : null); if ((Object)(object)val2 != (Object)null) { val2.updateWhenOffscreen = true; } NormalizeRendererMaterials(val); } } } private static void BindLegacyHeldRendererFields(Item item, Renderer legacyRenderer, Transform legacyRoot) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown if ((Object)(object)item == (Object)null || (Object)(object)legacyRenderer == (Object)null) { return; } List list = (from r in ((Component)item).GetComponentsInChildren(true) where (Object)(object)r != (Object)null && (((Renderer)r).enabled || (Object)(object)r == (Object)(object)legacyRenderer || IsHandItemRenderer((Renderer)r) || ((Object)(object)legacyRoot != (Object)null && ((Component)r).transform.IsChildOf(legacyRoot))) select r).ToList(); List list2 = (from r in ((Component)item).GetComponentsInChildren(true) where (Object)(object)r != (Object)null && (((Renderer)r).enabled || (Object)(object)r == (Object)(object)legacyRenderer || IsHandItemRenderer((Renderer)r) || ((Object)(object)legacyRoot != (Object)null && ((Component)r).transform.IsChildOf(legacyRoot))) select r).ToList(); Renderer val = legacyRenderer; MeshRenderer val2 = (MeshRenderer)((val is MeshRenderer) ? val : null); if ((Object)(object)val2 != (Object)null) { list.Remove(val2); list.Insert(0, val2); } else { Renderer val3 = legacyRenderer; SkinnedMeshRenderer val4 = (SkinnedMeshRenderer)((val3 is SkinnedMeshRenderer) ? val3 : null); if ((Object)(object)val4 != (Object)null) { list2.Remove(val4); list2.Insert(0, val4); } } BindItemRendererFields(item, list.ToArray(), list2.ToArray()); } private static void BindSimpleVisualRendererFields(Item item, Transform modelRoot) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown if ((Object)(object)item == (Object)null || (Object)(object)modelRoot == (Object)null) { return; } List list = (from r in ((Component)item).GetComponentsInChildren(true) where (Object)(object)r != (Object)null && (((Renderer)r).enabled || IsHandItemRenderer((Renderer)r) || ((Component)r).transform.IsChildOf(modelRoot)) select r).ToList(); List list2 = (from r in ((Component)item).GetComponentsInChildren(true) where (Object)(object)r != (Object)null && (((Renderer)r).enabled || IsHandItemRenderer((Renderer)r) || ((Component)r).transform.IsChildOf(modelRoot)) select r).ToList(); Renderer val = SelectPreferredRenderer(list.Cast().Concat((IEnumerable)list2), modelRoot); MeshRenderer val2 = (MeshRenderer)((val is MeshRenderer) ? val : null); if ((Object)(object)val2 != (Object)null) { list.Remove(val2); list.Insert(0, val2); } else { SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)((val is SkinnedMeshRenderer) ? val : null); if ((Object)(object)val3 != (Object)null) { list2.Remove(val3); list2.Insert(0, val3); } } BindItemRendererFields(item, list.ToArray(), list2.ToArray()); } private static void SetItemNonHandRenderersEnabled(Item item, bool enabled, Transform excludedRoot) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown if ((Object)(object)item == (Object)null) { return; } Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && (!((Object)(object)excludedRoot != (Object)null) || !((Component)val).transform.IsChildOf(excludedRoot)) && !IsHandItemRenderer(val)) { val.enabled = enabled; val.forceRenderingOff = !enabled; val.allowOcclusionWhenDynamic = false; SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)((val is SkinnedMeshRenderer) ? val : null); if ((Object)(object)val2 != (Object)null) { val2.updateWhenOffscreen = true; } } } } private static bool IsHandItemRenderer(Renderer renderer) { if ((Object)(object)renderer == (Object)null) { return false; } string text = ((((Object)renderer).name ?? string.Empty) + "/" + GetTransformPath(((Component)renderer).transform)).ToLowerInvariant(); if (!text.Contains("hand") && !text.Contains("arm")) { return text.Contains("finger"); } return true; } private static void DestroyLegacyHeldVisual(Item item, bool restoreRenderers) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (!((Object)(object)item == (Object)null)) { AkHeldLegacyVisualMarker componentInChildren = ((Component)item).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { Object.Destroy((Object)((Component)componentInChildren).gameObject); } if (restoreRenderers) { SetItemNonHandRenderersEnabled(item, enabled: true, null); SetOriginalItemCollidersEnabled(item, enabled: true); } CleanupAllWeaponWorldColliders(item); } } private static void BindOriginalItemRendererFields(Item item) { if (!((Object)(object)item == (Object)null)) { MeshRenderer[] array = (from r in ((Component)item).GetComponentsInChildren(true) where (Object)(object)r != (Object)null && !IsCustomAkRenderer((Renderer)r) select r).ToArray(); SkinnedMeshRenderer[] array2 = (from r in ((Component)item).GetComponentsInChildren(true) where (Object)(object)r != (Object)null && !IsCustomAkRenderer((Renderer)r) select r).ToArray(); if ((array != null && array.Length != 0) || (array2 != null && array2.Length != 0)) { BindItemRendererFields(item, array, array2); } } } private static bool IsCustomAkRenderer(Renderer renderer) { if ((Object)(object)renderer != (Object)null) { if (!((Object)(object)((Component)renderer).GetComponentInParent(true) != (Object)null) && !((Object)(object)((Component)renderer).GetComponentInParent(true) != (Object)null)) { if ((Object)(object)((Component)renderer).GetComponentInParent(true) != (Object)null) { return true; } return HasNamedAncestor(((Component)renderer).transform, "AK_InPlaceVisualRoot"); } return true; } return false; } private static bool HasNamedAncestor(Transform transform, string ancestorName) { while ((Object)(object)transform != (Object)null) { if (string.Equals(((Object)transform).name, ancestorName, StringComparison.Ordinal)) { return true; } transform = transform.parent; } return false; } private static void EnsureMuzzleMarkerForItem(Item item, Renderer preferredRenderer) { //IL_002b: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0083: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_0063: 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) if (!((Object)(object)item == (Object)null)) { Transform val = ((Component)item).transform.Find("AK_MuzzleMarker"); if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("AK_MuzzleMarker"); val2.transform.SetParent(((Component)item).transform, false); val2.AddComponent(); val = val2.transform; } if ((Object)(object)preferredRenderer == (Object)null) { val.localPosition = Vector3.forward * 0.6f; val.localRotation = Quaternion.identity; } else { Bounds bounds = preferredRenderer.bounds; val.position = ((Bounds)(ref bounds)).center + ((Component)preferredRenderer).transform.forward * Mathf.Max(((Bounds)(ref bounds)).extents.z, 0.06f); val.rotation = ((Component)preferredRenderer).transform.rotation; } } } private static Material[] BuildVisibleMaterials(Material[] preferredMaterials, Material[] fallbackMaterials, int subMeshCount) { if (subMeshCount <= 0) { return Array.Empty(); } if (preferredMaterials != null && preferredMaterials.Length != 0 && HasUsableTexture(preferredMaterials)) { return BuildDirectAkMaterials(preferredMaterials, subMeshCount); } Material[] array = preferredMaterials; if (array == null || array.Length == 0 || array.All((Material m) => (Object)(object)m == (Object)null)) { array = fallbackMaterials; } if (array == null || array.Length == 0 || array.All((Material m) => (Object)(object)m == (Object)null)) { Material[] array2 = (Material[])(object)new Material[subMeshCount]; for (int i = 0; i < subMeshCount; i++) { array2[i] = CreateRuntimeMaterial(null, null); NormalizeMaterialForVisibility(array2[i]); } return array2; } Material[] array3 = NormalizeMaterialArray(array, subMeshCount); Material[] array4 = (Material[])(object)new Material[subMeshCount]; Material val = ((IEnumerable)array3).FirstOrDefault((Func)((Material m) => (Object)(object)m != (Object)null)); for (int j = 0; j < subMeshCount; j++) { Material val2 = ((j < array3.Length) ? array3[j] : null); if ((Object)(object)val2 == (Object)null) { val2 = val; } Material template = ((fallbackMaterials != null && fallbackMaterials.Length != 0) ? fallbackMaterials[Math.Min(j, fallbackMaterials.Length - 1)] : null); array4[j] = CreateRuntimeMaterial(val2, template); NormalizeMaterialForVisibility(array4[j]); } return array4; } private static Material[] NormalizeMaterialArray(Material[] sourceMaterials, int subMeshCount) { if (sourceMaterials == null || sourceMaterials.Length == 0 || subMeshCount <= 0) { return sourceMaterials ?? Array.Empty(); } if (sourceMaterials.Length == subMeshCount) { return sourceMaterials; } Material[] array = (Material[])(object)new Material[subMeshCount]; for (int i = 0; i < subMeshCount; i++) { array[i] = sourceMaterials[Math.Min(i, sourceMaterials.Length - 1)]; } return array; } private static void NormalizeMaterialForVisibility(Material material) { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)material == (Object)null) { return; } Shader val = ResolvePreferredVisibleShader(); Texture val2 = ResolvePrimaryTexture(material); if ((Object)(object)val2 == (Object)null && material.HasProperty("_BaseMap")) { val2 = material.GetTexture("_BaseMap"); } if ((Object)(object)val2 == (Object)null && material.HasProperty("_MainTex")) { val2 = material.GetTexture("_MainTex"); } string text = (((Object)(object)material.shader != (Object)null) ? ((Object)material.shader).name : string.Empty); bool flag = (Object)(object)material.shader == (Object)null || !material.shader.isSupported || string.IsNullOrWhiteSpace(text); if (!flag && (text.IndexOf("Character", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Skin", StringComparison.OrdinalIgnoreCase) >= 0)) { flag = true; } if (flag && (Object)(object)val != (Object)null) { material.shader = val; if ((Object)(object)val2 != (Object)null) { if (material.HasProperty("_BaseMap")) { material.SetTexture("_BaseMap", val2); } if (material.HasProperty("_MainTex")) { material.SetTexture("_MainTex", val2); } } } if (material.HasProperty("_Surface")) { material.SetFloat("_Surface", 0f); } if (material.HasProperty("_AlphaClip")) { material.SetFloat("_AlphaClip", 0f); } if (material.HasProperty("_Cutoff")) { material.SetFloat("_Cutoff", 0f); } if (material.HasProperty("_Cull")) { material.SetInt("_Cull", 0); } if (material.HasProperty("_BaseColor")) { Color color = material.GetColor("_BaseColor"); color.a = 1f; color.r = Mathf.Max(color.r, 0.85f); color.g = Mathf.Max(color.g, 0.85f); color.b = Mathf.Max(color.b, 0.85f); material.SetColor("_BaseColor", color); } if (material.HasProperty("_Color")) { Color color2 = material.color; color2.a = 1f; color2.r = Mathf.Max(color2.r, 0.85f); color2.g = Mathf.Max(color2.g, 0.85f); color2.b = Mathf.Max(color2.b, 0.85f); material.color = color2; } if (material.HasProperty("_EmissionColor")) { material.EnableKeyword("_EMISSION"); material.SetColor("_EmissionColor", new Color(0.1f, 0.1f, 0.1f, 1f)); } material.renderQueue = -1; } private static Shader ResolvePreferredVisibleShader() { return Shader.Find("Unlit/Texture") ?? Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("W/Peak_Standard") ?? Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Diffuse") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Hidden/InternalErrorShader"); } private static void NormalizeRendererMaterials(Renderer renderer) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown if ((Object)(object)renderer == (Object)null) { return; } int num = 0; if (renderer is MeshRenderer) { MeshFilter component = ((Component)renderer).GetComponent(); num = (((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) ? component.sharedMesh.subMeshCount : 0); } else { SkinnedMeshRenderer val = (SkinnedMeshRenderer)((renderer is SkinnedMeshRenderer) ? renderer : null); if ((Object)(object)val != (Object)null) { num = (((Object)(object)val.sharedMesh != (Object)null) ? val.sharedMesh.subMeshCount : 0); } } if (num <= 0) { return; } Material[] array = renderer.sharedMaterials; if (array == null || array.Length == 0) { renderer.sharedMaterials = BuildVisibleMaterials(null, null, num); return; } if (array.Length > num) { Array.Resize(ref array, num); } if (array.Length < num) { array = NormalizeMaterialArray(array, num); } for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] == (Object)null) { array[i] = CreateRuntimeMaterial(null, null); } NormalizeMaterialForVisibility(array[i]); } renderer.sharedMaterials = array; } private static void BindItemRendererFields(Item item, MeshRenderer[] meshRenderers, SkinnedMeshRenderer[] skinnedRenderers) { List list = new List(((meshRenderers != null) ? meshRenderers.Length : 0) + ((skinnedRenderers != null) ? skinnedRenderers.Length : 0)); if (meshRenderers != null) { list.AddRange((IEnumerable)meshRenderers.Where((MeshRenderer r) => (Object)(object)r != (Object)null)); } if (skinnedRenderers != null) { list.AddRange((IEnumerable)skinnedRenderers.Where((SkinnedMeshRenderer r) => (Object)(object)r != (Object)null)); } Renderer val = SelectPreferredRenderer(list, null) ?? list.FirstOrDefault(); if (!((Object)(object)val == (Object)null)) { Type type = ((object)item).GetType(); if (SetMember(item, type, MainRendererFieldNames, MainRendererPropertyNames, val)) { list.Remove(val); list.Insert(0, val); SetMember(item, type, AddtlRendererFieldNames, null, list.ToArray()); } } } private static Renderer SelectPreferredRenderer(IEnumerable renderers, Transform modelRoot) { Renderer val = null; int num = int.MinValue; Renderer val2 = null; int num2 = int.MinValue; foreach (Renderer item in renderers ?? Enumerable.Empty()) { if ((Object)(object)item == (Object)null || ((Object)(object)modelRoot != (Object)null && !((Component)item).transform.IsChildOf(modelRoot)) || !IsMeshBackedRenderer(item)) { continue; } int num3 = ScoreRendererCandidate(item); if (IsPreferredMainRendererCandidate(item)) { if (num3 > num) { num = num3; val = item; } } else if (num3 > num2) { num2 = num3; val2 = item; } } return val ?? val2; } private static bool IsPreferredMainRendererCandidate(Renderer renderer) { if (!IsMeshBackedRenderer(renderer)) { return false; } string text = GetTransformPath(((Component)renderer).transform).ToLowerInvariant(); string text2 = (((Object)renderer).name ?? string.Empty).ToLowerInvariant(); if (text2.Contains("vfx") || text2.Contains("muzzle") || text2.Contains("flash") || text2.Contains("particle") || text2.Contains("effect")) { return false; } if (text.Contains("/vfx") || text.Contains("gunshot") || text.Contains("muzzle") || text.Contains("particle") || text.Contains("effect")) { return false; } return true; } private static int ScoreRendererCandidate(Renderer renderer) { if ((Object)(object)renderer == (Object)null || !IsMeshBackedRenderer(renderer)) { return int.MinValue; } string text = GetTransformPath(((Component)renderer).transform).ToLowerInvariant(); string text2 = (((Object)renderer).name ?? string.Empty).ToLowerInvariant(); int num = 0; if (text2.Contains("vfx") || text2.Contains("muzzle") || text2.Contains("flash") || text2.Contains("particle")) { num -= 50000; } if (text.Contains("/vfx") || text.Contains("gunshot")) { num -= 40000; } Mesh rendererMesh = GetRendererMesh(renderer); if ((Object)(object)rendererMesh != (Object)null) { num += rendererMesh.vertexCount; if (rendererMesh.subMeshCount > 1) { num += 300; } } if (text2.Contains("ak") || text.Contains("/ak") || text2.Contains("weapon") || text2.Contains("gun")) { num += 1000; } return num; } private static bool SetMember(object target, Type targetType, string[] fieldNames, string[] propertyNames, object value) { Type type = value.GetType(); string[] array = fieldNames ?? Array.Empty(); foreach (string name in array) { FieldInfo field = targetType.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field == null) && field.FieldType.IsAssignableFrom(type)) { field.SetValue(target, value); return true; } } array = propertyNames ?? Array.Empty(); foreach (string name2 in array) { PropertyInfo property = targetType.GetProperty(name2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(property == null) && property.CanWrite && property.PropertyType.IsAssignableFrom(type)) { property.SetValue(target, value); return true; } } return false; } private static int ResolveReferenceLayer(Item item, Transform originalAnchor) { if ((Object)(object)item != (Object)null && (Object)(object)item.mainRenderer != (Object)null) { return ((Component)item.mainRenderer).gameObject.layer; } Renderer val = (((Object)(object)item != (Object)null) ? ((IEnumerable)((Component)item).GetComponentsInChildren(true)).FirstOrDefault((Func)((Renderer r) => (Object)(object)r != (Object)null && ((Object)(object)originalAnchor == (Object)null || !((Component)r).transform.IsChildOf(originalAnchor)))) : null); if ((Object)(object)val != (Object)null) { return ((Component)val).gameObject.layer; } if ((Object)(object)originalAnchor != (Object)null) { return ((Component)originalAnchor).gameObject.layer; } if (!((Object)(object)item != (Object)null)) { return 0; } return ((Component)item).gameObject.layer; } private static string GetTransformPath(Transform transform) { if ((Object)(object)transform == (Object)null) { return "null"; } Stack stack = new Stack(); Transform val = transform; while ((Object)(object)val != (Object)null) { stack.Push(((Object)val).name); val = val.parent; } return string.Join("/", stack); } private static string DescribeMaterialStateForDiagnostics(Material material) { if ((Object)(object)material == (Object)null) { return "null"; } Texture val = ResolvePrimaryTexture(material); string text = (material.HasProperty("_Cull") ? material.GetInt("_Cull").ToString() : "-"); object[] obj = new object[5] { ((Object)material).name, null, null, null, null }; Shader shader = material.shader; obj[1] = ((shader != null) ? ((Object)shader).name : null) ?? "null"; obj[2] = material.renderQueue; obj[3] = text; obj[4] = (((Object)(object)val != (Object)null) ? ((Object)val).name : "null"); return string.Format("{0}[shader={1},rq={2},cull={3},tex={4}]", obj); } private static string DescribeRendererStateForDiagnostics(Renderer renderer) { if ((Object)(object)renderer == (Object)null) { return "null"; } Mesh rendererMesh = GetRendererMesh(renderer); Transform transform = ((Component)renderer).transform; Material[] array = renderer.sharedMaterials ?? Array.Empty(); string text = string.Join(" | ", array.Take(4).Select(DescribeMaterialStateForDiagnostics)); if (array.Length > 4) { text += $" | ...+{array.Length - 4}"; } string text2 = (((Object)(object)rendererMesh != (Object)null) ? ((Object)rendererMesh).name : "null"); int num = (((Object)(object)rendererMesh != (Object)null) ? rendererMesh.subMeshCount : 0); int num2 = (((Object)(object)rendererMesh != (Object)null) ? rendererMesh.vertexCount : 0); return $"{GetTransformPath(transform)}[enabled={renderer.enabled},forceOff={renderer.forceRenderingOff},active={((Component)renderer).gameObject.activeInHierarchy},layer={((Component)renderer).gameObject.layer},mesh={text2},subMeshes={num},verts={num2},mats={text}]"; } private static string DescribeRendererCollectionForDiagnostics(IEnumerable renderers, int maxCount = 10) { if (renderers == null) { return "none"; } List list = renderers.Where((Renderer r) => (Object)(object)r != (Object)null).Take(maxCount).Select(DescribeRendererStateForDiagnostics) .ToList(); if (list.Count == 0) { return "none"; } int num = renderers.Count((Renderer r) => (Object)(object)r != (Object)null); if (num > list.Count) { list.Add("...+" + (num - list.Count)); } return string.Join(" || ", list); } private static string DescribeBoundsForDiagnostics(Transform root) { //IL_0018: 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) if (!TryGetCombinedRenderableBounds(root, out var bounds)) { return "none"; } return $"center={((Bounds)(ref bounds)).center},size={((Bounds)(ref bounds)).size}"; } private static void LogWorldVisualState(Item item, Transform visualRoot, string phase, Transform targetVisualRoot) { //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)item == (Object)null) && !((Object)(object)visualRoot == (Object)null)) { int instanceID = ((Object)item).GetInstanceID(); string text = DisplayName ?? "unknown"; string text2 = DescribeRendererCollectionForDiagnostics(((Component)visualRoot).GetComponentsInChildren(true)); string text3 = "none"; if (HiddenRendererCache.TryGetValue(instanceID, out var value)) { text3 = DescribeRendererCollectionForDiagnostics(value); } int num = ResolveReferenceLayer(item, targetVisualRoot); string key = "ak-world-state:" + phase + ":" + instanceID + ":" + text + ":" + ((Object)visualRoot).GetInstanceID(); object[] obj = new object[18] { phase, DescribeItemForDiagnostics(item), GetTransformPath(targetVisualRoot), ((Object)(object)targetVisualRoot != (Object)null) ? ((Component)targetVisualRoot).gameObject.layer : (-1), num, GetTransformPath(visualRoot), GetTransformPath(visualRoot.parent), visualRoot.localPosition, null, null, null, null, null, null, null, null, null, null }; Quaternion val = visualRoot.localRotation; obj[8] = ((Quaternion)(ref val)).eulerAngles; obj[9] = visualRoot.localScale; obj[10] = visualRoot.position; val = visualRoot.rotation; obj[11] = ((Quaternion)(ref val)).eulerAngles; obj[12] = visualRoot.lossyScale; obj[13] = ((Component)visualRoot).gameObject.activeSelf; obj[14] = ((Component)visualRoot).gameObject.activeInHierarchy; obj[15] = DescribeBoundsForDiagnostics(visualRoot); obj[16] = text2; obj[17] = text3; Plugin.LogDiagnosticOnce(key, string.Format("World visual state: phase={0}, {1}, targetRoot={2}, targetLayer={3}, refLayer={4}, visualRoot={5}, parent={6}, localPos={7}, localRot={8}, localScale={9}, worldPos={10}, worldRot={11}, lossyScale={12}, activeSelf={13}, activeInHierarchy={14}, bounds={15}, renderers={16}, hiddenRenderers={17}", obj)); } } private static void LogHeldVisualCameraState(Item item, Transform visualRoot, string phase) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)item == (Object)null) && !((Object)(object)visualRoot == (Object)null)) { Vector3 val = visualRoot.position; if (TryGetCombinedRenderableBounds(visualRoot, out var bounds)) { val = ((Bounds)(ref bounds)).center; } int layer = ((Component)visualRoot).gameObject.layer; int layer2 = -1; string sourcePath = "none"; TryResolveHeldHandRendererLayer(item, out layer2, out sourcePath); Camera val2 = ResolvePreferredLocalCamera(); string text = "camera=null"; if ((Object)(object)val2 != (Object)null) { Vector3 position = ((Component)val2).transform.position; Vector3 val3 = val - position; float magnitude = ((Vector3)(ref val3)).magnitude; float num = ((magnitude > 0.0001f) ? Vector3.Dot(((Component)val2).transform.forward, val3 / magnitude) : 0f); text = $"camera={GetTransformPath(((Component)val2).transform)}, nearClip={val2.nearClipPlane:0.###}, farClip={val2.farClipPlane:0.###}, camLayer={((Component)val2).gameObject.layer}, cullingMask={val2.cullingMask}, distanceToBounds={magnitude:0.###}, dotForward={num:0.###}"; } string key = "ak-held-camera:" + phase + ":" + ((Object)item).GetInstanceID() + ":" + ((Object)visualRoot).GetInstanceID(); object[] obj = new object[13] { phase, DescribeItemForDiagnostics(item), GetTransformPath(visualRoot), GetTransformPath(visualRoot.parent), layer, layer2, sourcePath, visualRoot.localPosition, null, null, null, null, null }; Quaternion localRotation = visualRoot.localRotation; obj[8] = ((Quaternion)(ref localRotation)).eulerAngles; obj[9] = visualRoot.localScale; obj[10] = visualRoot.position; obj[11] = DescribeBoundsForDiagnostics(visualRoot); obj[12] = text; Plugin.LogDiagnosticOnce(key, string.Format("Held visual camera state: phase={0}, {1}, visualRoot={2}, parent={3}, visualLayer={4}, handLayer={5}, handSource={6}, localPos={7}, localRot={8}, localScale={9}, worldPos={10}, bounds={11}, {12}", obj)); } } private static bool ContainsKeyword(string value) { if (string.IsNullOrEmpty(value)) { return false; } string text = value.ToLowerInvariant(); string value2 = DisplayName.ToLowerInvariant(); if (!string.IsNullOrWhiteSpace(value2) && text.Contains(value2)) { return true; } string[] selectableWeaponKeywords = SelectableWeaponKeywords; foreach (string value3 in selectableWeaponKeywords) { if (text.Contains(value3)) { return true; } } selectableWeaponKeywords = ItemKeywords; foreach (string value4 in selectableWeaponKeywords) { if (text.Contains(value4)) { return true; } } return false; } private static Mesh GetRendererMesh(Renderer renderer) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown if ((Object)(object)renderer == (Object)null) { return null; } if (renderer is MeshRenderer) { MeshFilter component = ((Component)renderer).GetComponent(); if (!((Object)(object)component != (Object)null)) { return null; } return component.sharedMesh; } SkinnedMeshRenderer val = (SkinnedMeshRenderer)((renderer is SkinnedMeshRenderer) ? renderer : null); if ((Object)(object)val != (Object)null) { return val.sharedMesh; } return null; } private static void SetLayerRecursively(Transform root, int layer) { if (!((Object)(object)root == (Object)null)) { ((Component)root).gameObject.layer = layer; for (int i = 0; i < root.childCount; i++) { SetLayerRecursively(root.GetChild(i), layer); } } } private static int ResolveVisibleLayerForLocalPlayer(int fallbackLayer) { Camera val = ResolvePreferredLocalCamera(); if ((Object)(object)val == (Object)null) { return fallbackLayer; } int cullingMask = val.cullingMask; if (fallbackLayer >= 0 && fallbackLayer < 32 && (cullingMask & (1 << fallbackLayer)) != 0) { return fallbackLayer; } int layer = ((Component)val).gameObject.layer; if ((cullingMask & (1 << layer)) != 0) { return layer; } for (int i = 0; i < 32; i++) { if ((cullingMask & (1 << i)) != 0) { return i; } } return fallbackLayer; } private static bool TryResolveHeldHandRendererLayer(Item item, out int layer, out string sourcePath) { layer = -1; sourcePath = "none"; if ((Object)(object)item == (Object)null) { return false; } Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && IsHandItemRenderer(val)) { layer = ((Component)val).gameObject.layer; sourcePath = GetTransformPath(((Component)val).transform); return true; } } return false; } private static int ResolveBestVisibleLayerForLocalHeldItem(Item item, Transform preferredRoot) { int num = ResolveReferenceLayer(item, preferredRoot); if (ShouldUseSeparateLocalFirstPersonVisual(item)) { return num; } if (TryResolveHeldHandRendererLayer(item, out var layer, out var _)) { return layer; } Camera val = ResolvePreferredLocalCamera(); if ((Object)(object)val == (Object)null) { return num; } int cullingMask = val.cullingMask; List list = new List(); if ((Object)(object)preferredRoot != (Object)null) { list.Add(((Component)preferredRoot).gameObject.layer); } Transform val2 = ResolveTargetVisualRoot(item); if ((Object)(object)val2 != (Object)null) { list.Add(((Component)val2).gameObject.layer); } if ((Object)(object)item != (Object)null) { Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (Renderer val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null)) { if (IsHandItemRenderer(val3)) { list.Insert(0, ((Component)val3).gameObject.layer); } else { list.Add(((Component)val3).gameObject.layer); } } } } foreach (int item2 in list.Distinct()) { if (item2 >= 0 && item2 < 32 && (cullingMask & (1 << item2)) != 0) { return item2; } } return ResolveVisibleLayerForLocalPlayer(num); } internal static bool TryGetTransformPoseRelativeToAkRoot(Transform sourceTransform, out Vector3 localPosition, out Quaternion localRotation, out Vector3 localScale) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_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) localPosition = Vector3.zero; localRotation = Quaternion.identity; localScale = Vector3.one; if ((Object)(object)sourceTransform == (Object)null || (Object)(object)Plugin._ak47Prefab == (Object)null) { return false; } DecomposeMatrix(Plugin._ak47Prefab.transform.worldToLocalMatrix * sourceTransform.localToWorldMatrix, out localPosition, out localRotation, out localScale); localPosition = SanitizeLocalPosition(localPosition, Vector3.zero); localRotation = SanitizeLocalRotation(localRotation); localScale = SanitizeLocalScale(localScale, Vector3.one); return true; } private static Vector3 SanitizeLocalPosition(Vector3 value, Vector3 fallback) { //IL_0000: 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_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!IsFiniteFloat(value.x) || !IsFiniteFloat(value.y) || !IsFiniteFloat(value.z)) { return fallback; } if (((Vector3)(ref value)).sqrMagnitude > 100f) { return fallback; } return value; } private static Quaternion SanitizeLocalRotation(Quaternion value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004d: 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_005b: 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_0069: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a5: 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) if (!IsFiniteFloat(value.x) || !IsFiniteFloat(value.y) || !IsFiniteFloat(value.z) || !IsFiniteFloat(value.w)) { return Quaternion.identity; } float num = Mathf.Sqrt(value.x * value.x + value.y * value.y + value.z * value.z + value.w * value.w); if (!IsFiniteFloat(num) || num < 1E-05f) { return Quaternion.identity; } return new Quaternion(value.x / num, value.y / num, value.z / num, value.w / num); } private static Vector3 SanitizeLocalScale(Vector3 value, Vector3 fallback) { //IL_0000: 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_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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0080: 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_0073: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (!IsFiniteFloat(value.x) || !IsFiniteFloat(value.y) || !IsFiniteFloat(value.z)) { return fallback; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Abs(value.x), Mathf.Abs(value.y), Mathf.Abs(value.z)); if (val.x < 0.0001f || val.y < 0.0001f || val.z < 0.0001f) { return fallback; } if (val.x > 10f || val.y > 10f || val.z > 10f) { return fallback; } return val; } private static bool IsFiniteFloat(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private static Camera ResolvePreferredLocalCamera() { Camera main = Camera.main; if ((Object)(object)main != (Object)null && ((Behaviour)main).isActiveAndEnabled && (Object)(object)main.targetTexture == (Object)null) { return main; } Camera[] array = Object.FindObjectsByType((FindObjectsSortMode)0); Camera result = null; int num = int.MinValue; Character localCharacter = Character.localCharacter; Camera[] array2 = array; foreach (Camera val in array2) { if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && !((Object)(object)val.targetTexture != (Object)null)) { int num2 = 0; string text = ((((Object)val).name ?? string.Empty) + "/" + (((Object)(object)((Component)val).transform.parent != (Object)null) ? ((Object)((Component)val).transform.parent).name : string.Empty)).ToLowerInvariant(); if (text.Contains("main")) { num2 += 80; } if (text.Contains("player") || text.Contains("fps") || text.Contains("view")) { num2 += 50; } if ((Object)(object)localCharacter != (Object)null && ((Component)val).transform.IsChildOf(((Component)localCharacter).transform)) { num2 += 120; } if (val.depth > 0f) { num2 += 10; } if (num2 > num) { num = num2; result = val; } } } return result; } private static void SyncVisualRootToTarget(Transform visualRoot, Transform targetVisualRoot) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_004d: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) if (!((Object)(object)visualRoot == (Object)null)) { if ((Object)(object)targetVisualRoot == (Object)null) { visualRoot.localPosition = Vector3.zero; visualRoot.localRotation = Quaternion.identity; visualRoot.localScale = Vector3.one; } else if ((Object)visualRoot.parent == (Object)targetVisualRoot) { visualRoot.localPosition = Vector3.zero; visualRoot.localRotation = Quaternion.identity; visualRoot.localScale = Vector3.one; } else { visualRoot.SetParent(targetVisualRoot, false); visualRoot.localPosition = Vector3.zero; visualRoot.localRotation = Quaternion.identity; visualRoot.localScale = Vector3.one; } } } private static void DecomposeMatrix(Matrix4x4 matrix, out Vector3 position, out Quaternion rotation, out Vector3 scale) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) position = Vector4.op_Implicit(((Matrix4x4)(ref matrix)).GetColumn(3)); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(matrix.m00, matrix.m10, matrix.m20); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(matrix.m01, matrix.m11, matrix.m21); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(matrix.m02, matrix.m12, matrix.m22); scale = new Vector3(((Vector3)(ref val)).magnitude, ((Vector3)(ref val2)).magnitude, ((Vector3)(ref val3)).magnitude); if (scale.x == 0f) { scale.x = 1f; } if (scale.y == 0f) { scale.y = 1f; } if (scale.z == 0f) { scale.z = 1f; } rotation = Quaternion.LookRotation(val3 / scale.z, val2 / scale.y); } } [HarmonyPatch(typeof(ItemSlot), "SetItem")] public static class ItemSlotSetItemPatch { [HarmonyPostfix] public static void SetItemPostfix(ItemSlot __instance, object[] __args) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (__instance == null) { return; } try { if (Plugin.IsWeaponFeatureEnabled()) { Item val = null; if (__args != null && __args.Length != 0) { object obj = __args[0]; val = (Item)((obj is Item) ? obj : null); } if ((Object)(object)val == (Object)null) { val = AkUiPatchHelpers.ResolveItemFromSlot(__instance); } if ((Object)(object)val != (Object)null && ItemPatch.IsBlowgunLike(val)) { ItemPatch.ApplyAkDisplayIfNeeded(val); } if ((Object)(object)__instance.prefab != (Object)null && ItemPatch.IsBlowgunLike(__instance.prefab)) { ItemPatch.ApplyAkDisplayIfNeeded(__instance.prefab); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[ShootZombies] ItemSlotSetItemPatch failed: " + ex.Message)); } } } [HarmonyPatch] public static class ItemUIDataPatch { [CompilerGenerated] private sealed class d__12 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; goto IL_008c; case 1: <>1__state = -1; goto IL_0073; case 2: { <>1__state = -1; goto IL_0073; } IL_0073: if (!_pendingVisibleUiRefresh) { break; } if (!Plugin.IsRuntimeVisualRefreshBlocked()) { _pendingVisibleUiRefresh = false; RefreshVisibleUiNow(); } goto IL_008c; IL_008c: if (_pendingVisibleUiRefresh) { float num = 0.5f - (Time.unscaledTime - _lastVisibleUiRefreshTime); if (num > 0f) { <>2__current = (object)new WaitForSecondsRealtime(num); <>1__state = 1; return true; } <>2__current = null; <>1__state = 2; return true; } break; } _deferredVisibleUiRefreshCoroutine = null; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const float VisibleUiRefreshCooldown = 0.5f; private static MethodBase _targetMethod; private static bool _hasPerformedFallbackVisibleUiScan; private static float _lastVisibleUiRefreshTime = -999f; private static bool _pendingVisibleUiRefresh; private static Coroutine _deferredVisibleUiRefreshCoroutine; public static MethodBase TargetMethod() { if (_targetMethod != null) { return _targetMethod; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { Type type = assembly.GetTypes().FirstOrDefault((Type t) => t.Name == "ItemUIData"); if (!(type == null)) { MethodInfo method = type.GetMethod("GetIcon", BindingFlags.Instance | BindingFlags.Public); if (method != null) { _targetMethod = method; return _targetMethod; } } } catch { } } } catch { } return null; } [HarmonyPostfix] public static void GetIconPostfix(object __instance, ref Texture2D __result) { try { if (Plugin.IsWeaponFeatureEnabled()) { Texture2D akIconTexture = Plugin.GetAkIconTexture(); if (!((Object)(object)akIconTexture == (Object)null) && ShouldUseAkIcon(__instance.GetType().GetField("itemName", BindingFlags.Instance | BindingFlags.Public)?.GetValue(__instance) as string)) { __result = akIconTexture; } } } catch { } } private static bool ShouldUseAkIcon(string itemName) { return ItemPatch.ContainsWeaponKeyword(itemName); } public static void ForceRefreshVisibleUi() { if (!Plugin.IsWeaponFeatureEnabled()) { ResetVisibleUiTrackingFallback(); InventoryItemUiPatch.ClearCaches(); } else if (Plugin.IsRuntimeVisualRefreshBlocked()) { _pendingVisibleUiRefresh = true; ScheduleDeferredVisibleUiRefresh(); } else if (Time.unscaledTime - _lastVisibleUiRefreshTime < 0.5f) { _pendingVisibleUiRefresh = true; ScheduleDeferredVisibleUiRefresh(); } else { RefreshVisibleUiNow(); } } private static void RefreshVisibleUiNow() { _lastVisibleUiRefreshTime = Time.unscaledTime; try { Plugin.GetAkIconTexture(); if (!AkUiPatchHelpers.RefreshTrackedUi() && !_hasPerformedFallbackVisibleUiScan) { FallbackScanVisibleUiOnce(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[ShootZombies] ForceRefreshVisibleUi failed: " + ex.Message)); } } private static void ScheduleDeferredVisibleUiRefresh() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (_deferredVisibleUiRefreshCoroutine == null) { Plugin instance = Plugin.Instance; if (!((Object)instance == (Object)null)) { _deferredVisibleUiRefreshCoroutine = ((MonoBehaviour)instance).StartCoroutine(DeferredVisibleUiRefresh()); } } } [IteratorStateMachine(typeof(d__12))] private static IEnumerator DeferredVisibleUiRefresh() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0); } private static void FallbackScanVisibleUiOnce() { _hasPerformedFallbackVisibleUiScan = true; InventoryItemUI[] array = Object.FindObjectsByType((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { AkUiPatchHelpers.ApplyAkToInventoryUi(array[i]); } BackpackWheelSlice[] array2 = Object.FindObjectsByType((FindObjectsSortMode)0); for (int j = 0; j < array2.Length; j++) { AkUiPatchHelpers.ApplyAkToSliceImage(array2[j]); } BackpackWheel[] array3 = Object.FindObjectsByType((FindObjectsSortMode)0); for (int k = 0; k < array3.Length; k++) { AkUiPatchHelpers.ApplyAkToBackpackWheel(array3[k]); } } internal static void ResetVisibleUiTrackingFallback() { _hasPerformedFallbackVisibleUiScan = false; _pendingVisibleUiRefresh = false; _lastVisibleUiRefreshTime = -999f; } } internal sealed class LobbyConfigPanel { private enum PanelThemeMode { Dark, Light, Transparent } private sealed class ConfigSource { public string Id; public string DisplayName; public ConfigFile Config; public bool IsShootZombies; public ConfigLocalizer Localizer; public List Sections = new List(); } private sealed class ConfigLocalizer { public Func LocalizeSectionName; public Func LocalizeKeyName; public Func LocalizeDescription; public Func LocalizeOptionDisplayText; } private sealed class ConfigSection { public string Key; public string DisplayName; public List Entries = new List(); } private sealed class EntryBinding { public ConfigSource Source; public ConfigEntryBase Entry; public bool SuppressCallbacks; public Action Refresh; } private sealed class LobbyConfigPanelGuiHost : MonoBehaviour { public LobbyConfigPanel Owner; private void OnGUI() { Owner?.RenderImmediateGui(); } } private static readonly Color BackdropColor = new Color(0f, 0f, 0f, 0.18f); private static readonly Color PanelColor = new Color(0.13f, 0.15f, 0.22f, 0.93f); private static readonly Color HeaderColor = new Color(0.21f, 0.26f, 0.36f, 1f); private static readonly Color SidebarColor = new Color(0.11f, 0.12f, 0.17f, 1f); private static readonly Color ContentColor = new Color(0.22f, 0.31f, 0.42f, 0.97f); private static readonly Color CardColor = new Color(0.18f, 0.22f, 0.29f, 0.98f); private static readonly Color ButtonColor = new Color(0.28f, 0.31f, 0.39f, 1f); private static readonly Color ButtonActiveColor = new Color(0.22f, 0.62f, 0.54f, 1f); private static readonly Color ButtonSecondaryActiveColor = new Color(0.25f, 0.47f, 0.71f, 1f); private static readonly Color FieldColor = new Color(0.24f, 0.27f, 0.34f, 1f); private static readonly Color BorderColor = new Color(0.44f, 0.5f, 0.61f, 0.95f); private static readonly Color TextPrimaryColor = new Color(0.96f, 0.96f, 0.98f, 1f); private static readonly Color TextSecondaryColor = new Color(0.82f, 0.85f, 0.9f, 1f); private static readonly Color TextMutedColor = new Color(0.7f, 0.73f, 0.79f, 1f); private readonly Plugin _owner; private readonly List _sources = new List(); private readonly List _visibleBindings = new List(); private GameObject _rootObject; private Canvas _canvas; private RectTransform _panelRect; private RectTransform _pluginTabsRect; private RectTransform _sectionListRect; private RectTransform _entryListRect; private TextMeshProUGUI _panelTitleText; private TextMeshProUGUI _contentTitleText; private bool _isOpen; private bool _isDirty = true; private bool _hasDataModel; private string _selectedSourceId = string.Empty; private string _selectedSectionKey = string.Empty; private ConfigEntryBase _pendingKeyCaptureEntry; private TextMeshProUGUI _pendingKeyCaptureText; private float _nextExternalRefreshTime; private bool _cursorStateCaptured; private bool _savedCursorVisible; private CursorLockMode _savedCursorLockMode; private bool _pendingRenderDiagnostic; private float _nextDiagnosticLogTime; private string _lastDiagnosticSummary = string.Empty; private Rect _windowRect; private Vector2 _entryScrollPosition; private readonly Dictionary _textBufferByEntry = new Dictionary(); private static LobbyConfigPanel _cursorOwner; private PanelThemeMode _panelTheme; private readonly Dictionary _immediateTextureCache = new Dictionary(); private GUIStyle _immediateWindowStyle; private GUIStyle _immediatePaneStyle; private GUIStyle _immediateCardStyle; private GUIStyle _immediateButtonStyle; private GUIStyle _immediateFieldStyle; private GUIStyle _immediateTextFieldStyle; private GUIStyle _immediateLabelStyle; private GUIStyle _immediateTitleStyle; private GUIStyle _immediateDescriptionStyle; public LobbyConfigPanel(Plugin owner) { _owner = owner; _panelTheme = GetConfiguredThemeMode(); } private bool IsLightTheme() { return _panelTheme == PanelThemeMode.Light; } private bool IsTransparentTheme() { return _panelTheme == PanelThemeMode.Transparent; } private static bool IsChineseUi() { return Plugin.Instance?.GetCachedChineseLanguageSettingRuntime() ?? string.Equals(Plugin.GetLocalizedConfigSectionDisplayRuntime("Weapon"), "武器", StringComparison.Ordinal); } private static string GetAkSoundOptionDisplayText(string value) { bool flag = IsChineseUi(); return value switch { "ak_sound1" => flag ? "音效 1" : "Sound 1", "ak_sound2" => flag ? "音效 2" : "Sound 2", "ak_sound3" => flag ? "音效 3" : "Sound 3", _ => value, }; } private static string GetPanelThemeOptionDisplayText(string value) { bool flag = IsChineseUi(); string text = NormalizeThemeSelectionValue(value); if (!(text == "light")) { if (text == "transparent") { return flag ? "透明" : "Transparent"; } return flag ? "黑色" : "Dark"; } return flag ? "白色" : "Light"; } private string GetThemeToggleIcon() { return _panelTheme switch { PanelThemeMode.Light => "☽", PanelThemeMode.Transparent => "◌", _ => "☀", }; } private string GetSectionsLabel() { if (!IsChineseUi()) { return "Sections"; } return "章节"; } private string GetToggleStateLabel(bool value) { if (IsChineseUi()) { if (!value) { return "关闭"; } return "开启"; } if (!value) { return "Off"; } return "On"; } private string GetPressAnyKeyLabel() { if (!IsChineseUi()) { return "Press any key..."; } return "按任意键..."; } private string GetNoVisibleEntriesLabel() { if (!IsChineseUi()) { return "No visible settings."; } return "没有可显示的配置项。"; } private float GetImmediateEntryContentWidth() { return Mathf.Clamp(((Rect)(ref _windowRect)).width - 254f, 560f, 1040f); } private float GetImmediateEntryTitleWidth() { return Mathf.Clamp(GetImmediateEntryContentWidth() * 0.24f, 168f, 308f); } private float GetImmediateCompactControlWidth() { return Mathf.Clamp(GetImmediateEntryContentWidth() * 0.34f, 280f, 420f); } private float GetImmediateRangeControlWidth() { return Mathf.Clamp(GetImmediateEntryContentWidth() * 0.52f, 360f, 560f); } private float GetImmediateRangeSliderWidth() { return Mathf.Clamp(GetImmediateRangeControlWidth() - 92f, 260f, 460f); } private float GetImmediateDescriptionWidth() { return Mathf.Max(520f, GetImmediateEntryContentWidth() - 24f); } private void ToggleTheme() { SetTheme(GetNextThemeMode(_panelTheme)); } private void SetTheme(PanelThemeMode theme, bool persist = true) { if (_panelTheme != theme) { _panelTheme = theme; _isDirty = true; if (Plugin.ShouldEmitVerboseInfoLogsRuntime()) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[ShootZombies] LobbyConfigPanel theme changed to " + theme.ToString() + ".")); } } } if (persist) { PersistThemeSelection(theme); } } internal static string NormalizeThemeSelectionValue(string value) { if (string.IsNullOrWhiteSpace(value)) { return "dark"; } switch (value.Trim().ToLowerInvariant()) { case "black": case "黑": case "黑色": case "dark": return "dark"; case "light": case "white": case "白": case "白色": return "light"; case "clear": case "透": case "透明": case "translucent": case "transparent": return "transparent"; default: return "dark"; } } private static PanelThemeMode GetThemeModeFromConfigValue(string value) { string text = NormalizeThemeSelectionValue(value); if (!(text == "light")) { if (text == "transparent") { return PanelThemeMode.Transparent; } return PanelThemeMode.Dark; } return PanelThemeMode.Light; } private static string GetThemeConfigValue(PanelThemeMode theme) { return theme switch { PanelThemeMode.Light => "light", PanelThemeMode.Transparent => "transparent", _ => "dark", }; } private static PanelThemeMode GetNextThemeMode(PanelThemeMode current) { return current switch { PanelThemeMode.Dark => PanelThemeMode.Light, PanelThemeMode.Light => PanelThemeMode.Transparent, _ => PanelThemeMode.Dark, }; } private static PanelThemeMode GetConfiguredThemeMode() { return GetThemeModeFromConfigValue(Plugin.ConfigPanelTheme?.Value); } private void SyncThemeFromConfig() { SetTheme(GetConfiguredThemeMode(), persist: false); } private void PersistThemeSelection(PanelThemeMode theme) { if (Plugin.ConfigPanelTheme != null) { string themeConfigValue = GetThemeConfigValue(theme); if (!string.Equals(NormalizeThemeSelectionValue(Plugin.ConfigPanelTheme.Value), themeConfigValue, StringComparison.Ordinal)) { Plugin.ConfigPanelTheme.Value = themeConfigValue; } _owner?.SaveOwnedConfigRuntime(); } } private Color GetImmediateBackdropColor() { //IL_001c: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (IsTransparentTheme()) { return new Color(0f, 0f, 0f, 0.01f); } if (!IsLightTheme()) { return new Color(0f, 0f, 0f, 0.1f); } return new Color(0f, 0f, 0f, 0.06f); } private Color GetImmediateWindowColor() { //IL_001c: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (IsTransparentTheme()) { return new Color(0.04f, 0.04f, 0.04f, 0.34f); } if (!IsLightTheme()) { return new Color(0.05f, 0.05f, 0.05f, 1f); } return new Color(0.97f, 0.97f, 0.97f, 1f); } private Color GetImmediatePaneColor() { //IL_001c: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (IsTransparentTheme()) { return new Color(0.08f, 0.08f, 0.08f, 0.24f); } if (!IsLightTheme()) { return new Color(0.09f, 0.09f, 0.09f, 1f); } return new Color(0.92f, 0.92f, 0.92f, 1f); } private Color GetImmediateCardColor() { //IL_001c: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (IsTransparentTheme()) { return new Color(0.11f, 0.11f, 0.11f, 0.28f); } if (!IsLightTheme()) { return new Color(0.14f, 0.14f, 0.14f, 1f); } return new Color(0.98f, 0.98f, 0.98f, 1f); } private Color GetImmediateFieldColor() { //IL_001c: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (IsTransparentTheme()) { return new Color(0.16f, 0.16f, 0.16f, 0.36f); } if (!IsLightTheme()) { return new Color(0.2f, 0.2f, 0.2f, 1f); } return new Color(0.87f, 0.87f, 0.87f, 1f); } private Color GetImmediateFieldFocusColor() { //IL_001c: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (IsTransparentTheme()) { return new Color(0.2f, 0.2f, 0.2f, 0.44f); } if (!IsLightTheme()) { return new Color(0.24f, 0.24f, 0.24f, 1f); } return new Color(0.88f, 0.88f, 0.88f, 1f); } private Color GetImmediateButtonColor(bool active) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_005e: Unknown result type (might be due to invalid IL or missing references) if (IsTransparentTheme()) { if (!active) { return new Color(0.18f, 0.18f, 0.18f, 0.58f); } return new Color(0.34f, 0.34f, 0.34f, 0.78f); } if (IsLightTheme()) { if (!active) { return new Color(0.86f, 0.86f, 0.86f, 1f); } return new Color(0.72f, 0.72f, 0.72f, 1f); } if (!active) { return new Color(0.18f, 0.18f, 0.18f, 1f); } return new Color(0.34f, 0.34f, 0.34f, 1f); } private Color GetImmediateThemeButtonColor(PanelThemeMode theme, bool active) { //IL_0035: 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_00a7: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) switch (theme) { case PanelThemeMode.Light: if (!active) { return new Color(0.8f, 0.8f, 0.8f, 1f); } return new Color(0.98f, 0.98f, 0.98f, 1f); case PanelThemeMode.Transparent: if (!active) { return new Color(0.22f, 0.22f, 0.22f, 0.48f); } return new Color(0.18f, 0.18f, 0.18f, 0.82f); default: if (!active) { return new Color(0.28f, 0.28f, 0.28f, 1f); } return new Color(0.12f, 0.12f, 0.12f, 1f); } } private Color GetImmediateThemeButtonTextColor(PanelThemeMode theme, bool active) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) switch (theme) { case PanelThemeMode.Light: return new Color(0.08f, 0.08f, 0.08f, 1f); case PanelThemeMode.Transparent: return new Color(0.96f, 0.96f, 0.96f, active ? 1f : 0.92f); default: if (!active) { return new Color(0.86f, 0.86f, 0.86f, 1f); } return new Color(0.96f, 0.96f, 0.96f, 1f); } } private Color GetImmediateTextPrimaryColor() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!IsLightTheme()) { return new Color(0.96f, 0.96f, 0.96f, 1f); } return new Color(0.08f, 0.08f, 0.08f, 1f); } private Color GetImmediateTextMutedColor() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!IsLightTheme()) { return new Color(0.78f, 0.78f, 0.78f, 1f); } return new Color(0.28f, 0.28f, 0.28f, 1f); } private Texture2D GetSolidTexture(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) Color32 val = Color32.op_Implicit(color); int key = val.r | (val.g << 8) | (val.b << 16) | (val.a << 24); if (_immediateTextureCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Texture2D val2 = new Texture2D(1, 1, (TextureFormat)5, false); ((Object)val2).hideFlags = (HideFlags)61; val2.SetPixel(0, 0, color); val2.Apply(false, true); _immediateTextureCache[key] = val2; return val2; } private void EnsureImmediateStyles() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0166: 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_01a9: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Expected O, but got Unknown //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: 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_031a: Expected O, but got Unknown //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Expected O, but got Unknown //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0425: 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_0105: Expected O, but got Unknown if (_immediateWindowStyle == null) { _immediateWindowStyle = new GUIStyle(GUI.skin.window); } if (_immediatePaneStyle == null) { _immediatePaneStyle = new GUIStyle(GUI.skin.box); } if (_immediateCardStyle == null) { _immediateCardStyle = new GUIStyle(GUI.skin.box); } if (_immediateButtonStyle == null) { _immediateButtonStyle = new GUIStyle(GUI.skin.button); } if (_immediateFieldStyle == null) { _immediateFieldStyle = new GUIStyle(GUI.skin.box); } if (_immediateTextFieldStyle == null) { _immediateTextFieldStyle = new GUIStyle(GUI.skin.textField); } if (_immediateLabelStyle == null) { _immediateLabelStyle = new GUIStyle(GUI.skin.label); } if (_immediateTitleStyle == null) { _immediateTitleStyle = new GUIStyle(GUI.skin.label); } if (_immediateDescriptionStyle == null) { _immediateDescriptionStyle = new GUIStyle(GUI.skin.label); } Texture2D solidTexture = GetSolidTexture(Color.white); Color immediateTextPrimaryColor = GetImmediateTextPrimaryColor(); Color immediateTextMutedColor = GetImmediateTextMutedColor(); _immediateWindowStyle.normal.background = GetSolidTexture(GetImmediateWindowColor()); _immediateWindowStyle.onNormal.background = _immediateWindowStyle.normal.background; _immediateWindowStyle.normal.textColor = immediateTextPrimaryColor; _immediateWindowStyle.alignment = (TextAnchor)0; _immediateWindowStyle.fontSize = 15; _immediateWindowStyle.fontStyle = (FontStyle)1; _immediateWindowStyle.padding = new RectOffset(12, 12, 12, 12); _immediatePaneStyle.normal.background = GetSolidTexture(GetImmediatePaneColor()); _immediatePaneStyle.normal.textColor = immediateTextPrimaryColor; _immediatePaneStyle.border = new RectOffset(1, 1, 1, 1); _immediateCardStyle.normal.background = GetSolidTexture(GetImmediateCardColor()); _immediateCardStyle.normal.textColor = immediateTextPrimaryColor; _immediateCardStyle.alignment = (TextAnchor)0; _immediateCardStyle.padding = new RectOffset(10, 10, 8, 8); _immediateButtonStyle.normal.background = solidTexture; _immediateButtonStyle.hover.background = solidTexture; _immediateButtonStyle.active.background = solidTexture; _immediateButtonStyle.focused.background = solidTexture; _immediateButtonStyle.normal.textColor = immediateTextPrimaryColor; _immediateButtonStyle.hover.textColor = immediateTextPrimaryColor; _immediateButtonStyle.active.textColor = immediateTextPrimaryColor; _immediateButtonStyle.focused.textColor = immediateTextPrimaryColor; _immediateButtonStyle.alignment = (TextAnchor)4; _immediateFieldStyle.normal.background = GetSolidTexture(GetImmediateFieldColor()); _immediateFieldStyle.normal.textColor = immediateTextPrimaryColor; _immediateFieldStyle.alignment = (TextAnchor)4; _immediateFieldStyle.padding = new RectOffset(8, 8, 6, 6); _immediateTextFieldStyle.normal.background = GetSolidTexture(GetImmediateFieldColor()); _immediateTextFieldStyle.focused.background = GetSolidTexture(GetImmediateFieldFocusColor()); _immediateTextFieldStyle.hover.background = _immediateTextFieldStyle.normal.background; _immediateTextFieldStyle.normal.textColor = immediateTextPrimaryColor; _immediateTextFieldStyle.focused.textColor = immediateTextPrimaryColor; _immediateTextFieldStyle.hover.textColor = immediateTextPrimaryColor; _immediateTextFieldStyle.padding = new RectOffset(8, 8, 6, 6); _immediateLabelStyle.fontSize = 12; _immediateLabelStyle.normal.textColor = immediateTextPrimaryColor; _immediateTitleStyle.fontSize = 14; _immediateTitleStyle.fontStyle = (FontStyle)1; _immediateTitleStyle.normal.textColor = immediateTextPrimaryColor; _immediateDescriptionStyle.fontSize = 10; _immediateDescriptionStyle.wordWrap = true; _immediateDescriptionStyle.normal.textColor = immediateTextMutedColor; } internal static bool IsCursorOwnershipActive() { if (_cursorOwner != null) { return _cursorOwner._isOpen; } return false; } public void Tick() { //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_0006: 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) Scene activeScene = SceneManager.GetActiveScene(); if (!Plugin.IsLobbySceneRuntime(activeScene) && !Plugin.IsGameplaySceneRuntime(activeScene)) { if (_isOpen) { Close(); } return; } SyncThemeFromConfig(); if (!_isOpen && (Object)(object)_rootObject == (Object)null) { BuildUi(); RefreshDataModel(); _isDirty = false; } if (_pendingKeyCaptureEntry != null) { HandleKeyCapture(); } else if (ShouldTogglePanel()) { if (_isOpen) { Close(); } else { Open(); } } else { if (!_isOpen) { return; } if (Input.GetKeyDown((KeyCode)27)) { Close(); return; } if ((Object)(object)_rootObject == (Object)null) { BuildUi(); _isDirty = true; } ClampPanelToScreen(); EnsureWindowRectInitialized(); Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if (_isDirty || Time.unscaledTime >= _nextExternalRefreshTime) { if (_isDirty || !_hasDataModel) { RefreshDataModel(); RefreshUi(); _isDirty = false; } else { RefreshVisibleBindings(); UpdatePanelHeaders(); } _nextExternalRefreshTime = Time.unscaledTime + 0.5f; } } } public void Dispose() { Close(); if (_cursorOwner == this) { _cursorOwner = null; } if ((Object)(object)_rootObject != (Object)null) { Object.Destroy((Object)(object)_rootObject); _rootObject = null; _canvas = null; _panelRect = null; _pluginTabsRect = null; _sectionListRect = null; _entryListRect = null; _panelTitleText = null; _contentTitleText = null; } foreach (Texture2D value in _immediateTextureCache.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } } _immediateTextureCache.Clear(); _sources.Clear(); _visibleBindings.Clear(); _hasDataModel = false; } private void Open() { EnsureEventSystem(); SyncThemeFromConfig(); if ((Object)(object)_rootObject == (Object)null) { BuildUi(); } _rootObject.SetActive(true); if ((Object)(object)_canvas != (Object)null) { ((Behaviour)_canvas).enabled = false; } ClampPanelToScreen(); if (!_hasDataModel || _sources.Count == 0 || _isDirty) { RefreshDataModel(); RefreshUi(); _isDirty = false; } else { RefreshVisibleBindings(); UpdatePanelHeaders(); } CaptureCursorState(); EnsureWindowRectInitialized(((Rect)(ref _windowRect)).width <= 1f || ((Rect)(ref _windowRect)).height <= 1f); _cursorOwner = this; EventSystem current = EventSystem.current; if (current != null) { current.SetSelectedGameObject((GameObject)null); } _isOpen = true; _pendingRenderDiagnostic = true; _nextExternalRefreshTime = Time.unscaledTime + 0.5f; if (Plugin.ShouldEmitVerboseInfoLogsRuntime()) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[ShootZombies] LobbyConfigPanel opened."); } } } public void NotifyLanguageChanged(bool isChineseLanguage) { _selectedSectionKey = string.Empty; _isDirty = true; _nextExternalRefreshTime = 0f; if (!_isOpen || (Object)(object)_rootObject == (Object)null) { return; } RefreshDataModel(); RefreshUi(); _isDirty = false; _nextExternalRefreshTime = Time.unscaledTime + 0.5f; _pendingRenderDiagnostic = true; if (Plugin.ShouldEmitVerboseInfoLogsRuntime()) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[ShootZombies] LobbyConfigPanel language refresh applied. isChinese=" + isChineseLanguage + ".")); } } } private void Close() { _pendingKeyCaptureEntry = null; _pendingKeyCaptureText = null; if ((Object)(object)_rootObject != (Object)null) { _rootObject.SetActive(false); } if (_cursorOwner == this) { _cursorOwner = null; } RestoreCursorState(); _isOpen = false; _pendingRenderDiagnostic = false; } private bool ShouldTogglePanel() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (IsTypingIntoInputField()) { return false; } return Input.GetKeyDown(GetOpenKey()); } private KeyCode GetOpenKey() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (Plugin.OpenConfigPanelKey == null || (int)Plugin.OpenConfigPanelKey.Value == 0) { return (KeyCode)92; } return Plugin.OpenConfigPanelKey.Value; } private void HandleKeyCapture() { //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (_pendingKeyCaptureEntry == null) { return; } if (Input.GetKeyDown((KeyCode)27)) { CancelKeyCapture(); return; } foreach (KeyCode value in Enum.GetValues(typeof(KeyCode))) { if ((int)value != 0 && Input.GetKeyDown(value)) { TryAssignBoxedValue(_pendingKeyCaptureEntry, (object)value); SaveEntryOwner(_pendingKeyCaptureEntry); CancelKeyCapture(); RefreshVisibleBindings(); break; } } } private void CancelKeyCapture() { _pendingKeyCaptureEntry = null; _pendingKeyCaptureText = null; RefreshVisibleBindings(); } private void CaptureCursorState() { //IL_0015: 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) if (!_cursorStateCaptured) { _savedCursorVisible = Cursor.visible; _savedCursorLockMode = Cursor.lockState; _cursorStateCaptured = true; Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } } private void RestoreCursorState() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (_cursorStateCaptured) { Cursor.visible = _savedCursorVisible; Cursor.lockState = _savedCursorLockMode; _cursorStateCaptured = false; } } private void EnterPauseMenuMode() { } private void ExitPauseMenuMode() { } private void RefreshDataModel() { _sources.Clear(); ConfigSource configSource = BuildShootZombiesSource(); if (configSource != null) { _sources.Add(configSource); } ConfigSource configSource2 = BuildFogAndColdControlSource(); if (configSource2 != null) { _sources.Add(configSource2); } if (_sources.Count == 0) { _selectedSourceId = string.Empty; _selectedSectionKey = string.Empty; _hasDataModel = false; return; } _hasDataModel = true; if (!_sources.Any((ConfigSource source) => string.Equals(source.Id, _selectedSourceId, StringComparison.Ordinal))) { _selectedSourceId = _sources[0].Id; } ConfigSource selectedSource = GetSelectedSource(); if (selectedSource == null || selectedSource.Sections.Count == 0) { _selectedSectionKey = string.Empty; return; } if (!selectedSource.Sections.Any((ConfigSection section) => string.Equals(section.Key, _selectedSectionKey, StringComparison.Ordinal))) { _selectedSectionKey = selectedSource.Sections[0].Key; } MaybeLogDiagnostics(); } private ConfigSource BuildShootZombiesSource() { if ((Object)(object)Plugin.Instance == (Object)null) { return null; } ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config; return BuildSource("shootzombies", "ShootZombies", config, CreateShootZombiesLocalizer(), isShootZombies: true); } private bool GetCurrentLanguageIsChinese() { return _owner?.GetCachedChineseLanguageSettingRuntime() ?? IsChineseUi(); } private ConfigSource BuildFogAndColdControlSource() { bool currentLanguageIsChinese = GetCurrentLanguageIsChinese(); foreach (PluginInfo value in Chainloader.PluginInfos.Values) { BaseUnityPlugin val = ((value != null) ? value.Instance : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)Plugin.Instance) && IsFogAndColdControlPlugin(value)) { BepInPlugin metadata = value.Metadata; string text = ((metadata != null) ? metadata.GUID : null); if (string.IsNullOrWhiteSpace(text)) { text = "thanks.fogandcoldcontrol"; } BepInPlugin metadata2 = value.Metadata; string text2 = ((metadata2 != null) ? metadata2.Name : null); if (string.IsNullOrWhiteSpace(text2)) { text2 = "Fog&ColdControl"; } return BuildSource(text, text2, val.Config, TryCreatePluginLocalizer(val, currentLanguageIsChinese), isShootZombies: false); } } return null; } private static bool IsFogAndColdControlPlugin(PluginInfo info) { if (info == null) { return false; } string[] array3 = new string[4]; BepInPlugin metadata = info.Metadata; array3[0] = ((metadata != null) ? metadata.GUID : null); BepInPlugin metadata2 = info.Metadata; array3[1] = ((metadata2 != null) ? metadata2.Name : null); array3[2] = ((object)info.Instance)?.GetType().Assembly.GetName().Name; array3[3] = Path.GetFileNameWithoutExtension(info.Location ?? string.Empty); string[] source = array3; string[] array2 = new string[4] { "Thanks.Fog&ColdControl", "Fog&ColdControl", "FogAndColdControl", "FogColdControl" }; return source.Any((string candidate) => !string.IsNullOrWhiteSpace(candidate) && array2.Any((string matchToken) => candidate.IndexOf(matchToken, StringComparison.OrdinalIgnoreCase) >= 0)); } private static ConfigLocalizer CreateShootZombiesLocalizer() { return new ConfigLocalizer { LocalizeSectionName = (string section) => Plugin.GetLocalizedConfigSectionDisplayRuntime(section), LocalizeKeyName = (string key) => Plugin.GetLocalizedConfigKeyDisplayRuntime(key), LocalizeDescription = (string key) => Plugin.GetLocalizedConfigDescriptionRuntime(key), LocalizeOptionDisplayText = (string key, object option) => GetShootZombiesOptionDisplayText(key, option) }; } private static ConfigLocalizer TryCreatePluginLocalizer(BaseUnityPlugin pluginInstance, bool isChineseLanguage) { if ((Object)(object)pluginInstance == (Object)null) { return null; } ConfigLocalizer configLocalizer = TryCreateConfigKeyEnumPluginLocalizer(pluginInstance, isChineseLanguage); if (configLocalizer != null) { return configLocalizer; } Type type = ((object)pluginInstance).GetType(); if (!HasMethod(type, "GetLocalizedConfigKeyDisplayRuntime") && !HasMethod(type, "GetLocalizedKeyName") && !HasMethod(type, "GetKeyName") && !HasMethod(type, "GetLocalizedConfigSectionDisplayRuntime") && !HasMethod(type, "GetLocalizedSectionName") && !HasMethod(type, "GetSectionName") && !HasMethod(type, "GetLocalizedConfigDescriptionRuntime") && !HasMethod(type, "GetLocalizedDescription") && !HasMethod(type, "GetLocalizedConfigOptionDisplayRuntime") && !HasMethod(type, "GetLocalizedConfigOptionDisplayTextRuntime") && !HasMethod(type, "GetLocalizedOptionDisplayText") && !HasMethod(type, "GetOptionDisplayText")) { return null; } return new ConfigLocalizer { LocalizeSectionName = (string section) => TryLocalizePluginSectionName(pluginInstance, section, isChineseLanguage) ?? section, LocalizeKeyName = (string key) => TryLocalizePluginKeyName(pluginInstance, key, isChineseLanguage) ?? key, LocalizeDescription = (string key) => TryLocalizePluginDescription(pluginInstance, key, isChineseLanguage) ?? string.Empty, LocalizeOptionDisplayText = (string key, object option) => TryLocalizePluginOptionDisplayText(pluginInstance, key, option, isChineseLanguage) ?? option?.ToString() ?? string.Empty }; } private ConfigSource BuildSource(string id, string displayName, ConfigFile config, ConfigLocalizer localizer, bool isShootZombies) { ConfigEntryBase[] configEntriesSnapshotRuntime = Plugin.GetConfigEntriesSnapshotRuntime(config); if (configEntriesSnapshotRuntime.Length == 0) { return null; } ConfigSource configSource = new ConfigSource { Id = id, DisplayName = displayName, Config = config, IsShootZombies = isShootZombies, Localizer = localizer }; foreach (IGrouping item in (from entry in configEntriesSnapshotRuntime where entry != null && entry.Definition != (ConfigDefinition)null && (!isShootZombies || Plugin.ShouldExposeOwnedConfigEntryRuntime(entry)) group entry by entry.Definition.Section ?? string.Empty into @group orderby GetSectionSortIndex(configSource, @group.Key) select @group).ThenBy, string>((IGrouping group) => GetSectionDisplayName(configSource, group.Key), StringComparer.OrdinalIgnoreCase)) { ConfigSection configSection = new ConfigSection { Key = item.Key, DisplayName = GetSectionDisplayName(configSource, item.Key) }; configSection.Entries.AddRange(item.OrderBy((ConfigEntryBase entry) => GetEntrySortIndex(configSource, entry)).ThenBy((ConfigEntryBase entry) => GetEntryDisplayName(configSource, entry), StringComparer.OrdinalIgnoreCase)); if (configSection.Entries.Count > 0) { configSource.Sections.Add(configSection); } } if (configSource.Sections.Count == 0) { return null; } return configSource; } private static string GetShootZombiesOptionDisplayText(string key, object option) { string text = option?.ToString() ?? string.Empty; if (string.Equals(key, "Config Panel Theme", StringComparison.Ordinal)) { return GetPanelThemeOptionDisplayText(text); } if (string.Equals(key, "AK Sound", StringComparison.Ordinal)) { return GetAkSoundOptionDisplayText(text); } if (string.Equals(key, "Weapon Selection", StringComparison.Ordinal)) { return text switch { "AK47" => "AK47", "HK416" => "HK416", "MPX" => "MPX", _ => text, }; } if (string.Equals(key, "Behavior Difficulty", StringComparison.Ordinal)) { return Plugin.GetZombieBehaviorDifficultyDisplayNameRuntime(text); } return text; } private static bool HasMethod(Type type, string methodName) { if (type == null || string.IsNullOrWhiteSpace(methodName)) { return false; } return type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Any((MethodInfo method) => string.Equals(method.Name, methodName, StringComparison.Ordinal)); } private static bool TryResolvePluginChineseLanguage(BaseUnityPlugin pluginInstance) { if ((Object)(object)pluginInstance != (Object)null) { Type type = ((object)pluginInstance).GetType(); if (TryInvokeCompatibleMethod(type, pluginInstance, "GetCachedChineseLanguageSetting", out var result) && result is bool) { return (bool)result; } if (TryInvokeCompatibleMethod(type, pluginInstance, "IsChineseLanguage", out result) && result is bool) { return (bool)result; } } return string.Equals(Plugin.GetLocalizedConfigSectionDisplayRuntime("Weapon"), "武器", StringComparison.Ordinal); } private static ConfigLocalizer TryCreateConfigKeyEnumPluginLocalizer(BaseUnityPlugin pluginInstance, bool isChineseLanguage) { if ((Object)(object)pluginInstance == (Object)null) { return null; } Type type = ((object)pluginInstance).GetType(); Type nestedType = type.GetNestedType("ConfigKey", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (nestedType == null || !nestedType.IsEnum) { return null; } MethodInfo methodInfo = FindCompatibleMethod(type, "GetKeyName", nestedType, typeof(bool)); MethodInfo methodInfo2 = FindCompatibleMethod(type, "GetSectionName", nestedType, typeof(bool)); MethodInfo methodInfo3 = FindCompatibleMethod(type, "GetLocalizedDescription", nestedType, typeof(bool)); if (methodInfo == null || methodInfo2 == null || methodInfo3 == null) { return null; } Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); Dictionary dictionary2 = new Dictionary(StringComparer.OrdinalIgnoreCase); Dictionary dictionary3 = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (object value in Enum.GetValues(nestedType)) { string source = InvokeStringMethod(methodInfo, pluginInstance, value, false); string source2 = InvokeStringMethod(methodInfo, pluginInstance, value, true); string target = InvokeStringMethod(methodInfo, pluginInstance, value, isChineseLanguage); AddLocalizationAlias(dictionary, source, target); AddLocalizationAlias(dictionary, source2, target); string source3 = InvokeStringMethod(methodInfo2, pluginInstance, value, false); string source4 = InvokeStringMethod(methodInfo2, pluginInstance, value, true); string target2 = InvokeStringMethod(methodInfo2, pluginInstance, value, isChineseLanguage); AddLocalizationAlias(dictionary2, source3, target2); AddLocalizationAlias(dictionary2, source4, target2); string source5 = InvokeStringMethod(methodInfo3, pluginInstance, value, false); string source6 = InvokeStringMethod(methodInfo3, pluginInstance, value, true); string target3 = InvokeStringMethod(methodInfo3, pluginInstance, value, isChineseLanguage); AddLocalizationAlias(dictionary3, source, target3); AddLocalizationAlias(dictionary3, source2, target3); AddLocalizationAlias(dictionary3, source5, target3); AddLocalizationAlias(dictionary3, source6, target3); } if (dictionary.Count == 0 && dictionary2.Count == 0 && dictionary3.Count == 0) { return null; } return new ConfigLocalizer { LocalizeSectionName = (string section) => LookupLocalization(dictionary2, section), LocalizeKeyName = (string key) => LookupLocalization(dictionary, key), LocalizeDescription = (string key) => LookupLocalization(dictionary3, key), LocalizeOptionDisplayText = (string key, object option) => option?.ToString() ?? string.Empty }; } private static MethodInfo FindCompatibleMethod(Type declaringType, string methodName, params Type[] parameterTypes) { if (declaringType == null || string.IsNullOrWhiteSpace(methodName)) { return null; } return declaringType.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault(delegate(MethodInfo method) { if (!string.Equals(method.Name, methodName, StringComparison.Ordinal)) { return false; } ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length != parameterTypes.Length) { return false; } for (int i = 0; i < parameterTypes.Length; i++) { if (parameters[i].ParameterType != parameterTypes[i]) { return false; } } return method.ReturnType == typeof(string); }); } private static string InvokeStringMethod(MethodInfo method, object target, params object[] arguments) { if (method == null) { return null; } try { object obj = method.Invoke(method.IsStatic ? null : target, arguments); return (obj as string) ?? obj?.ToString(); } catch { } return null; } private static void AddLocalizationAlias(Dictionary map, string source, string target) { if (map != null && !string.IsNullOrWhiteSpace(source) && !string.IsNullOrWhiteSpace(target)) { map[source] = target; } } private static string LookupLocalization(Dictionary map, string value) { if (map == null || string.IsNullOrWhiteSpace(value)) { return null; } if (!map.TryGetValue(value, out var value2)) { return null; } return value2; } private static string TryLocalizePluginSectionName(BaseUnityPlugin pluginInstance, string section, bool isChinese) { if ((Object)(object)pluginInstance == (Object)null || string.IsNullOrWhiteSpace(section)) { return null; } Type type = ((object)pluginInstance).GetType(); return TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedConfigSectionDisplayRuntime", section) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedSectionName", section, isChinese); } private static string TryLocalizePluginKeyName(BaseUnityPlugin pluginInstance, string key, bool isChinese) { if ((Object)(object)pluginInstance == (Object)null || string.IsNullOrWhiteSpace(key)) { return null; } Type type = ((object)pluginInstance).GetType(); return TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedConfigKeyDisplayRuntime", key) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedKeyName", key, isChinese); } private static string TryLocalizePluginDescription(BaseUnityPlugin pluginInstance, string key, bool isChinese) { if ((Object)(object)pluginInstance == (Object)null || string.IsNullOrWhiteSpace(key)) { return null; } Type type = ((object)pluginInstance).GetType(); return TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedConfigDescriptionRuntime", key) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedDescription", key, isChinese); } private static string TryLocalizePluginOptionDisplayText(BaseUnityPlugin pluginInstance, string key, object option, bool isChinese) { if ((Object)(object)pluginInstance == (Object)null) { return null; } Type type = ((object)pluginInstance).GetType(); string text = option?.ToString() ?? string.Empty; return TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedConfigOptionDisplayRuntime", key, option) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedConfigOptionDisplayRuntime", key, text) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedConfigOptionDisplayTextRuntime", key, option) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedConfigOptionDisplayTextRuntime", key, text) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedOptionDisplayText", key, option, isChinese) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedOptionDisplayText", key, text, isChinese) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedOptionDisplayText", option, isChinese) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetLocalizedOptionDisplayText", text, isChinese) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetOptionDisplayText", key, option, isChinese) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetOptionDisplayText", key, text, isChinese) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetOptionDisplayText", option, isChinese) ?? TryInvokeStringCompatibleMethod(type, pluginInstance, "GetOptionDisplayText", text, isChinese); } private static string TryInvokeStringCompatibleMethod(Type declaringType, object target, string methodName, params object[] suppliedArguments) { if (!TryInvokeCompatibleMethod(declaringType, target, methodName, out var result, suppliedArguments) || result == null) { return null; } return (result as string) ?? result.ToString(); } private static bool TryInvokeCompatibleMethod(Type declaringType, object target, string methodName, out object result, params object[] suppliedArguments) { result = null; if (declaringType == null || string.IsNullOrWhiteSpace(methodName)) { return false; } MethodInfo[] array = (from method in declaringType.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where string.Equals(method.Name, methodName, StringComparison.Ordinal) select method).OrderBy(delegate(MethodInfo method) { int num = method.GetParameters().Length; object[] array2 = suppliedArguments; return Math.Abs(num - ((array2 != null) ? array2.Length : 0)); }).ThenBy((MethodInfo method) => method.GetParameters().Length).ToArray(); foreach (MethodInfo methodInfo in array) { if ((methodInfo.IsStatic || target != null) && TryBuildCompatibleInvokeArguments(methodInfo, suppliedArguments, out var invokeArguments)) { try { result = methodInfo.Invoke(methodInfo.IsStatic ? null : target, invokeArguments); return true; } catch (TargetParameterCountException) { } catch (ArgumentException) { } catch (TargetInvocationException) { return false; } catch { return false; } } } return false; } private static bool TryBuildCompatibleInvokeArguments(MethodInfo method, object[] suppliedArguments, out object[] invokeArguments) { invokeArguments = null; if (method == null) { return false; } suppliedArguments = suppliedArguments ?? Array.Empty(); ParameterInfo[] parameters = method.GetParameters(); if (suppliedArguments.Length > parameters.Length) { return false; } object[] array = new object[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { ParameterInfo parameterInfo = parameters[i]; if (i < suppliedArguments.Length) { if (!TryCoerceInvokeArgument(parameterInfo.ParameterType, suppliedArguments[i], out array[i])) { return false; } continue; } if (parameterInfo.HasDefaultValue) { array[i] = parameterInfo.DefaultValue; continue; } Type type = (parameterInfo.ParameterType.IsByRef ? parameterInfo.ParameterType.GetElementType() : parameterInfo.ParameterType); if (type == null) { return false; } if (Nullable.GetUnderlyingType(parameterInfo.ParameterType) != null || !type.IsValueType) { array[i] = null; continue; } return false; } invokeArguments = array; return true; } private static bool TryCoerceInvokeArgument(Type parameterType, object value, out object coercedValue) { coercedValue = null; if (parameterType == null) { return false; } if (parameterType.IsByRef) { parameterType = parameterType.GetElementType(); if (parameterType == null) { return false; } } Type type = Nullable.GetUnderlyingType(parameterType) ?? parameterType; if (value == null) { if (Nullable.GetUnderlyingType(parameterType) != null || !type.IsValueType) { coercedValue = null; return true; } return false; } if (type.IsInstanceOfType(value)) { coercedValue = value; return true; } try { if (type.IsEnum) { if (value is string value2) { coercedValue = Enum.Parse(type, value2, ignoreCase: true); return true; } coercedValue = Enum.ToObject(type, value); return true; } if (value is IConvertible && typeof(IConvertible).IsAssignableFrom(type)) { coercedValue = Convert.ChangeType(value, type, CultureInfo.InvariantCulture); return true; } } catch { } return false; } private void RefreshUi() { RebuildPluginTabs(); RebuildSectionButtons(); RebuildEntryContent(); UpdatePanelHeaders(); } private void UpdatePanelHeaders() { ConfigSource selectedSource = GetSelectedSource(); ConfigSection selectedSection = GetSelectedSection(); if ((Object)(object)_panelTitleText != (Object)null) { ((TMP_Text)_panelTitleText).text = selectedSource?.DisplayName ?? "Config"; } if ((Object)(object)_contentTitleText != (Object)null) { string text = selectedSection?.DisplayName ?? string.Empty; ((TMP_Text)_contentTitleText).text = ((!string.IsNullOrWhiteSpace(text)) ? ((selectedSource?.DisplayName ?? "Config") + " / " + text) : (selectedSource?.DisplayName ?? "Config")); } } private void RebuildPluginTabs() { //IL_00a2: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown DestroyChildren((Transform)(object)_pluginTabsRect); if ((Object)(object)_pluginTabsRect == (Object)null) { return; } HorizontalLayoutGroup orAddComponent = GetOrAddComponent(((Component)_pluginTabsRect).gameObject); ((HorizontalOrVerticalLayoutGroup)orAddComponent).spacing = 10f; ((HorizontalOrVerticalLayoutGroup)orAddComponent).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)orAddComponent).childForceExpandWidth = false; ((LayoutGroup)orAddComponent).childAlignment = (TextAnchor)3; ConfigSource[] array = _sources.ToArray(); foreach (ConfigSource source in array) { bool flag = string.Equals(source.Id, _selectedSourceId, StringComparison.Ordinal); ((UnityEvent)CreateButton((Transform)(object)_pluginTabsRect, source.DisplayName, flag ? ButtonSecondaryActiveColor : ButtonColor, 18f, 150f, 36f).onClick).AddListener((UnityAction)delegate { _selectedSourceId = source.Id; _selectedSectionKey = string.Empty; _isDirty = true; RefreshDataModel(); RefreshUi(); }); } } private void RebuildSectionButtons() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00e6: Expected O, but got Unknown DestroyChildren((Transform)(object)_sectionListRect); if ((Object)(object)_sectionListRect == (Object)null) { return; } VerticalLayoutGroup orAddComponent = GetOrAddComponent(((Component)_sectionListRect).gameObject); ((HorizontalOrVerticalLayoutGroup)orAddComponent).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)orAddComponent).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)orAddComponent).childForceExpandWidth = true; ((LayoutGroup)orAddComponent).padding = new RectOffset(0, 0, 0, 0); ConfigSource selectedSource = GetSelectedSource(); if (selectedSource == null) { return; } foreach (ConfigSection section in selectedSource.Sections) { bool flag = string.Equals(section.Key, _selectedSectionKey, StringComparison.Ordinal); ((UnityEvent)CreateButton((Transform)(object)_sectionListRect, section.DisplayName, flag ? ButtonActiveColor : ButtonColor, 18f, -1f, 42f).onClick).AddListener((UnityAction)delegate { _selectedSectionKey = section.Key; RefreshUi(); }); } } private void RebuildEntryContent() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown if (RebuildEntryContentManual()) { return; } DestroyChildren((Transform)(object)_entryListRect); _visibleBindings.Clear(); if ((Object)(object)_entryListRect == (Object)null) { return; } VerticalLayoutGroup orAddComponent = GetOrAddComponent(((Component)_entryListRect).gameObject); ((HorizontalOrVerticalLayoutGroup)orAddComponent).spacing = 12f; ((HorizontalOrVerticalLayoutGroup)orAddComponent).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)orAddComponent).childForceExpandWidth = true; ((LayoutGroup)orAddComponent).padding = new RectOffset(4, 12, 4, 18); GetOrAddComponent(((Component)_entryListRect).gameObject).verticalFit = (FitMode)2; ConfigSection selectedSection = GetSelectedSection(); if (selectedSection == null || selectedSection.Entries.Count == 0) { CreateEmptyState((Transform)(object)_entryListRect, GetNoVisibleEntriesLabel()); RefreshEntryLayout(); return; } foreach (ConfigEntryBase entry in selectedSection.Entries) { CreateEntryCard((Transform)(object)_entryListRect, GetSelectedSource(), entry); } RefreshEntryLayout(); } private void CreateEntryCard(Transform parent, ConfigSource source, ConfigEntryBase entry) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateUiObject("EntryCard", parent); ((Graphic)val.AddComponent()).color = CardColor; AddOutline(val, BorderColor); val.AddComponent().minHeight = 88f; VerticalLayoutGroup obj = val.AddComponent(); ((LayoutGroup)obj).padding = new RectOffset(18, 18, 14, 14); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true; GameObject val2 = CreateUiObject("HeaderRow", val.transform); HorizontalLayoutGroup obj2 = val2.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 16f; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ((Component)CreateText(val2.transform, GetEntryDisplayName(source, entry), 21f, TextPrimaryColor, (TextAlignmentOptions)4097)).gameObject.AddComponent().flexibleWidth = 1f; EntryBinding entryBinding = new EntryBinding { Source = source, Entry = entry }; Type entryValueType = GetEntryValueType(entry); List options; if (entryValueType == typeof(bool)) { CreateBoolControl(val2.transform, entryBinding); } else if (entryValueType == typeof(KeyCode)) { CreateKeyControl(val2.transform, entryBinding); } else if (TryGetSelectableOptions(entry, entryValueType, out options)) { CreateDropdownControl(val2.transform, entryBinding, options); } else { CreateInputControl(val2.transform, entryBinding, entryValueType); } string entryDescriptionText = GetEntryDescriptionText(source, entry); if (!string.IsNullOrWhiteSpace(entryDescriptionText)) { CreateText(val.transform, entryDescriptionText, 15f, TextMutedColor, (TextAlignmentOptions)257); } string entrySupplementalText = GetEntrySupplementalText(source, entry); if (!string.IsNullOrWhiteSpace(entrySupplementalText)) { TextMeshProUGUI obj3 = CreateText(val.transform, entrySupplementalText, 14f, TextMutedColor, (TextAlignmentOptions)257); ((TMP_Text)obj3).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)obj3).overflowMode = (TextOverflowModes)0; } entryBinding.Refresh?.Invoke(); _visibleBindings.Add(entryBinding); } private bool RebuildEntryContentManual() { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) DestroyChildren((Transform)(object)_entryListRect); _visibleBindings.Clear(); if ((Object)(object)_entryListRect == (Object)null) { return true; } VerticalLayoutGroup component = ((Component)_entryListRect).GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } ContentSizeFitter component2 = ((Component)_entryListRect).GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } ConfigSource selectedSource = GetSelectedSource(); ConfigSection selectedSection = GetSelectedSection(); if (selectedSection == null || selectedSection.Entries.Count == 0) { CreateEmptyState((Transform)(object)_entryListRect, GetNoVisibleEntriesLabel()); _entryListRect.sizeDelta = new Vector2(0f, 220f); RefreshEntryLayout(); return true; } float num = 8f; foreach (ConfigEntryBase entry in selectedSection.Entries) { num += CreateEntryCardManual((Transform)(object)_entryListRect, selectedSource, entry, num) + 10f; } _entryListRect.sizeDelta = new Vector2(0f, Mathf.Max(num + 8f, 120f)); RefreshEntryLayout(); return true; } private float CreateEntryCardManual(Transform parent, ConfigSource source, ConfigEntryBase entry, float topOffset) { //IL_005d: 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_0087: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: 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_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) string entryDescriptionText = GetEntryDescriptionText(source, entry); bool flag = !string.IsNullOrWhiteSpace(entryDescriptionText); string entrySupplementalText = GetEntrySupplementalText(source, entry); bool num = !string.IsNullOrWhiteSpace(entrySupplementalText); float num2 = (flag ? 108f : 74f); if (num) { num2 += 128f; } GameObject val = CreateUiObject("EntryCardManual", parent); RectTransform rectTransform = GetRectTransform(val); rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.offsetMin = new Vector2(4f, 0f - topOffset - num2); rectTransform.offsetMax = new Vector2(-12f, 0f - topOffset); ((Graphic)val.AddComponent()).color = CardColor; AddOutline(val, BorderColor); RectTransform rectTransform2 = ((TMP_Text)CreateText(val.transform, GetEntryDisplayName(source, entry), 20f, TextPrimaryColor, (TextAlignmentOptions)257)).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 1f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.pivot = new Vector2(0f, 1f); rectTransform2.sizeDelta = new Vector2(-332f, 28f); rectTransform2.anchoredPosition = new Vector2(18f, -14f); GameObject val2 = CreateUiObject("ControlHost", val.transform); RectTransform rectTransform3 = GetRectTransform(val2); rectTransform3.anchorMin = new Vector2(1f, 1f); rectTransform3.anchorMax = new Vector2(1f, 1f); rectTransform3.pivot = new Vector2(1f, 1f); rectTransform3.sizeDelta = new Vector2(286f, 38f); rectTransform3.anchoredPosition = new Vector2(-18f, -12f); EntryBinding entryBinding = new EntryBinding { Source = source, Entry = entry }; Type entryValueType = GetEntryValueType(entry); List options; if (entryValueType == typeof(bool)) { CreateBoolControl(val2.transform, entryBinding); } else if (entryValueType == typeof(KeyCode)) { CreateKeyControl(val2.transform, entryBinding); } else if (TryGetSelectableOptions(entry, entryValueType, out options)) { CreateDropdownControl(val2.transform, entryBinding, options); } else { CreateInputControl(val2.transform, entryBinding, entryValueType); } RectTransform val3 = (RectTransform)((val2.transform.childCount > 0) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val3 != (Object)null) { val3.anchorMin = new Vector2(0.5f, 0.5f); val3.anchorMax = new Vector2(0.5f, 0.5f); val3.pivot = new Vector2(0.5f, 0.5f); val3.anchoredPosition = Vector2.zero; } float num3 = -48f; if (flag) { TextMeshProUGUI obj = CreateText(val.transform, entryDescriptionText, 14f, TextMutedColor, (TextAlignmentOptions)257); RectTransform rectTransform4 = ((TMP_Text)obj).rectTransform; rectTransform4.anchorMin = new Vector2(0f, 1f); rectTransform4.anchorMax = new Vector2(1f, 1f); rectTransform4.pivot = new Vector2(0f, 1f); rectTransform4.sizeDelta = new Vector2(-36f, 40f); rectTransform4.anchoredPosition = new Vector2(18f, num3); ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)obj).overflowMode = (TextOverflowModes)1; num3 -= 46f; } if (num) { TextMeshProUGUI obj2 = CreateText(val.transform, entrySupplementalText, 13.5f, TextMutedColor, (TextAlignmentOptions)257); RectTransform rectTransform5 = ((TMP_Text)obj2).rectTransform; rectTransform5.anchorMin = new Vector2(0f, 1f); rectTransform5.anchorMax = new Vector2(1f, 1f); rectTransform5.pivot = new Vector2(0f, 1f); rectTransform5.sizeDelta = new Vector2(-36f, 116f); rectTransform5.anchoredPosition = new Vector2(18f, num3); ((TMP_Text)obj2).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)obj2).overflowMode = (TextOverflowModes)0; } entryBinding.Refresh?.Invoke(); _visibleBindings.Add(entryBinding); return num2; } private void CreateBoolControl(Transform parent, EntryBinding binding) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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) GameObject val = CreateUiObject("ToggleRoot", parent); GetRectTransform(val).sizeDelta = new Vector2(78f, 30f); LayoutElement obj = val.AddComponent(); obj.preferredWidth = 78f; obj.preferredHeight = 30f; Image val2 = val.AddComponent(); ((Graphic)val2).color = FieldColor; AddOutline(val, BorderColor); Toggle toggle = val.AddComponent(); ((Selectable)toggle).targetGraphic = (Graphic)(object)val2; GameObject val3 = CreateUiObject("Checkmark", val.transform); RectTransform rectTransform = GetRectTransform(val3); rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.sizeDelta = new Vector2(50f, 22f); Image image2 = val3.AddComponent(); ((Graphic)image2).color = ButtonActiveColor; toggle.graphic = (Graphic)(object)image2; ((UnityEvent)(object)toggle.onValueChanged).AddListener((UnityAction)delegate(bool value) { if (!binding.SuppressCallbacks) { TryAssignBoxedValue(binding.Entry, value); SaveEntryOwner(binding.Entry); binding.Refresh?.Invoke(); } }); binding.Refresh = delegate { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) binding.SuppressCallbacks = true; object boxedValue = GetBoxedValue(binding.Entry); bool flag = default(bool); int num; if (boxedValue is bool) { flag = (bool)boxedValue; num = 1; } else { num = 0; } bool flag2 = (byte)((uint)num & (flag ? 1u : 0u)) != 0; toggle.isOn = flag2; ((Graphic)image2).color = (flag2 ? ButtonActiveColor : ButtonColor); binding.SuppressCallbacks = false; }; } private void CreateKeyControl(Transform parent, EntryBinding binding) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown Button val = CreateButton(parent, string.Empty, FieldColor, 17f, 210f, 34f); TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren(); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { _pendingKeyCaptureEntry = binding.Entry; _pendingKeyCaptureText = componentInChildren; RefreshVisibleBindings(); }); binding.Refresh = delegate { binding.SuppressCallbacks = true; if (_pendingKeyCaptureEntry == binding.Entry && (Object)(object)_pendingKeyCaptureText == (Object)(object)componentInChildren) { ((TMP_Text)componentInChildren).text = "鎸変换鎰忛敭..."; } else { ((TMP_Text)componentInChildren).text = GetDisplayValueText(binding.Entry); } binding.SuppressCallbacks = false; }; } private void CreateDropdownControl(Transform parent, EntryBinding binding, List options) { TMP_Dropdown tMP_Dropdown = CreateDropdown(parent, 270f, 34f); List list = options.Select((object option) => GetOptionDisplayText(binding.Source, binding.Entry, option)).ToList(); tMP_Dropdown.ClearOptions(); tMP_Dropdown.AddOptions(list); ((UnityEvent)(object)tMP_Dropdown.onValueChanged).AddListener((UnityAction)delegate(int index) { if (!binding.SuppressCallbacks && index >= 0 && index < options.Count) { TryAssignBoxedValue(binding.Entry, options[index]); SaveEntryOwner(binding.Entry); binding.Refresh?.Invoke(); } }); binding.Refresh = delegate { binding.SuppressCallbacks = true; object boxedValue = GetBoxedValue(binding.Entry); int valueWithoutNotify = 0; for (int i = 0; i < options.Count; i++) { if (ValuesEqual(options[i], boxedValue)) { valueWithoutNotify = i; break; } } tMP_Dropdown.SetValueWithoutNotify(valueWithoutNotify); tMP_Dropdown.RefreshShownValue(); binding.SuppressCallbacks = false; }; } private void CreateInputControl(Transform parent, EntryBinding binding, Type valueType) { TMP_InputField tMP_InputField = CreateInputField(parent, 270f, 34f); ((UnityEvent)(object)tMP_InputField.onEndEdit).AddListener((UnityAction)delegate(string value) { if (!binding.SuppressCallbacks) { if (!TryAssignTextValue(binding.Entry, valueType, value)) { binding.Refresh?.Invoke(); } else { SaveEntryOwner(binding.Entry); binding.Refresh?.Invoke(); } } }); binding.Refresh = delegate { binding.SuppressCallbacks = true; tMP_InputField.SetTextWithoutNotify(GetDisplayValueText(binding.Entry)); binding.SuppressCallbacks = false; }; } private void RefreshVisibleBindings() { foreach (EntryBinding visibleBinding in _visibleBindings) { visibleBinding.Refresh?.Invoke(); } } private void RefreshEntryLayout() { if ((Object)(object)_entryListRect == (Object)null) { return; } LayoutRebuilder.ForceRebuildLayoutImmediate(_entryListRect); ScrollRect componentInParent = ((Component)_entryListRect).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { RectTransform component = ((Component)componentInParent).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component != (Object)(object)_entryListRect) { LayoutRebuilder.ForceRebuildLayoutImmediate(component); } } } private ConfigSource GetSelectedSource() { return _sources.FirstOrDefault((ConfigSource source) => string.Equals(source.Id, _selectedSourceId, StringComparison.Ordinal)); } private ConfigSection GetSelectedSection() { return GetSelectedSource()?.Sections.FirstOrDefault((ConfigSection section) => string.Equals(section.Key, _selectedSectionKey, StringComparison.Ordinal)); } private ConfigSource GetSourceForEntry(ConfigEntryBase entry) { if (entry == null) { return null; } return _sources.FirstOrDefault((ConfigSource source) => source.Sections.Any((ConfigSection section) => section.Entries.Contains(entry))); } private string GetOptionDisplayText(ConfigSource source, ConfigEntryBase entry, object option) { if (option?.ToString() == null) { _ = string.Empty; } object obj; if (entry == null) { obj = null; } else { ConfigDefinition definition = entry.Definition; obj = ((definition != null) ? definition.Key : null); } if (obj == null) { obj = string.Empty; } string arg = (string)obj; string text = source?.Localizer?.LocalizeOptionDisplayText?.Invoke(arg, option); if (!string.IsNullOrWhiteSpace(text)) { return text; } return GetOptionDisplayText(entry, option); } private static string GetEntryDisplayName(ConfigSource source, ConfigEntryBase entry) { if (entry == null || entry.Definition == (ConfigDefinition)null) { return string.Empty; } string key = entry.Definition.Key; string text = source?.Localizer?.LocalizeKeyName?.Invoke(key); if (!string.IsNullOrWhiteSpace(text)) { return text; } return key; } private static string GetSectionDisplayName(ConfigSource source, string section) { if (string.IsNullOrWhiteSpace(section)) { return "General"; } string text = source?.Localizer?.LocalizeSectionName?.Invoke(section); if (!string.IsNullOrWhiteSpace(text)) { return text; } return section; } private static int GetEntrySortIndex(ConfigSource source, ConfigEntryBase entry) { if (source == null || !source.IsShootZombies) { return int.MaxValue; } return Plugin.GetOwnedConfigEntrySortIndexRuntime(entry); } private static int GetSectionSortIndex(ConfigSource source, string section) { if (source == null || !source.IsShootZombies) { return int.MaxValue; } return Plugin.GetOwnedConfigSectionSortIndexRuntime(section); } private string GetDisplayValueText(ConfigEntryBase entry) { object boxedValue = GetBoxedValue(entry); if (boxedValue == null) { return string.Empty; } if (boxedValue is float num) { if (ShouldRenderWithSingleDecimal(entry)) { return num.ToString("0.0", CultureInfo.InvariantCulture); } return num.ToString("0.###", CultureInfo.InvariantCulture); } if (boxedValue is double num2) { if (ShouldRenderWithSingleDecimal(entry)) { return num2.ToString("0.0", CultureInfo.InvariantCulture); } return num2.ToString("0.###", CultureInfo.InvariantCulture); } return boxedValue.ToString(); } private static string GetOptionDisplayText(ConfigEntryBase entry, object option) { string text = option?.ToString() ?? string.Empty; if (entry == Plugin.ConfigPanelTheme) { return GetPanelThemeOptionDisplayText(text); } if (entry == Plugin.AkSoundSelection) { return GetAkSoundOptionDisplayText(text); } if (entry == Plugin.WeaponSelection) { return text switch { "AK47" => "AK47", "HK416" => "HK416", "MPX" => "MPX", _ => text, }; } if (entry == Plugin.ZombieBehaviorDifficulty) { return Plugin.GetZombieBehaviorDifficultyDisplayNameRuntime(text); } return text; } private static string GetEntryDisplayName(bool isShootZombies, ConfigEntryBase entry) { if (entry == null || entry.Definition == (ConfigDefinition)null) { return string.Empty; } if (!isShootZombies) { return entry.Definition.Key; } return Plugin.GetLocalizedConfigKeyDisplayRuntime(entry.Definition.Key); } private static string GetEntryDescriptionText(ConfigSource source, ConfigEntryBase entry) { if (source != null && ((entry != null) ? entry.Definition : null) != (ConfigDefinition)null) { string text = source.Localizer?.LocalizeDescription?.Invoke(entry.Definition.Key); if (!string.IsNullOrWhiteSpace(text)) { return text; } } object obj; if (entry == null) { obj = null; } else { ConfigDescription description = entry.Description; obj = ((description != null) ? description.Description : null); } if (obj == null) { obj = string.Empty; } return (string)obj; } private static string GetEntrySupplementalText(ConfigSource source, ConfigEntryBase entry) { if (source != null && source.IsShootZombies && entry == Plugin.ZombieBehaviorDifficulty) { return Plugin.GetZombieBehaviorDifficultyDetailsRuntime(); } return string.Empty; } private static string GetSectionDisplayName(bool isShootZombies, string section) { if (string.IsNullOrWhiteSpace(section)) { return "General"; } if (!isShootZombies) { return section; } return Plugin.GetLocalizedConfigSectionDisplayRuntime(section); } private static int GetEntrySortIndex(bool isShootZombies, ConfigEntryBase entry) { if (!isShootZombies) { return int.MaxValue; } return Plugin.GetOwnedConfigEntrySortIndexRuntime(entry); } private static int GetSectionSortIndex(bool isShootZombies, string section) { if (!isShootZombies) { return int.MaxValue; } return Plugin.GetOwnedConfigSectionSortIndexRuntime(section); } private static object GetBoxedValue(ConfigEntryBase entry) { return ((object)entry)?.GetType().GetProperty("BoxedValue", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(entry); } private static bool TryAssignBoxedValue(ConfigEntryBase entry, object value) { if (entry == null) { return false; } try { ((object)entry).GetType().GetProperty("BoxedValue", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(entry, value); return true; } catch { return false; } } private bool TryAssignTextValue(ConfigEntryBase entry, Type valueType, string text) { if (entry == null) { return false; } try { if (valueType == typeof(string)) { TryAssignBoxedValue(entry, text ?? string.Empty); return true; } if (valueType == typeof(int)) { if (!int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) && !int.TryParse(text, NumberStyles.Integer, CultureInfo.CurrentCulture, out result)) { return false; } if (TryGetNumericRange(entry, out var min, out var max)) { result = Mathf.Clamp(result, Mathf.RoundToInt((float)min), Mathf.RoundToInt((float)max)); } return TryAssignBoxedValue(entry, result); } if (valueType == typeof(float)) { if (!float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && !float.TryParse(text, NumberStyles.Float, CultureInfo.CurrentCulture, out result2)) { return false; } if (TryGetNumericRange(entry, out var min2, out var max2)) { result2 = Mathf.Clamp(result2, (float)min2, (float)max2); } return TryAssignBoxedValue(entry, result2); } if (valueType == typeof(double)) { if (!double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result3) && !double.TryParse(text, NumberStyles.Float, CultureInfo.CurrentCulture, out result3)) { return false; } if (TryGetNumericRange(entry, out var min3, out var max3)) { result3 = Math.Min(Math.Max(result3, min3), max3); } return TryAssignBoxedValue(entry, result3); } if (valueType.IsEnum) { object value = Enum.Parse(valueType, text, ignoreCase: true); return TryAssignBoxedValue(entry, value); } entry.SetSerializedValue(text ?? string.Empty); return true; } catch { return false; } } private void SaveEntryOwner(ConfigEntryBase entry) { ConfigSource configSource = _sources.ToArray().FirstOrDefault((ConfigSource source) => source.Sections.Any((ConfigSection section) => section.Entries.Contains(entry))); if (configSource != null && configSource.IsShootZombies) { _owner?.SaveOwnedConfigRuntime(); } else if (configSource != null) { ConfigFile config = configSource.Config; if (config != null) { config.Save(); } } if (entry == Plugin.ConfigPanelTheme) { SyncThemeFromConfig(); _isDirty = true; } } private static Type GetEntryValueType(ConfigEntryBase entry) { Type type = ((object)entry)?.GetType(); while (type != null) { if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(ConfigEntry<>)) { return type.GetGenericArguments()[0]; } type = type.BaseType; } return GetBoxedValue(entry)?.GetType() ?? typeof(string); } private static bool TryGetSelectableOptions(ConfigEntryBase entry, Type valueType, out List options) { options = new List(); if (valueType.IsEnum) { options.AddRange(Enum.GetValues(valueType).Cast()); return options.Count > 0; } if (entry != null) { string[] ownedSelectableConfigValuesRuntime = Plugin.GetOwnedSelectableConfigValuesRuntime(entry); if (ownedSelectableConfigValuesRuntime.Length != 0) { options.AddRange(ownedSelectableConfigValuesRuntime.Cast()); return true; } } object obj; if (entry == null) { obj = null; } else { ConfigDescription description = entry.Description; obj = ((description != null) ? description.AcceptableValues : null); } object obj2 = obj; if (obj2 == null) { return false; } if ((obj2.GetType().GetProperty("AcceptableValues", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj2) ?? obj2.GetType().GetField("AcceptableValues", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj2)) is IEnumerable enumerable) { foreach (object item in enumerable) { options.Add(item); } } return options.Count > 0; } private static bool TryGetNumericRange(ConfigEntryBase entry, out double min, out double max) { min = 0.0; max = 0.0; object obj; if (entry == null) { obj = null; } else { ConfigDescription description = entry.Description; obj = ((description != null) ? description.AcceptableValues : null); } object obj2 = obj; if (obj2 == null) { return false; } object obj3 = obj2.GetType().GetProperty("MinValue", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj2) ?? obj2.GetType().GetField("MinValue", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj2); object obj4 = obj2.GetType().GetProperty("MaxValue", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj2) ?? obj2.GetType().GetField("MaxValue", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj2); if (obj3 == null || obj4 == null) { return false; } try { min = Convert.ToDouble(obj3, CultureInfo.InvariantCulture); max = Convert.ToDouble(obj4, CultureInfo.InvariantCulture); return true; } catch { return false; } } private static int CountFractionDigits(double value) { string text = Math.Abs(value).ToString("0.###", CultureInfo.InvariantCulture); int num = text.IndexOf('.'); if (num < 0) { return 0; } return text.Length - num - 1; } private static string NormalizeNumericFormatEntryKey(string key) { if (string.IsNullOrWhiteSpace(key)) { return string.Empty; } return key.Trim(); } private static bool IsFogSpeedEntry(ConfigEntryBase entry) { object key; if (entry == null) { key = null; } else { ConfigDefinition definition = entry.Definition; key = ((definition != null) ? definition.Key : null); } string a = NormalizeNumericFormatEntryKey((string)key); if (!string.Equals(a, "Fog Speed", StringComparison.OrdinalIgnoreCase) && !string.Equals(a, "FogSpeed", StringComparison.OrdinalIgnoreCase) && !string.Equals(a, "毒雾移动速度", StringComparison.Ordinal)) { return string.Equals(a, "毒速", StringComparison.Ordinal); } return true; } private static bool ShouldRenderWithSingleDecimal(ConfigEntryBase entry) { if (entry != Plugin.FireInterval) { return IsFogSpeedEntry(entry); } return true; } private static int GetNumericStepScale(ConfigEntryBase entry, Type entryValueType, double min, double max) { if (entryValueType == typeof(int)) { return 1; } if (ShouldRenderWithSingleDecimal(entry)) { return 10; } double value = 0.0; try { object boxedValue = GetBoxedValue(entry); if (boxedValue is float num) { value = num; } else if (boxedValue is double num2) { value = num2; } else if (boxedValue is int) { int num3 = (int)boxedValue; value = num3; } } catch { } return Math.Max(CountFractionDigits(min), Math.Max(CountFractionDigits(max), CountFractionDigits(value))) switch { 1 => 10, 2 => 100, 3 => 1000, _ => 1, }; } private static bool TryGetScaledNumericRange(ConfigEntryBase entry, Type entryValueType, out int scaledMin, out int scaledMax, out int scale) { scaledMin = 0; scaledMax = 0; scale = 1; if (!TryGetNumericRange(entry, out var min, out var max)) { return false; } scale = GetNumericStepScale(entry, entryValueType, min, max); scaledMin = Mathf.RoundToInt((float)(min * (double)scale)); scaledMax = Mathf.RoundToInt((float)(max * (double)scale)); if (scaledMax < scaledMin) { int num = scaledMax; int num2 = scaledMin; scaledMin = num; scaledMax = num2; } return true; } private static int GetScaledNumericValue(ConfigEntryBase entry, Type entryValueType, int scale) { object boxedValue = GetBoxedValue(entry); if (entryValueType == typeof(int)) { return Convert.ToInt32(boxedValue ?? ((object)0), CultureInfo.InvariantCulture); } if (entryValueType == typeof(double)) { return Mathf.RoundToInt((float)(Convert.ToDouble(boxedValue ?? ((object)0.0), CultureInfo.InvariantCulture) * (double)scale)); } return Mathf.RoundToInt(Convert.ToSingle(boxedValue ?? ((object)0f), CultureInfo.InvariantCulture) * (float)scale); } private static bool TryAssignScaledNumericValue(ConfigEntryBase entry, Type entryValueType, int scaledValue, int scale) { if (entryValueType == typeof(int)) { return TryAssignBoxedValue(entry, scaledValue); } if (entryValueType == typeof(double)) { return TryAssignBoxedValue(entry, (double)scaledValue / (double)scale); } return TryAssignBoxedValue(entry, (float)scaledValue / (float)scale); } private static bool ValuesEqual(object left, object right) { if (left == null && right == null) { return true; } if (left == null || right == null) { return false; } if (left.Equals(right)) { return true; } return string.Equals(left.ToString(), right.ToString(), StringComparison.OrdinalIgnoreCase); } private void EnsureWindowRectInitialized(bool forceReset = false) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (!forceReset && ((Rect)(ref _windowRect)).width > 100f && ((Rect)(ref _windowRect)).height > 100f) { ClampWindowRectToScreen(); return; } float num = Mathf.Clamp((float)Screen.width * 0.64f, 900f, 1360f); float num2 = Mathf.Clamp((float)Screen.height * 0.52f, 460f, 760f); _windowRect = new Rect(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2); ClampWindowRectToScreen(); } private void ClampWindowRectToScreen() { if (!(((Rect)(ref _windowRect)).width <= 0f) && !(((Rect)(ref _windowRect)).height <= 0f)) { float num = Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _windowRect)).width); float num2 = Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _windowRect)).height); ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, num); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, num2); } } private bool HandleOutsideWindowClick() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if (current == null || (int)current.type != 0 || current.button < 0) { return false; } if (((Rect)(ref _windowRect)).Contains(current.mousePosition)) { return false; } Close(); current.Use(); return true; } private void RenderImmediateGui() { //IL_0089: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_00fd: 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_0107: 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_006a: Unknown result type (might be due to invalid IL or missing references) if (!_isOpen) { return; } EnsureWindowRectInitialized(); EnsureImmediateStyles(); if (_pendingRenderDiagnostic) { _pendingRenderDiagnostic = false; if (Plugin.ShouldEmitVerboseInfoLogsRuntime()) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[ShootZombies] LobbyConfigPanel OnGUI active. sources={_sources.Count}, selectedSource={_selectedSourceId}, selectedSection={_selectedSectionKey}, rect={_windowRect}."); } } } GUI.depth = -1000; Color color = GUI.color; GUI.color = Color.white; GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)GetSolidTexture(GetImmediateBackdropColor())); if (HandleOutsideWindowClick()) { GUI.color = color; GUIUtility.ExitGUI(); } else { _windowRect = GUI.Window(GetHashCode(), _windowRect, new WindowFunction(DrawImmediateWindow), string.Empty, _immediateWindowStyle); GUI.color = color; ClampWindowRectToScreen(); } } private void MaybeLogDiagnostics() { if (!_isOpen || Time.unscaledTime < _nextDiagnosticLogTime) { return; } ConfigSource selectedSource = GetSelectedSource(); ConfigSection selectedSection = GetSelectedSection(); int valueOrDefault = (selectedSource?.Sections?.Count).GetValueOrDefault(); int valueOrDefault2 = (selectedSection?.Entries?.Count).GetValueOrDefault(); string text = string.Format("{0}|{1}|{2}|{3}|{4}", _sources.Count, selectedSource?.DisplayName ?? "", valueOrDefault, selectedSection?.DisplayName ?? "", valueOrDefault2); if (!string.Equals(text, _lastDiagnosticSummary, StringComparison.Ordinal)) { _lastDiagnosticSummary = text; if (Plugin.ShouldEmitVerboseInfoLogsRuntime()) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)string.Format("[ShootZombies] LobbyConfigPanel data sources={0}, selectedSource={1}, sections={2}, selectedSection={3}, entries={4}.", _sources.Count, selectedSource?.DisplayName ?? "", valueOrDefault, selectedSection?.DisplayName ?? "", valueOrDefault2)); } } } _nextDiagnosticLogTime = Time.unscaledTime + 5f; } private void DrawImmediateWindow(int windowId) { //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_003d: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_0241: 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_02f7: 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_0331: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) GUIStyle immediateLabelStyle = _immediateLabelStyle; GUIStyle immediateTitleStyle = _immediateTitleStyle; GUIStyle immediateDescriptionStyle = _immediateDescriptionStyle; GUIStyle immediateCardStyle = _immediateCardStyle; float width = ((Rect)(ref _windowRect)).width; float height = ((Rect)(ref _windowRect)).height; Color backgroundColor = GUI.backgroundColor; Color contentColor = GUI.contentColor; GUI.Label(new Rect(14f, 8f, width - 136f, 20f), GetSelectedSource()?.DisplayName ?? "Config", immediateTitleStyle); Rect val = new Rect(width - 78f, 6f, 32f, 22f); GUI.backgroundColor = GetImmediateThemeButtonColor(_panelTheme, active: true); GUI.contentColor = GetImmediateThemeButtonTextColor(_panelTheme, active: true); if (GUI.Button(val, GetThemeToggleIcon(), _immediateButtonStyle)) { ToggleTheme(); GUI.backgroundColor = backgroundColor; GUI.contentColor = contentColor; GUIUtility.ExitGUI(); return; } GUI.backgroundColor = GetImmediateButtonColor(active: true); GUI.contentColor = contentColor; if (GUI.Button(new Rect(width - 38f, 6f, 26f, 22f), "x", _immediateButtonStyle)) { GUI.backgroundColor = backgroundColor; GUI.contentColor = contentColor; Close(); GUIUtility.ExitGUI(); return; } GUI.backgroundColor = backgroundColor; GUI.contentColor = contentColor; float num = 34f; float num2 = 12f; float num3 = height - num - 14f; float num4 = 156f; float num5 = width - num4 - 34f; GUILayout.BeginArea(new Rect(num2, num, width - num2 * 2f, 30f)); GUILayout.BeginHorizontal(Array.Empty()); ConfigSource[] array = _sources.ToArray(); foreach (ConfigSource configSource in array) { Color backgroundColor2 = GUI.backgroundColor; GUI.backgroundColor = GetImmediateButtonColor(string.Equals(configSource.Id, _selectedSourceId, StringComparison.Ordinal)); if (GUILayout.Button(configSource.DisplayName, _immediateButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(124f), GUILayout.Height(24f) })) { _selectedSourceId = configSource.Id; _selectedSectionKey = string.Empty; RefreshDataModel(); } GUI.backgroundColor = backgroundColor2; GUILayout.Space(6f); } GUILayout.EndHorizontal(); GUILayout.EndArea(); GUI.Box(new Rect(num2, num + 32f, num4, num3 - 32f), GUIContent.none, _immediatePaneStyle); GUI.Label(new Rect(num2 + 8f, num + 40f, num4 - 16f, 22f), GetSectionsLabel(), immediateTitleStyle); ConfigSource selectedSource = GetSelectedSource(); float num6 = num + 70f; if (selectedSource != null) { ConfigSection[] array2 = selectedSource.Sections.ToArray(); foreach (ConfigSection configSection in array2) { Color backgroundColor3 = GUI.backgroundColor; GUI.backgroundColor = GetImmediateButtonColor(string.Equals(configSection.Key, _selectedSectionKey, StringComparison.Ordinal)); if (GUI.Button(new Rect(num2 + 12f, num6, num4 - 24f, 32f), configSection.DisplayName, _immediateButtonStyle)) { _selectedSectionKey = configSection.Key; } GUI.backgroundColor = backgroundColor3; num6 += 38f; } } float num7 = num2 + num4 + 10f; GUI.Box(new Rect(num7, num + 32f, num5, num3 - 32f), GUIContent.none, _immediatePaneStyle); string text = GetSelectedSection()?.DisplayName ?? string.Empty; string text2 = ((!string.IsNullOrWhiteSpace(text)) ? ((selectedSource?.DisplayName ?? "Config") + " / " + text) : (selectedSource?.DisplayName ?? "Config")); GUI.Label(new Rect(num7 + 10f, num + 40f, num5 - 20f, 24f), text2, immediateTitleStyle); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num7 + 10f, num + 72f, num5 - 20f, num3 - 82f); GUILayout.BeginArea(val2); _entryScrollPosition = GUILayout.BeginScrollView(_entryScrollPosition, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, Array.Empty()); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(((Rect)(ref val2)).width - 22f) }); ConfigSection selectedSection = GetSelectedSection(); if (selectedSection == null || selectedSection.Entries.Count == 0) { GUILayout.Space(8f); GUILayout.Label(GetNoVisibleEntriesLabel(), immediateLabelStyle, Array.Empty()); } else { ConfigEntryBase[] array3 = selectedSection.Entries.ToArray(); foreach (ConfigEntryBase entry in array3) { DrawImmediateEntry(selectedSource, entry, immediateLabelStyle, immediateTitleStyle, immediateDescriptionStyle, immediateCardStyle); GUILayout.Space(8f); } } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); GUI.DragWindow(new Rect(0f, 0f, width - 54f, 36f)); } private void DrawImmediateEntry(ConfigSource source, ConfigEntryBase entry, GUIStyle labelStyle, GUIStyle titleStyle, GUIStyle descriptionStyle, GUIStyle cardStyle) { float immediateEntryTitleWidth = GetImmediateEntryTitleWidth(); float immediateDescriptionWidth = GetImmediateDescriptionWidth(); GUILayout.BeginVertical(cardStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label(GetEntryDisplayName(source, entry), titleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(immediateEntryTitleWidth) }); GUILayout.Space(12f); DrawImmediateEntryControlStableV2(entry); GUILayout.EndHorizontal(); string entryDescriptionText = GetEntryDescriptionText(source, entry); if (!string.IsNullOrWhiteSpace(entryDescriptionText)) { GUILayout.Space(4f); GUILayout.Label(entryDescriptionText, descriptionStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(immediateDescriptionWidth) }); } string entrySupplementalText = GetEntrySupplementalText(source, entry); if (!string.IsNullOrWhiteSpace(entrySupplementalText)) { GUILayout.Space(6f); GUILayout.Label(entrySupplementalText, descriptionStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(immediateDescriptionWidth) }); } GUILayout.EndVertical(); } private void DrawImmediateEntryControlStable(ConfigEntryBase entry) { //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Invalid comparison between Unknown and I4 //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Invalid comparison between Unknown and I4 Type entryValueType = GetEntryValueType(entry); if (entryValueType == typeof(bool)) { object boxedValue2 = GetBoxedValue(entry); bool flag = default(bool); int num; if (boxedValue2 is bool) { flag = (bool)boxedValue2; num = 1; } else { num = 0; } bool flag2 = (byte)((uint)num & (flag ? 1u : 0u)) != 0; bool flag3 = GUILayout.Toggle(flag2, GetToggleStateLabel(flag2), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(92f), GUILayout.Height(28f) }); if (flag3 != flag2) { TryAssignBoxedValue(entry, flag3); SaveEntryOwner(entry); } } else if (entryValueType == typeof(KeyCode)) { if (GUILayout.Button((_pendingKeyCaptureEntry == entry) ? "鎸変换鎰忛敭..." : GetDisplayValueText(entry), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(280f), GUILayout.Height(28f) })) { _pendingKeyCaptureEntry = entry; _pendingKeyCaptureText = null; } } else { if (TryDrawImmediateRangeControlStable(entry, entryValueType)) { return; } if (TryGetSelectableOptions(entry, entryValueType, out var options) && options.Count > 0) { if (ShouldRenderOptionSelectionBoxStable(entry)) { DrawImmediateOptionSelectionBoxStable(entry, options); return; } object boxedValue = GetBoxedValue(entry); int num2 = Mathf.Max(0, options.FindIndex((object option) => ValuesEqual(option, boxedValue))); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(280f) }); if (GUILayout.Button("<", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(28f), GUILayout.Height(28f) })) { num2 = (num2 - 1 + options.Count) % options.Count; TryAssignBoxedValue(entry, options[num2]); SaveEntryOwner(entry); } GUILayout.Box(GetOptionDisplayText(GetSourceForEntry(entry), entry, options[num2]), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(220f), GUILayout.Height(28f) }); if (GUILayout.Button(">", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(28f), GUILayout.Height(28f) })) { num2 = (num2 + 1) % options.Count; TryAssignBoxedValue(entry, options[num2]); SaveEntryOwner(entry); } GUILayout.EndHorizontal(); } else { string value; string text = ((!_textBufferByEntry.TryGetValue(entry, out value)) ? GetDisplayValueText(entry) : value); ConfigDefinition definition = entry.Definition; string obj = ((definition != null) ? definition.Section : null) ?? string.Empty; ConfigDefinition definition2 = entry.Definition; string text2 = "cfg_" + obj + "_" + (((definition2 != null) ? definition2.Key : null) ?? string.Empty); GUI.SetNextControlName(text2); string text3 = GUILayout.TextField(text ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(280f), GUILayout.Height(28f) }); if (!string.Equals(text3, text, StringComparison.Ordinal)) { _textBufferByEntry[entry] = text3; } bool flag4 = string.Equals(GUI.GetNameOfFocusedControl(), text2, StringComparison.Ordinal); if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 13 && flag4) { CommitBufferedEntryText(entry, entryValueType); GUI.FocusControl((string)null); Event.current.Use(); } if (!flag4 && _textBufferByEntry.TryGetValue(entry, out var _) && !string.Equals(_textBufferByEntry[entry], GetDisplayValueText(entry), StringComparison.Ordinal)) { CommitBufferedEntryText(entry, entryValueType); } } } } private void DrawImmediateEntryControlStableV2(ConfigEntryBase entry) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Invalid comparison between Unknown and I4 //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Invalid comparison between Unknown and I4 Type entryValueType = GetEntryValueType(entry); float immediateCompactControlWidth = GetImmediateCompactControlWidth(); if (entryValueType == typeof(bool)) { object boxedValue2 = GetBoxedValue(entry); bool flag = default(bool); int num; if (boxedValue2 is bool) { flag = (bool)boxedValue2; num = 1; } else { num = 0; } bool flag2 = (byte)((uint)num & (flag ? 1u : 0u)) != 0; Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = GetImmediateButtonColor(flag2); if (GUILayout.Button(GetToggleStateLabel(flag2), _immediateButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(92f), GUILayout.Height(28f) })) { TryAssignBoxedValue(entry, !flag2); SaveEntryOwner(entry); } GUI.backgroundColor = backgroundColor; } else if (entryValueType == typeof(KeyCode)) { string obj = ((_pendingKeyCaptureEntry == entry) ? GetPressAnyKeyLabel() : GetDisplayValueText(entry)); Color backgroundColor2 = GUI.backgroundColor; GUI.backgroundColor = GetImmediateButtonColor(active: false); if (GUILayout.Button(obj, _immediateButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(immediateCompactControlWidth), GUILayout.Height(28f) })) { _pendingKeyCaptureEntry = entry; _pendingKeyCaptureText = null; } GUI.backgroundColor = backgroundColor2; } else { if (TryDrawImmediateRangeControlStableV2(entry, entryValueType)) { return; } if (TryGetSelectableOptions(entry, entryValueType, out var options) && options.Count > 0) { if (ShouldRenderOptionSelectionBoxStable(entry)) { DrawImmediateOptionSelectionBoxStableV2(entry, options); return; } object boxedValue = GetBoxedValue(entry); int num2 = Mathf.Max(0, options.FindIndex((object option) => ValuesEqual(option, boxedValue))); float num3 = Mathf.Clamp(immediateCompactControlWidth - 60f, 180f, 360f); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(immediateCompactControlWidth) }); Color backgroundColor3 = GUI.backgroundColor; GUI.backgroundColor = GetImmediateButtonColor(active: false); if (GUILayout.Button("<", _immediateButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(28f), GUILayout.Height(28f) })) { num2 = (num2 - 1 + options.Count) % options.Count; TryAssignBoxedValue(entry, options[num2]); SaveEntryOwner(entry); } GUILayout.Box(GetOptionDisplayText(GetSourceForEntry(entry), entry, options[num2]), _immediateFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(num3), GUILayout.Height(28f) }); if (GUILayout.Button(">", _immediateButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(28f), GUILayout.Height(28f) })) { num2 = (num2 + 1) % options.Count; TryAssignBoxedValue(entry, options[num2]); SaveEntryOwner(entry); } GUI.backgroundColor = backgroundColor3; GUILayout.EndHorizontal(); } else { string value; string text = ((!_textBufferByEntry.TryGetValue(entry, out value)) ? GetDisplayValueText(entry) : value); ConfigDefinition definition = entry.Definition; string obj2 = ((definition != null) ? definition.Section : null) ?? string.Empty; ConfigDefinition definition2 = entry.Definition; string text2 = "cfg_" + obj2 + "_" + (((definition2 != null) ? definition2.Key : null) ?? string.Empty); GUI.SetNextControlName(text2); string text3 = GUILayout.TextField(text ?? string.Empty, _immediateTextFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(immediateCompactControlWidth), GUILayout.Height(28f) }); if (!string.Equals(text3, text, StringComparison.Ordinal)) { _textBufferByEntry[entry] = text3; } bool flag3 = string.Equals(GUI.GetNameOfFocusedControl(), text2, StringComparison.Ordinal); if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 13 && flag3) { CommitBufferedEntryText(entry, entryValueType); GUI.FocusControl((string)null); Event.current.Use(); } if (!flag3 && _textBufferByEntry.TryGetValue(entry, out var _) && !string.Equals(_textBufferByEntry[entry], GetDisplayValueText(entry), StringComparison.Ordinal)) { CommitBufferedEntryText(entry, entryValueType); } } } } private bool TryDrawImmediateRangeControlStableV2(ConfigEntryBase entry, Type entryValueType) { if ((entryValueType != typeof(int) && entryValueType != typeof(float) && entryValueType != typeof(double)) || !TryGetScaledNumericRange(entry, entryValueType, out var scaledMin, out var scaledMax, out var scale)) { return false; } float immediateRangeControlWidth = GetImmediateRangeControlWidth(); float immediateRangeSliderWidth = GetImmediateRangeSliderWidth(); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(immediateRangeControlWidth) }); int scaledNumericValue = GetScaledNumericValue(entry, entryValueType, scale); int num = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)scaledNumericValue, (float)scaledMin, (float)scaledMax, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(immediateRangeSliderWidth) })); num = Mathf.Clamp(num, scaledMin, scaledMax); if (num != scaledNumericValue && TryAssignScaledNumericValue(entry, entryValueType, num, scale)) { SaveEntryOwner(entry); } GUILayout.Space(10f); GUILayout.Label(GetDisplayValueText(entry), _immediateLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); GUILayout.EndHorizontal(); return true; } private void DrawImmediateOptionSelectionBoxStableV2(ConfigEntryBase entry, List options) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) object right = GetBoxedValue(entry); int count = options.Count; float num = 86f; GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num * (float)count + 6f * (float)(count - 1)) }); for (int i = 0; i < options.Count; i += count) { GUILayout.BeginHorizontal(Array.Empty()); for (int j = i; j < Mathf.Min(i + count, options.Count); j++) { object obj = options[j]; bool flag = ValuesEqual(obj, right); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = GetImmediateButtonColor(flag); if (GUILayout.Button(GetOptionDisplayText(GetSourceForEntry(entry), entry, obj), _immediateButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(num), GUILayout.Height(28f) }) && !flag) { TryAssignBoxedValue(entry, obj); SaveEntryOwner(entry); right = obj; } GUI.backgroundColor = backgroundColor; if (j < Mathf.Min(i + count, options.Count) - 1) { GUILayout.Space(6f); } } GUILayout.EndHorizontal(); if (i + count < options.Count) { GUILayout.Space(4f); } } GUILayout.EndVertical(); } private bool TryDrawImmediateRangeControlStable(ConfigEntryBase entry, Type entryValueType) { if ((entryValueType != typeof(int) && entryValueType != typeof(float) && entryValueType != typeof(double)) || !TryGetScaledNumericRange(entry, entryValueType, out var scaledMin, out var scaledMax, out var scale)) { return false; } GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(380f) }); int scaledNumericValue = GetScaledNumericValue(entry, entryValueType, scale); int num = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)scaledNumericValue, (float)scaledMin, (float)scaledMax, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) })); num = Mathf.Clamp(num, scaledMin, scaledMax); if (num != scaledNumericValue && TryAssignScaledNumericValue(entry, entryValueType, num, scale)) { SaveEntryOwner(entry); } GUILayout.Space(10f); GUILayout.Label(GetDisplayValueText(entry), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); GUILayout.EndHorizontal(); return true; } private static bool ShouldRenderOptionSelectionBoxStable(ConfigEntryBase entry) { if (entry != Plugin.WeaponSelection && entry != Plugin.AkSoundSelection) { return entry == Plugin.ConfigPanelTheme; } return true; } private void DrawImmediateOptionSelectionBoxStable(ConfigEntryBase entry, List options) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_0110: Unknown result type (might be due to invalid IL or missing references) object right = GetBoxedValue(entry); int num = ((entry == Plugin.AkSoundSelection) ? options.Count : options.Count); float num2 = ((entry == Plugin.AkSoundSelection) ? 86f : 86f); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num2 * (float)num + 6f * (float)(num - 1)) }); for (int i = 0; i < options.Count; i += num) { GUILayout.BeginHorizontal(Array.Empty()); for (int j = i; j < Mathf.Min(i + num, options.Count); j++) { object obj = options[j]; bool flag = ValuesEqual(obj, right); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = (flag ? new Color(0.27f, 0.66f, 0.58f, 1f) : new Color(0.34f, 0.37f, 0.45f, 1f)); if (GUILayout.Button(GetOptionDisplayText(GetSourceForEntry(entry), entry, obj), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(num2), GUILayout.Height(28f) }) && !flag) { TryAssignBoxedValue(entry, obj); SaveEntryOwner(entry); right = obj; } GUI.backgroundColor = backgroundColor; if (j < Mathf.Min(i + num, options.Count) - 1) { GUILayout.Space(6f); } } GUILayout.EndHorizontal(); if (i + num < options.Count) { GUILayout.Space(4f); } } GUILayout.EndVertical(); } private void DrawImmediateEntryControl(ConfigEntryBase entry) { //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Invalid comparison between Unknown and I4 //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Invalid comparison between Unknown and I4 Type entryValueType = GetEntryValueType(entry); if (entryValueType == typeof(bool)) { object boxedValue2 = GetBoxedValue(entry); bool flag = default(bool); int num; if (boxedValue2 is bool) { flag = (bool)boxedValue2; num = 1; } else { num = 0; } bool flag2 = (byte)((uint)num & (flag ? 1u : 0u)) != 0; bool flag3 = GUILayout.Toggle(flag2, GetToggleStateLabel(flag2), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(80f), GUILayout.Height(28f) }); if (flag3 != flag2) { TryAssignBoxedValue(entry, flag3); SaveEntryOwner(entry); } } else if (entryValueType == typeof(KeyCode)) { if (GUILayout.Button((_pendingKeyCaptureEntry == entry) ? "鎸変换鎰忛敭..." : GetDisplayValueText(entry), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(220f), GUILayout.Height(28f) })) { _pendingKeyCaptureEntry = entry; _pendingKeyCaptureText = null; } } else { if (TryDrawImmediateRangeControl(entry, entryValueType)) { return; } if (TryGetSelectableOptions(entry, entryValueType, out var options) && options.Count > 0) { if (ShouldRenderOptionSelectionBox(entry)) { DrawImmediateOptionSelectionBox(entry, options); return; } object boxedValue = GetBoxedValue(entry); int num2 = Mathf.Max(0, options.FindIndex((object option) => ValuesEqual(option, boxedValue))); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) }); if (GUILayout.Button("<", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(28f), GUILayout.Height(28f) })) { num2 = (num2 - 1 + options.Count) % options.Count; TryAssignBoxedValue(entry, options[num2]); SaveEntryOwner(entry); } GUILayout.Box(GetOptionDisplayText(GetSourceForEntry(entry), entry, options[num2]), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(160f), GUILayout.Height(28f) }); if (GUILayout.Button(">", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(28f), GUILayout.Height(28f) })) { num2 = (num2 + 1) % options.Count; TryAssignBoxedValue(entry, options[num2]); SaveEntryOwner(entry); } GUILayout.EndHorizontal(); } else { string value; string text = ((!_textBufferByEntry.TryGetValue(entry, out value)) ? GetDisplayValueText(entry) : value); ConfigDefinition definition = entry.Definition; string obj = ((definition != null) ? definition.Section : null) ?? string.Empty; ConfigDefinition definition2 = entry.Definition; string text2 = "cfg_" + obj + "_" + (((definition2 != null) ? definition2.Key : null) ?? string.Empty); GUI.SetNextControlName(text2); string text3 = GUILayout.TextField(text ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(260f), GUILayout.Height(28f) }); if (!string.Equals(text3, text, StringComparison.Ordinal)) { _textBufferByEntry[entry] = text3; } bool flag4 = string.Equals(GUI.GetNameOfFocusedControl(), text2, StringComparison.Ordinal); if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 13 && flag4) { CommitBufferedEntryText(entry, entryValueType); GUI.FocusControl((string)null); Event.current.Use(); } if (!flag4 && _textBufferByEntry.TryGetValue(entry, out var _) && !string.Equals(_textBufferByEntry[entry], GetDisplayValueText(entry), StringComparison.Ordinal)) { CommitBufferedEntryText(entry, entryValueType); } } } } private bool TryDrawImmediateRangeControl(ConfigEntryBase entry, Type entryValueType) { if ((entryValueType != typeof(int) && entryValueType != typeof(float) && entryValueType != typeof(double)) || !TryGetScaledNumericRange(entry, entryValueType, out var scaledMin, out var scaledMax, out var scale)) { return false; } GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(320f) }); int scaledNumericValue = GetScaledNumericValue(entry, entryValueType, scale); int num = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)scaledNumericValue, (float)scaledMin, (float)scaledMax, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(240f) })); num = Mathf.Clamp(num, scaledMin, scaledMax); if (num != scaledNumericValue && TryAssignScaledNumericValue(entry, entryValueType, num, scale)) { SaveEntryOwner(entry); } GUILayout.Space(10f); GUILayout.Label(GetDisplayValueText(entry), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); GUILayout.EndHorizontal(); return true; } private static bool ShouldRenderOptionSelectionBox(ConfigEntryBase entry) { if (entry != Plugin.WeaponSelection && entry != Plugin.AkSoundSelection) { return entry == Plugin.ConfigPanelTheme; } return true; } private void DrawImmediateOptionSelectionBox(ConfigEntryBase entry, List options) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_0110: Unknown result type (might be due to invalid IL or missing references) object right = GetBoxedValue(entry); int num = ((entry == Plugin.AkSoundSelection) ? options.Count : options.Count); float num2 = ((entry == Plugin.AkSoundSelection) ? 72f : 72f); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num2 * (float)num + 6f * (float)(num - 1)) }); for (int i = 0; i < options.Count; i += num) { GUILayout.BeginHorizontal(Array.Empty()); for (int j = i; j < Mathf.Min(i + num, options.Count); j++) { object obj = options[j]; bool flag = ValuesEqual(obj, right); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = (flag ? new Color(0.27f, 0.66f, 0.58f, 1f) : new Color(0.34f, 0.37f, 0.45f, 1f)); if (GUILayout.Button(GetOptionDisplayText(GetSourceForEntry(entry), entry, obj), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(num2), GUILayout.Height(28f) }) && !flag) { TryAssignBoxedValue(entry, obj); SaveEntryOwner(entry); right = obj; } GUI.backgroundColor = backgroundColor; if (j < Mathf.Min(i + num, options.Count) - 1) { GUILayout.Space(6f); } } GUILayout.EndHorizontal(); if (i + num < options.Count) { GUILayout.Space(4f); } } GUILayout.EndVertical(); } private void CommitBufferedEntryText(ConfigEntryBase entry, Type valueType) { if (entry != null && _textBufferByEntry.TryGetValue(entry, out var value)) { if (TryAssignTextValue(entry, valueType, value)) { SaveEntryOwner(entry); _textBufferByEntry[entry] = GetDisplayValueText(entry); } else { _textBufferByEntry[entry] = GetDisplayValueText(entry); } } } private void BuildUi() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: 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_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: 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_02c7: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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_035c: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_063d: Unknown result type (might be due to invalid IL or missing references) //IL_0667: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Unknown result type (might be due to invalid IL or missing references) _rootObject = new GameObject("ShootZombiesLobbyConfigPanel", new Type[1] { typeof(RectTransform) }); _canvas = _rootObject.AddComponent(); _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = 3100; CanvasScaler obj = _rootObject.AddComponent(); obj.uiScaleMode = (ScaleMode)1; obj.referenceResolution = new Vector2(1920f, 1080f); obj.screenMatchMode = (ScreenMatchMode)0; obj.matchWidthOrHeight = 0.5f; _rootObject.AddComponent(); Object.DontDestroyOnLoad((Object)(object)_rootObject); GameObject val = CreateUiObject("Backdrop", _rootObject.transform); StretchToFill(GetRectTransform(val)); ((Graphic)val.AddComponent()).color = BackdropColor; GameObject val2 = CreateUiObject("Panel", val.transform); _panelRect = GetRectTransform(val2); ((Graphic)val2.AddComponent()).color = PanelColor; AddOutline(val2, BorderColor); ClampPanelToScreen(); GameObject val3 = CreateUiObject("Header", val2.transform); RectTransform rectTransform = GetRectTransform(val3); rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.sizeDelta = new Vector2(0f, 62f); rectTransform.anchoredPosition = Vector2.zero; ((Graphic)val3.AddComponent()).color = HeaderColor; _panelTitleText = CreateText(val3.transform, "ShootZombies", 28f, TextPrimaryColor, (TextAlignmentOptions)4097); RectTransform rectTransform2 = ((TMP_Text)_panelTitleText).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 0f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.offsetMin = new Vector2(26f, 0f); rectTransform2.offsetMax = new Vector2(-100f, 0f); Button obj2 = CreateButton(val3.transform, "x", new Color(0.55f, 0.24f, 0.24f, 1f), 22f, 40f, 32f); RectTransform component = ((Component)obj2).GetComponent(); component.anchorMin = new Vector2(1f, 0.5f); component.anchorMax = new Vector2(1f, 0.5f); component.pivot = new Vector2(1f, 0.5f); component.anchoredPosition = new Vector2(-20f, 0f); ((UnityEvent)obj2.onClick).AddListener(new UnityAction(Close)); GameObject gameObject = CreateUiObject("PluginTabs", val2.transform); _pluginTabsRect = GetRectTransform(gameObject); _pluginTabsRect.anchorMin = new Vector2(0f, 1f); _pluginTabsRect.anchorMax = new Vector2(1f, 1f); _pluginTabsRect.pivot = new Vector2(0.5f, 1f); _pluginTabsRect.sizeDelta = new Vector2(-40f, 42f); _pluginTabsRect.anchoredPosition = new Vector2(0f, -74f); GameObject val4 = CreateUiObject("Sidebar", val2.transform); RectTransform rectTransform3 = GetRectTransform(val4); rectTransform3.anchorMin = new Vector2(0f, 0f); rectTransform3.anchorMax = new Vector2(0f, 1f); rectTransform3.pivot = new Vector2(0f, 1f); rectTransform3.sizeDelta = new Vector2(250f, -134f); rectTransform3.anchoredPosition = new Vector2(20f, -124f); ((Graphic)val4.AddComponent()).color = SidebarColor; AddOutline(val4, BorderColor); RectTransform rectTransform4 = ((TMP_Text)CreateText(val4.transform, "Sections", 20f, TextPrimaryColor, (TextAlignmentOptions)257)).rectTransform; rectTransform4.anchorMin = new Vector2(0f, 1f); rectTransform4.anchorMax = new Vector2(1f, 1f); rectTransform4.pivot = new Vector2(0f, 1f); rectTransform4.sizeDelta = new Vector2(-28f, 28f); rectTransform4.anchoredPosition = new Vector2(16f, -12f); GameObject gameObject2 = CreateUiObject("SectionList", val4.transform); _sectionListRect = GetRectTransform(gameObject2); _sectionListRect.anchorMin = new Vector2(0f, 0f); _sectionListRect.anchorMax = new Vector2(1f, 1f); _sectionListRect.offsetMin = new Vector2(14f, 14f); _sectionListRect.offsetMax = new Vector2(-14f, -52f); GameObject val5 = CreateUiObject("Content", val2.transform); RectTransform rectTransform5 = GetRectTransform(val5); rectTransform5.anchorMin = new Vector2(0f, 0f); rectTransform5.anchorMax = new Vector2(1f, 1f); rectTransform5.offsetMin = new Vector2(286f, 20f); rectTransform5.offsetMax = new Vector2(-20f, -124f); ((Graphic)val5.AddComponent()).color = ContentColor; AddOutline(val5, BorderColor); GameObject val6 = CreateUiObject("ContentHeader", val5.transform); RectTransform rectTransform6 = GetRectTransform(val6); rectTransform6.anchorMin = new Vector2(0f, 1f); rectTransform6.anchorMax = new Vector2(1f, 1f); rectTransform6.pivot = new Vector2(0.5f, 1f); rectTransform6.sizeDelta = new Vector2(0f, 52f); rectTransform6.anchoredPosition = Vector2.zero; ((Graphic)val6.AddComponent()).color = HeaderColor; _contentTitleText = CreateText(val6.transform, "Config", 24f, TextPrimaryColor, (TextAlignmentOptions)4097); RectTransform rectTransform7 = ((TMP_Text)_contentTitleText).rectTransform; rectTransform7.anchorMin = new Vector2(0f, 0f); rectTransform7.anchorMax = new Vector2(1f, 1f); rectTransform7.offsetMin = new Vector2(20f, 0f); rectTransform7.offsetMax = new Vector2(-20f, 0f); CreateScrollView(val5.transform, out var _, out _entryListRect, new Vector2(16f, 16f), new Vector2(-16f, -68f)); _rootObject.AddComponent().Owner = this; ((Behaviour)_canvas).enabled = false; _rootObject.SetActive(false); } private void ClampPanelToScreen() { //IL_0031: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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) //IL_015c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_panelRect == (Object)null)) { float num = Mathf.Max((float)Screen.width, 1f); float num2 = Mathf.Max((float)Screen.height, 1f); Rect safeArea = Screen.safeArea; float num3 = Mathf.Max(Mathf.Min(((Rect)(ref safeArea)).width - 96f, ((Rect)(ref safeArea)).width * 0.76f), 960f); float num4 = Mathf.Max(Mathf.Min(((Rect)(ref safeArea)).height - 84f, ((Rect)(ref safeArea)).height * 0.74f), 620f); num3 = Mathf.Clamp(num3, 640f, Mathf.Max(((Rect)(ref safeArea)).width - 32f, 640f)); num4 = Mathf.Clamp(num4, 520f, Mathf.Max(((Rect)(ref safeArea)).height - 32f, 520f)); Vector2 anchoredPosition = ((Rect)(ref safeArea)).center - new Vector2(num * 0.5f, num2 * 0.5f); _panelRect.anchorMin = new Vector2(0.5f, 0.5f); _panelRect.anchorMax = new Vector2(0.5f, 0.5f); _panelRect.pivot = new Vector2(0.5f, 0.5f); _panelRect.sizeDelta = new Vector2(num3, num4); _panelRect.anchoredPosition = anchoredPosition; } } private void CreateScrollView(Transform parent, out RectTransform viewportRect, out RectTransform contentRect, Vector2 offsetMin, Vector2 offsetMax) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0030: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_0111: 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_0133: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateUiObject("ScrollView", parent); RectTransform rectTransform = GetRectTransform(val); rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = offsetMin; rectTransform.offsetMax = offsetMax; ((Graphic)val.AddComponent()).color = new Color(0f, 0f, 0f, 0.08f); ScrollRect obj = val.AddComponent(); obj.horizontal = false; obj.scrollSensitivity = 28f; obj.movementType = (MovementType)2; GameObject val2 = CreateUiObject("Viewport", val.transform); viewportRect = GetRectTransform(val2); StretchToFill(viewportRect); ((Graphic)val2.AddComponent()).color = Color.clear; val2.AddComponent().showMaskGraphic = false; GameObject gameObject = CreateUiObject("Content", val2.transform); contentRect = GetRectTransform(gameObject); contentRect.anchorMin = new Vector2(0f, 1f); contentRect.anchorMax = new Vector2(1f, 1f); contentRect.pivot = new Vector2(0.5f, 1f); contentRect.anchoredPosition = Vector2.zero; contentRect.sizeDelta = new Vector2(0f, 0f); obj.viewport = viewportRect; obj.content = contentRect; } private static Button CreateButton(Transform parent, string label, Color backgroundColor, float fontSize, float preferredWidth, float preferredHeight) { //IL_003d: 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_002f: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateUiObject("Button", parent); RectTransform rectTransform = GetRectTransform(obj); LayoutElement val = obj.AddComponent(); if (preferredWidth > 0f) { val.preferredWidth = preferredWidth; rectTransform.sizeDelta = new Vector2(preferredWidth, preferredHeight); } else { rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, preferredHeight); } val.preferredHeight = preferredHeight; Image val2 = obj.AddComponent(); ((Graphic)val2).color = backgroundColor; AddOutline(obj, BorderColor); Button val3 = obj.AddComponent