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 RedEye v1.0.0
BepInEx/plugins/RedEye/RedEye.dll
Decompiled 3 hours 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("RedEye")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RedEye")] [assembly: AssemblyTitle("RedEye")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace RedEye; public static class LethalConfigHelper { public static void Register() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_012b: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_0151: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<ColorPreset>(Plugin.Color, new EnumDropDownOptions { Name = "Color Preset", RequiresRestart = false })); ConfigEntry<float> screenTintOpacity = Plugin.ScreenTintOpacity; FloatSliderOptions val = new FloatSliderOptions { Name = "Screen Tint Opacity" }; ((BaseRangeOptions<float>)val).Min = 0f; ((BaseRangeOptions<float>)val).Max = 0.2f; ((BaseOptions)val).RequiresRestart = false; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(screenTintOpacity, val)); ConfigEntry<float> glowIntensity = Plugin.GlowIntensity; FloatSliderOptions val2 = new FloatSliderOptions { Name = "Glow Intensity" }; ((BaseRangeOptions<float>)val2).Min = 0.1f; ((BaseRangeOptions<float>)val2).Max = 3f; ((BaseOptions)val2).RequiresRestart = false; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(glowIntensity, val2)); ConfigEntry<float> maxRange = Plugin.MaxRange; FloatSliderOptions val3 = new FloatSliderOptions { Name = "Max Range (meters)" }; ((BaseRangeOptions<float>)val3).Min = 25f; ((BaseRangeOptions<float>)val3).Max = 500f; ((BaseOptions)val3).RequiresRestart = false; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(maxRange, val3)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(Plugin.IncludeHazards, new BoolCheckBoxOptions { Name = "Include Map Hazards", RequiresRestart = false })); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(Plugin.EnableScanline, new BoolCheckBoxOptions { Name = "Enable Scanline", RequiresRestart = false })); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(Plugin.EnableTargetHUD, new BoolCheckBoxOptions { Name = "Enable Target HUD", RequiresRestart = false })); ConfigEntry<float> hUDPositionX = Plugin.HUDPositionX; FloatSliderOptions val4 = new FloatSliderOptions { Name = "Entity HUD Text: Position X" }; ((BaseRangeOptions<float>)val4).Min = -800f; ((BaseRangeOptions<float>)val4).Max = 800f; ((BaseOptions)val4).RequiresRestart = false; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(hUDPositionX, val4)); ConfigEntry<float> hUDPositionY = Plugin.HUDPositionY; FloatSliderOptions val5 = new FloatSliderOptions { Name = "Entity HUD Text: Position Y" }; ((BaseRangeOptions<float>)val5).Min = 0f; ((BaseRangeOptions<float>)val5).Max = 900f; ((BaseOptions)val5).RequiresRestart = false; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(hUDPositionY, val5)); } } [HarmonyPatch(typeof(NetworkManager))] internal static class NetworkPrefabPatch { private static readonly string MOD_GUID = "RedEye"; [HarmonyPostfix] [HarmonyPatch("SetSingleton")] private static void RegisterPrefab() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(MOD_GUID + " Prefab"); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D); Object.DontDestroyOnLoad((Object)(object)val); NetworkObject obj = val.AddComponent<NetworkObject>(); typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, GetHash(MOD_GUID)); NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val); static uint GetHash(string value) { return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0; } } } public enum ColorPreset { Ruby, Emerald, Lapis, Amethyst, Amber } [BepInPlugin("RedEye", "RedEye", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; internal static RedEyeInputActions InputActions; internal static RedEyeController ControllerInstance; internal static ConfigEntry<ColorPreset> Color; internal static ConfigEntry<float> ScreenTintOpacity; internal static ConfigEntry<float> GlowIntensity; internal static ConfigEntry<float> MaxRange; internal static ConfigEntry<bool> IncludeHazards; internal static ConfigEntry<bool> EnableScanline; internal static ConfigEntry<bool> EnableTargetHUD; internal static ConfigEntry<float> HUDPositionX; internal static ConfigEntry<float> HUDPositionY; private static GameObject runnerObject; private void Awake() { //IL_001f: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin RedEye is loaded!"); new Harmony("RedEye").PatchAll(); Color = ((BaseUnityPlugin)this).Config.Bind<ColorPreset>("Visual", "Color", ColorPreset.Ruby, "Color preset for the entity highlight and screen tint.\nOptions: Ruby, Emerald, Lapis, Amethyst, Amber."); ScreenTintOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "ScreenTintOpacity", 0.03f, new ConfigDescription("Opacity of the full-screen color tint when active. Simulates a goggles/filter effect.\nValid range: 0.0 to 0.2.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.2f), Array.Empty<object>())); GlowIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "GlowIntensity", 1f, new ConfigDescription("Multiplier for the overall glow brightness on entities. Lower values reduce how strongly entities are highlighted.\nValid range: 0.1 to 3.0.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>())); MaxRange = ((BaseUnityPlugin)this).Config.Bind<float>("Behavior", "MaxRange", 200f, new ConfigDescription("Maximum distance (in meters) at which entities will glow. Default is far enough for outdoor entities.\nValid range: 25 to 500.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(25f, 500f), Array.Empty<object>())); IncludeHazards = ((BaseUnityPlugin)this).Config.Bind<bool>("Behavior", "IncludeHazards", true, "Highlight map hazards (Turrets, Landmines, Spike Traps) in addition to enemies."); EnableScanline = ((BaseUnityPlugin)this).Config.Bind<bool>("Behavior", "EnableScanline", true, "Show a soft CRT-style scanline that sweeps from top to bottom of the screen."); EnableTargetHUD = ((BaseUnityPlugin)this).Config.Bind<bool>("Behavior", "EnableTargetHUD", true, "Display a tactical HUD readout showing the name and distance of the enemy you are directly looking at."); HUDPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "HUDPositionX", 0f, new ConfigDescription("Horizontal offset of the Entity HUD Text from screen center. Negative = left, Positive = right.\nValid range: -800 to 800.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-800f, 800f), Array.Empty<object>())); HUDPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "HUDPositionY", 250f, new ConfigDescription("Vertical offset of the Entity HUD Text from the bottom of the screen.\nValid range: 0 to 900.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 900f), Array.Empty<object>())); if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig")) { LethalConfigHelper.Register(); Logger.LogInfo((object)"RedEye: LethalConfig registered."); } InputActions = new RedEyeInputActions(); ((LcInputActions)InputActions).Enable(); ControllerInstance = new RedEyeController(); SceneManager.sceneLoaded += OnSceneLoaded; } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown Logger.LogInfo((object)("RedEye: Scene loaded - " + ((Scene)(ref scene)).name)); if ((Object)(object)runnerObject == (Object)null) { runnerObject = new GameObject("RedEye_Runner"); runnerObject.AddComponent<RedEyeRunner>(); Object.DontDestroyOnLoad((Object)(object)runnerObject); Logger.LogInfo((object)"RedEye: Runner created."); } } internal static Color ResolvePresetColor(ColorPreset preset) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_007f: 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) return (Color)(preset switch { ColorPreset.Ruby => new Color(1f, 0.05f, 0.1f), ColorPreset.Emerald => new Color(0f, 1f, 0.2f), ColorPreset.Lapis => new Color(0.1f, 0.3f, 1f), ColorPreset.Amethyst => new Color(0.6f, 0f, 1f), ColorPreset.Amber => new Color(1f, 0.6f, 0f), _ => new Color(1f, 0.05f, 0.1f), }); } } public class RedEyeController { private class TrackedRenderer { public Renderer Original; public Material[] OriginalMaterials; public Material[] CopiedMaterials; public Renderer Overlay; public MaterialPropertyBlock OverlayBlock; } private struct TargetInfo { public string DisplayName; public Transform Transform; } private bool _active; private bool _initialized; private GameObject _overlayRoot; private RawImage _screenTint; private RawImage _scanline; private Material _overlayMat; private readonly Dictionary<Renderer, TrackedRenderer> _tracked = new Dictionary<Renderer, TrackedRenderer>(); private float _refreshTimer; private const float REFRESH_INTERVAL = 0.5f; private Camera _cachedCam; private PlayerControllerB _cachedPlayer; private readonly RaycastHit[] _raycastBuffer = (RaycastHit[])(object)new RaycastHit[32]; private readonly Dictionary<Transform, Renderer> _bracketRendCache = new Dictionary<Transform, Renderer>(); private float _hazardRefreshTimer; private const float HAZARD_REFRESH_INTERVAL = 3f; private const float SCANLINE_CYCLE = 2.5f; private const float SCANLINE_HEIGHT = 50f; private const float SCANLINE_OPACITY = 0.01f; private float _glitchUntil; private float _nextGlitchAt; private float _glitchX; private float _glitchOpacityMul = 1f; private GameObject _hudRoot; private RectTransform _hudCanvasRt; private RectTransform _hudPanelRt; private Text _hudName; private Text _hudDist; private RectTransform[] _bracketCorners; private float _hudFadeTimer; private const float HUD_FADE_TIME = 2f; private float _time; private readonly HashSet<Renderer> _validBuffer = new HashSet<Renderer>(); private int _glowFrameCounter; private TargetInfo? _lastTargetInfo; public void Toggle() { if (!_initialized) { Initialize(); } SetActive(!_active); Plugin.Logger.LogInfo((object)$"RedEye: Toggled to {_active}."); RedEyeRunner.Instance?.PlayClick(); } public void Tick(float deltaTime) { if (_active) { _time += deltaTime; _refreshTimer -= deltaTime; if (_refreshTimer <= 0f) { RefreshEnemyTargets(); _refreshTimer = 0.5f; } _hazardRefreshTimer -= deltaTime; if (_hazardRefreshTimer <= 0f) { RefreshHazardTargets(); _hazardRefreshTimer = 3f; } UpdateScreenTint(); UpdateScanline(); UpdateTargetHUD(); } } public void ApplyGlowColors() { if (_active) { UpdateGlow(); } } private void Initialize() { try { BuildOverlay(); BuildTargetHUD(); _initialized = true; Plugin.Logger.LogInfo((object)"RedEye: Initialized."); } catch (Exception ex) { Plugin.Logger.LogError((object)("RedEye: Init failed - " + ex.Message)); } } private void SetActive(bool value) { _active = value; if ((Object)(object)_overlayRoot != (Object)null) { _overlayRoot.SetActive(value); } if ((Object)(object)_hudRoot != (Object)null) { _hudRoot.SetActive(value); } if (!value) { ClearAll(); _bracketRendCache.Clear(); _cachedCam = null; _cachedPlayer = null; } } private void RefreshEnemyTargets() { _validBuffer.Clear(); if ((Object)(object)RoundManager.Instance != (Object)null) { foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies) { if ((Object)(object)spawnedEnemy == (Object)null || spawnedEnemy.isEnemyDead) { continue; } Renderer[] componentsInChildren = ((Component)spawnedEnemy).GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val != (Object)null) { _validBuffer.Add(val); } } } } foreach (Renderer item in _tracked.Keys.Where((Renderer r) => (Object)(object)r == (Object)null || (!_validBuffer.Contains(r) && !IsTrackedHazard(r))).ToList()) { if (_tracked.TryGetValue(item, out var value)) { RestoreTracked(value); } _tracked.Remove(item); } foreach (Renderer item2 in _validBuffer) { if (!_tracked.ContainsKey(item2)) { TrackRenderer(item2); } } } private void RefreshHazardTargets() { if (!Plugin.IncludeHazards.Value) { return; } _validBuffer.Clear(); CollectHazardRenderers<Turret>(_validBuffer); CollectHazardRenderers<Landmine>(_validBuffer); CollectHazardRenderers<SpikeRoofTrap>(_validBuffer); foreach (Renderer item in _tracked.Keys.Where((Renderer r) => (Object)(object)r == (Object)null || (IsTrackedHazard(r) && !_validBuffer.Contains(r))).ToList()) { if (_tracked.TryGetValue(item, out var value)) { RestoreTracked(value); } _tracked.Remove(item); } foreach (Renderer item2 in _validBuffer) { if (!_tracked.ContainsKey(item2)) { TrackRenderer(item2); } } } private static bool IsTrackedHazard(Renderer r) { if ((Object)(object)r == (Object)null) { return false; } Transform root = ((Component)r).transform.root; if (!((Object)(object)((Component)root).GetComponentInChildren<Turret>() != (Object)null) && !((Object)(object)((Component)root).GetComponentInChildren<Landmine>() != (Object)null)) { return (Object)(object)((Component)root).GetComponentInChildren<SpikeRoofTrap>() != (Object)null; } return true; } private static void CollectHazardRenderers<T>(HashSet<Renderer> bag) where T : MonoBehaviour { T[] array = Object.FindObjectsOfType<T>(); foreach (T val in array) { if ((Object)(object)val == (Object)null) { continue; } Renderer[] componentsInChildren = ((Component)((Component)(object)val).transform.root).GetComponentsInChildren<Renderer>(); foreach (Renderer val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null) { bag.Add(val2); } } } } private void TrackRenderer(Renderer rend) { //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if (((Object)((Component)rend).gameObject).name == "RedEye_GlowOverlay" || rend is LineRenderer || ((object)rend).GetType().Name == "VFXRenderer") { return; } bool flag = false; if (rend.sharedMaterials != null) { Material[] sharedMaterials = rend.sharedMaterials; foreach (Material val in sharedMaterials) { if ((Object)(object)val != (Object)null && val.HasProperty("_EmissiveColor") && (val.HasProperty("_EmissiveIntensity") || val.HasProperty("_EmissiveColorLDR"))) { flag = true; break; } } } if (flag) { Material[] sharedMaterials2 = rend.sharedMaterials; if (sharedMaterials2 != null && sharedMaterials2.Length != 0) { Material[] array = (Material[])(object)new Material[sharedMaterials2.Length]; for (int j = 0; j < sharedMaterials2.Length; j++) { object obj = array; int num = j; obj = (object)(((Object)(object)sharedMaterials2[j] != (Object)null) ? new Material(sharedMaterials2[j]) : ((Material)null)); ((object[])obj)[num] = obj; } rend.sharedMaterials = array; _tracked[rend] = new TrackedRenderer { Original = rend, OriginalMaterials = sharedMaterials2, CopiedMaterials = array }; } } else { Renderer val2 = BuildMeshOverlay(rend); if ((Object)(object)val2 != (Object)null) { _tracked[rend] = new TrackedRenderer { Original = rend, Overlay = val2, OverlayBlock = new MaterialPropertyBlock() }; } } } private Renderer BuildMeshOverlay(Renderer source) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //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_0059: Unknown result type (might be due to invalid IL or missing references) EnsureOverlayMaterial(); if ((Object)(object)_overlayMat == (Object)null) { return null; } GameObject val = new GameObject("RedEye_GlowOverlay"); val.transform.SetParent(((Component)source).transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((source is SkinnedMeshRenderer) ? source : null); if (val2 != null) { SkinnedMeshRenderer obj = val.AddComponent<SkinnedMeshRenderer>(); obj.sharedMesh = val2.sharedMesh; obj.bones = val2.bones; obj.rootBone = val2.rootBone; ((Renderer)obj).sharedMaterial = _overlayMat; return (Renderer)(object)obj; } if (source is MeshRenderer) { MeshFilter component = ((Component)source).GetComponent<MeshFilter>(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val); return null; } val.AddComponent<MeshFilter>().sharedMesh = component.sharedMesh; MeshRenderer obj2 = val.AddComponent<MeshRenderer>(); ((Renderer)obj2).sharedMaterial = _overlayMat; return (Renderer)(object)obj2; } Object.Destroy((Object)(object)val); return null; } private void EnsureOverlayMaterial() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_00d4: 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) if ((Object)(object)_overlayMat != (Object)null) { return; } Shader val = Shader.Find("HDRP/Lit") ?? Shader.Find("HDRP/Unlit"); if ((Object)(object)val == (Object)null) { Plugin.Logger.LogError((object)"RedEye: No suitable overlay shader found - Hygrodere will not glow."); return; } _overlayMat = new Material(val) { name = "RedEye_OverlayMat", renderQueue = 3000 }; _overlayMat.SetFloat("_SurfaceType", 1f); _overlayMat.SetFloat("_BlendMode", 1f); _overlayMat.SetFloat("_ZWrite", 0f); _overlayMat.SetFloat("_AlphaCutoffEnable", 0f); if (_overlayMat.HasProperty("_BaseColor")) { _overlayMat.SetColor("_BaseColor", Color.black); } if (_overlayMat.HasProperty("_EmissiveColor")) { _overlayMat.EnableKeyword("_EMISSION"); _overlayMat.SetColor("_EmissiveColor", Color.black); } if (_overlayMat.HasProperty("_EmissiveIntensity")) { _overlayMat.SetFloat("_EmissiveIntensity", 1f); } Plugin.Logger.LogInfo((object)("RedEye: Overlay material created (" + ((Object)val).name + ").")); } private static void RestoreTracked(TrackedRenderer t) { if ((Object)(object)t.Overlay != (Object)null) { if ((Object)(object)((Component)t.Overlay).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)t.Overlay).gameObject); } } else { if (t.OriginalMaterials == null || !((Object)(object)t.Original != (Object)null)) { return; } t.Original.sharedMaterials = t.OriginalMaterials; if (t.CopiedMaterials == null) { return; } Material[] copiedMaterials = t.CopiedMaterials; foreach (Material val in copiedMaterials) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } } private void ClearAll() { foreach (TrackedRenderer value in _tracked.Values) { RestoreTracked(value); } _tracked.Clear(); } private void UpdateGlow() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0174: 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_00cc: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: 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_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) _glowFrameCounter++; if (_glowFrameCounter % 2 != 0) { return; } float num = 0.7f + 0.3f * (Mathf.Sin(_time * (float)Math.PI / 0.75f) * 0.5f + 0.5f); float num2 = Random.Range(0.92f, 1.08f); float value = Plugin.MaxRange.Value; float value2 = Plugin.GlowIntensity.Value; Color val = Plugin.ResolvePresetColor(Plugin.Color.Value); Vector3? cachedPlayerPosition = GetCachedPlayerPosition(); Color val2 = default(Color); Color val3 = default(Color); foreach (TrackedRenderer value3 in _tracked.Values) { if ((Object)(object)value3.Original == (Object)null) { continue; } float num3 = 1f; if (cachedPlayerPosition.HasValue) { float num4 = Vector3.Distance(cachedPlayerPosition.Value, ((Component)value3.Original).transform.position); num3 = Mathf.Lerp(2.5f, 0.6f, Mathf.Clamp01(num4 / value)); } float num5 = num3 * num * num2; ((Color)(ref val2))..ctor(val.r * num5, val.g * num5, val.b * num5, 1f); float num6 = Mathf.Max(new float[4] { val2.r, val2.g, val2.b, 0.001f }); ((Color)(ref val3))..ctor(val2.r / num6, val2.g / num6, val2.b / num6, 1f); if ((Object)(object)value3.Overlay != (Object)null) { value3.Overlay.GetPropertyBlock(value3.OverlayBlock); value3.OverlayBlock.SetColor("_EmissiveColor", val2 * value2); value3.OverlayBlock.SetColor("_EmissiveColorLDR", val3); value3.OverlayBlock.SetFloat("_EmissiveIntensity", 500f * value2); value3.OverlayBlock.SetColor("_BaseColor", Color.black); value3.Overlay.SetPropertyBlock(value3.OverlayBlock); } else { if (value3.CopiedMaterials == null) { continue; } Material[] copiedMaterials = value3.CopiedMaterials; foreach (Material val4 in copiedMaterials) { if (!((Object)(object)val4 == (Object)null)) { ApplyEmission(val4, val2, val3, value2); } } } } } private static void ApplyEmission(Material mat, Color glow, Color glowN, float userMul) { //IL_001e: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (mat.HasProperty("_EmissionColor")) { mat.EnableKeyword("_EMISSION"); mat.SetColor("_EmissionColor", glow); } if (mat.HasProperty("_EmissiveColor")) { mat.SetColor("_EmissiveColor", glow * userMul); } if (mat.HasProperty("_EmissiveColorLDR")) { mat.SetColor("_EmissiveColorLDR", glowN); } if (mat.HasProperty("_EmissiveIntensity")) { mat.SetFloat("_EmissiveIntensity", 500f * userMul); } if (mat.HasProperty("_EmissiveColorMap")) { mat.SetTexture("_EmissiveColorMap", (Texture)(object)Texture2D.whiteTexture); } if (mat.HasProperty("_UseEmissiveIntensity")) { mat.SetFloat("_UseEmissiveIntensity", 1f); } } private Vector3? GetCachedPlayerPosition() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_cachedPlayer == (Object)null) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null) { _cachedPlayer = instance.localPlayerController; } } if (!((Object)(object)_cachedPlayer != (Object)null)) { return null; } return ((Component)_cachedPlayer).transform.position; } private Camera GetCachedCamera() { if ((Object)(object)_cachedCam == (Object)null) { if ((Object)(object)_cachedPlayer == (Object)null) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null) { _cachedPlayer = instance.localPlayerController; } } if ((Object)(object)_cachedPlayer != (Object)null) { _cachedCam = _cachedPlayer.gameplayCamera; } } return _cachedCam; } private static Vector3? GetLocalPlayerPosition() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.localPlayerController != (Object)null) { return ((Component)instance.localPlayerController).transform.position; } return null; } private void UpdateScreenTint() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_screenTint == (Object)null)) { Color color = Plugin.ResolvePresetColor(Plugin.Color.Value); color.a = Mathf.Clamp(Plugin.ScreenTintOpacity.Value, 0f, 0.2f); ((Graphic)_screenTint).color = color; } } private void UpdateScanline() { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_scanline == (Object)null) { return; } if (!Plugin.EnableScanline.Value) { ((Component)_scanline).gameObject.SetActive(false); return; } ((Component)_scanline).gameObject.SetActive(true); if (_time >= _nextGlitchAt && _time >= _glitchUntil) { _glitchUntil = _time + Random.Range(0.04f, 0.13f); _glitchX = Random.Range(-30f, 30f); _glitchOpacityMul = Random.Range(0.35f, 1.7f); _nextGlitchAt = _glitchUntil + Random.Range(0.4f, 1.6f); } bool num = _time < _glitchUntil; float num2 = (num ? _glitchX : 0f); float num3 = (num ? _glitchOpacityMul : 1f); float num4 = _time % 2.5f / 2.5f; ((Graphic)_scanline).rectTransform.anchoredPosition = new Vector2(num2, (0f - num4) * ((float)Screen.height + 50f)); Color val = Plugin.ResolvePresetColor(Plugin.Color.Value); ((Graphic)_scanline).color = new Color(Mathf.Lerp(1f, val.r, 0.4f), Mathf.Lerp(1f, val.g, 0.4f), Mathf.Lerp(1f, val.b, 0.4f), Mathf.Clamp01(0.01f * num3)); } private void UpdateTargetHUD() { //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_0050: 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_00a8: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_hudRoot == (Object)null) { return; } if (!Plugin.EnableTargetHUD.Value) { _hudRoot.SetActive(false); return; } if ((Object)(object)_hudPanelRt != (Object)null) { _hudPanelRt.anchoredPosition = new Vector2(Plugin.HUDPositionX.Value, Plugin.HUDPositionY.Value); } TargetInfo? lookedAtTarget = GetLookedAtTarget(); Color c = Plugin.ResolvePresetColor(Plugin.Color.Value); if (lookedAtTarget.HasValue) { _lastTargetInfo = lookedAtTarget; _hudFadeTimer = 2f; Vector3? cachedPlayerPosition = GetCachedPlayerPosition(); float num = (cachedPlayerPosition.HasValue ? Vector3.Distance(cachedPlayerPosition.Value, lookedAtTarget.Value.Transform.position) : 0f); _hudName.text = "[ " + lookedAtTarget.Value.DisplayName + " ]"; _hudDist.text = $"{num:F1}m"; SetHudAlpha(c, 1f); UpdateBrackets(lookedAtTarget.Value.Transform, num); _hudRoot.SetActive(true); } else if (_hudFadeTimer > 0f) { _hudFadeTimer -= Time.deltaTime; float alpha = Mathf.Clamp01(_hudFadeTimer / 2f); SetHudAlpha(c, alpha); if (_lastTargetInfo.HasValue) { Vector3? cachedPlayerPosition2 = GetCachedPlayerPosition(); float dist = (cachedPlayerPosition2.HasValue ? Vector3.Distance(cachedPlayerPosition2.Value, _lastTargetInfo.Value.Transform.position) : 0f); UpdateBrackets(_lastTargetInfo.Value.Transform, dist); } } else { _hudRoot.SetActive(false); _lastTargetInfo = null; } } private void UpdateBrackets(Transform target, float dist) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) if (_bracketCorners == null || (Object)(object)target == (Object)null) { return; } Camera cachedCamera = GetCachedCamera(); if ((Object)(object)cachedCamera == (Object)null) { return; } if (!_bracketRendCache.TryGetValue(target, out var value) || (Object)(object)value == (Object)null) { value = (Renderer)(((object)((Component)target).GetComponentInChildren<SkinnedMeshRenderer>()) ?? ((object)((Component)target).GetComponentInChildren<MeshRenderer>())); _bracketRendCache[target] = value; } Vector3 val; if ((Object)(object)value != (Object)null) { Bounds bounds = value.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (((Vector3)(ref size)).sqrMagnitude > 0f) { bounds = value.bounds; val = ((Bounds)(ref bounds)).center; goto IL_00ad; } } val = target.position + Vector3.up * 1f; goto IL_00ad; IL_00ad: Vector3 val2 = val; Vector3 val3 = cachedCamera.WorldToViewportPoint(val2); RectTransform[] bracketCorners; if (val3.z < 0f) { bracketCorners = _bracketCorners; foreach (RectTransform val4 in bracketCorners) { if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(false); } } return; } bracketCorners = _bracketCorners; foreach (RectTransform val5 in bracketCorners) { if ((Object)(object)val5 != (Object)null) { ((Component)val5).gameObject.SetActive(true); } } float num = Mathf.Lerp(60f, 18f, Mathf.Clamp01(dist / 30f)); Vector2[] array = (Vector2[])(object)new Vector2[4] { new Vector2(0f - num, num), new Vector2(num, num), new Vector2(num, 0f - num), new Vector2(0f - num, 0f - num) }; Vector2 val6 = default(Vector2); ((Vector2)(ref val6))..ctor(val3.x * (float)Screen.width - (float)Screen.width * 0.5f, val3.y * (float)Screen.height - (float)Screen.height * 0.5f); for (int j = 0; j < _bracketCorners.Length; j++) { if ((Object)(object)_bracketCorners[j] != (Object)null) { _bracketCorners[j].anchoredPosition = val6 + array[j]; } } } private TargetInfo? GetLookedAtTarget() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_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) Camera cachedCamera = GetCachedCamera(); if ((Object)(object)cachedCamera == (Object)null) { return null; } float value = Plugin.MaxRange.Value; int num = Physics.SphereCastNonAlloc(((Component)cachedCamera).transform.position, 1.5f, ((Component)cachedCamera).transform.forward, _raycastBuffer, value); Array.Sort(_raycastBuffer, 0, num, Comparer<RaycastHit>.Create((RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance))); for (int i = 0; i < num; i++) { RaycastHit val = _raycastBuffer[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null)) { EnemyAI componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<EnemyAI>(); if ((Object)(object)componentInParent != (Object)null && !componentInParent.isEnemyDead) { TargetInfo value2 = default(TargetInfo); value2.DisplayName = GetEnemyDisplayName(componentInParent); value2.Transform = ((Component)componentInParent).transform; return value2; } } } return null; } private static string GetEnemyDisplayName(EnemyAI enemy) { ScanNodeProperties componentInChildren = ((Component)enemy).GetComponentInChildren<ScanNodeProperties>(); if ((Object)(object)componentInChildren != (Object)null && !string.IsNullOrEmpty(componentInChildren.headerText)) { return componentInChildren.headerText.ToUpper(); } if (!((Object)(object)enemy.enemyType != (Object)null)) { return "UNKNOWN"; } return enemy.enemyType.enemyName.ToUpper(); } private void SetHudAlpha(Color c, float alpha) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(c.r, c.g, c.b, alpha); Color color2 = default(Color); ((Color)(ref color2))..ctor(c.r * 0.6f, c.g * 0.6f, c.b * 0.6f, alpha * 0.7f); if ((Object)(object)_hudName != (Object)null) { ((Graphic)_hudName).color = color; } if ((Object)(object)_hudDist != (Object)null) { ((Graphic)_hudDist).color = color; } if (_bracketCorners == null) { return; } RectTransform[] bracketCorners = _bracketCorners; foreach (RectTransform val in bracketCorners) { if ((Object)(object)val != (Object)null) { Image[] componentsInChildren = ((Component)val).GetComponentsInChildren<Image>(); for (int j = 0; j < componentsInChildren.Length; j++) { ((Graphic)componentsInChildren[j]).color = color2; } } } } private void BuildOverlay() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _overlayRoot = new GameObject("RedEye_Overlay"); Object.DontDestroyOnLoad((Object)(object)_overlayRoot); _overlayRoot.SetActive(false); Canvas obj = _overlayRoot.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 100; _overlayRoot.AddComponent<CanvasScaler>(); BuildScreenTint(); BuildStaticScanlines(); BuildScanline(); } private void BuildScreenTint() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ScreenTint"); val.transform.SetParent(_overlayRoot.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; _screenTint = val.AddComponent<RawImage>(); _screenTint.texture = (Texture)(object)Texture2D.whiteTexture; ((Graphic)_screenTint).color = Plugin.ResolvePresetColor(Plugin.Color.Value); ((Graphic)_screenTint).raycastTarget = false; } private void BuildStaticScanlines() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_00a4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("StaticScanlines"); val.transform.SetParent(_overlayRoot.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; RawImage obj2 = val.AddComponent<RawImage>(); obj2.texture = (Texture)(object)BuildStaticScanlineTex(); ((Graphic)obj2).color = new Color(0f, 0f, 0f, 0.18f); obj2.uvRect = new Rect(0f, 0f, (float)Screen.width / 3f, (float)Screen.height / 3f); ((Graphic)obj2).raycastTarget = false; } private void BuildScanline() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Scanline"); val.transform.SetParent(_overlayRoot.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 1f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(0.5f, 1f); obj.sizeDelta = new Vector2(0f, 50f); obj.anchoredPosition = Vector2.zero; _scanline = val.AddComponent<RawImage>(); _scanline.texture = (Texture)(object)BuildSoftBandTex(); ((Graphic)_scanline).color = new Color(1f, 1f, 1f, 0.01f); ((Graphic)_scanline).raycastTarget = false; } private static Texture2D BuildSoftBandTex() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 96, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; for (int i = 0; i < 96; i++) { val.SetPixel(0, i, new Color(1f, 1f, 1f, Mathf.Sin((float)i / 95f * (float)Math.PI))); } val.Apply(); return val; } private static Texture2D BuildStaticScanlineTex() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0066: Expected O, but got Unknown Texture2D val = new Texture2D(1, 4, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)0 }; val.SetPixel(0, 0, new Color(0f, 0f, 0f, 1f)); val.SetPixel(0, 1, Color.clear); val.SetPixel(0, 2, Color.clear); val.SetPixel(0, 3, Color.clear); val.Apply(); return val; } private void BuildTargetHUD() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00bb: 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_00ef: 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_012d: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) _hudRoot = new GameObject("RedEye_TargetHUD"); Object.DontDestroyOnLoad((Object)(object)_hudRoot); _hudRoot.SetActive(false); Canvas obj = _hudRoot.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 101; CanvasScaler obj2 = _hudRoot.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)0; obj2.scaleFactor = 1f; _hudCanvasRt = _hudRoot.GetComponent<RectTransform>(); Color val = Plugin.ResolvePresetColor(Plugin.Color.Value); GameObject val2 = new GameObject("HUD_InfoPanel"); val2.transform.SetParent(_hudRoot.transform, false); _hudPanelRt = val2.AddComponent<RectTransform>(); _hudPanelRt.anchorMin = new Vector2(0.5f, 0f); _hudPanelRt.anchorMax = new Vector2(0.5f, 0f); _hudPanelRt.pivot = new Vector2(0.5f, 0f); _hudPanelRt.anchoredPosition = new Vector2(Plugin.HUDPositionX.Value, Plugin.HUDPositionY.Value); _hudPanelRt.sizeDelta = new Vector2(280f, 56f); _hudName = BuildText(val2.transform, "TGT_Name", "[ — ]", 20, (FontStyle)1, (TextAnchor)4, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -4f), new Vector2(270f, 28f)); _hudDist = BuildText(val2.transform, "TGT_Dist", "—", 17, (FontStyle)1, (TextAnchor)4, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -34f), new Vector2(270f, 26f)); _bracketCorners = (RectTransform[])(object)new RectTransform[4]; for (int i = 0; i < 4; i++) { _bracketCorners[i] = BuildBracketCorner(_hudRoot.transform, i, val); } SetHudAlpha(val, 0f); } private static RectTransform BuildBracketCorner(Transform parent, int cornerIndex, Color preset) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(preset.r, preset.g, preset.b, 0.9f); GameObject val = new GameObject($"Bracket_{cornerIndex}"); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); obj.anchorMax = val2; obj.anchorMin = val2; obj.pivot = new Vector2(0.5f, 0.5f); obj.sizeDelta = Vector2.zero; obj.anchoredPosition = Vector2.zero; float num = ((cornerIndex == 0 || cornerIndex == 3) ? 1f : (-1f)); float num2 = ((cornerIndex == 0 || cornerIndex == 1) ? (-1f) : 1f); GameObject val3 = new GameObject("H"); val3.transform.SetParent(val.transform, false); RectTransform obj2 = val3.AddComponent<RectTransform>(); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); obj2.anchorMax = val2; obj2.anchorMin = val2; obj2.pivot = new Vector2(0.5f, 0.5f); obj2.anchoredPosition = new Vector2(7f * num, 0f); obj2.sizeDelta = new Vector2(14f, 2f); ((Graphic)val3.AddComponent<Image>()).color = color; GameObject val4 = new GameObject("V"); val4.transform.SetParent(val.transform, false); RectTransform obj3 = val4.AddComponent<RectTransform>(); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); obj3.anchorMax = val2; obj3.anchorMin = val2; obj3.pivot = new Vector2(0.5f, 0.5f); obj3.anchoredPosition = new Vector2(0f, 7f * num2); obj3.sizeDelta = new Vector2(2f, 14f); ((Graphic)val4.AddComponent<Image>()).color = color; return obj; } private static Text BuildText(Transform parent, string goName, string defaultText, int fontSize, FontStyle style, TextAnchor alignment, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 anchoredPos, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0032: 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_0064: 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_0074: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(goName); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = anchorMin; obj.anchorMax = anchorMax; obj.pivot = pivot; obj.anchoredPosition = anchoredPos; obj.sizeDelta = sizeDelta; Text obj2 = val.AddComponent<Text>(); obj2.text = defaultText; obj2.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); obj2.fontSize = fontSize; obj2.fontStyle = style; obj2.alignment = alignment; ((Graphic)obj2).color = Color.white; ((Graphic)obj2).raycastTarget = false; return obj2; } } public class RedEyeInputActions : LcInputActions { [InputAction("<Keyboard>/period", Name = "Toggle RedEye")] public InputAction ToggleKey { get; set; } } public class RedEyeRunner : MonoBehaviour { private AudioSource _audioSource; private AudioClip _clickClip; public static RedEyeRunner Instance { get; private set; } private void Awake() { Instance = this; Plugin.Logger.LogInfo((object)"RedEye: Runner Awake."); _audioSource = ((Component)this).gameObject.AddComponent<AudioSource>(); _audioSource.playOnAwake = false; _audioSource.spatialBlend = 0f; _audioSource.volume = 1f; LoadClickClip(); CleanupLegacyFiles(); } private void Start() { Plugin.Logger.LogInfo((object)"RedEye: Runner Start."); } private void Update() { if (Plugin.InputActions != null && Plugin.InputActions.ToggleKey.WasPressedThisFrame()) { Plugin.Logger.LogInfo((object)"RedEye: Toggle via InputUtils."); Plugin.ControllerInstance?.Toggle(); } else if (Keyboard.current != null && ((ButtonControl)Keyboard.current.periodKey).wasPressedThisFrame) { Plugin.Logger.LogInfo((object)"RedEye: Toggle via raw keyboard."); Plugin.ControllerInstance?.Toggle(); } Plugin.ControllerInstance?.Tick(Time.deltaTime); } private void LateUpdate() { Plugin.ControllerInstance?.ApplyGlowColors(); } private void LoadClickClip() { try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string n) => n.EndsWith("ButtonClick.wav", StringComparison.OrdinalIgnoreCase)); if (string.IsNullOrEmpty(text)) { Plugin.Logger.LogError((object)"RedEye: ButtonClick.wav not embedded in assembly."); return; } byte[] data; using (Stream stream = executingAssembly.GetManifestResourceStream(text)) { using MemoryStream memoryStream = new MemoryStream(); if (stream == null) { return; } stream.CopyTo(memoryStream); data = memoryStream.ToArray(); } _clickClip = WavLoader.LoadFromBytes(data, "RedEye_ButtonClick"); if ((Object)(object)_clickClip != (Object)null) { Plugin.Logger.LogInfo((object)"RedEye: Click sound loaded."); } else { Plugin.Logger.LogError((object)"RedEye: WAV decode failed - check format."); } } catch (Exception ex) { Plugin.Logger.LogError((object)("RedEye: Audio load failed - " + ex.Message)); } } private static void CleanupLegacyFiles() { try { string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "RedEye_ButtonClick.ogg"); if (File.Exists(path)) { File.Delete(path); } } catch { } } public void PlayClick() { if ((Object)(object)_clickClip != (Object)null && (Object)(object)_audioSource != (Object)null) { _audioSource.PlayOneShot(_clickClip); } } } public static class WavLoader { public static AudioClip LoadFromBytes(byte[] data, string clipName) { if (data == null || data.Length < 44) { return null; } if (data[0] != 82 || data[1] != 73 || data[2] != 70 || data[3] != 70) { return null; } if (data[8] != 87 || data[9] != 65 || data[10] != 86 || data[11] != 69) { return null; } int num = FindChunk(data, "fmt "); int num2 = FindChunk(data, "data"); if (num < 0 || num2 < 0) { return null; } short num3 = BitConverter.ToInt16(data, num + 8); short num4 = BitConverter.ToInt16(data, num + 10); int num5 = BitConverter.ToInt32(data, num + 12); short num6 = BitConverter.ToInt16(data, num + 22); if (num3 != 1) { return null; } int num7 = BitConverter.ToInt32(data, num2 + 4); int num8 = num2 + 8; int num9 = num6 / 8; if (num9 == 0) { return null; } int num10 = num7 / num9; int num11 = num10 / num4; float[] array = new float[num10]; switch (num6) { case 8: { for (int l = 0; l < num10; l++) { array[l] = (float)(data[num8 + l] - 128) / 128f; } break; } case 16: { for (int j = 0; j < num10; j++) { short num13 = BitConverter.ToInt16(data, num8 + j * 2); array[j] = (float)num13 / 32768f; } break; } case 24: { for (int k = 0; k < num10; k++) { int num14 = data[num8 + k * 3]; int num15 = data[num8 + k * 3 + 1]; int num16 = (data[num8 + k * 3 + 2] << 16) | (num15 << 8) | num14; if (((uint)num16 & 0x800000u) != 0) { num16 |= -16777216; } array[k] = (float)num16 / 8388608f; } break; } case 32: { for (int i = 0; i < num10; i++) { int num12 = BitConverter.ToInt32(data, num8 + i * 4); array[i] = (float)num12 / 2.1474836E+09f; } break; } default: return null; } AudioClip obj = AudioClip.Create(clipName, num11, (int)num4, num5, false); obj.SetData(array, 0); return obj; } private static int FindChunk(byte[] data, string id) { int num = 12; while (num < data.Length - 8) { if (data[num] == id[0] && data[num + 1] == id[1] && data[num + 2] == id[2] && data[num + 3] == id[3]) { return num; } int num2 = BitConverter.ToInt32(data, num + 4); num += 8 + num2; if (((uint)num2 & (true ? 1u : 0u)) != 0) { num++; } } return -1; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "RedEye"; public const string PLUGIN_NAME = "RedEye"; public const string PLUGIN_VERSION = "1.0.0"; }