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 DeafLink v1.0.1
DeafLink.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using DeafLink.Core; using DeafLink.UI; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.Addressables")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")] [assembly: IgnoresAccessChecksTo("Unity.Localization")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.ResourceManager")] [assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("Exypson")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Visualizes important game sounds as directional icons on screen for deaf/hard-of-hearing players of R.E.P.O.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a45a663277ae67acb97bc82167a5ca31b6e50efe")] [assembly: AssemblyProduct("DeafLink")] [assembly: AssemblyTitle("DeafLink")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DeafLink { [BepInPlugin("deaflink.accessibility", "DeafLink", "1.0.0")] public class DeafLinkPlugin : BaseUnityPlugin { private Harmony _harmony = null; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Log.LogMessage((object)"=== DeafLink v1.0.0 starting ==="); try { _harmony = new Harmony("deaflink.accessibility"); _harmony.PatchAll(); Log.LogMessage((object)"Harmony patches applied successfully."); } catch (Exception arg) { Log.LogError((object)$"FAILED to apply Harmony patches: {arg}"); } } } internal static class PluginInfo { public const string PLUGIN_GUID = "deaflink.accessibility"; public const string PLUGIN_NAME = "DeafLink"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace DeafLink.UI { public class SoundIcon : MonoBehaviour { private const float DisplayDuration = 1.5f; private const float FadeStartAt = 0.8f; private float _timer; private bool _active; private Vector3 _worldPos; private RectTransform _rectTransform = null; private Image _iconImage = null; private CanvasGroup _canvasGroup = null; private static readonly Color[] CategoryColors = (Color[])(object)new Color[4] { Color.red, Color.white, new Color(1f, 0.6f, 0f), Color.yellow }; public Vector3 WorldPos => _worldPos; public string IconName { get; private set; } = string.Empty; public bool IsActive => _active; private void Awake() { //IL_0043: 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_0079: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) _rectTransform = ((Component)this).gameObject.GetComponent<RectTransform>(); if ((Object)(object)_rectTransform == (Object)null) { _rectTransform = ((Component)this).gameObject.AddComponent<RectTransform>(); } _rectTransform.sizeDelta = new Vector2(64f, 64f); _rectTransform.anchorMin = new Vector2(0.5f, 0.5f); _rectTransform.anchorMax = new Vector2(0.5f, 0.5f); _rectTransform.pivot = new Vector2(0.5f, 0.5f); _canvasGroup = ((Component)this).gameObject.AddComponent<CanvasGroup>(); GameObject val = new GameObject("IconImage"); val.transform.SetParent(((Component)this).transform, false); _iconImage = val.AddComponent<Image>(); _iconImage.preserveAspect = true; RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(64f, 64f); ((Component)this).gameObject.SetActive(false); } public void Activate(Vector3 soundWorldPos, SoundCategory category, string iconName) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_005f: Unknown result type (might be due to invalid IL or missing references) _worldPos = soundWorldPos; IconName = iconName ?? string.Empty; _timer = 1.5f; _active = true; if (!string.IsNullOrEmpty(iconName)) { Sprite icon = IconManager.GetIcon(iconName); if ((Object)(object)icon != (Object)null) { _iconImage.sprite = icon; ((Graphic)_iconImage).color = Color.white; } else { _iconImage.sprite = null; ((Graphic)_iconImage).color = CategoryColors[(int)category]; } } else { _iconImage.sprite = null; ((Graphic)_iconImage).color = CategoryColors[(int)category]; } _canvasGroup.alpha = 1f; UpdateScreenPosition(); ((Component)this).gameObject.SetActive(true); } public void Deactivate() { _active = false; ((Component)this).gameObject.SetActive(false); } private void Update() { if (_active) { UpdateScreenPosition(); _timer -= Time.deltaTime; if (_timer <= 0.8f) { _canvasGroup.alpha = Mathf.Clamp01(_timer / 0.8f); } if (_timer <= 0f) { Deactivate(); } } } private void UpdateScreenPosition() { //IL_004f: 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_0065: 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_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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_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) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00de: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_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_015a: 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) //IL_00fe: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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) //IL_01f4: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)main == (Object)null || (Object)(object)instance == (Object)null) { return; } Transform parent = ((Transform)_rectTransform).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (!((Object)(object)val == (Object)null)) { Vector3 val2 = _worldPos - ((Component)instance).transform.position; Vector3 val3 = Vector3.ProjectOnPlane(val2, Vector3.up); Vector3 normalized = ((Vector3)(ref val3)).normalized; val3 = Vector3.ProjectOnPlane(((Component)main).transform.forward, Vector3.up); Vector3 normalized2 = ((Vector3)(ref val3)).normalized; val3 = Vector3.ProjectOnPlane(((Component)main).transform.right, Vector3.up); Vector3 normalized3 = ((Vector3)(ref val3)).normalized; float num = Vector3.Dot(normalized, normalized3); float num2 = Vector3.Dot(normalized, normalized2); Vector2 val4 = new Vector2(num, num2); Vector2 val5 = ((Vector2)(ref val4)).normalized; if (((Vector2)(ref val5)).sqrMagnitude < 0.001f) { val5 = Vector2.up; } Rect rect = val.rect; float num3 = ((Rect)(ref rect)).width / 2f; rect = val.rect; float num4 = ((Rect)(ref rect)).height / 2f; float num5 = 48f; float num6 = 0f - num3 + num5; float num7 = num3 - num5; float num8 = 0f - num4 + num5; float num9 = num4 - num5; float num10 = float.MaxValue; if (val5.x > 0f) { num10 = num7 / val5.x; } else if (val5.x < 0f) { num10 = num6 / val5.x; } float num11 = float.MaxValue; if (val5.y > 0f) { num11 = num9 / val5.y; } else if (val5.y < 0f) { num11 = num8 / val5.y; } float num12 = Mathf.Min(num10, num11); Vector2 anchoredPosition = val5 * num12; _rectTransform.anchoredPosition = anchoredPosition; } } } public class SoundIndicatorHUD : MonoBehaviour { private static SoundIndicatorHUD? _instance; private const int IconPoolSize = 32; private const float MinorHearingDistance = 10f; private const float MajorHearingDistance = 20f; private SoundIcon[] _pool = null; private readonly Queue<SoundEvent> _pendingEvents = new Queue<SoundEvent>(); private Canvas _canvas = null; private RectTransform _canvasRect = null; private CanvasScaler _scaler = null; private void Awake() { _instance = this; BuildCanvas(); BuildPool(); } private void OnDestroy() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } public static void RegisterSoundEvent(SoundEvent evt) { if ((Object)(object)_instance == (Object)null) { return; } lock (_instance._pendingEvents) { _instance._pendingEvents.Enqueue(evt); } } private void Update() { lock (_pendingEvents) { while (_pendingEvents.Count > 0) { SoundEvent evt = _pendingEvents.Dequeue(); SpawnIcon(evt); } } } private void SpawnIcon(SoundEvent evt) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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_0145: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar instance = PlayerAvatar.instance; Camera main = Camera.main; if ((Object)(object)instance == (Object)null || (Object)(object)main == (Object)null) { return; } Vector3 val = evt.WorldPosition - ((Component)instance).transform.position; float num = ((evt.Category == SoundCategory.Weapon || evt.Category == SoundCategory.Explosion) ? 20f : 10f); if (((Vector3)(ref val)).magnitude > num) { return; } if (evt.Category == SoundCategory.Monster && !string.IsNullOrEmpty(evt.IconName)) { SoundIcon[] pool = _pool; foreach (SoundIcon soundIcon in pool) { if (soundIcon.IsActive && soundIcon.IconName == evt.IconName) { float num2 = Vector3.Distance(soundIcon.WorldPos, evt.WorldPosition); if (num2 <= 3f) { soundIcon.Activate(evt.WorldPosition, evt.Category, evt.IconName); return; } } } } SoundIcon freeIcon = GetFreeIcon(); if (!((Object)(object)freeIcon == (Object)null)) { freeIcon.Activate(evt.WorldPosition, evt.Category, evt.IconName); } } private SoundIcon? GetFreeIcon() { SoundIcon[] pool = _pool; foreach (SoundIcon soundIcon in pool) { if (!soundIcon.IsActive) { return soundIcon; } } return null; } private void BuildCanvas() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DeafLink_Canvas"); val.transform.SetParent(((Component)this).transform, false); _canvas = val.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = 100; _scaler = val.AddComponent<CanvasScaler>(); _scaler.uiScaleMode = (ScaleMode)1; _scaler.referenceResolution = new Vector2(1920f, 1080f); _scaler.matchWidthOrHeight = 0.5f; val.AddComponent<GraphicRaycaster>(); _canvasRect = val.GetComponent<RectTransform>(); } private void BuildPool() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown _pool = new SoundIcon[32]; for (int i = 0; i < 32; i++) { GameObject val = new GameObject($"DeafLink_Icon_{i}"); val.transform.SetParent(((Component)_canvas).transform, false); _pool[i] = val.AddComponent<SoundIcon>(); } } } } namespace DeafLink.Patches { [HarmonyPatch(typeof(ParticleScriptExplosion), "Spawn")] internal static class ExplosionPatch { [HarmonyPostfix] private static void Postfix(Vector3 position, float size) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SoundIndicatorHUD.RegisterSoundEvent(new SoundEvent(position, SoundCategory.Explosion, "Explosions_Icon.png")); } } [HarmonyPatch(typeof(AudioScare), "PlayImpact")] internal static class MonsterScarePatch { [HarmonyPostfix] private static void Postfix() { //IL_0063: 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_0119: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance == (Object)null || (Object)(object)EnemyDirector.instance == (Object)null) { return; } EnemyParent val = null; float num = float.MaxValue; foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned) { if (!((Object)(object)item == (Object)null)) { float num2 = Vector3.Distance(((Component)instance).transform.position, ((Component)item).transform.position); if (num2 < num) { num = num2; val = item; } } } if ((Object)(object)val != (Object)null) { string name = ((object)val).GetType().Name; string iconName = ""; string value; if (name.StartsWith("EnemyHead") && name != "EnemyHeadGrabber") { iconName = "Headman_Icon.png"; } else if (MonsterSoundPatch.MonsterIconMap.TryGetValue(name, out value)) { iconName = value; } SoundIndicatorHUD.RegisterSoundEvent(new SoundEvent(((Component)val).transform.position, SoundCategory.Monster, iconName)); } } } internal static class MonsterSoundPatch { private const float MONSTER_SOUND_RADIUS = 3.5f; internal static readonly Dictionary<string, string> MonsterIconMap = new Dictionary<string, string> { { "EnemyAnimal", "Animal_Icon.png" }, { "EnemyDuck", "ApexPredator_Icon.png" }, { "EnemyBang", "Banger_Icon.png" }, { "EnemyTricycle", "Bella_Icon.png" }, { "EnemyBirthdayBoy", "BirthdayBoy_Icon.png" }, { "EnemyBowtie", "Bowtie_Icon.png" }, { "EnemyTumbler", "Chef_Icon.png" }, { "EnemyBombThrower", "CleanupCrew_Icon.png" }, { "EnemyBeamer", "Clown_Icon.png" }, { "EnemyElsa", "Elsa_Icon.png" }, { "EnemySpinny", "Gambit_Icon.png" }, { "EnemyGnome", "Gnome_Icon.png" }, { "EnemyHeadGrabber", "HeadGrab_Icon.png" }, { "EnemyHeartHugger", "HeartHugger_Icon.png" }, { "EnemyHidden", "Hidden_Icon.png" }, { "EnemyHunter", "Huntsman_Icon.png" }, { "EnemyShadow", "Loom_Icon.png" }, { "EnemyFloater", "Mentalist_Icon.png" }, { "EnemyOogly", "Oogly_Icon.png" }, { "EnemyCeilingEye", "Peeper_Icon.png" }, { "EnemyRunner", "Reaper_Icon.png" }, { "EnemyRobe", "Robe_Icon.png" }, { "EnemyValuableThrower", "Rugrat_Icon.png" }, { "EnemyThinMan", "ShadowChild_Icon.png" }, { "EnemySlowMouth", "Spewer_Icon.png" }, { "EnemyTick", "Tick_Icon.png" }, { "EnemySlowWalker", "Trudge_Icon.png" }, { "EnemyUpscream", "Upscream_Icon.png" } }; public static void CheckMonsterSound(Sound soundInstance, Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_012e: Unknown result type (might be due to invalid IL or missing references) if ((int)soundInstance.Type == 5) { return; } bool flag = false; string iconName = ""; StackTrace stackTrace = new StackTrace(2, fNeedFileInfo: false); for (int i = 0; i < 4; i++) { StackFrame frame = stackTrace.GetFrame(i); if (frame == null) { break; } MethodBase method = frame.GetMethod(); if (method == null || method.DeclaringType == null) { continue; } string text = method.DeclaringType.Name; if (text.StartsWith("Enemy")) { flag = true; if (text.EndsWith("Anim")) { text = text.Substring(0, text.Length - 4); } iconName = ((text.StartsWith("EnemyHead") && text != "EnemyHeadGrabber") ? "Headman_Icon.png" : ((!MonsterIconMap.TryGetValue(text, out string value)) ? "" : value)); break; } } if (flag) { SoundIndicatorHUD.RegisterSoundEvent(new SoundEvent(position, SoundCategory.Monster, iconName)); } } } [HarmonyPatch(typeof(Sound), "Play", new Type[] { typeof(Vector3), typeof(float), typeof(float), typeof(float), typeof(float) })] internal static class MonsterSoundPosPatch { [HarmonyPrefix] private static void Prefix(Sound __instance, Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) MonsterSoundPatch.CheckMonsterSound(__instance, position); } } [HarmonyPatch(typeof(Sound), "Play", new Type[] { typeof(Transform), typeof(float), typeof(float), typeof(float), typeof(float) })] internal static class MonsterSoundTransformPatch { [HarmonyPrefix] private static void Prefix(Sound __instance, Transform followTarget) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)followTarget != (Object)null) { MonsterSoundPatch.CheckMonsterSound(__instance, followTarget.position); } } } [HarmonyPatch(typeof(Sound), "Play", new Type[] { typeof(Transform), typeof(Vector3), typeof(float), typeof(float), typeof(float), typeof(float) })] internal static class MonsterSoundContactPatch { [HarmonyPrefix] private static void Prefix(Sound __instance, Transform followTarget, Vector3 contactPoint) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) MonsterSoundPatch.CheckMonsterSound(__instance, contactPoint); } } [HarmonyPatch] internal static class PhysGrabBreakPatch { [HarmonyTargetMethod] private static MethodBase TargetMethod() { MethodInfo methodInfo = AccessTools.Method(typeof(PhysGrabObjectImpactDetector), "BreakRPC", new Type[5] { typeof(float), typeof(Vector3), typeof(int), typeof(bool), typeof(PhotonMessageInfo) }, (Type[])null); if (methodInfo == null) { DeafLinkPlugin.Log.LogError((object)"[DeafLink] FAILED to find PhysGrabObjectImpactDetector.BreakRPC via AccessTools!"); } return methodInfo; } [HarmonyPostfix] private static void Postfix(PhysGrabObjectImpactDetector __instance, float valueLost, Vector3 _contactPoint, int breakLevel, bool _loseValue, PhotonMessageInfo _info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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) Vector3 worldPosition = ((_contactPoint != Vector3.zero) ? _contactPoint : ((Component)__instance).transform.position); SoundIndicatorHUD.RegisterSoundEvent(new SoundEvent(worldPosition, SoundCategory.ItemBreak, "ItemBreakFall_Icon.png")); } } [HarmonyPatch(typeof(PlayerAvatar), "Start")] internal static class PlayerAvatarSpawnPatch { [HarmonyPostfix] private static void Postfix(PlayerAvatar __instance) { if ((!SemiFunc.IsMultiplayer() || __instance.photonView.IsMine) && (Object)(object)((Component)__instance).gameObject.GetComponent<SoundIndicatorHUD>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<SoundIndicatorHUD>(); } } } [HarmonyPatch(typeof(ItemGun), "ShootRPC")] internal static class WeaponPatch { [HarmonyPostfix] private static void Postfix(ItemGun __instance) { //IL_0022: 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_0028: Unknown result type (might be due to invalid IL or missing references) Vector3 worldPosition = (((Object)(object)__instance.gunMuzzle != (Object)null) ? __instance.gunMuzzle.position : ((Component)__instance).transform.position); SoundIndicatorHUD.RegisterSoundEvent(new SoundEvent(worldPosition, SoundCategory.Weapon, "Weapons_Icon.png")); } } } namespace DeafLink.Core { public static class IconManager { private static readonly Dictionary<string, Sprite> _iconCache; private static readonly string[] _manifestResourceNames; private static readonly Assembly _assembly; static IconManager() { _iconCache = new Dictionary<string, Sprite>(); _assembly = Assembly.GetExecutingAssembly(); _manifestResourceNames = _assembly.GetManifestResourceNames(); } public static Sprite? GetIcon(string fileName) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_010f: 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) if (string.IsNullOrEmpty(fileName)) { return null; } string key = fileName.ToLowerInvariant(); if (_iconCache.TryGetValue(key, out Sprite value)) { return value; } string text = _manifestResourceNames.FirstOrDefault((string r) => r.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)); if (text == null) { DeafLinkPlugin.Log.LogWarning((object)("[DeafLink] IconManager: Failed to find embedded resource for " + fileName)); return null; } try { using Stream stream = _assembly.GetManifestResourceStream(text); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, (int)stream.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (ImageConversion.LoadImage(val, array)) { Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); _iconCache[key] = val2; return val2; } } catch (Exception arg) { DeafLinkPlugin.Log.LogError((object)$"[DeafLink] Failed to load icon {fileName}: {arg}"); } return null; } } public enum SoundCategory { Monster, ItemBreak, Weapon, Explosion } public struct SoundEvent { public Vector3 WorldPosition; public SoundCategory Category; public string IconName; public SoundEvent(Vector3 worldPosition, SoundCategory category, string iconName = "") { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) WorldPosition = worldPosition; Category = category; IconName = iconName; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }