Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Accessibility v0.6.0
Pix.Accessibility.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] namespace Pix.Accessibility; [BepInPlugin("Pix.Accessibility", "Accessibility", "0.6.0")] public sealed class AccessibilityPlugin : BaseUnityPlugin { internal enum ThreatKind { Radar, Aggro, Attack, Damage } private enum ColorblindMode { Off, Deuteranopia, Protanopia, Tritanopia } [HarmonyPatch(typeof(Character), "Damage")] private static class Patch_Character_Damage { private static void Postfix(Character __instance, HitData hit) { //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_00b2: 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_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_0113: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_01c2: Unknown result type (might be due to invalid IL or missing references) try { if (CfgEnabled == null || !CfgEnabled.Value || CfgSrcDamageDirection == null || !CfgSrcDamageDirection.Value) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || __instance != localPlayer || hit == null) { return; } Character val = null; try { val = hit.GetAttacker(); } catch { } string text = ""; float num = 0f; Vector3 val2; if ((Object)(object)val != (Object)null) { val2 = ((Component)val).transform.position; text = SafePrefabName(((Component)val).gameObject); num = Vector3.Distance(((Component)localPlayer).transform.position, val2); _hud?.TryRegisterIconSource(val, text); } else { Vector3 val3 = hit.m_dir; if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = -((Component)localPlayer).transform.forward; } val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = Vector3.back; } ((Vector3)(ref val3)).Normalize(); val2 = ((Component)localPlayer).transform.position - val3 * 6f; text = "Unknown"; num = 6f; } float num2 = 0f; try { num2 = hit.GetTotalDamage(); } catch { try { num2 = ((DamageTypes)(ref hit.m_damage)).GetTotalDamage(); } catch { } } int severity = ((num2 >= 35f) ? 3 : ((!(num2 >= 12f)) ? 1 : 2)); PushThreat(val2, severity, ThreatKind.Damage, text, num); } catch { } } } [HarmonyPatch(typeof(MonsterAI), "SetTarget")] private static class Patch_MonsterAI_SetTarget { private static void Postfix(MonsterAI __instance, Character attacker) { //IL_00ca: 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_0121: Unknown result type (might be due to invalid IL or missing references) try { if (CfgEnabled == null || !CfgEnabled.Value || CfgSrcAggroTargeting == null || !CfgSrcAggroTargeting.Value) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)attacker == (Object)null || attacker != localPlayer) { return; } Character val = (((Object)(object)__instance != (Object)null) ? ((Component)__instance).GetComponent<Character>() : null); if (!((Object)(object)val == (Object)null) && !val.IsDead()) { string text = SafePrefabName(((Component)val).gameObject); float distance = Vector3.Distance(((Component)localPlayer).transform.position, ((Component)val).transform.position); _hud?.TryRegisterIconSource(val, text); int severity = 2; if (CfgRadarBoostDangerousMobs != null && CfgRadarBoostDangerousMobs.Value && IsDangerousPrefab(text)) { severity = 3; } PushThreat(((Component)val).transform.position, severity, ThreatKind.Aggro, text, distance); } } catch { } } } internal sealed class AccessibilityHud : MonoBehaviour { private struct Callout { public string Text; public float Until; public int Severity; } private struct ThreatSignal { public Vector3 WorldPos; public float Born; public int Severity; public ThreatKind Kind; public string Prefab; public float Distance; } private struct SpriteIcon { public Texture2D Texture; public Rect UV; public bool IsValid; } [CompilerGenerated] private sealed class <CoLoadFileIconDictionary>d__92 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string dictPath; public AccessibilityHud <>4__this; private string[] <files>5__1; private int <i>5__2; private string <file>5__3; private string <key>5__4; private string <url>5__5; private UnityWebRequest <req>5__6; private UnityWebRequestAsyncOperation <op>5__7; private bool <ok>5__8; private Texture2D <tex>5__9; private SpriteIcon <si>5__10; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CoLoadFileIconDictionary>d__92(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <files>5__1 = null; <file>5__3 = null; <key>5__4 = null; <url>5__5 = null; <req>5__6 = null; <op>5__7 = null; <tex>5__9 = null; <si>5__10 = default(SpriteIcon); <>1__state = -2; } private bool MoveNext() { //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Invalid comparison between Unknown and I4 try { int num; switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this._fileSpriteIconsByPrefab.Clear(); <>4__this._fileIconTexByPrefab.Clear(); <files>5__1 = null; try { <files>5__1 = Directory.GetFiles(dictPath, "*.png", SearchOption.TopDirectoryOnly); } catch { <files>5__1 = null; } if (<files>5__1 == null || <files>5__1.Length == 0) { <>4__this._fileIconsLoaded = true; <>4__this._fileIconsLoading = false; return false; } <i>5__2 = 0; goto IL_03ef; case 1: <>1__state = -3; goto IL_021a; case 2: { <>1__state = -1; goto IL_03c0; } IL_021a: if (!((AsyncOperation)<op>5__7).isDone) { <>2__current = null; <>1__state = 1; return true; } <ok>5__8 = false; try { <ok>5__8 = (int)<req>5__6.result == 1; } catch { <ok>5__8 = string.IsNullOrEmpty(<req>5__6.error); } if (<ok>5__8) { <tex>5__9 = null; try { <tex>5__9 = DownloadHandlerTexture.GetContent(<req>5__6); } catch { <tex>5__9 = null; } if (!((Object)(object)<tex>5__9 == (Object)null)) { try { ((Texture)<tex>5__9).filterMode = (FilterMode)1; ((Texture)<tex>5__9).wrapMode = (TextureWrapMode)1; } catch { } <>4__this._fileIconTexByPrefab[<key>5__4] = <tex>5__9; <si>5__10 = default(SpriteIcon); <si>5__10.Texture = <tex>5__9; <si>5__10.UV = new Rect(0f, 0f, 1f, 1f); <si>5__10.IsValid = true; <>4__this._fileSpriteIconsByPrefab[<key>5__4] = <si>5__10; <op>5__7 = null; <tex>5__9 = null; <si>5__10 = default(SpriteIcon); <>m__Finally1(); if (<i>5__2 % 8 == 7) { <>2__current = null; <>1__state = 2; return true; } goto IL_03c0; } } <>m__Finally1(); goto IL_03dd; IL_03c0: <file>5__3 = null; <key>5__4 = null; <url>5__5 = null; <req>5__6 = null; goto IL_03dd; IL_03ef: if (<i>5__2 < <files>5__1.Length) { <file>5__3 = <files>5__1[<i>5__2]; if (!string.IsNullOrEmpty(<file>5__3)) { <key>5__4 = null; try { <key>5__4 = Path.GetFileNameWithoutExtension(<file>5__3); } catch { <key>5__4 = null; } if (!string.IsNullOrEmpty(<key>5__4) && !<>4__this._fileIconTexByPrefab.ContainsKey(<key>5__4)) { <url>5__5 = null; try { <url>5__5 = "file:///" + <file>5__3.Replace("\\", "/"); } catch { <url>5__5 = null; } if (!string.IsNullOrEmpty(<url>5__5)) { <req>5__6 = null; try { <req>5__6 = UnityWebRequestTexture.GetTexture(<url>5__5, true); } catch { <req>5__6 = null; } if (<req>5__6 != null) { <>1__state = -3; <op>5__7 = <req>5__6.SendWebRequest(); goto IL_021a; } } } } goto IL_03dd; } <>4__this._fileIconsLoaded = true; <>4__this._fileIconsLoading = false; try { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[Accessibility] Loaded Dictionary icons: " + <>4__this._fileSpriteIconsByPrefab.Count)); } } catch { } return false; IL_03dd: num = <i>5__2 + 1; <i>5__2 = num; goto IL_03ef; } } 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; try { <req>5__6.Dispose(); } catch { } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private readonly List<Callout> _callouts = new List<Callout>(16); private readonly List<ThreatSignal> _signals = new List<ThreatSignal>(96); private float _lastSignalTime; private GUIStyle _calloutStyle; private Texture2D _bgTex; private Texture2D _bgTexStrong; private GUIStyle _iconLabelStyle; private GUIStyle _iconLabelStyleHC; private Texture2D _iconLabelBgTex; private Texture2D _shapeCircle; private Texture2D _shapeTriangle; private Texture2D _shapeDiamond; private Texture2D _shapeX; private Texture2D _whiteTex; private static Material _glMat; private Texture2D _blackTex; private static float[] _segIntensity; private static Color[] _segColor; private static int[] _segPriority; private float _nextRadarScan; private float _ringAutoAlpha; private readonly Dictionary<int, float> _radarLastPingById = new Dictionary<int, float>(256); private readonly Collider[] _radarHitsBuffer = (Collider[])(object)new Collider[256]; private bool _suspended; private bool _wasDead; private readonly Dictionary<string, SpriteIcon> _spriteIconsByPrefab = new Dictionary<string, SpriteIcon>(64); private readonly Dictionary<string, Texture2D> _iconTexByPrefab = new Dictionary<string, Texture2D>(64); private bool _fileIconsLoaded; private bool _fileIconsLoading; private readonly Dictionary<string, Texture2D> _fileIconTexByPrefab = new Dictionary<string, Texture2D>(128, StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, SpriteIcon> _fileSpriteIconsByPrefab = new Dictionary<string, SpriteIcon>(128, StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, float> _soundLastByPrefab = new Dictionary<string, float>(128); private readonly HashSet<string> _loggedNoIconForPrefab = new HashSet<string>(128); private readonly HashSet<string> _loggedPortraitFailForPrefab = new HashSet<string>(128); private readonly Dictionary<string, RenderTexture> _portraitRtByPrefab = new Dictionary<string, RenderTexture>(32); private readonly Dictionary<string, GameObject> _portraitCloneByPrefab = new Dictionary<string, GameObject>(32, StringComparer.Ordinal); private readonly Dictionary<string, float> _iconBuiltAtByPrefab = new Dictionary<string, float>(StringComparer.Ordinal); private static FieldInfo[] _spriteFields_Character; private static FieldInfo[] _spriteFields_BaseAI; private static PropertyInfo[] _spriteProps_Character; private static PropertyInfo[] _spriteProps_BaseAI; private static MethodInfo[] _spriteMethods_Character; private static MethodInfo[] _spriteMethods_BaseAI; private static bool _spriteFieldScanDone; private GameObject _iconRigRoot; private Camera _iconCam; private Light _iconLight; private void Awake() { //IL_0018: 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_0050: 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_009c: Unknown result type (might be due to invalid IL or missing references) _bgTex = MakeTex(2, 2, new Color(0f, 0f, 0f, 0.45f)); _bgTexStrong = MakeTex(2, 2, new Color(0f, 0f, 0f, 0.7f)); _whiteTex = MakeTex(1, 1, Color.white); _blackTex = MakeTex(1, 1, new Color(0f, 0f, 0f, 1f)); _iconLabelBgTex = MakeTex(2, 2, new Color(0f, 0f, 0f, 0.7f)); _shapeCircle = BuildShapeCircle(32, 32); _shapeTriangle = BuildShapeTriangle(32, 32); _shapeDiamond = BuildShapeDiamond(32, 32); _shapeX = BuildShapeX(32, 32); LoadEmbeddedIconDictionary(); } private void OnDestroy() { try { if ((Object)(object)_bgTex != (Object)null) { Object.Destroy((Object)(object)_bgTex); } } catch { } try { if ((Object)(object)_bgTexStrong != (Object)null) { Object.Destroy((Object)(object)_bgTexStrong); } } catch { } try { if ((Object)(object)_whiteTex != (Object)null) { Object.Destroy((Object)(object)_whiteTex); } } catch { } try { if ((Object)(object)_blackTex != (Object)null) { Object.Destroy((Object)(object)_blackTex); } } catch { } foreach (KeyValuePair<string, Texture2D> item in _iconTexByPrefab) { try { if ((Object)(object)item.Value != (Object)null) { Object.Destroy((Object)(object)item.Value); } } catch { } } _iconTexByPrefab.Clear(); foreach (KeyValuePair<string, Texture2D> item2 in _fileIconTexByPrefab) { try { if ((Object)(object)item2.Value != (Object)null) { Object.Destroy((Object)(object)item2.Value); } } catch { } } _fileIconTexByPrefab.Clear(); _fileSpriteIconsByPrefab.Clear(); foreach (KeyValuePair<string, RenderTexture> item3 in _portraitRtByPrefab) { try { if ((Object)(object)item3.Value != (Object)null) { item3.Value.Release(); } } catch { } } _portraitRtByPrefab.Clear(); try { if ((Object)(object)_iconCam != (Object)null) { Object.Destroy((Object)(object)((Component)_iconCam).gameObject); } } catch { } try { if ((Object)(object)_iconRigRoot != (Object)null) { Object.Destroy((Object)(object)_iconRigRoot); } } catch { } } internal void PushCallout(string text, int severity) { float unscaledTime = Time.unscaledTime; for (int i = 0; i < _callouts.Count; i++) { if (_callouts[i].Text == text) { Callout value = _callouts[i]; value.Until = Mathf.Max(value.Until, unscaledTime + Mathf.Max(0.5f, CfgCalloutSeconds.Value * 0.75f)); value.Severity = Mathf.Max(value.Severity, severity); _callouts[i] = value; return; } } _callouts.Add(new Callout { Text = text, Severity = Mathf.Clamp(severity, 1, 3), Until = unscaledTime + Mathf.Max(0.5f, CfgCalloutSeconds.Value) }); int num = Mathf.Clamp(CfgMaxQueue.Value, 1, 20); while (_callouts.Count > num) { _callouts.RemoveAt(0); } } internal void PushThreat(Vector3 worldPos, int severity, ThreatKind kind, string prefabName, float distance) { //IL_0017: 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) float unscaledTime = Time.unscaledTime; _signals.Add(new ThreatSignal { WorldPos = worldPos, Born = unscaledTime, Severity = Mathf.Clamp(severity, 1, 3), Kind = kind, Prefab = (prefabName ?? ""), Distance = Mathf.Max(0f, distance) }); if (_signals.Count > 96) { _signals.RemoveRange(0, _signals.Count - 96); } _lastSignalTime = unscaledTime; } internal bool TrySoundCooldown(string prefab, float cd) { if (string.IsNullOrEmpty(prefab)) { return false; } float unscaledTime = Time.unscaledTime; if (_soundLastByPrefab.TryGetValue(prefab, out var value) && unscaledTime - value < cd) { return false; } _soundLastByPrefab[prefab] = unscaledTime; if (_soundLastByPrefab.Count > 2048) { _soundLastByPrefab.Clear(); } return true; } internal void TryRegisterIconSource(Character ch, string prefabName) { if ((Object)(object)ch == (Object)null || string.IsNullOrEmpty(prefabName) || CfgIconsEnabled == null || !CfgIconsEnabled.Value || _spriteIconsByPrefab.ContainsKey(prefabName)) { return; } if (CfgIconUseSprite != null && CfgIconUseSprite.Value && TryExtractSpriteIcon(ch, prefabName, out var icon) && icon.IsValid) { _spriteIconsByPrefab[prefabName] = icon; if (CfgIconCutoutEnabled == null || !CfgIconCutoutEnabled.Value) { return; } try { Texture2D val = BuildCutoutFromSpriteIcon(icon); if ((Object)(object)val != (Object)null) { _iconTexByPrefab[prefabName] = val; } return; } catch { return; } } if (!_loggedNoIconForPrefab.Contains(prefabName)) { _loggedNoIconForPrefab.Add(prefabName); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[Accessibility] No sprite icon found for prefab: " + prefabName + " (will draw without icon unless portrait fallback is enabled)")); } } } private static void EnsureSpriteFieldScan() { if (_spriteFieldScanDone) { return; } _spriteFieldScanDone = true; string[] candidates = new string[7] { "m_minimapIcon", "m_mapIcon", "m_icon", "m_hudIcon", "m_portrait", "m_statusIcon", "m_alertIcon" }; string[] candidates2 = new string[7] { "MinimapIcon", "MapIcon", "Icon", "HudIcon", "Portrait", "StatusIcon", "AlertIcon" }; string[] candidates3 = new string[7] { "GetMinimapIcon", "GetMapIcon", "GetIcon", "GetHudIcon", "GetPortrait", "GetStatusIcon", "GetAlertIcon" }; _spriteFields_Character = CollectSpriteFields(typeof(Character), candidates); _spriteFields_BaseAI = CollectSpriteFields(typeof(BaseAI), candidates); _spriteProps_Character = CollectSpriteProps(typeof(Character), candidates2); _spriteProps_BaseAI = CollectSpriteProps(typeof(BaseAI), candidates2); _spriteMethods_Character = CollectSpriteMethods(typeof(Character), candidates3); _spriteMethods_BaseAI = CollectSpriteMethods(typeof(BaseAI), candidates3); if ((_spriteFields_Character != null && _spriteFields_Character.Length != 0) || (_spriteFields_BaseAI != null && _spriteFields_BaseAI.Length != 0) || (_spriteProps_Character != null && _spriteProps_Character.Length != 0) || (_spriteProps_BaseAI != null && _spriteProps_BaseAI.Length != 0) || (_spriteMethods_Character != null && _spriteMethods_Character.Length != 0) || (_spriteMethods_BaseAI != null && _spriteMethods_BaseAI.Length != 0)) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[Accessibility] Icon member scan: Character fields=" + ((_spriteFields_Character != null) ? _spriteFields_Character.Length : 0) + ", props=" + ((_spriteProps_Character != null) ? _spriteProps_Character.Length : 0) + ", methods=" + ((_spriteMethods_Character != null) ? _spriteMethods_Character.Length : 0) + " | BaseAI fields=" + ((_spriteFields_BaseAI != null) ? _spriteFields_BaseAI.Length : 0) + ", props=" + ((_spriteProps_BaseAI != null) ? _spriteProps_BaseAI.Length : 0) + ", methods=" + ((_spriteMethods_BaseAI != null) ? _spriteMethods_BaseAI.Length : 0))); } } else { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)"[Accessibility] No Sprite fields/properties/methods discovered on Character/BaseAI (this build may not expose sprite icons via members)."); } } } private static FieldInfo[] CollectSpriteFields(Type t, string[] candidates) { List<FieldInfo> list = new List<FieldInfo>(8); for (int i = 0; i < candidates.Length; i++) { try { FieldInfo field = t.GetField(candidates[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); if (field != null && typeof(Sprite).IsAssignableFrom(field.FieldType)) { list.Add(field); } } catch { } } return (list.Count > 0) ? list.ToArray() : new FieldInfo[0]; } private static PropertyInfo[] CollectSpriteProps(Type t, string[] candidates) { List<PropertyInfo> list = new List<PropertyInfo>(8); for (int i = 0; i < candidates.Length; i++) { try { PropertyInfo property = t.GetProperty(candidates[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); if (!(property == null) && typeof(Sprite).IsAssignableFrom(property.PropertyType) && (property.GetIndexParameters() == null || property.GetIndexParameters().Length == 0)) { MethodInfo getMethod = property.GetGetMethod(nonPublic: true); if (getMethod != null && getMethod.GetParameters().Length == 0) { list.Add(property); } } } catch { } } return (list.Count > 0) ? list.ToArray() : new PropertyInfo[0]; } private static MethodInfo[] CollectSpriteMethods(Type t, string[] candidates) { List<MethodInfo> list = new List<MethodInfo>(8); for (int i = 0; i < candidates.Length; i++) { try { MethodInfo method = t.GetMethod(candidates[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy, null, Type.EmptyTypes, null); if (!(method == null) && typeof(Sprite).IsAssignableFrom(method.ReturnType) && method.GetParameters().Length == 0) { list.Add(method); } } catch { } } return (list.Count > 0) ? list.ToArray() : new MethodInfo[0]; } private static bool TryExtractSpriteIcon(Character ch, string prefabName, out SpriteIcon icon) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown icon = default(SpriteIcon); EnsureSpriteFieldScan(); if ((Object)ch == (Object)null) { return false; } string pn = NormalizeIconName(prefabName); int bestScore = int.MinValue; SpriteIcon best = default(SpriteIcon); if (_spriteFields_Character != null && _spriteFields_Character.Length != 0) { for (int i = 0; i < _spriteFields_Character.Length; i++) { FieldInfo fieldInfo = _spriteFields_Character[i]; if (!(fieldInfo == null)) { Sprite val = null; try { object? value = fieldInfo.GetValue(ch); val = (Sprite)((value is Sprite) ? value : null); } catch { val = null; } Consider(val); } } } if (_spriteFields_BaseAI != null && _spriteFields_BaseAI.Length != 0) { BaseAI val2 = null; try { val2 = ((Component)ch).GetComponent<BaseAI>(); } catch { val2 = null; } if ((Object)val2 != (Object)null) { for (int j = 0; j < _spriteFields_BaseAI.Length; j++) { FieldInfo fieldInfo2 = _spriteFields_BaseAI[j]; if (!(fieldInfo2 == null)) { Sprite val3 = null; try { object? value2 = fieldInfo2.GetValue(val2); val3 = (Sprite)((value2 is Sprite) ? value2 : null); } catch { val3 = null; } Consider(val3); } } } } if (bestScore == int.MinValue) { return false; } icon = best; return true; void Consider(Sprite sp) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown try { if (!((Object)sp == (Object)null) && TryBuildSpriteIcon(sp, out var icon2)) { Texture2D texture = icon2.Texture; if (!((Object)texture == (Object)null)) { int num = 0; int width = ((Texture)texture).width; int height = ((Texture)texture).height; int num2 = width * height; num = ((num2 >= 65536) ? (num + 20) : ((num2 >= 16384) ? (num + 10) : ((num2 < 4096) ? (num + 1) : (num + 5)))); if (((Texture)texture).isReadable) { num += 5; } num += NameMatchBoost(sp, texture); if (num > bestScore) { bestScore = num; best = icon2; } } } } catch { } } int NameMatchBoost(Sprite sp, Texture2D tex) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if (string.IsNullOrEmpty(pn)) { return 0; } string text = NormalizeIconName(((Object)sp != (Object)null) ? ((Object)sp).name : null); string text2 = NormalizeIconName(((Object)tex != (Object)null) ? ((Object)tex).name : null); if (!string.IsNullOrEmpty(text) && (text.Contains(pn) || pn.Contains(text))) { return 10000; } if (!string.IsNullOrEmpty(text2) && (text2.Contains(pn) || pn.Contains(text2))) { return 8000; } return 0; } static string NormalizeIconName(string s) { if (string.IsNullOrEmpty(s)) { return string.Empty; } s = s.ToLowerInvariant(); s = s.Replace("(clone)", ""); s = s.Replace("icon", ""); s = s.Replace("ico", ""); StringBuilder stringBuilder = new StringBuilder(s.Length); foreach (char c in s) { if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) { stringBuilder.Append(c); } } return stringBuilder.ToString(); } } private static bool TryBuildSpriteIcon(Sprite sp, out SpriteIcon icon) { //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_00c3: 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) icon = default(SpriteIcon); if ((Object)(object)sp == (Object)null) { return false; } if ((Object)(object)sp.texture == (Object)null) { return false; } Texture2D texture = sp.texture; Rect textureRect = sp.textureRect; if (((Rect)(ref textureRect)).width < 1f || ((Rect)(ref textureRect)).height < 1f) { return false; } Rect uV = default(Rect); ((Rect)(ref uV))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height); icon = new SpriteIcon { Texture = texture, UV = uV, IsValid = true }; return true; } private static bool IsRingModeAlways() { string text = ((CfgRingMode != null && CfgRingMode.Value != null) ? CfgRingMode.Value.Trim() : "Auto"); return text.Equals("Always", StringComparison.OrdinalIgnoreCase); } private static bool IsRingModeAuto() { string text = ((CfgRingMode != null && CfgRingMode.Value != null) ? CfgRingMode.Value.Trim() : "Auto"); return text.Equals("Auto", StringComparison.OrdinalIgnoreCase); } private bool ShouldDrawRing() { if (CfgEnabled == null || !CfgEnabled.Value) { return false; } if (CfgRingEnabled == null || !CfgRingEnabled.Value) { return false; } if (IsRingModeAlways()) { return true; } float unscaledTime = Time.unscaledTime; float num = Mathf.Max(0f, CfgRingAutoHideSeconds.Value); return unscaledTime - _lastSignalTime <= num; } private void EnsureCalloutStyle() { //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_008f: 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_009f: 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_00b8: Expected O, but got Unknown //IL_00be: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) float num = 1f; try { if (CfgUiTextScale != null) { num = Mathf.Clamp(CfgUiTextScale.Value, 0.5f, 3f); } } catch { num = 1f; } int num2 = Mathf.Clamp(Mathf.RoundToInt((float)CfgFontSize.Value * num), 10, 64); if (_calloutStyle == null || _calloutStyle.fontSize != num2) { _calloutStyle = new GUIStyle(GUI.skin.label) { wordWrap = true, richText = true, alignment = (TextAnchor)0, fontSize = num2, padding = new RectOffset(10, 10, 8, 8) }; _calloutStyle.normal.textColor = Color.white; } } private void DrawCenterMarker() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_00e4: 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 (Event.current != null && (int)Event.current.type != 7) { return; } float num = 14f; float num2 = 2f; try { if (CfgCenterMarkerSizePx != null) { num = Mathf.Clamp(CfgCenterMarkerSizePx.Value, 4f, 120f); } } catch { } try { if (CfgCenterMarkerThicknessPx != null) { num2 = Mathf.Clamp(CfgCenterMarkerThicknessPx.Value, 1f, 12f); } } catch { } float num3 = (float)Screen.width * 0.5f; float num4 = (float)Screen.height * 0.5f; float num5 = num * 0.5f; Rect val = default(Rect); ((Rect)(ref val))..ctor(num3 - num5, num4 - num2 * 0.5f, num, num2); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num3 - num2 * 0.5f, num4 - num5, num2, num); GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(val2, (Texture)(object)Texture2D.whiteTexture); } private void Update() { //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; if (CfgEnabled != null && !CfgEnabled.Value) { if (_signals.Count > 0) { _signals.Clear(); } if (_callouts.Count > 0) { _callouts.Clear(); } _ringAutoAlpha = 0f; _suspended = true; _wasDead = false; return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { if (!_suspended) { _suspended = true; _wasDead = true; ClearTransientState(); } _ringAutoAlpha = 0f; return; } if (_suspended) { _suspended = false; if (_wasDead) { _wasDead = false; ClearTransientState(); } } for (int num = _callouts.Count - 1; num >= 0; num--) { if (_callouts[num].Until <= unscaledTime) { _callouts.RemoveAt(num); } } float num2 = Mathf.Clamp(CfgRingMaxSignalAge.Value, 0.15f, 10f); for (int num3 = _signals.Count - 1; num3 >= 0; num3--) { if (unscaledTime - _signals[num3].Born > num2) { _signals.RemoveAt(num3); } } if (CfgRingMode != null && string.Equals(CfgRingMode.Value, "Always", StringComparison.OrdinalIgnoreCase)) { _ringAutoAlpha = 1f; } else { float num4 = -999999f; for (int i = 0; i < _signals.Count; i++) { if (_signals[i].Born > num4) { num4 = _signals[i].Born; } } if (_signals.Count > 0) { float num5 = unscaledTime - num4; _ringAutoAlpha = Mathf.Clamp01(1f - num5 / Mathf.Max(0.0001f, num2)); } else { _ringAutoAlpha = 0f; } } int num6 = Mathf.Clamp(CfgRingSegments.Value, 8, 64); if (_segIntensity == null || _segIntensity.Length != num6) { _segIntensity = new float[num6]; _segColor = (Color[])(object)new Color[num6]; _segPriority = new int[num6]; } for (int j = 0; j < num6; j++) { _segIntensity[j] = 0f; _segColor[j] = Color.clear; _segPriority[j] = 0; } if (CfgSrcProximityRadar != null && CfgSrcProximityRadar.Value) { bool flag = true; if (CfgRadarMode != null && CfgRadarMode.Value != null) { string text = CfgRadarMode.Value.Trim(); if (text.Equals("Earshot", StringComparison.OrdinalIgnoreCase)) { flag = false; } } if (flag) { RadarTick(unscaledTime); } } RecomputeRingSegments(); } private void ClearTransientState() { try { _signals.Clear(); } catch { } try { _callouts.Clear(); } catch { } try { _radarLastPingById.Clear(); } catch { } try { _soundLastByPrefab.Clear(); } catch { } try { _loggedPortraitFailForPrefab.Clear(); } catch { } _nextRadarScan = 0f; _lastSignalTime = 0f; } private void RadarTick(float now) { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) if (now < _nextRadarScan) { return; } float num = Mathf.Clamp(CfgRadarIntervalSeconds.Value, 0.15f, 5f); _nextRadarScan = now + num; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return; } if (CfgRadarDisableWhileBuilding != null && CfgRadarDisableWhileBuilding.Value) { ItemData val = null; try { val = RightItemRef.Invoke((Humanoid)(object)localPlayer); } catch { } if (val != null && val.m_shared != null && val.m_shared.m_name != null && val.m_shared.m_name.IndexOf("Hammer", StringComparison.OrdinalIgnoreCase) >= 0) { return; } } float num2 = Mathf.Clamp(CfgRadarRadiusMeters.Value, 5f, 120f); float num3 = Mathf.Clamp(CfgRadarPerEnemyCooldownSeconds.Value, 0.15f, 30f); float num4 = Mathf.Clamp(CfgRadarDangerousExtraRadiusMult.Value, 1f, 4f); int mask = LayerMask.GetMask(new string[1] { "character" }); int num5 = Physics.OverlapSphereNonAlloc(((Component)localPlayer).transform.position, num2 * num4, _radarHitsBuffer, mask); for (int i = 0; i < num5; i++) { Collider val2 = _radarHitsBuffer[i]; if ((Object)(object)val2 == (Object)null) { continue; } Character componentInParent = ((Component)val2).GetComponentInParent<Character>(); if ((Object)(object)componentInParent == (Object)null || componentInParent.IsDead() || componentInParent == localPlayer || componentInParent is Player) { continue; } string text = SafePrefabName(((Component)componentInParent).gameObject); Vector3 val3 = ((Component)componentInParent).transform.position - ((Component)localPlayer).transform.position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; TryRegisterIconSource(componentInParent, text); bool flag = CfgRadarBoostDangerousMobs != null && CfgRadarBoostDangerousMobs.Value && IsDangerousPrefab(text); float num6 = (flag ? (num2 * num4) : num2); float num7 = num6 * num6; if (sqrMagnitude > num7) { continue; } float distance = Mathf.Sqrt(sqrMagnitude); int instanceID = ((Object)componentInParent).GetInstanceID(); if (_radarLastPingById.TryGetValue(instanceID, out var value) && now - value < num3) { continue; } _radarLastPingById[instanceID] = now; bool flag2 = false; if (CfgSrcAggroTargeting != null && CfgSrcAggroTargeting.Value && _aiGetTarget != null) { try { BaseAI component = ((Component)componentInParent).GetComponent<BaseAI>(); if ((Object)(object)component != (Object)null) { Character val4 = _aiGetTarget(component); if ((Object)(object)val4 != (Object)null && val4 == localPlayer) { flag2 = true; } } } catch { } } int num8 = ((!flag) ? 1 : 3); if (!flag && IsMediumThreatPrefab(text)) { num8 = 2; } ThreatKind kind = (flag2 ? ThreatKind.Aggro : ThreatKind.Radar); if (flag2) { num8 = Mathf.Max(num8, 2); } PushThreat(((Component)componentInParent).transform.position, num8, kind, text, distance); } if (_radarLastPingById.Count > 1600) { _radarLastPingById.Clear(); } } private void RecomputeRingSegments() { //IL_0066: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_013c: 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_01cd: 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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Clamp(CfgRingSegments.Value, 8, 64); if (_segIntensity == null || _segIntensity.Length != num) { return; } Player localPlayer = Player.m_localPlayer; Camera main = Camera.main; if ((Object)(object)localPlayer == (Object)null || (Object)(object)main == (Object)null) { return; } Vector3 position = ((Component)localPlayer).transform.position; Vector3 forward = ((Component)main).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { return; } ((Vector3)(ref forward)).Normalize(); float unscaledTime = Time.unscaledTime; float num2 = Mathf.Clamp(CfgRingMaxSignalAge.Value, 0.15f, 10f); for (int i = 0; i < _signals.Count; i++) { ThreatSignal threatSignal = _signals[i]; float num3 = unscaledTime - threatSignal.Born; float num4 = Mathf.Clamp01(1f - num3 / num2); Vector3 val = threatSignal.WorldPos - position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { ((Vector3)(ref val)).Normalize(); float num5 = Vector3.SignedAngle(forward, val, Vector3.up); if (num5 < 0f) { num5 += 360f; } int num6 = Mathf.FloorToInt(num5 / 360f * (float)num); if (num6 < 0) { num6 = 0; } if (num6 >= num) { num6 = num - 1; } float num7 = ((threatSignal.Severity == 3) ? 1f : ((threatSignal.Severity == 2) ? 0.72f : 0.5f)); float num8 = num7 * num4; Color c = KindColor(threatSignal.Kind); int num9 = KindPriority(threatSignal.Kind); ApplySegment(num6, num8, c, num9); float strength = num8 * 0.35f; int idx = (num6 - 1 + num) % num; int idx2 = (num6 + 1) % num; ApplySegment(idx, strength, c, num9 - 1); ApplySegment(idx2, strength, c, num9 - 1); } } } private void ApplySegment(int idx, float strength, Color c, int priority) { //IL_0054: 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) if (!(strength <= 0f) && (priority > _segPriority[idx] || (priority == _segPriority[idx] && strength > _segIntensity[idx]))) { _segPriority[idx] = priority; _segIntensity[idx] = strength; _segColor[idx] = c; } } private void OnGUI() { if (CfgEnabled == null || !CfgEnabled.Value) { return; } if (ShouldDrawRing()) { DrawThreatRing(); if (CfgIconsEnabled != null && CfgIconsEnabled.Value) { DrawThreatIcons(); } } if (CfgShowCallouts != null && CfgShowCallouts.Value && _callouts.Count > 0) { DrawCallouts(); } if (CfgCenterMarkerEnabled != null && CfgCenterMarkerEnabled.Value) { DrawCenterMarker(); } } private void DrawCallouts() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_003d: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_012f: 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) EnsureCalloutStyle(); Vector2 value = CfgAnchor.Value; value.x = Mathf.Clamp01(value.x); value.y = Mathf.Clamp01(value.y); float num = (float)Screen.width * value.x; float num2 = (float)Screen.height * value.y; float num3 = Mathf.Min(520f, (float)Screen.width * 0.45f); float num4 = num2; int num5 = Mathf.Clamp(CfgMaxQueue.Value, 1, 20); int num6 = Mathf.Max(0, _callouts.Count - num5); Rect val = default(Rect); for (int i = num6; i < _callouts.Count; i++) { Callout callout = _callouts[i]; string text = ((callout.Severity >= 2) ? ("<b>" + callout.Text + "</b>") : callout.Text); float num7 = _calloutStyle.CalcHeight(new GUIContent(text), num3); ((Rect)(ref val))..ctor(num, num4, num3, num7); if (CfgHighContrast.Value) { GUI.DrawTexture(val, (Texture)(object)((callout.Severity >= 2) ? _bgTexStrong : _bgTex), (ScaleMode)0, false); } GUI.Label(val, text, _calloutStyle); num4 += num7 + 6f; } } private void DrawThreatRing() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0131: 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_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025f: 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_01a6: 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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: 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_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: 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_02fd: Unknown result type (might be due to invalid IL or missing references) if (!CfgRingEnabled.Value || !ShouldDrawRing() || (Event.current != null && (int)Event.current.type != 7)) { return; } int num = Mathf.Clamp(CfgRingSegments.Value, 8, 64); float num2 = Mathf.Clamp(CfgRingRadiusPx.Value, 40f, 1000f); float num3 = Mathf.Clamp(CfgRingThicknessPx.Value, 2f, 128f); float num4 = Mathf.Clamp(CfgRingSegmentLengthPx.Value, 2f, 400f); float num5 = Mathf.Clamp01(CfgRingAlpha.Value) * _ringAutoAlpha; float num6 = Mathf.Clamp01(CfgRingBaseAlpha.Value) * num5; float num7 = Mathf.Clamp01(CfgRingActiveAlpha.Value) * num5; Vector2 pivot = default(Vector2); ((Vector2)(ref pivot))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.5f); if (!EnsureGlMaterial()) { for (int i = 0; i < num; i++) { DrawSingleRingSegment(i, num, num2, num3, num4, pivot, new Color(1f, 1f, 1f, num6)); } for (int j = 0; j < num; j++) { float threatValueForSegment = GetThreatValueForSegment(_segIntensity, j, num); if (!(threatValueForSegment <= 0.001f)) { Color threatColor = GetThreatColor(threatValueForSegment); threatColor.a *= num7; DrawSingleRingSegment(j, num, num2, num3, num4, pivot, threatColor); } } return; } float num8 = ((num2 > 0.01f) ? (num4 / num2) : ((float)Math.PI * 2f / (float)num)); num8 = Mathf.Clamp(num8, 0.03f, (float)Math.PI * 2f / (float)num * 0.98f); GL.PushMatrix(); _glMat.SetPass(0); GL.LoadPixelMatrix(0f, (float)Screen.width, (float)Screen.height, 0f); GL.Begin(4); if (num6 > 0.001f) { Color col = default(Color); ((Color)(ref col))..ctor(1f, 1f, 1f, num6); AddRingWedges(num, pivot, num2, num3, num8, col, Mathf.Min(8f, num3 * 0.35f)); } for (int k = 0; k < num; k++) { float threatValueForSegment2 = GetThreatValueForSegment(_segIntensity, k, num); if (!(threatValueForSegment2 <= 0.001f)) { Color threatColor2 = GetThreatColor(threatValueForSegment2); threatColor2.a *= num7; Color col2 = threatColor2; col2.a *= 0.35f; AddSingleWedge(k, num, pivot, num2 + 3f, num3 + 6f, num8 * 1.1f, col2); AddSingleWedge(k, num, pivot, num2, num3, num8, threatColor2); } } GL.End(); GL.PopMatrix(); } private void AddRingWedges(int segs, Vector2 pivot, float radius, float thickness, float angleSpan, Color col, float featherPx) { //IL_0003: 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_0023: 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_0038: 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_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_006c: 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) AddAllWedges(segs, pivot, radius, thickness, angleSpan, col); if (!(featherPx <= 0.5f)) { Color col2 = col; col2.a *= 0.35f; AddAllWedges(segs, pivot, radius + featherPx, thickness + featherPx * 2f, angleSpan * 1.02f, col2); Color col3 = col; col3.a *= 0.2f; AddAllWedges(segs, pivot, radius, Mathf.Max(1f, thickness - featherPx * 0.9f), angleSpan * 1.02f, col3); } } private void AddAllWedges(int segs, Vector2 pivot, float radius, float thickness, float angleSpan, Color col) { //IL_0008: 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) for (int i = 0; i < segs; i++) { AddSingleWedge(i, segs, pivot, radius, thickness, angleSpan, col); } } private void AddSingleWedge(int segIndex, int segs, Vector2 pivot, float radius, float thickness, float angleSpan, Color col) { //IL_004a: 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) float num = Mathf.Max(0f, radius - thickness); float outerR = Mathf.Max(num + 0.5f, radius); float num2 = (float)segIndex * ((float)Math.PI * 2f / (float)segs) - (float)Math.PI / 2f; float a = num2 - angleSpan * 0.5f; float a2 = num2 + angleSpan * 0.5f; AddWedgeTriangles(pivot, num, outerR, a, a2, col); } private void AddWedgeTriangles(Vector2 pivot, float innerR, float outerR, float a0, float a1, Color col) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_006d: 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_008d: 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_00a9: 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_00b9: 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_00c9: 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) float num = Mathf.Cos(a0); float num2 = Mathf.Sin(a0); float num3 = Mathf.Cos(a1); float num4 = Mathf.Sin(a1); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(pivot.x + num * outerR, pivot.y + num2 * outerR, 0f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(pivot.x + num3 * outerR, pivot.y + num4 * outerR, 0f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(pivot.x + num * innerR, pivot.y + num2 * innerR, 0f); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(pivot.x + num3 * innerR, pivot.y + num4 * innerR, 0f); GL.Color(col); GL.Vertex(val); GL.Vertex(val2); GL.Vertex(val4); GL.Vertex(val); GL.Vertex(val4); GL.Vertex(val3); } private bool EnsureGlMaterial() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown try { if ((Object)(object)_glMat != (Object)null) { return true; } Shader val = Shader.Find("Hidden/Internal-Colored"); if ((Object)(object)val == (Object)null) { return false; } _glMat = new Material(val); ((Object)_glMat).hideFlags = (HideFlags)61; _glMat.SetInt("_SrcBlend", 5); _glMat.SetInt("_DstBlend", 10); _glMat.SetInt("_Cull", 0); _glMat.SetInt("_ZWrite", 0); return true; } catch { _glMat = null; return false; } } private void DrawSingleRingSegment(int segIndex, int segCount, float radiusPx, float thicknessPx, float segLengthPx, Vector2 pivot, Color c) { //IL_0039: 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_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_0064: 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_006a: 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_007b: 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_0016: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_whiteTex == (Object)null) { _whiteTex = MakeTex(2, 2, Color.white); } float num = (float)segIndex * 360f / (float)segCount - 90f; Rect val = default(Rect); ((Rect)(ref val))..ctor(pivot.x - segLengthPx * 0.5f, pivot.y - radiusPx - thicknessPx, segLengthPx, thicknessPx); Matrix4x4 matrix = GUI.matrix; Color color = GUI.color; GUI.color = c; GUIUtility.RotateAroundPivot(num, pivot); GUI.DrawTexture(val, (Texture)(object)_whiteTex, (ScaleMode)0, true); GUI.matrix = matrix; GUI.color = color; } private void DrawThreatIcons() { //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_0658: Unknown result type (might be due to invalid IL or missing references) //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: 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_0378: 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_0382: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0516: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b8: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Camera main = Camera.main; if ((Object)(object)localPlayer == (Object)null || (Object)(object)main == (Object)null) { return; } float unscaledTime = Time.unscaledTime; float num = Mathf.Clamp(CfgRingMaxSignalAge.Value, 0.15f, 10f); Dictionary<string, ThreatSignal> dictionary = new Dictionary<string, ThreatSignal>(16); for (int i = 0; i < _signals.Count; i++) { ThreatSignal value = _signals[i]; if (string.IsNullOrEmpty(value.Prefab)) { continue; } float num2 = unscaledTime - value.Born; if (num2 > num) { continue; } if (!dictionary.TryGetValue(value.Prefab, out var value2)) { dictionary[value.Prefab] = value; continue; } int num3 = KindPriority(value.Kind); int num4 = KindPriority(value2.Kind); if (num3 > num4) { dictionary[value.Prefab] = value; } else if (num3 == num4) { if (value.Distance < value2.Distance - 0.01f) { dictionary[value.Prefab] = value; } else if (Mathf.Abs(value.Distance - value2.Distance) < 0.01f && value.Born > value2.Born) { dictionary[value.Prefab] = value; } } } List<ThreatSignal> list = new List<ThreatSignal>(dictionary.Values); list.Sort(delegate(ThreatSignal a, ThreatSignal b) { int value4 = KindPriority(a.Kind); int num23 = KindPriority(b.Kind).CompareTo(value4); return (num23 != 0) ? num23 : a.Distance.CompareTo(b.Distance); }); int num5 = Mathf.Clamp(CfgIconMaxVisible.Value, 1, 16); if (list.Count > num5) { list.RemoveRange(num5, list.Count - num5); } Vector3 forward = ((Component)main).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { return; } ((Vector3)(ref forward)).Normalize(); float num6 = Mathf.Clamp(CfgRingRadius.Value, 60f, 520f); float num7 = Mathf.Clamp(CfgIconRingOffsetPx.Value, 0f, 120f); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.5f); float num8 = Mathf.Clamp(CfgIconBasePx.Value, 12f, 140f); float num9 = Mathf.Clamp(CfgIconNearScale.Value, 0.5f, 3f); float num10 = Mathf.Clamp(CfgIconFarScale.Value, 0.25f, 2f); float num11 = Mathf.Max(5f, CfgRadarRadiusMeters.Value); float num12 = Mathf.Clamp(CfgRadarDangerousExtraRadiusMult.Value, 1f, 4f); bool value3 = CfgIconOutline.Value; Rect val3 = default(Rect); Rect val4 = default(Rect); for (int j = 0; j < list.Count; j++) { ThreatSignal threatSignal = list[j]; if (!TryGetIconForPrefab(threatSignal.Prefab, out var spriteIcon, out var portraitRt)) { continue; } Vector3 val2 = threatSignal.WorldPos - ((Component)localPlayer).transform.position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { continue; } ((Vector3)(ref val2)).Normalize(); float num13 = Vector3.SignedAngle(forward, val2, Vector3.up); float num14 = num13 * ((float)Math.PI / 180f); float num15 = (IsDangerousPrefab(threatSignal.Prefab) ? (num11 * num12) : num11); float num16 = Mathf.Clamp01(threatSignal.Distance / Mathf.Max(0.01f, num15)); float num17 = Mathf.Lerp(num9, num10, num16); float num18 = num8 * num17; float num19 = num6 + num7; float num20 = val.x + Mathf.Sin(num14) * num19; float num21 = val.y - Mathf.Cos(num14) * num19; Color c = KindColor(threatSignal.Kind); float num22 = 0.92f; if (threatSignal.Kind == ThreatKind.Radar) { num22 = 0.78f; } ((Rect)(ref val3))..ctor(num20 - num18 * 0.5f, num21 - num18 * 0.5f, num18, num18); if (value3) { Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.55f); ((Rect)(ref val4))..ctor(((Rect)(ref val3)).x - 2f, ((Rect)(ref val3)).y - 2f, ((Rect)(ref val3)).width + 4f, ((Rect)(ref val3)).height + 4f); GUI.DrawTexture(val4, (Texture)(object)_blackTex, (ScaleMode)0, false); GUI.color = color; } Color color2 = GUI.color; GUI.color = new Color(1f, 1f, 1f, num22); bool flag = CfgIconCutoutEnabled != null && CfgIconCutoutEnabled.Value; Texture2D val5 = EnsureIconTexture(threatSignal.Prefab, spriteIcon, portraitRt); if ((Object)(object)val5 != (Object)null) { GUI.DrawTexture(val3, (Texture)(object)val5, (ScaleMode)2, true); } else if (!flag) { if (spriteIcon.IsValid && (Object)(object)spriteIcon.Texture != (Object)null) { GUI.DrawTextureWithTexCoords(val3, (Texture)(object)spriteIcon.Texture, spriteIcon.UV, true); } else if ((Object)(object)portraitRt != (Object)null) { GUI.DrawTexture(val3, (Texture)(object)portraitRt, (ScaleMode)2, true); } } DrawThreatShapeBadge(val3, threatSignal.Kind); bool flag2 = false; try { flag2 = CfgIconLabelsEnabled != null && CfgIconLabelsEnabled.Value; } catch { flag2 = false; } if (flag2) { string displayNameForPrefab = GetDisplayNameForPrefab(threatSignal.Prefab); DrawIconLabel(val3, displayNameForPrefab); } if (CfgIconBorder != null && CfgIconBorder.Value) { DrawBorderRect(val3, c, Mathf.Lerp(3f, 2f, num16), num22); } GUI.color = color2; } } private void DrawBorderRect(Rect r, Color c, float thickness, float alpha) { //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_002d: 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_0039: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00f9: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_whiteTex == (Object)null)) { float num = Mathf.Clamp(thickness, 1f, 6f); Color color = GUI.color; GUI.color = new Color(c.r, c.g, c.b, Mathf.Clamp01(alpha)); GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, num), (Texture)(object)_whiteTex, (ScaleMode)0, false); GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - num, ((Rect)(ref r)).width, num), (Texture)(object)_whiteTex, (ScaleMode)0, false); GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, num, ((Rect)(ref r)).height), (Texture)(object)_whiteTex, (ScaleMode)0, false); GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - num, ((Rect)(ref r)).y, num, ((Rect)(ref r)).height), (Texture)(object)_whiteTex, (ScaleMode)0, false); GUI.color = color; } } private void LoadFileIconDictionary() { _fileIconsLoaded = true; _fileIconsLoading = false; } private void LoadEmbeddedIconDictionary() { //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown if (_fileIconsLoaded || _fileIconsLoading) { return; } _fileIconsLoading = true; _fileSpriteIconsByPrefab.Clear(); _fileIconTexByPrefab.Clear(); try { Assembly assembly = typeof(AccessibilityPlugin).Assembly; string[] manifestResourceNames = assembly.GetManifestResourceNames(); int num = 0; foreach (string text in manifestResourceNames) { if (string.IsNullOrEmpty(text) || !text.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) { continue; } int num2 = text.LastIndexOf('.'); if (num2 <= 0) { continue; } int num3 = text.LastIndexOf('.', num2 - 1); if (num3 < 0 || num3 >= num2) { continue; } string text2 = text.Substring(num3 + 1, num2 - num3 - 1); if (string.IsNullOrEmpty(text2) || _fileIconTexByPrefab.ContainsKey(text2)) { continue; } Stream stream = null; try { stream = assembly.GetManifestResourceStream(text); } catch { stream = null; } if (stream == null) { continue; } try { byte[] array; using (stream) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } if (array == null || array.Length < 8) { continue; } Texture2D val = null; try { int width; int height; byte[] array2 = PxDecodePngToRgba32(array, out width, out height); PxFlipRgbaVertically(array2, width, height); if (array2 == null || array2.Length == 0 || width <= 0 || height <= 0) { continue; } val = new Texture2D(width, height, (TextureFormat)4, false, false); ((Texture)val).filterMode = (FilterMode)0; ((Texture)val).wrapMode = (TextureWrapMode)1; val.LoadRawTextureData(array2); val.Apply(false, false); goto IL_022f; } catch { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } val = null; goto IL_022f; } IL_022f: if (!((Object)(object)val == (Object)null)) { try { ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; } catch { } _fileIconTexByPrefab[text2] = val; SpriteIcon value = default(SpriteIcon); value.Texture = val; value.UV = new Rect(0f, 0f, 1f, 1f); value.IsValid = true; _fileSpriteIconsByPrefab[text2] = value; num++; } } catch { } } } finally { _fileIconsLoaded = true; _fileIconsLoading = false; } } private static byte[] PxDecodePngToRgba32(byte[] png, out int width, out int height) { width = 0; height = 0; if (png == null || png.Length < 8) { return null; } if (png[0] != 137 || png[1] != 80 || png[2] != 78 || png[3] != 71 || png[4] != 13 || png[5] != 10 || png[6] != 26 || png[7] != 10) { return null; } int num = 8; int num2 = 0; int num3 = 0; byte[] array = null; uint num4; for (; num + 8 <= png.Length; num += (int)num4, num += 4) { num4 = PxReadU32BE(png, num); num += 4; if (num + 4 > png.Length) { break; } uint num5 = PxReadU32BE(png, num); num += 4; if (num + (int)num4 + 4 > png.Length) { break; } switch (num5) { case 1229472850u: width = (int)PxReadU32BE(png, num); height = (int)PxReadU32BE(png, num + 4); num2 = png[num + 8]; num3 = png[num + 9]; if (num2 != 8 || (num3 != 2 && num3 != 6)) { return null; } continue; case 1229209940u: if (num4 != 0) { if (array == null) { array = new byte[num4]; Buffer.BlockCopy(png, num, array, 0, (int)num4); } else { int num6 = array.Length; Array.Resize(ref array, num6 + (int)num4); Buffer.BlockCopy(png, num, array, num6, (int)num4); } } continue; default: continue; case 1229278788u: break; } break; } if (width <= 0 || height <= 0 || array == null || array.Length == 0) { return null; } byte[] array2 = PxInflateZlib(array); if (array2 == null || array2.Length == 0) { return null; } int num7 = ((num3 == 6) ? 4 : 3); int num8 = width * num7; int num9 = (num8 + 1) * height; if (array2.Length < num9) { return null; } byte[] array3 = new byte[num8 * height]; int num10 = 0; int num11 = 0; byte[] array4 = null; byte[] array5 = new byte[num8]; for (int i = 0; i < height; i++) { int filter = array2[num10++] & 0xFF; Buffer.BlockCopy(array2, num10, array5, 0, num8); num10 += num8; PxUnfilterRow(filter, array5, array4, num7); Buffer.BlockCopy(array5, 0, array3, num11, num8); num11 += num8; if (array4 == null) { array4 = new byte[num8]; } Buffer.BlockCopy(array5, 0, array4, 0, num8); } if (num3 == 2) { byte[] array6 = new byte[width * height * 4]; int num12 = 0; int num13 = 0; int num14 = width * height; for (int j = 0; j < num14; j++) { array6[num13++] = array3[num12++]; array6[num13++] = array3[num12++]; array6[num13++] = array3[num12++]; array6[num13++] = byte.MaxValue; } return array6; } return array3; } private static void PxUnfilterRow(int filter, byte[] row, byte[] prevRow, int bpp) { switch (filter) { case 0: break; case 1: { for (int l = bpp; l < row.Length; l++) { row[l] += row[l - bpp]; } break; } case 2: if (prevRow != null) { for (int k = 0; k < row.Length; k++) { row[k] += prevRow[k]; } } break; case 3: { if (prevRow == null) { for (int m = bpp; m < row.Length; m++) { row[m] = (byte)(row[m] + (row[m - bpp] >> 1)); } break; } for (int n = 0; n < row.Length; n++) { int num = ((n >= bpp) ? row[n - bpp] : 0); int num2 = prevRow[n]; row[n] = (byte)(row[n] + (num + num2 >> 1)); } break; } case 4: { if (prevRow == null) { for (int i = bpp; i < row.Length; i++) { row[i] += row[i - bpp]; } break; } for (int j = 0; j < row.Length; j++) { int a = ((j >= bpp) ? row[j - bpp] : 0); int b = prevRow[j]; int c = ((j >= bpp) ? prevRow[j - bpp] : 0); row[j] = (byte)(row[j] + PxPaeth(a, b, c)); } break; } } } private static int PxPaeth(int a, int b, int c) { int num = a + b - c; int num2 = Math.Abs(num - a); int num3 = Math.Abs(num - b); int num4 = Math.Abs(num - c); if (num2 <= num3 && num2 <= num4) { return a; } if (num3 <= num4) { return b; } return c; } private static void PxFlipRgbaVertically(byte[] rgba, int width, int height) { if (rgba != null && width > 0 && height > 0) { int num = width * 4; byte[] array = new byte[num]; int num2 = 0; int num3 = (height - 1) * num; for (int i = 0; i < height / 2; i++) { Buffer.BlockCopy(rgba, num2, array, 0, num); Buffer.BlockCopy(rgba, num3, rgba, num2, num); Buffer.BlockCopy(array, 0, rgba, num3, num); num2 += num; num3 -= num; } } } private static uint PxReadU32BE(byte[] buf, int offset) { return (uint)((buf[offset] << 24) | (buf[offset + 1] << 16) | (buf[offset + 2] << 8) | buf[offset + 3]); } private static byte[] PxInflateZlib(byte[] zlibData) { if (zlibData == null || zlibData.Length < 6) { return null; } byte[] array = PxTryInflate(zlibData, 0, zlibData.Length); if (array != null && array.Length != 0) { return array; } if (zlibData.Length > 2) { return PxTryInflate(zlibData, 2, zlibData.Length - 2); } return null; } private static byte[] PxTryInflate(byte[] data, int offset, int count) { try { using MemoryStream stream = new MemoryStream(data, offset, count); using DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress); using MemoryStream memoryStream = new MemoryStream(); deflateStream.CopyTo(memoryStream); return memoryStream.ToArray(); } catch { return null; } } [IteratorStateMachine(typeof(<CoLoadFileIconDictionary>d__92))] private IEnumerator CoLoadFileIconDictionary(string dictPath) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CoLoadFileIconDictionary>d__92(0) { <>4__this = this, dictPath = dictPath }; } private Texture2D EnsureIconTexture(string prefab, SpriteIcon spriteIcon, RenderTexture portraitRt) { if (string.IsNullOrEmpty(prefab)) { return null; } if (_fileIconTexByPrefab.TryGetValue(prefab, out var value) && (Object)(object)value != (Object)null) { return value; } if (_iconTexByPrefab.TryGetValue(prefab, out value) && (Object)(object)value != (Object)null) { return value; } bool flag = CfgIconCutoutEnabled != null && CfgIconCutoutEnabled.Value; if (spriteIcon.IsValid && (Object)(object)spriteIcon.Texture != (Object)null) { if (flag) { try { value = BuildCutoutFromSpriteIcon(spriteIcon); if ((Object)(object)value != (Object)null) { _iconTexByPrefab[prefab] = value; return value; } } catch { } return null; } return null; } if ((Object)(object)portraitRt != (Object)null) { if (flag) { try { value = BuildCutoutFromRenderTexture(portraitRt); if ((Object)(object)value != (Object)null) { _iconTexByPrefab[prefab] = value; return value; } } catch { } return null; } return null; } return null; } private bool TryGetIconForPrefab(string prefab, out SpriteIcon spriteIcon, out RenderTexture portraitRt) { spriteIcon = default(SpriteIcon); portraitRt = null; if (string.IsNullOrEmpty(prefab)) { return false; } float unscaledTime = Time.unscaledTime; float num = ((CfgIconRefreshSeconds != null) ? Mathf.Max(0f, CfgIconRefreshSeconds.Value) : 0f); if (IsSafeMode()) { num = 0f; } if (_fileSpriteIconsByPrefab.TryGetValue(prefab, out spriteIcon) && spriteIcon.IsValid && (Object)(object)spriteIcon.Texture != (Object)null) { return true; } if (CfgIconUseSprite != null && CfgIconUseSprite.Value && _spriteIconsByPrefab.TryGetValue(prefab, out spriteIcon) && spriteIcon.IsValid && (Object)(object)spriteIcon.Texture != (Object)null) { return true; } bool flag = false; return false; } private void EnsurePortraitRig() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_00b1: 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_0121: Expected O, but got Unknown //IL_017d: 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_0193: Expected O, but got Unknown //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_iconRigRoot != (Object)null)) { _iconRigRoot = new GameObject("PX_AccessibilityPortraitRig"); try { Object.DontDestroyOnLoad((Object)(object)_iconRigRoot); } catch { } GameObject val = new GameObject("PX_AccessibilityPortraitCam"); val.transform.SetParent(_iconRigRoot.transform, false); _iconCam = val.AddComponent<Camera>(); ((Behaviour)_iconCam).enabled = false; _iconCam.cullingMask = int.MinValue; _iconCam.clearFlags = (CameraClearFlags)2; _iconCam.backgroundColor = new Color(0f, 0f, 0f, 0f); _iconCam.orthographic = false; _iconCam.fieldOfView = 28f; _iconCam.nearClipPlane = 0.02f; _iconCam.farClipPlane = 50f; _iconCam.allowHDR = false; _iconCam.allowMSAA = false; GameObject val2 = new GameObject("PX_AccessibilityPortraitLight"); val2.transform.SetParent(_iconRigRoot.transform, false); _iconLight = val2.AddComponent<Light>(); _iconLight.type = (LightType)1; _iconLight.intensity = 1.25f; _iconLight.color = new Color(1f, 1f, 1f, 1f); GameObject val3 = new GameObject("PX_AccessibilityPortraitLightFill"); val3.transform.SetParent(_iconRigRoot.transform, false); Light val4 = val3.AddComponent<Light>(); val4.type = (LightType)1; val4.intensity = 0.65f; val4.color = new Color(0.92f, 0.92f, 1f, 1f); _iconRigRoot.transform.position = new Vector3(0f, 10000f, 0f); } } private RenderTexture BuildPortraitFallback(string prefabName) { return null; } private static void SetLayerRecursive(GameObject root, int layer) { if ((Object)(object)root == (Object)null) { return; } try { root.layer = layer; } catch { } Transform val = null; try { val = root.transform; } catch { } if ((Object)(object)val == (Object)null) { return; } int num = 0; try { num = val.childCount; } catch { } for (int i = 0; i < num; i++) { Transform val2 = null; try { val2 = val.GetChild(i); } catch { } if (!((Object)(object)val2 == (Object)null)) { GameObject val3 = null; try { val3 = ((Component)val2).gameObject; } catch { } if (!((Object)(object)val3 == (Object)null)) { SetLayerRecursive(val3, layer); } } } } private bool IsRenderTextureBlank(RenderTexture rt) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_00b5: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_0214: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rt == (Object)null) { return true; } Texture2D val = null; try { val = new Texture2D(8, 8, (TextureFormat)4, false); } catch { return false; } RenderTexture active = null; try { active = RenderTexture.active; } catch { } try { try { RenderTexture.active = rt; } catch { return false; } int num = 0; int num2 = 0; try { num = Mathf.Clamp(((Texture)rt).width / 2 - 4, 0, Mathf.Max(0, ((Texture)rt).width - 8)); num2 = Mathf.Clamp(((Texture)rt).height / 2 - 4, 0, Mathf.Max(0, ((Texture)rt).height - 8)); } catch { } try { val.ReadPixels(new Rect((float)num, (float)num2, 8f, 8f), 0, 0, false); } catch { return false; } try { val.Apply(false, false); } catch { } Color32[] array = null; try { array = val.GetPixels32(); } catch { return false; } if (array == null || array.Length == 0) { return false; } Color32 val2 = array[0]; int num3 = 0; for (int i = 1; i < array.Length; i++) { Color32 val3 = array[i]; int num4 = val3.r - val2.r; if (num4 < 0) { num4 = -num4; } int num5 = val3.g - val2.g; if (num5 < 0) { num5 = -num5; } int num6 = val3.b - val2.b; if (num6 < 0) { num6 = -num6; } int num7 = val3.a - val2.a; if (num7 < 0) { num7 = -num7; } if (num4 + num5 + num6 + num7 > 8) { num3++; if (num3 > 3) { return false; } } } bool flag = val2.a < 25; bool flag2 = val2.r < 10 && val2.g < 10 && val2.b < 10; return flag || flag2; } finally { try { RenderTexture.active = active; } catch { } try { Object.Destroy((Object)(object)val); } catch { } } } private void LogPortraitFailOnce(string prefabName, string reason) { if (!string.IsNullOrEmpty(prefabName) && !_loggedPortraitFailForPrefab.Contains(prefabName)) { _loggedPortraitFailForPrefab.Add(prefabName); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[Accessibility] Portrait fallback failed for " + prefabName + " (" + reason + ")")); } } } private Texture2D BuildCutoutFromSpriteIcon(SpriteIcon si) { //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) if (!si.IsValid || (Object)(object)si.Texture == (Object)null) { return null; } int width = ((Texture)si.Texture).width; int height = ((Texture)si.Texture).height; float num = Mathf.Clamp01(((Rect)(ref si.UV)).x); float num2 = Mathf.Clamp01(((Rect)(ref si.UV)).y); float num3 = Mathf.Clamp01(((Rect)(ref si.UV)).x + ((Rect)(ref si.UV)).width); float num4 = Mathf.Clamp01(((Rect)(ref si.UV)).y + ((Rect)(ref si.UV)).height); int num5 = Mathf.Clamp((int)Mathf.Round(num * (float)width), 0, width - 1); int num6 = Mathf.Clamp((int)Mathf.Round(num2 * (float)height), 0, height - 1); int num7 = Mathf.Clamp((int)Mathf.Round(num3 * (float)width), 0, width); int num8 = Mathf.Clamp((int)Mathf.Round(num4 * (float)height), 0, height); int num9 = Mathf.Clamp(num7 - num5, 1, width - num5); int num10 = Mathf.Clamp(num8 - num6, 1, height - num6); Color[] pixels; try { pixels = si.Texture.GetPixels(num5, num6, num9, num10); } catch { return null; } if (pixels == null || pixels.Length != num9 * num10) { return null; } bool flag = false; for (int i = 0; i < pixels.Length; i++) { if (pixels[i].a < 0.98f) { flag = true; break; } } float num11 = 0.12f; if (CfgIconCutoutBgTolerance != null) { num11 = Mathf.Clamp01(CfgIconCutoutBgTolerance.Value); } float num12 = num11 * num11; if (!flag) { Color val = SampleEdgeModeColor(pixels, num9, num10); bool[] array = new bool[pixels.Length]; for (int j = 0; j < pixels.Length; j++) { Color val2 = pixels[j]; float num13 = val2.r - val.r; float num14 = val2.g - val.g; float num15 = val2.b - val.b; float num16 = num13 * num13 + num14 * num14 + num15 * num15; array[j] = num16 <= num12; } bool[] array2 = new bool[pixels.Length]; Queue<int> queue = new Queue<int>(num9 * 2 + num10 * 2); for (int k = 0; k < num9; k++) { int num17 = k; int num18 = (num10 - 1) * num9 + k; if (array[num17]) { array2[num17] = true; queue.Enqueue(num17); } if (array[num18]) { array2[num18] = true; queue.Enqueue(num18); } } for (int l = 0; l < num10; l++) { int num19 = l * num9; int num20 = l * num9 + (num9 - 1); if (array[num19] && !array2[num19]) { array2[num19] = true; queue.Enqueue(num19); } if (array[num20] && !array2[num20]) { array2[num20] = true; queue.Enqueue(num20); } } while (queue.Count > 0) { int num21 = queue.Dequeue(); int num22 = num21 % num9; int num23 = num21 / num9; if (num22 > 0) { int num24 = num21 - 1; if (!array2[num24] && array[num24]) { array2[num24] = true; queue.Enqueue(num24); } } if (num22 < num9 - 1) { int num24 = num21 + 1; if (!array2[num24] && array[num24]) { array2[num24] = true; queue.Enqueue(num24); } } if (num23 > 0) { int num24 = num21 - num9; if (!array2[num24] && array[num24]) { array2[num24] = true; queue.Enqueue(num24); } } if (num23 < num10 - 1) { int num24 = num21 + num9; if (!array2[num24] && array[num24]) { array2[num24] = true; queue.Enqueue(num24); } } } for (int m = 0; m < pixels.Length; m++) { if (array2[m]) { pixels[m].a = 0f; } else { pixels[m].a = 1f; } } } Texture2D val3 = new Texture2D(num9, num10, (TextureFormat)4, false); ((Texture)val3).wrapMode = (TextureWrapMode)1; ((Texture)val3).filterMode = (FilterMode)1; val3.SetPixels(pixels); val3.Apply(false, false); if (CfgIconCutoutFeatherEdges != null && CfgIconCutoutFeatherEdges.Value) { FeatherAlphaEdge(val3); } return val3; } private Texture2D BuildCutoutFromRenderTexture(RenderTexture rt) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_005e: 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_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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_014b: 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) if ((Object)(object)rt == (Object)null) { return null; } try { int width = ((Texture)rt).width; int height = ((Texture)rt).height; RenderTexture active = RenderTexture.active; RenderTexture.active = rt; Texture2D val = new Texture2D(width, height, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; val.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0, false); val.Apply(false, false); RenderTexture.active = active; Color[] pixels = val.GetPixels(); bool flag = false; for (int i = 0; i < pixels.Length; i++) { if (pixels[i].a < 0.98f) { flag = true; break; } } if (!flag) { Color val2 = SampleEdgeModeColor(pixels, width, height); float num = 0.12f; if (CfgIconCutoutBgTolerance != null) { num = Mathf.Clamp01(CfgIconCutoutBgTolerance.Value); } float num2 = num * num; bool[] array = new bool[pixels.Length]; for (int j = 0; j < pixels.Length; j++) { Color val3 = pixels[j]; float num3 = val3.r - val2.r; float num4 = val3.g - val2.g; float num5 = val3.b - val2.b; float num6 = num3 * num3 + num4 * num4 + num5 * num5; array[j] = num6 <= num2; } bool[] array2 = new bool[pixels.Length]; Queue<int> queue = new Queue<int>(width * 2 + height * 2); for (int k = 0; k < width; k++) { int num7 = k; int num8 = (height - 1) * width + k; if (array[num7]) { array2[num7] = true; queue.Enqueue(num7); } if (array[num8]) { array2[num8] = true; queue.Enqueue(num8); } } for (int l = 0; l < height; l++) { int num9 = l * width; int num10 = l * width + (width - 1); if (array[num9] && !array2[num9]) { array2[num9] = true; queue.Enqueue(num9); } if (array[num10] && !array2[num10]) { array2[num10] = true; queue.Enqueue(num10); } } while (queue.Count > 0) { int num11 = queue.Dequeue(); int num12 = num11 % width; int num13 = num11 / width; if (num12 > 0) { int num14 = num11 - 1; if (!array2[num14] && array[num14]) { array2[num14] = true; queue.Enqueue(num14); } } if (num12 < width - 1) { int num14 = num11 + 1; if (!array2[num14] && array[num14]) { array2[num14] = true; queue.Enqueue(num14); } } if (num13 > 0) { int num14 = num11 - width; if (!array2[num14] && array[num14]) { array2[num14] = true; queue.Enqueue(num14); } } if (num13 < height - 1) { int num14 = num11 + width; if (!array2[num14] && array[num14]) { array2[num14] = true; queue.Enqueue(num14); } } } for (int m = 0; m < pixels.Length; m++) { if (array2[m]) { pixels[m].a = 0f; } else { pixels[m].a = 1f; } } val.SetPixels(pixels); val.Apply(false, false); } if (CfgIconCutoutFeatherEdges != null && CfgIconCutoutFeatherEdges.Value) { FeatherAlphaEdge(val); } return val; } catch { return null; } } private static Color SampleEdgeModeColor(Color[] px, int w, int h) { //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) //IL_0198: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) if (px == null || px.Length == 0 || w <= 0 || h <= 0) { return Color.white; } Dictionary<int, int> counts = new Dictionary<int, int>(128); Dictionary<int, Color> sums = new Dictionary<int, Color>(128); Func<Color, int> keyOf = delegate(Color c) { //IL_0001: 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_0037: Unknown result type (might be due to invalid IL or missing references) int num3 = Mathf.Clamp((int)Mathf.Round(c.r * 15f), 0, 15); int num4 = Mathf.Clamp((int)Mathf.Round(c.g * 15f), 0, 15); int num5 = Mathf.Clamp((int)Mathf.Round(c.b * 15f), 0, 15); return (num3 << 8) | (num4 << 4) | num5; }; Action<int> action = delegate(int idx) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_006e: 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 (idx >= 0 && idx < px.Length) { Color val = px[idx]; int key = keyOf(val); counts.TryGetValue(key, out var value2); counts[key] = value2 + 1; sums.TryGetValue(key, out var value3); sums[key] = value3 + val; } }; for (int i = 0; i < w; i++) { action(i); action((h - 1) * w + i); } for (int j = 0; j < h; j++) { action(j * w); action(j * w + (w - 1)); } int num = -1; int num2 = -1; foreach (KeyValuePair<int, int> item in counts) { if (item.Value > num2) { num2 = item.Value; num = item.Key; } } if (num == -1 || num2 <= 0) { return Color.white; } if (!sums.TryGetValue(num, out var value)) { return Color.white; } return value / (float)num2; } private static void FeatherAlphaEdge(Texture2D tex) { //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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) try { if ((Object)(object)tex == (Object)null) { return; } int width = ((Texture)tex).width; int height = ((Texture)tex).height; Color[] pixels = tex.GetPixels(); Color[] array = (Color[])(object)new Color[pixels.Length]; Array.Copy(pixels, array, pixels.Length); for (int i = 1; i < height - 1; i++) { for (int j = 1; j < width - 1; j++) { int num = i * width + j; float a = pixels[num].a; if (a <= 0.01f || a >= 0.99f) { } } } for (int k = 1; k < height - 1; k++) { for (int l = 1; l < width - 1; l++) { int num2 = k * width + l; float a2 = pixels[num2].a; if (!(a2 < 0.99f) && (pixels[num2 - 1].a < 0.01f || pixels[num2 + 1].a < 0.01f || pixels[num2 - width].a < 0.01f || pixels[num2 + width].a < 0.01f || pixels[num2 - width - 1].a < 0.01f || pixels[num2 - width + 1].a < 0.01f || pixels[num2 + width - 1].a < 0.01f || pixels[num2 + width + 1].a < 0.01f)) { Color val = array[num2]; val.a = 0.85f; array[num2] = val; } } } tex.SetPixels(array); tex.Apply(false, false); } catch { } } private static Texture2D MakeTex(int w, int h, Color col) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(w, h, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; Color[] array = (Color[])(object)new Color[w * h]; for (int i = 0; i < array.Length; i++) { array[i] = col; } val.SetPixels(array); val.Apply(false, false); return val; } private void EnsureIconLabelStyles() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0056: 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_0081: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (_iconLabelStyle == null) { _iconLabelStyle = new GUIStyle(GUI.skin.label); _iconLabelStyle.alignment = (TextAnchor)1; _iconLabelStyle.wordWrap = false; _iconLabelStyle.clipping = (TextClipping)1; _iconLabelStyle.normal.textColor = Color.white; } if (_iconLabelStyleHC == null) { _iconLabelStyleHC = new GUIStyle(_iconLabelStyle);