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 ScanRecolorPlus v1.0.1
ScanRecolorRework.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ScanRecolorRework")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ScanRecolorRework")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("46114aec-931f-4466-b3f9-9e803b580843")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("1.0.0.0")] namespace hoppinhauler.ScanRecolorRework; [HarmonyPatch] internal static class HUDManagerPatch { private const float ScanDuration = 1.3f; private static MeshRenderer _scanRenderer; private static Volume _scanVolume; private static Vignette _scanVignette; private static Bloom _scanBloom; private static Texture2D _baseScanLinesTextureReadable; private static Color? _currentRandomColor; private static float _gradientT; private static FieldInfo _fiPlayerPingingScan; private static MethodInfo _miCanPlayerScan; private static bool _applyQueued; private static bool HasScanMaterial { get { MeshRenderer scanRenderer = ScanRenderer; return (Object)(object)scanRenderer != (Object)null && (Object)(object)((Renderer)scanRenderer).material != (Object)null; } } private static MeshRenderer ScanRenderer { get { if ((Object)(object)_scanRenderer != (Object)null && (Object)(object)((Renderer)_scanRenderer).material != (Object)null) { return _scanRenderer; } HUDManager instance = HUDManager.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.scanEffectAnimator == (Object)null) { return null; } MeshRenderer scanRenderer = default(MeshRenderer); if (!((Component)instance.scanEffectAnimator).TryGetComponent<MeshRenderer>(ref scanRenderer)) { return null; } _scanRenderer = scanRenderer; return _scanRenderer; } } private static Volume ScanVolume { get { if ((Object)(object)_scanVolume != (Object)null) { return _scanVolume; } try { Volume[] array = Object.FindObjectsByType<Volume>((FindObjectsSortMode)0); if (array != null) { _scanVolume = ((IEnumerable<Volume>)array).FirstOrDefault((Func<Volume, bool>)delegate(Volume v) { if ((Object)(object)v == (Object)null) { return false; } VolumeProfile profile = v.profile; if ((Object)(object)profile == (Object)null) { return false; } string name = ((Object)profile).name; return !string.IsNullOrEmpty(name) && name.StartsWith("ScanVolume", StringComparison.OrdinalIgnoreCase); }); } } catch { } return _scanVolume; } } private static Vignette ScanVignette { get { if ((Object)(object)_scanVignette != (Object)null) { return _scanVignette; } Volume scanVolume = ScanVolume; if ((Object)(object)scanVolume == (Object)null || (Object)(object)scanVolume.profile == (Object)null || scanVolume.profile.components == null) { return null; } VolumeComponent? obj = ((IEnumerable<VolumeComponent>)scanVolume.profile.components).FirstOrDefault((Func<VolumeComponent, bool>)delegate(VolumeComponent c) { if ((Object)(object)c == (Object)null) { return false; } string name = ((Object)c).name; return !string.IsNullOrEmpty(name) && name.StartsWith("Vignette", StringComparison.OrdinalIgnoreCase); }); _scanVignette = (Vignette)(object)((obj is Vignette) ? obj : null); return _scanVignette; } } private static Bloom ScanBloom { get { if ((Object)(object)_scanBloom != (Object)null) { return _scanBloom; } Volume scanVolume = ScanVolume; if ((Object)(object)scanVolume == (Object)null || (Object)(object)scanVolume.profile == (Object)null || scanVolume.profile.components == null) { return null; } VolumeComponent? obj = ((IEnumerable<VolumeComponent>)scanVolume.profile.components).FirstOrDefault((Func<VolumeComponent, bool>)delegate(VolumeComponent c) { if ((Object)(object)c == (Object)null) { return false; } string name = ((Object)c).name; return !string.IsNullOrEmpty(name) && name.StartsWith("Bloom", StringComparison.OrdinalIgnoreCase); }); _scanBloom = (Bloom)(object)((obj is Bloom) ? obj : null); return _scanBloom; } } internal static void RequestApply() { _applyQueued = true; ApplyAllIfPossible(); } private static bool TryGetPlayerPingingScan(out float value) { value = -1f; HUDManager instance = HUDManager.Instance; if ((Object)(object)instance == (Object)null) { return false; } try { if (_fiPlayerPingingScan == null) { _fiPlayerPingingScan = typeof(HUDManager).GetField("playerPingingScan", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_fiPlayerPingingScan == null) { return false; } object value2 = _fiPlayerPingingScan.GetValue(instance); if (value2 is float) { float num = (float)value2; if (true) { value = num; return true; } } } catch { } return false; } private static bool IsScanActive() { float value; return TryGetPlayerPingingScan(out value) && value > -1f; } private static float ScanProgress01() { if (!TryGetPlayerPingingScan(out var value)) { return 0f; } float num = (value + 1f) / 1.3f; if (num < 0f) { num = 0f; } if (num > 1f) { num = 1f; } return num; } private static bool CanPlayerScanSafe() { HUDManager instance = HUDManager.Instance; if ((Object)(object)instance == (Object)null) { return false; } try { if (_miCanPlayerScan == null) { _miCanPlayerScan = AccessTools.Method(typeof(HUDManager), "CanPlayerScan", (Type[])null, (Type[])null); } if (_miCanPlayerScan == null) { return false; } object obj = _miCanPlayerScan.Invoke(instance, null); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } private static Color GetEffectiveScanColor(bool includeAnimatedAlpha) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0029: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_023f: Unknown result type (might be due to invalid IL or missing references) Color baseScanColor = ModConfig.GetBaseScanColor(); Color c = baseScanColor; if (ModConfig.RandomModePerScan.Value == RandomMode.Gradient) { Color val = ResolveColorOrFallback(ModConfig.GradientA.Value, baseScanColor); Color val2 = ResolveColorOrFallback(ModConfig.GradientB.Value, baseScanColor); float value = ModConfig.GradientSpeed.Value; if (value <= 0f) { c = val; } else { _gradientT += Time.deltaTime * value; float gradientT = _gradientT; float num = gradientT - (float)Math.Floor(gradientT); if (ModConfig.GradientPingPong.Value) { float num2 = ((num < 0.5f) ? (num * 2f) : (2f - num * 2f)); c = Color.Lerp(val, val2, num2); } else { c = Color.Lerp(val, val2, num); } } c.a = baseScanColor.a; } else if (ModConfig.RandomModePerScan.Value != 0) { c = ((!_currentRandomColor.HasValue) ? baseScanColor : _currentRandomColor.Value); } c.a = baseScanColor.a; if (includeAnimatedAlpha && IsScanActive()) { float num3 = baseScanColor.a; if (ModConfig.FadeEnabled.Value) { float x = ScanProgress01(); num3 *= ModConfig.ApplyCurve(x, ModConfig.FadeCurveMode.Value); } if (ModConfig.PulseEnabled.Value) { float value2 = ModConfig.PulseStrength.Value; float value3 = ModConfig.PulseSpeed.Value; if (value2 > 0f && value3 > 0f) { float num4 = (float)(Math.Sin((double)(Time.time * value3) * Math.PI * 2.0) * 0.5 + 0.5); float num5 = 1f - value2 + value2 * num4; num3 *= num5; } } c.a = ModConfig.Clamp01(num3); } return ModConfig.ApplyMaxBrightness(c, ModConfig.Clamp01(ModConfig.MaxBrightness.Value)); } private static Color ResolveColorOrFallback(string s, Color fallback) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (ModConfig.TryParseColorString(s, out var color)) { return color; } return fallback; } private static Color BuildRandomFull() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); ((Color)(ref result))..ctor(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), 1f); result.a = ModConfig.ResolveRandomAlpha(); return result; } private static Color BuildRandomHueOnly() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_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_00cc: Unknown result type (might be due to invalid IL or missing references) Color baseScanColor = ModConfig.GetBaseScanColor(); float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(baseScanColor, ref num, ref num2, ref num3); float num4 = ModConfig.RandomHueJitter.Value / 360f; float num5 = Random.Range(0f - num4, num4); float num6 = ModConfig.Clamp01(ModConfig.RandomSVJitter.Value); float num7 = Random.Range(0f - num6, num6); float num8 = Random.Range(0f - num6, num6); float num9; for (num9 = num + num5; num9 < 0f; num9 += 1f) { } while (num9 > 1f) { num9 -= 1f; } float num10 = ModConfig.Clamp01(num2 + num7); float num11 = ModConfig.Clamp01(num3 + num8); Color result = Color.HSVToRGB(num9, num10, num11); result.a = ModConfig.ResolveRandomAlpha(); return result; } private static Color BuildRandomFromPalette() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) List<Color> list = ModConfig.ParsePaletteOrFallback(); int index = Random.Range(0, list.Count); Color result = list[index]; result.a = ModConfig.ResolveRandomAlpha(); return result; } private static void ApplyAllIfPossible() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (ModConfig.Enabled.Value) { if ((Object)(object)ScanRenderer == (Object)null) { _applyQueued = true; return; } _applyQueued = false; Color effectiveScanColor = GetEffectiveScanColor(includeAnimatedAlpha: true); ApplyScanOverlayColor(effectiveScanColor); ApplyVignette(effectiveScanColor); ApplyBloom(effectiveScanColor); ApplyScanLines(effectiveScanColor); } } private static void ApplyScanOverlayColor(Color col) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!HasScanMaterial) { return; } try { ((Renderer)ScanRenderer).material.color = col; } catch { } } private static void ApplyVignette(Color scanColor) { //IL_006f: 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_0075: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (!ModConfig.VignetteEnabled.Value) { return; } Vignette scanVignette = ScanVignette; if ((Object)(object)scanVignette == (Object)null) { return; } try { ((VolumeParameter<float>)(object)scanVignette.intensity).value = ModConfig.VignetteIntensity.Value; Color value; if (ModConfig.VignetteUseScanColor.Value) { value = scanColor; value.a = 1f; } else { value = ResolveColorOrFallback(ModConfig.VignetteColor.Value, scanColor); value.a = ModConfig.Clamp01(ModConfig.VignetteAlpha.Value); } ((VolumeParameter<Color>)(object)scanVignette.color).value = value; } catch { } } private static void ApplyBloom(Color scanColor) { //IL_004d: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_009d: 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) if (!ModConfig.BloomEnabled.Value) { return; } Bloom scanBloom = ScanBloom; if ((Object)(object)scanBloom == (Object)null) { return; } try { Color val = (ModConfig.BloomUseScanColor.Value ? scanColor : ResolveColorOrFallback(ModConfig.BloomColor.Value, scanColor)); val.a = ModConfig.Clamp01(ModConfig.BloomAlpha.Value); float value = ModConfig.BloomTintStrength.Value; val.r = ModConfig.Clamp01(val.r * value); val.g = ModConfig.Clamp01(val.g * value); val.b = ModConfig.Clamp01(val.b * value); ((VolumeParameter<Color>)(object)scanBloom.tint).Override(val); } catch { } } private static void ApplyScanLines(Color scanColor) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (!ModConfig.ScanLinesEnabled.Value) { return; } Bloom scanBloom = ScanBloom; if ((Object)(object)scanBloom == (Object)null || (VolumeParameter<Texture>)(object)scanBloom.dirtTexture == (Texture)null) { return; } if (!ModConfig.RecolorScanLines.Value) { RevertScanLinesTexture(); return; } try { EnsureBaseScanLinesReadable(); if (!((Object)(object)_baseScanLinesTextureReadable == (Object)null) && ((Texture)_baseScanLinesTextureReadable).isReadable) { float num = ModConfig.Clamp01(ModConfig.ScanLinesRecolorStrength.Value); if (num <= 0.001f) { RevertScanLinesTexture(); return; } Texture2D val = new Texture2D(((Texture)_baseScanLinesTextureReadable).width, ((Texture)_baseScanLinesTextureReadable).height, _baseScanLinesTextureReadable.format, false); val.SetPixels(_baseScanLinesTextureReadable.GetPixels()); val.Apply(false, false); TextureUtils.RecolorTextureInPlace(val, scanColor, num, ModConfig.Clamp01(ModConfig.ScanLinesMinLuma.Value), ModConfig.Clamp01(ModConfig.ScanLinesMinAlpha.Value)); val.Apply(false, false); ((VolumeParameter<Texture>)(object)scanBloom.dirtTexture).Override((Texture)(object)Object.Instantiate<Texture2D>(val)); } } catch { } } private static void EnsureBaseScanLinesReadable() { if ((Object)(object)_baseScanLinesTextureReadable != (Object)null) { return; } Bloom scanBloom = ScanBloom; if ((Object)(object)scanBloom == (Object)null || (VolumeParameter<Texture>)(object)scanBloom.dirtTexture == (Texture)null) { return; } try { Texture value = ((VolumeParameter<Texture>)(object)scanBloom.dirtTexture).value; if (!((Object)(object)value == (Object)null)) { Texture2D val = (Texture2D)(object)((value is Texture2D) ? value : null); if ((Object)(object)val != (Object)null && ((Texture)val).isReadable) { _baseScanLinesTextureReadable = val; } else { _baseScanLinesTextureReadable = TextureUtils.MakeReadableTexture(value); } } } catch { } } private static void RevertScanLinesTexture() { try { Bloom scanBloom = ScanBloom; if (!((Object)(object)scanBloom == (Object)null) && !((VolumeParameter<Texture>)(object)scanBloom.dirtTexture == (Texture)null) && (Object)(object)_baseScanLinesTextureReadable != (Object)null) { ((VolumeParameter<Texture>)(object)scanBloom.dirtTexture).Override((Texture)(object)_baseScanLinesTextureReadable); } } catch { } } [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyPostfix] private static void HUDStartPostfix() { _scanRenderer = null; _scanVolume = null; _scanVignette = null; _scanBloom = null; _fiPlayerPingingScan = null; _miCanPlayerScan = null; _currentRandomColor = null; _gradientT = 0f; _applyQueued = true; ApplyAllIfPossible(); } [HarmonyPatch(typeof(HUDManager), "Update")] [HarmonyPostfix] private static void HUDUpdatePostfix() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (ModConfig.Enabled.Value) { if (_applyQueued && Time.frameCount % 10 == 0) { ApplyAllIfPossible(); } if (IsScanActive()) { Color effectiveScanColor = GetEffectiveScanColor(includeAnimatedAlpha: true); ApplyScanOverlayColor(effectiveScanColor); ApplyVignette(effectiveScanColor); ApplyBloom(effectiveScanColor); } } } [HarmonyPatch(typeof(HUDManager), "Awake")] [HarmonyPostfix] private static void HUDAwakePostfix() { ResetForNewHudInstance(); } [HarmonyPatch(typeof(HUDManager), "OnEnable")] [HarmonyPostfix] private static void HUDOnEnablePostfix() { ResetForNewHudInstance(); } private static void ResetForNewHudInstance() { _scanRenderer = null; _scanVolume = null; _scanVignette = null; _scanBloom = null; _fiPlayerPingingScan = null; _miCanPlayerScan = null; _currentRandomColor = null; _gradientT = 0f; _applyQueued = true; ApplyAllIfPossible(); } [HarmonyPatch(typeof(HUDManager), "PingScan_performed")] [HarmonyPrefix] private static void PingScanPerformedPrefix(object __0) { //IL_005e: 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_0080: Unknown result type (might be due to invalid IL or missing references) if (ModConfig.Enabled.Value && CanPlayerScanSafe()) { switch (ModConfig.RandomModePerScan.Value) { case RandomMode.Off: _currentRandomColor = null; break; case RandomMode.Full: _currentRandomColor = BuildRandomFull(); break; case RandomMode.HueOnly: _currentRandomColor = BuildRandomHueOnly(); break; case RandomMode.Palette: _currentRandomColor = BuildRandomFromPalette(); break; case RandomMode.Gradient: _currentRandomColor = null; _gradientT = 0f; break; } _applyQueued = true; ApplyAllIfPossible(); } } } internal enum ColorMode { Preset, RGB, HSV } internal enum RandomMode { Off, Full, HueOnly, Palette, Gradient } internal enum FadeCurve { Linear, EaseIn, EaseOut, EaseInOut, Exponential } internal static class ModConfig { public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> ResetOnSceneLoad; public static ConfigEntry<ColorMode> BaseColorMode; public static ConfigEntry<string> Preset; public static ConfigEntry<int> Red; public static ConfigEntry<int> Green; public static ConfigEntry<int> Blue; public static ConfigEntry<float> Hue; public static ConfigEntry<float> Saturation; public static ConfigEntry<float> Value; public static ConfigEntry<float> Alpha; public static ConfigEntry<float> MaxBrightness; public static ConfigEntry<RandomMode> RandomModePerScan; public static ConfigEntry<bool> RandomFixedAlpha; public static ConfigEntry<float> RandomAlpha; public static ConfigEntry<float> RandomAlphaMin; public static ConfigEntry<float> RandomAlphaMax; public static ConfigEntry<string> RandomPalette; public static ConfigEntry<float> RandomHueJitter; public static ConfigEntry<float> RandomSVJitter; public static ConfigEntry<string> GradientA; public static ConfigEntry<string> GradientB; public static ConfigEntry<float> GradientSpeed; public static ConfigEntry<bool> GradientPingPong; public static ConfigEntry<bool> FadeEnabled; public static ConfigEntry<FadeCurve> FadeCurveMode; public static ConfigEntry<bool> PulseEnabled; public static ConfigEntry<float> PulseSpeed; public static ConfigEntry<float> PulseStrength; public static ConfigEntry<bool> VignetteEnabled; public static ConfigEntry<float> VignetteIntensity; public static ConfigEntry<bool> VignetteUseScanColor; public static ConfigEntry<string> VignetteColor; public static ConfigEntry<float> VignetteAlpha; public static ConfigEntry<bool> BloomEnabled; public static ConfigEntry<float> BloomTintStrength; public static ConfigEntry<bool> BloomUseScanColor; public static ConfigEntry<string> BloomColor; public static ConfigEntry<float> BloomAlpha; public static ConfigEntry<bool> ScanLinesEnabled; public static ConfigEntry<bool> RecolorScanLines; public static ConfigEntry<float> ScanLinesRecolorStrength; public static ConfigEntry<float> ScanLinesMinLuma; public static ConfigEntry<float> ScanLinesMinAlpha; private static readonly Dictionary<string, string> Presets = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Cyan", "#00E5FFFF" }, { "Green", "#00FF55FF" }, { "Red", "#FF2A2AFF" }, { "Purple", "#B000FFFF" }, { "Amber", "#FFB000FF" }, { "White", "#FFFFFFFF" }, { "Pink", "#FF4FD8FF" }, { "Default", "#000CFFFF" } }; public static void Bind(ConfigFile cfg) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Expected O, but got Unknown //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Expected O, but got Unknown //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Expected O, but got Unknown //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Expected O, but got Unknown //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Expected O, but got Unknown //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Expected O, but got Unknown //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Expected O, but got Unknown //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Expected O, but got Unknown //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Expected O, but got Unknown //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Expected O, but got Unknown //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0679: Expected O, but got Unknown //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06e8: Expected O, but got Unknown //IL_0717: Unknown result type (might be due to invalid IL or missing references) //IL_0721: Expected O, but got Unknown //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Expected O, but got Unknown Enabled = cfg.Bind<bool>("General", "Enabled", true, "Enable/disable the mod."); ResetOnSceneLoad = cfg.Bind<bool>("General", "ResetOnSceneLoad", true, "Reset cached references when a scene loads (recommended)."); BaseColorMode = cfg.Bind<ColorMode>("Color", "Mode", ColorMode.Preset, "Base color mode: Preset / RGB / HSV."); Preset = cfg.Bind<string>("Color", "Preset", "White", "Preset name (Cyan, Green, Red, Purple, Amber, White) or hex (#RRGGBB / #RRGGBBAA)."); Red = cfg.Bind<int>("Color.RGB", "Red", 0, new ConfigDescription("Red channel (0..255).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), new object[0])); Green = cfg.Bind<int>("Color.RGB", "Green", 229, new ConfigDescription("Green channel (0..255).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), new object[0])); Blue = cfg.Bind<int>("Color.RGB", "Blue", 255, new ConfigDescription("Blue channel (0..255).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), new object[0])); Hue = cfg.Bind<float>("Color.HSV", "Hue", 190f, new ConfigDescription("Hue (0..360).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 360f), new object[0])); Saturation = cfg.Bind<float>("Color.HSV", "Saturation", 1f, new ConfigDescription("Saturation (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); Value = cfg.Bind<float>("Color.HSV", "Value", 1f, new ConfigDescription("Value/Brightness (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); Alpha = cfg.Bind<float>("Color", "Alpha", 0.5636086f, new ConfigDescription("Scan overlay alpha/opacity (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); MaxBrightness = cfg.Bind<float>("Color", "MaxBrightness", 1f, new ConfigDescription("Clamp overall brightness (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); RandomModePerScan = cfg.Bind<RandomMode>("Random", "Mode", RandomMode.HueOnly, "Random color per scan: Off / Full / HueOnly / Palette / Gradient."); RandomFixedAlpha = cfg.Bind<bool>("Random", "FixedAlpha", true, "Use fixed alpha for random colors (otherwise AlphaMin..AlphaMax)."); RandomAlpha = cfg.Bind<float>("Random", "Alpha", 0.26f, new ConfigDescription("Fixed random alpha (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); RandomAlphaMin = cfg.Bind<float>("Random", "AlphaMin", 0.26f, new ConfigDescription("Min random alpha when FixedAlpha=false (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); RandomAlphaMax = cfg.Bind<float>("Random", "AlphaMax", 0.65f, new ConfigDescription("Max random alpha when FixedAlpha=false (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); RandomPalette = cfg.Bind<string>("Random", "Palette", "Cyan, Purple, Green, Amber", "Palette for Random=Palette. Items can be preset names or hex."); RandomHueJitter = cfg.Bind<float>("Random", "HueJitter", 9.65953f, new ConfigDescription("Hue jitter in degrees for HueOnly (0..180).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 180f), new object[0])); RandomSVJitter = cfg.Bind<float>("Random", "SVJitter", 0.02869597f, new ConfigDescription("Small S/V jitter for HueOnly (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); GradientA = cfg.Bind<string>("Gradient", "ColorA", "Cyan", "Gradient color A (preset or hex)."); GradientB = cfg.Bind<string>("Gradient", "ColorB", "Purple", "Gradient color B (preset or hex)."); GradientSpeed = cfg.Bind<float>("Gradient", "Speed", 0.6f, new ConfigDescription("Gradient speed in cycles per second (0..5).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); GradientPingPong = cfg.Bind<bool>("Gradient", "PingPong", true, "Ping-pong between A and B instead of looping."); FadeEnabled = cfg.Bind<bool>("Fade", "Enabled", false, "Enable fade alpha animation during scan."); FadeCurveMode = cfg.Bind<FadeCurve>("Fade", "Curve", FadeCurve.EaseOut, "Fade curve: Linear / EaseIn / EaseOut / EaseInOut / Exponential."); PulseEnabled = cfg.Bind<bool>("Animation", "Pulse", true, "Enable alpha pulsing during scan."); PulseSpeed = cfg.Bind<float>("Animation", "PulseSpeed", 3.139388f, new ConfigDescription("Pulse frequency in Hz (0..20).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), new object[0])); PulseStrength = cfg.Bind<float>("Animation", "PulseStrength", 0.2991548f, new ConfigDescription("Pulse strength (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); VignetteEnabled = cfg.Bind<bool>("Vignette", "Enabled", true, "Control scan vignette settings."); VignetteIntensity = cfg.Bind<float>("Vignette", "Intensity", 0.7582871f, new ConfigDescription("Vignette intensity (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); VignetteUseScanColor = cfg.Bind<bool>("Vignette", "UseScanColor", true, "Use scan color for vignette color."); VignetteColor = cfg.Bind<string>("Vignette", "Color", "#00E5FFFF", "Vignette color when UseScanColor=false (preset or hex)."); VignetteAlpha = cfg.Bind<float>("Vignette", "Alpha", 1f, new ConfigDescription("Vignette alpha when UseScanColor=false (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); BloomEnabled = cfg.Bind<bool>("Bloom", "Enabled", true, "Control scan bloom tint settings."); BloomTintStrength = cfg.Bind<float>("Bloom", "TintStrength", 1.511349f, new ConfigDescription("Bloom tint multiplier (0..2).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), new object[0])); BloomUseScanColor = cfg.Bind<bool>("Bloom", "UseScanColor", true, "Use scan color for bloom tint."); BloomColor = cfg.Bind<string>("Bloom", "Color", "#00E5FFFF", "Bloom tint color when UseScanColor=false (preset or hex)."); BloomAlpha = cfg.Bind<float>("Bloom", "Alpha", 1f, new ConfigDescription("Bloom tint alpha (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); ScanLinesEnabled = cfg.Bind<bool>("ScanLines", "Enabled", true, "Enable/disable scan-lines (bloom dirt texture) handling."); RecolorScanLines = cfg.Bind<bool>("ScanLines", "Recolor", true, "Recolor scan-lines texture using the scan color."); ScanLinesRecolorStrength = cfg.Bind<float>("ScanLines", "RecolorStrength", 1f, new ConfigDescription("How strongly to recolor scan-lines (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); ScanLinesMinLuma = cfg.Bind<float>("ScanLines", "MinLuma", 0.05f, new ConfigDescription("Minimum pixel brightness threshold to recolor (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); ScanLinesMinAlpha = cfg.Bind<float>("ScanLines", "MinAlpha", 0.05f, new ConfigDescription("Minimum pixel alpha threshold to recolor (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); HookApplyOnChanges(); } private static void HookApplyOnChanges() { Action apply = HUDManagerPatch.RequestApply; Enabled.SettingChanged += delegate { apply(); }; ResetOnSceneLoad.SettingChanged += delegate { apply(); }; BaseColorMode.SettingChanged += delegate { apply(); }; Preset.SettingChanged += delegate { apply(); }; Red.SettingChanged += delegate { apply(); }; Green.SettingChanged += delegate { apply(); }; Blue.SettingChanged += delegate { apply(); }; Hue.SettingChanged += delegate { apply(); }; Saturation.SettingChanged += delegate { apply(); }; Value.SettingChanged += delegate { apply(); }; Alpha.SettingChanged += delegate { apply(); }; MaxBrightness.SettingChanged += delegate { apply(); }; RandomModePerScan.SettingChanged += delegate { apply(); }; RandomFixedAlpha.SettingChanged += delegate { apply(); }; RandomAlpha.SettingChanged += delegate { apply(); }; RandomAlphaMin.SettingChanged += delegate { apply(); }; RandomAlphaMax.SettingChanged += delegate { apply(); }; RandomPalette.SettingChanged += delegate { apply(); }; RandomHueJitter.SettingChanged += delegate { apply(); }; RandomSVJitter.SettingChanged += delegate { apply(); }; GradientA.SettingChanged += delegate { apply(); }; GradientB.SettingChanged += delegate { apply(); }; GradientSpeed.SettingChanged += delegate { apply(); }; GradientPingPong.SettingChanged += delegate { apply(); }; FadeEnabled.SettingChanged += delegate { apply(); }; FadeCurveMode.SettingChanged += delegate { apply(); }; PulseEnabled.SettingChanged += delegate { apply(); }; PulseSpeed.SettingChanged += delegate { apply(); }; PulseStrength.SettingChanged += delegate { apply(); }; VignetteEnabled.SettingChanged += delegate { apply(); }; VignetteIntensity.SettingChanged += delegate { apply(); }; VignetteUseScanColor.SettingChanged += delegate { apply(); }; VignetteColor.SettingChanged += delegate { apply(); }; VignetteAlpha.SettingChanged += delegate { apply(); }; BloomEnabled.SettingChanged += delegate { apply(); }; BloomTintStrength.SettingChanged += delegate { apply(); }; BloomUseScanColor.SettingChanged += delegate { apply(); }; BloomColor.SettingChanged += delegate { apply(); }; BloomAlpha.SettingChanged += delegate { apply(); }; ScanLinesEnabled.SettingChanged += delegate { apply(); }; RecolorScanLines.SettingChanged += delegate { apply(); }; ScanLinesRecolorStrength.SettingChanged += delegate { apply(); }; ScanLinesMinLuma.SettingChanged += delegate { apply(); }; ScanLinesMinAlpha.SettingChanged += delegate { apply(); }; } internal static bool TryParseColorString(string s, out Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) color = default(Color); if (string.IsNullOrWhiteSpace(s)) { return false; } string text = s.Trim(); if (Presets.TryGetValue(text, out var value)) { text = value; } if (text.StartsWith("#", StringComparison.Ordinal)) { return TryParseHex(text, out color); } if (text.IndexOf(",") >= 0) { return TryParseCsv(text, out color); } return false; } private static bool TryParseHex(string hex, out Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) color = default(Color); string text = hex.Trim(); if (!text.StartsWith("#", StringComparison.Ordinal)) { return false; } text = text.Substring(1); if (text.Length != 6 && text.Length != 8) { return false; } try { byte b = byte.Parse(text.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); byte b2 = byte.Parse(text.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); byte b3 = byte.Parse(text.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); byte b4 = byte.MaxValue; if (text.Length == 8) { b4 = byte.Parse(text.Substring(6, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); } color = new Color((float)(int)b / 255f, (float)(int)b2 / 255f, (float)(int)b3 / 255f, (float)(int)b4 / 255f); return true; } catch { return false; } } private static bool TryParseCsv(string csv, out Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) color = default(Color); string[] array = csv.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length != 3 && array.Length != 4) { return false; } float[] array2 = new float[array.Length]; for (int i = 0; i < array.Length; i++) { if (!float.TryParse(array[i].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return false; } array2[i] = result; } bool flag = array2.Take(3).Any((float x) => x > 1f); float v = (flag ? (array2[0] / 255f) : array2[0]); float v2 = (flag ? (array2[1] / 255f) : array2[1]); float v3 = (flag ? (array2[2] / 255f) : array2[2]); float v4 = 1f; if (array.Length == 4) { v4 = ((array2[3] > 1f) ? (array2[3] / 255f) : array2[3]); } color = new Color(Clamp01(v), Clamp01(v2), Clamp01(v3), Clamp01(v4)); return true; } internal static Color GetBaseScanColor() { //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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); switch (BaseColorMode.Value) { case ColorMode.RGB: ((Color)(ref color))..ctor((float)Red.Value / 255f, (float)Green.Value / 255f, (float)Blue.Value / 255f, Alpha.Value); break; case ColorMode.HSV: color = Color.HSVToRGB(Clamp01(Hue.Value / 360f), Clamp01(Saturation.Value), Clamp01(Value.Value)); color.a = Alpha.Value; break; default: if (!TryParseColorString(Preset.Value, out color)) { ((Color)(ref color))..ctor(0f, 0.8980392f, 1f, Alpha.Value); } color.a = Alpha.Value; break; } color = ApplyMaxBrightness(color, Clamp01(MaxBrightness.Value)); return color; } internal static List<Color> ParsePaletteOrFallback() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) List<Color> list = new List<Color>(); string text = RandomPalette.Value ?? string.Empty; string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { if (TryParseColorString(array[i].Trim(), out var color)) { list.Add(color); } } if (list.Count == 0) { if (TryParseColorString("Cyan", out var color2)) { list.Add(color2); } if (TryParseColorString("Purple", out color2)) { list.Add(color2); } } return list; } internal static float ResolveRandomAlpha() { if (RandomFixedAlpha.Value) { return Clamp01(RandomAlpha.Value); } float num = Clamp01(RandomAlphaMin.Value); float num2 = Clamp01(RandomAlphaMax.Value); if (num2 < num) { float num3 = num; num = num2; num2 = num3; } return Random.Range(num, num2); } internal static float Clamp01(float v) { if (v < 0f) { return 0f; } if (v > 1f) { return 1f; } return v; } internal static Color ApplyMaxBrightness(Color c, float maxB) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0047: Unknown result type (might be due to invalid IL or missing references) if (maxB >= 0.999f) { return c; } float num = default(float); float num2 = default(float); float val = default(float); Color.RGBToHSV(c, ref num, ref num2, ref val); val = Math.Min(val, maxB); Color result = Color.HSVToRGB(num, num2, val); result.a = c.a; return result; } internal static float ApplyCurve(float x, FadeCurve curve) { x = Clamp01(x); return curve switch { FadeCurve.Linear => x, FadeCurve.EaseIn => x * x, FadeCurve.EaseOut => 1f - (1f - x) * (1f - x), FadeCurve.EaseInOut => (x < 0.5f) ? (2f * x * x) : (1f - (float)Math.Pow(-2f * x + 2f, 2.0) / 2f), FadeCurve.Exponential => (float)Math.Pow(x, 3.0), _ => x, }; } } [BepInPlugin("HoppinHauler.ScanRecolorPlus", "ScanRecolorPlus", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "HoppinHauler.ScanRecolorPlus"; public const string PluginName = "ScanRecolorPlus"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static Plugin Instance; private Harmony _harmony; internal static ConfigFile BepInExConfig() { return ((Object)(object)Instance != (Object)null) ? ((BaseUnityPlugin)Instance).Config : null; } private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; ModConfig.Bind(((BaseUnityPlugin)this).Config); _harmony = new Harmony("HoppinHauler.ScanRecolorPlus"); _harmony.PatchAll(typeof(HUDManagerPatch)); SceneHooks.Install(); Log.LogInfo((object)"ScanRecolorPlus v1.0.0 loaded."); } private void OnDestroy() { SceneHooks.Uninstall(); try { _harmony.UnpatchSelf(); } catch { } } } internal static class SceneHooks { private static bool _installed; public static void Install() { if (!_installed) { _installed = true; SceneManager.sceneLoaded += OnSceneLoaded; } } public static void Uninstall() { if (_installed) { _installed = false; SceneManager.sceneLoaded -= OnSceneLoaded; } } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (ModConfig.ResetOnSceneLoad.Value) { HUDManagerPatch.RequestApply(); } else { HUDManagerPatch.RequestApply(); } } } internal static class TextureUtils { public static Texture2D MakeReadableTexture(Texture original) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)original == (Object)null) { return null; } RenderTexture val = null; RenderTexture active = null; try { val = RenderTexture.GetTemporary(original.width, original.height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)1); Graphics.Blit(original, val); active = RenderTexture.active; RenderTexture.active = val; Texture2D val2 = new Texture2D(original.width, original.height, (TextureFormat)4, false); val2.ReadPixels(new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), 0, 0); val2.Apply(false, false); return val2; } catch { return null; } finally { try { RenderTexture.active = active; } catch { } try { if ((Object)(object)val != (Object)null) { RenderTexture.ReleaseTemporary(val); } } catch { } } } public static void RecolorTextureInPlace(Texture2D texture, Color targetColor, float strength, float minLuma, float minAlpha) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_009b: 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_00ad: 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_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) if ((Object)(object)texture == (Object)null) { return; } strength = Clamp01(strength); if (strength <= 0f) { return; } Color[] pixels; try { pixels = texture.GetPixels(); } catch { return; } Color val2 = default(Color); for (int i = 0; i < pixels.Length; i++) { Color val = pixels[i]; if (!(val.a < minAlpha)) { float num = (val.r + val.g + val.b) / 3f; if (!(num < minLuma)) { ((Color)(ref val2))..ctor(targetColor.r * num, targetColor.g * num, targetColor.b * num, val.a); pixels[i] = Color.Lerp(val, val2, strength); } } } try { texture.SetPixels(pixels); } catch { } } private static float Clamp01(float v) { if (v < 0f) { return 0f; } if (v > 1f) { return 1f; } return v; } }