Decompiled source of UltraRT v0.3.0
patchers/UltraRT.Preload.dll
Decompiled 4 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Mono.Cecil; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("UltraRT.Preload")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0+eb0851ff0245493cc431eed3e9fd57805a8b1d2d")] [assembly: AssemblyProduct("UltraRT.Preload")] [assembly: AssemblyTitle("UltraRT.Preload")] [assembly: AssemblyVersion("0.3.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace UltraRT.Preload { public static class HdrPreload { [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Unicode)] private delegate int InstallFn(string logPath, int force); private const string NativeDll = "UltraRT.Native.dll"; private const string PluginDll = "UltraRT.dll"; public static IEnumerable<string> TargetDLLs { get; } = new string[0]; public static void Patch(AssemblyDefinition assembly) { } [DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)] private static extern IntPtr LoadLibraryW(string path); [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] private static extern IntPtr GetProcAddress(IntPtr module, string name); public static void Initialize() { ManualLogSource val = null; try { if (!Wanted(out var force, out var why)) { return; } val = Logger.CreateLogSource("UltraRT.Preload"); string text = FindNativeDll(val); if (text == null) { val.LogWarning((object)("HDR output asked for (" + why + "), but no UltraRT.Native.dll was found under " + Paths.PluginPath)); return; } val.LogInfo((object)("HDR output: using " + text)); IntPtr intPtr = LoadLibraryW(text); if (intPtr == IntPtr.Zero) { val.LogWarning((object)$"HDR output: LoadLibrary({text}) failed, Win32 error {Marshal.GetLastWin32Error()}"); return; } IntPtr procAddress = GetProcAddress(intPtr, "UltraRT_Hdr_Install"); if (procAddress == IntPtr.Zero) { val.LogWarning((object)"HDR output: UltraRT.Native.dll has no UltraRT_Hdr_Install (old build?)"); return; } string text2 = Path.Combine(Paths.BepInExRootPath, "ultrart"); Directory.CreateDirectory(text2); string text3 = Path.Combine(text2, "hdr.log"); int num = Marshal.GetDelegateForFunctionPointer<InstallFn>(procAddress)(text3, force ? 1 : 0); val.LogInfo((object)("HDR output (" + why + "): swapchain hooks " + ((num != 0) ? "installed" : "NOT installed") + "; details in " + text3)); } catch (Exception ex) { try { (val ?? Logger.CreateLogSource("UltraRT.Preload")).LogWarning((object)("HDR output: preload failed: " + ex.GetType().Name + ": " + ex.Message)); } catch { } } } private static string FindNativeDll(ManualLogSource log) { List<(string, DateTime)> list = new List<(string, DateTime)>(); List<(string, DateTime)> list2 = new List<(string, DateTime)>(); foreach (string item in Folders(Paths.PluginPath, 4)) { string path = Path.Combine(item, "UltraRT.Native.dll"); if (File.Exists(path)) { string path2 = Path.Combine(item, "UltraRT.dll"); if (File.Exists(path2)) { list.Add((item, File.GetLastWriteTimeUtc(path2))); } else { list2.Add((item, File.GetLastWriteTimeUtc(path))); } } } List<(string, DateTime)> list3 = ((list.Count > 0) ? list : list2); if (list3.Count == 0) { return null; } list3.Sort(((string dir, DateTime stamp) a, (string dir, DateTime stamp) b) => b.stamp.CompareTo(a.stamp)); if (list3.Count > 1) { List<string> list4 = new List<string>(); foreach (var item2 in list3) { list4.Add(item2.Item1); } log.LogWarning((object)(string.Format("{0} is in {1} folders ({2}): using {3}. ", "UltraRT.Native.dll", list3.Count, string.Join(", ", list4), list3[0].Item1) + "Keep only one UltraRT install in BepInEx\\plugins.")); } return Path.Combine(list3[0].Item1, "UltraRT.Native.dll"); } private static IEnumerable<string> Folders(string root, int maxDepth) { if (!Directory.Exists(root)) { yield break; } Stack<(string dir, int depth)> stack = new Stack<(string, int)>(); stack.Push((root, 0)); while (stack.Count > 0) { var (dir, depth) = stack.Pop(); yield return dir; if (depth < maxDepth) { string[] directories; try { directories = Directory.GetDirectories(dir); } catch { continue; } string[] array = directories; foreach (string item in array) { stack.Push((item, depth + 1)); } } } } private static bool Wanted(out bool force, out string why) { force = false; why = null; string[] commandLineArgs = Environment.GetCommandLineArgs(); for (int i = 0; i < commandLineArgs.Length; i++) { if (string.Equals(commandLineArgs[i], "-ultrart-hdr", StringComparison.OrdinalIgnoreCase)) { string text = ((i + 1 < commandLineArgs.Length) ? commandLineArgs[i + 1].ToLowerInvariant() : ""); why = "-ultrart-hdr"; switch (text) { case "off": case "0": case "false": return false; } force = text == "force"; return true; } } string path = Path.Combine(Paths.ConfigPath, "ooo.lew.ultrart.cfg"); if (!File.Exists(path)) { return false; } bool flag = false; string[] array = File.ReadAllLines(path); for (int j = 0; j < array.Length; j++) { string text2 = array[j].Trim(); if (text2.StartsWith("[")) { flag = string.Equals(text2, "[Display]", StringComparison.OrdinalIgnoreCase); } else if (flag && !text2.StartsWith("#")) { int num = text2.IndexOf('='); if (num > 0 && string.Equals(text2.Substring(0, num).Trim(), "HDR", StringComparison.OrdinalIgnoreCase)) { why = "[Display] HDR = true"; return string.Equals(text2.Substring(num + 1).Trim(), "true", StringComparison.OrdinalIgnoreCase); } } } return false; } } }
plugins/UltraRT.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameConsole; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using PluginConfig.API; using PluginConfig.API.Decorators; using PluginConfig.API.Fields; using PluginConfig.API.Functionals; using Randomness; using TMPro; using ULTRAKILL.Cheats; using ULTRAKILL.Portal; using ULTRAKILL.Portal.Geometry; using ULTRAKILL.Portal.Native; using UltraRT.Bench; using UltraRT.Cinematics; using Unity.Collections; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Experimental.Rendering; using UnityEngine.InputSystem; using UnityEngine.LowLevel; using UnityEngine.PlayerLoop; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("UltraRT")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0+eb0851ff0245493cc431eed3e9fd57805a8b1d2d")] [assembly: AssemblyProduct("UltraRT")] [assembly: AssemblyTitle("UltraRT")] [assembly: AssemblyVersion("0.3.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace UltraRT { public sealed class AutoExposureSettings { public bool enabled = true; public bool ptDn; public float key = 0.45f; public bool hdrActive; public float hdrKeyScale = 1.3f; public float minEV = -4f; public float maxEV = 1f; public float speedUp = 1.5f; public float speedDown = 3f; public float lowFraction = 0.4f; public float highFraction = 0.95f; public float compensation; public float keyLow = 0.1f; public float upStrength; public float rtBrightness; public float levelBrightness; public bool levelOverride = true; public const float LegacyUpStrength = 0.5f; public const float LegacyGameMatchDown = 0.4f; public const float LegacyGameMatchBandDown = 0.35f; public float levelFollowGame; public const float FollowGameMatchDown = 0.9f; public const float FollowGameMatchBandDown = 0.1f; public float levelFollowGameUp; public const float FollowUpBand = 0.1f; public const float FollowUpMaxEV = 2f; public float deadBand = 0.05f; public float meterSpeed = 4f; public float settleTime = 0.5f; public float settleSpeed = 8f; public float gameMatchUp = 0.75f; public float gameMatchDown; public float gameMatchBand = 0.35f; public float gameMatchBandDown = 0.35f; public float gameMatchFog = 0.3f; public float colorMatch = 1f; public float colorMatchBand = 0.2f; public float colorMatchMax = 2f; public float EffectiveKey { get { if (!hdrActive) { return key; } return Mathf.Min(key * Mathf.Max(hdrKeyScale, 1f), 0.9f); } } public float Brightness => Mathf.Clamp01(Mathf.Max(rtBrightness, levelOverride ? levelBrightness : 0f)); public float EffectiveUpStrength => Mathf.Lerp(upStrength, Mathf.Max(upStrength, 0.5f), Brightness); private float Follow { get { if (!levelOverride) { return 0f; } return Mathf.Clamp01(levelFollowGame); } } private float FollowUp { get { if (!levelOverride) { return 0f; } return Mathf.Clamp01(levelFollowGameUp); } } public float EffectiveGameMatchUp => Mathf.Lerp(gameMatchUp, Mathf.Max(gameMatchUp, 1f), FollowUp); public float EffectiveGameMatchBand => Mathf.Lerp(gameMatchBand, Mathf.Min(gameMatchBand, 0.1f), FollowUp); public float EffectiveGameMatchFog => Mathf.Lerp(gameMatchFog, 1f, FollowUp); public float EffectiveMaxEV => Mathf.Lerp(maxEV, Mathf.Max(maxEV, 2f), FollowUp); public float EffectiveGameMatchDown { get { float num = Mathf.Lerp(gameMatchDown, Mathf.Min(gameMatchDown, 0.4f), Brightness); return Mathf.Lerp(num, Mathf.Max(num, 0.9f), Follow); } } public float EffectiveGameMatchBandDown { get { float num = Mathf.Lerp(gameMatchBandDown, Mathf.Max(gameMatchBandDown, 0.35f), Brightness); return Mathf.Lerp(num, Mathf.Min(num, 0.1f), Follow); } } public void ParseArgs() { string[] a = Environment.GetCommandLineArgs(); int i; for (i = 0; i < a.Length; i++) { switch (a[i].ToLowerInvariant()) { case "-ultrart-relight-autoexposure": { string text = (Next() ?? "on").ToLowerInvariant(); enabled = text != "off" && text != "0" && text != "false"; break; } case "-ultrart-ae-ptdn": ptDn = true; break; case "-ultrart-ae-key": key = F(Next(), key); break; case "-ultrart-ae-hdr-key": hdrKeyScale = Mathf.Max(1f, F(Next(), hdrKeyScale)); break; case "-ultrart-ae-match": { string[] array3 = (Next() ?? "").Split(','); gameMatchUp = F(array3[0], gameMatchUp); gameMatchDown = ((array3.Length > 1) ? F(array3[1], gameMatchDown) : gameMatchUp); break; } case "-ultrart-ae-match-band": { string[] array6 = (Next() ?? "").Split(','); gameMatchBand = F(array6[0], gameMatchBand); gameMatchBandDown = ((array6.Length > 1) ? F(array6[1], gameMatchBandDown) : gameMatchBand); break; } case "-ultrart-rt-brightness": rtBrightness = Mathf.Clamp01(F(Next(), rtBrightness)); break; case "-ultrart-ae-color": { string[] array4 = (Next() ?? "").Split(','); colorMatch = F(array4[0], colorMatch); if (array4.Length > 1) { colorMatchBand = F(array4[1], colorMatchBand); } if (array4.Length > 2) { colorMatchMax = F(array4[2], colorMatchMax); } break; } case "-ultrart-ae-min": minEV = F(Next(), minEV); break; case "-ultrart-ae-max": maxEV = F(Next(), maxEV); break; case "-ultrart-ae-comp": compensation = F(Next(), compensation); break; case "-ultrart-ae-up": upStrength = F(Next(), upStrength); break; case "-ultrart-ae-key-low": keyLow = F(Next(), keyLow); break; case "-ultrart-ae-deadband": deadBand = F(Next(), deadBand); break; case "-ultrart-ae-meter": meterSpeed = F(Next(), meterSpeed); break; case "-ultrart-ae-settle": { string[] array5 = (Next() ?? "").Split(','); settleTime = F(array5[0], settleTime); if (array5.Length > 1) { settleSpeed = F(array5[1], settleSpeed); } break; } case "-ultrart-ae-speed": { string[] array2 = (Next() ?? "").Split(','); speedUp = F(array2[0], speedUp); speedDown = ((array2.Length > 1) ? F(array2[1], speedDown) : (speedUp * 2f)); break; } case "-ultrart-ae-band": { string[] array = (Next() ?? "").Split(','); lowFraction = F(array[0], lowFraction); if (array.Length > 1) { highFraction = F(array[1], highFraction); } break; } } } static float F(string s, float fallback) { if (!float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return fallback; } return result; } string Next() { if (i + 1 >= a.Length) { return null; } return a[++i]; } } public override string ToString() { return FormattableString.Invariant(FormattableStringFactory.Create("auto exposure {0}{1}: key {2} (dark key {3}), EV [{4}, {5}], speed up {6}/s down {7}/s, band {8}-{9}, comp {10}, up {11}, dead band {12} EV, meter {13}/s, settle {14}s@{15}/s, RT brightness {16} (level {17}), game match {18}/{19} beyond {20}/{21} EV, colour match {22} (band {23}, max {24})", enabled ? "on" : "off", ptDn ? " (+pt-dn)" : "", key, keyLow, minEV, maxEV, speedUp, speedDown, lowFraction, highFraction, compensation, EffectiveUpStrength, deadBand, meterSpeed, settleTime, settleSpeed, rtBrightness, levelOverride ? levelBrightness : 0f, gameMatchUp, EffectiveGameMatchDown, gameMatchBand, EffectiveGameMatchBandDown, colorMatch, colorMatchBand, colorMatchMax)); } } internal sealed class AutoExposure : IDisposable { public const int Bins = 64; private const float MinLog2 = -12f; private const float MaxLog2 = 4f; private readonly ComputeShader _shader; private readonly int _kHistogram; private readonly int _kAdapt; private readonly ComputeBuffer _hist; private readonly ComputeBuffer _exposure; private bool _snap = true; private float _settleLeft = -1f; private float _nextReadback; private bool _readbackPending; public Texture Haze; public Vector4 HazeParams; public Texture GameColor; public static Texture PortalInstanceIds; private static readonly int IdAEInstanceId = Shader.PropertyToID("_AEInstanceId"); public Vector4 GameMap; public Vector4 GameFog; private static readonly int IdFiltered = Shader.PropertyToID("_Filtered"); private static readonly int IdAlbedo = Shader.PropertyToID("_Albedo"); private static readonly int IdSpecular = Shader.PropertyToID("_Specular"); private static readonly int IdHasSpecular = Shader.PropertyToID("_HasSpecular"); private static readonly int IdNormalDepth = Shader.PropertyToID("_NormalDepth"); private static readonly int IdLitWeight = Shader.PropertyToID("_LitWeight"); private static readonly int IdDim = Shader.PropertyToID("_Dim"); private static readonly int IdRange = Shader.PropertyToID("_Range"); private static readonly int IdHist = Shader.PropertyToID("_Hist"); private static readonly int IdExposure = Shader.PropertyToID("_Exposure"); private static readonly int IdParams0 = Shader.PropertyToID("_Params0"); private static readonly int IdParams1 = Shader.PropertyToID("_Params1"); private static readonly int IdParams2 = Shader.PropertyToID("_Params2"); private static readonly int IdParams3 = Shader.PropertyToID("_Params3"); private static readonly int IdParams4 = Shader.PropertyToID("_Params4"); private static readonly int IdVolHaze = Shader.PropertyToID("_VolHaze"); private static readonly int IdVolHazeParams = Shader.PropertyToID("_VolHazeParams"); private static readonly int IdGameColor = Shader.PropertyToID("_GameColor"); private static readonly int IdGameMap = Shader.PropertyToID("_GameMap"); private static readonly int IdGameFog = Shader.PropertyToID("_GameFog"); private static readonly int IdParams5 = Shader.PropertyToID("_Params5"); private static readonly int IdParams6 = Shader.PropertyToID("_Params6"); private static readonly int IdCompositeExposure = Shader.PropertyToID("_UltraRTExposure"); private static readonly int IdCompositeLitWeight = Shader.PropertyToID("_UltraRTLitWeight"); public List<(Vector4 state, Vector4 info)> Trace; public List<Vector4[]> FitTrace; public Vector4 Last { get; private set; } = new Vector4(1f, 0f, 0f, 0f); public float LastCount { get; private set; } public ComputeBuffer ExposureBuffer => _exposure; public Vector4 LastMatch { get; private set; } public Vector4 LastBalance { get; private set; } public AutoExposure(ComputeShader shader) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00a8: 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_00bd: 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_00eb: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)shader)) { throw new ArgumentNullException("shader"); } _shader = shader; _kHistogram = shader.FindKernel("Histogram"); _kAdapt = shader.FindKernel("Adapt"); _hist = new ComputeBuffer(204, 4) { name = "UltraRT Exposure Histogram" }; _hist.SetData((Array)new uint[204]); _exposure = new ComputeBuffer(8, 16) { name = "UltraRT Exposure" }; _exposure.SetData((Array)new Vector4[8] { new Vector4(1f, 0f, 0f, 0f), Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero }); } public void Reset() { _snap = true; _settleLeft = -1f; } public static void BindComposite(CommandBuffer cmd, ComputeShader denoise, int compositeKernel, ComputeBuffer exposure, Texture litWeight) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) cmd.SetComputeBufferParam(denoise, compositeKernel, IdCompositeExposure, exposure); cmd.SetComputeTextureParam(denoise, compositeKernel, IdCompositeLitWeight, RenderTargetIdentifier.op_Implicit(litWeight)); } public void Execute(CommandBuffer cmd, AutoExposureSettings s, Texture filtered, Texture albedo, Texture specular, Texture normalDepth, Texture litWeight, int w, int h, float dt) { //IL_001e: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) ComputeShader shader = _shader; cmd.SetComputeVectorParam(shader, IdDim, new Vector4((float)w, (float)h, 0f, 0f)); cmd.SetComputeVectorParam(shader, IdRange, new Vector4(-12f, 4f, 0f, 0f)); cmd.SetComputeTextureParam(shader, _kHistogram, IdFiltered, RenderTargetIdentifier.op_Implicit(filtered)); cmd.SetComputeTextureParam(shader, _kHistogram, IdAlbedo, RenderTargetIdentifier.op_Implicit(albedo)); cmd.SetComputeTextureParam(shader, _kHistogram, IdSpecular, RenderTargetIdentifier.op_Implicit((Texture)(((Object)(object)specular != (Object)null) ? ((object)specular) : ((object)Texture2D.blackTexture)))); cmd.SetComputeIntParam(shader, IdHasSpecular, ((Object)(object)specular != (Object)null) ? 1 : 0); cmd.SetComputeTextureParam(shader, _kHistogram, IdNormalDepth, RenderTargetIdentifier.op_Implicit(normalDepth)); cmd.SetComputeTextureParam(shader, _kHistogram, IdLitWeight, RenderTargetIdentifier.op_Implicit(litWeight)); cmd.SetComputeBufferParam(shader, _kHistogram, IdHist, _hist); bool flag = (Object)(object)Haze != (Object)null && HazeParams.w > 0.5f; cmd.SetComputeTextureParam(shader, _kHistogram, IdVolHaze, RenderTargetIdentifier.op_Implicit((Texture)(flag ? ((object)Haze) : ((object)Texture2D.blackTexture)))); cmd.SetComputeVectorParam(shader, IdVolHazeParams, flag ? HazeParams : Vector4.zero); cmd.SetComputeBufferParam(shader, _kHistogram, IdExposure, _exposure); bool flag2 = (Object)(object)GameColor != (Object)null && (s.gameMatchUp > 0f || s.gameMatchDown > 0f || s.colorMatch > 0f); cmd.SetComputeTextureParam(shader, _kHistogram, IdGameColor, RenderTargetIdentifier.op_Implicit((Texture)(flag2 ? ((object)GameColor) : ((object)Texture2D.blackTexture)))); if ((Object)(object)PortalInstanceIds != (Object)null) { cmd.SetComputeTextureParam(shader, _kHistogram, IdAEInstanceId, RenderTargetIdentifier.op_Implicit(PortalInstanceIds)); } cmd.SetComputeVectorParam(shader, IdGameMap, flag2 ? GameMap : Vector4.zero); cmd.SetComputeVectorParam(shader, IdGameFog, GameFog); cmd.SetComputeVectorParam(shader, IdParams5, new Vector4(flag2 ? Mathf.Max(0f, s.EffectiveGameMatchUp) : 0f, flag2 ? Mathf.Max(0f, s.EffectiveGameMatchDown) : 0f, Mathf.Max(0f, s.EffectiveGameMatchBand), Mathf.Clamp01(s.EffectiveGameMatchFog))); cmd.SetComputeVectorParam(shader, IdParams6, new Vector4(flag2 ? Mathf.Max(0f, s.colorMatch) : 0f, Mathf.Max(0f, s.colorMatchBand), Mathf.Max(0f, s.colorMatchMax), (FitTrace != null) ? 1f : 0f)); cmd.DispatchCompute(shader, _kHistogram, Mathf.CeilToInt((float)w / 32f), Mathf.CeilToInt((float)h / 32f), 1); float num = Mathf.Min(s.minEV, s.EffectiveMaxEV); cmd.SetComputeVectorParam(shader, IdParams0, new Vector4(Mathf.Log(Mathf.Max(s.EffectiveKey, 0.0001f), 2f), num, s.EffectiveMaxEV, Mathf.Clamp(dt, 0f, 0.25f))); cmd.SetComputeVectorParam(shader, IdParams1, new Vector4(Mathf.Max(0f, s.speedUp), Mathf.Max(0f, s.speedDown), Mathf.Clamp01(s.lowFraction), Mathf.Clamp(s.highFraction, Mathf.Clamp01(s.lowFraction) + 0.01f, 1f))); cmd.SetComputeVectorParam(shader, IdParams2, new Vector4(_snap ? 1f : 0f, Mathf.Max(16f, (float)(w * h) / 4f * 0.02f), s.compensation, 0f)); if (_settleLeft < 0f) { _settleLeft = s.settleTime; } bool flag3 = _settleLeft > 0f; _settleLeft = Mathf.Max(0f, _settleLeft - dt); cmd.SetComputeVectorParam(shader, IdParams3, new Vector4(Mathf.Clamp01(s.EffectiveUpStrength), Mathf.Max(0f, s.deadBand), Mathf.Max(0f, s.meterSpeed), flag3 ? Mathf.Max(0f, s.settleSpeed) : 0f)); cmd.SetComputeVectorParam(shader, IdParams4, new Vector4(Mathf.Log(Mathf.Clamp(s.keyLow, 0.0001f, Mathf.Max(s.EffectiveKey, 0.0001f)), 2f), Mathf.Max(0f, s.EffectiveGameMatchBandDown), 0f, 0f)); cmd.SetComputeVectorParam(shader, IdParams5, new Vector4(flag2 ? Mathf.Max(0f, s.EffectiveGameMatchUp) : 0f, flag2 ? Mathf.Max(0f, s.EffectiveGameMatchDown) : 0f, Mathf.Max(0f, s.EffectiveGameMatchBand), Mathf.Clamp01(s.EffectiveGameMatchFog))); cmd.SetComputeVectorParam(shader, IdParams6, new Vector4(flag2 ? Mathf.Max(0f, s.colorMatch) : 0f, Mathf.Max(0f, s.colorMatchBand), Mathf.Max(0f, s.colorMatchMax), (FitTrace != null) ? 1f : 0f)); cmd.SetComputeBufferParam(shader, _kAdapt, IdHist, _hist); cmd.SetComputeBufferParam(shader, _kAdapt, IdExposure, _exposure); cmd.DispatchCompute(shader, _kAdapt, 1, 1, 1); _snap = false; if (Trace != null) { List<(Vector4 state, Vector4 info)> trace = Trace; cmd.RequestAsyncReadback(_exposure, (Action<AsyncGPUReadbackRequest>)delegate(AsyncGPUReadbackRequest r) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!((AsyncGPUReadbackRequest)(ref r)).hasError) { NativeArray<Vector4> data = ((AsyncGPUReadbackRequest)(ref r)).GetData<Vector4>(0); trace.Add((data[0], data[1])); } }); } if (FitTrace != null) { List<Vector4[]> fit = FitTrace; cmd.RequestAsyncReadback(_exposure, (Action<AsyncGPUReadbackRequest>)delegate(AsyncGPUReadbackRequest r) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (!((AsyncGPUReadbackRequest)(ref r)).hasError) { NativeArray<Vector4> data = ((AsyncGPUReadbackRequest)(ref r)).GetData<Vector4>(0); if (data.Length > 7 && data[4].w > 0f) { fit.Add((Vector4[])(object)new Vector4[4] { data[4], data[5], data[6], data[7] }); } } }); } if (_readbackPending || !(Time.realtimeSinceStartup >= _nextReadback)) { return; } _readbackPending = true; _nextReadback = Time.realtimeSinceStartup + 0.25f; cmd.RequestAsyncReadback(_exposure, (Action<AsyncGPUReadbackRequest>)delegate(AsyncGPUReadbackRequest r) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) _readbackPending = false; if (!((AsyncGPUReadbackRequest)(ref r)).hasError) { NativeArray<Vector4> data = ((AsyncGPUReadbackRequest)(ref r)).GetData<Vector4>(0); Last = data[0]; LastCount = data[1].x; if (data.Length > 2) { LastMatch = data[2]; } if (data.Length > 3) { LastBalance = data[3]; } } }); } public void Dispose() { ComputeBuffer hist = _hist; if (hist != null) { hist.Release(); } ComputeBuffer exposure = _exposure; if (exposure != null) { exposure.Release(); } } } internal sealed class BloodWet : IDisposable { public static BloodWet Instance; private readonly ManualLogSource _log; private readonly Material _mat; private float[] _birth = new float[0]; private ComputeBuffer _birthBuffer; private ComputeBuffer _args; private readonly uint[] _argData = new uint[5]; private RenderTexture _mask; private BloodsplatterManager _owner; private int _newest = -1; private int _dirtyMin = int.MaxValue; private int _dirtyMax = -1; private float _lastBirth = -1E+09f; private int _logged; private readonly RenderTargetIdentifier[] _cameraTargets = (RenderTargetIdentifier[])(object)new RenderTargetIdentifier[3]; public static bool Hooked; public static string HookError; private static readonly int IdInstance = Shader.PropertyToID("instanceBuffer"); private static readonly int IdParent = Shader.PropertyToID("parentBuffer"); private static readonly int IdBirth = Shader.PropertyToID("_BloodBirth"); private static readonly int IdAtlas = Shader.PropertyToID("_SplatterAtlas"); private static readonly int IdDepth = Shader.PropertyToID("_BloodDepth"); private static readonly int IdNormal = Shader.PropertyToID("_BloodNormal"); private static readonly int IdVP = Shader.PropertyToID("_BloodVP"); private static readonly int IdInvVP = Shader.PropertyToID("_BloodInvVP"); private static readonly int IdParams = Shader.PropertyToID("_BloodParams"); private static readonly int IdParams2 = Shader.PropertyToID("_BloodParams2"); private static readonly int IdScreen = Shader.PropertyToID("_BloodScreen"); public RenderTexture Mask => _mask; public ComputeBuffer BirthBuffer => _birthBuffer; public int FreshStains { get; private set; } public BloodWet(ManualLogSource log, Shader shader) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown _log = log; _mat = new Material(shader) { name = "UltraRT BloodWet", hideFlags = (HideFlags)61 }; Instance = this; } public static void Patch(Harmony harmony) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(BloodsplatterManager), "CreateBloodstain", new Type[4] { typeof(Vector3), typeof(Vector3), typeof(bool), typeof(BloodstainParent) }, (Type[])null); if (methodInfo == null) { HookError = "BloodsplatterManager.CreateBloodstain not found"; return; } harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(BloodWet).GetMethod("CreatePostfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Hooked = true; MethodInfo methodInfo2 = AccessTools.Method(typeof(BloodsplatterManager), "LoadBloodstains", (Type[])null, (Type[])null); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(BloodWet).GetMethod("LoadPostfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception ex) { HookError = ex.Message; } } private static void CreatePostfix(BloodsplatterManager __instance, int __result) { Instance?.OnStain(__instance, __result); } private static void LoadPostfix() { Instance?.Forget(); } private void OnStain(BloodsplatterManager bsm, int slot) { if (bsm != _owner) { Adopt(bsm); } if ((uint)slot < (uint)_birth.Length) { float time = Time.time; _birth[slot] = time; _newest = slot; _lastBirth = time; if (slot < _dirtyMin) { _dirtyMin = slot; } if (slot > _dirtyMax) { _dirtyMax = slot; } } } private void Adopt(BloodsplatterManager bsm) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_owner != (Object)null) { _owner.StainsCleared -= Forget; } _owner = bsm; int num = (((Object)(object)bsm != (Object)null && bsm.props.IsCreated) ? bsm.props.Length : 0); _birth = new float[num]; Forget(); ComputeBuffer birthBuffer = _birthBuffer; if (birthBuffer != null) { birthBuffer.Release(); } _birthBuffer = ((num <= 0) ? ((ComputeBuffer)null) : new ComputeBuffer(num, 4) { name = "UltraRT Blood Birth" }); ComputeBuffer birthBuffer2 = _birthBuffer; if (birthBuffer2 != null) { birthBuffer2.SetData((Array)_birth); } if ((Object)(object)bsm != (Object)null) { bsm.StainsCleared += Forget; } } public void Forget() { for (int i = 0; i < _birth.Length; i++) { _birth[i] = -1E+09f; } _newest = -1; _lastBirth = -1E+09f; _dirtyMin = 0; _dirtyMax = _birth.Length - 1; FreshStains = 0; } public bool Render(CommandBuffer cmd, Camera cam, WetSettings s, int traceW = 0, int traceH = 0) { //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Expected O, but got Unknown //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Expected O, but got Unknown //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0516: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) FreshStains = 0; PostProcessV2_Handler instance = MonoSingleton<PostProcessV2_Handler>.Instance; BloodsplatterManager owner = _owner; float time = Time.time; float num = Mathf.Max(0.1f, s.bloodDryTime); if ((Object)(object)owner == (Object)null || (Object)(object)instance == (Object)null || _newest < 0 || time - _lastBirth > num || _lastBirth > time + 0.5f) { return false; } if (!owner.usedComputeShadersAtStart || owner.instanceBuffer == null || owner.parentBuffer == null || (Object)(object)owner.optimizedBloodMesh == (Object)null || (Object)(object)owner.stainMat == (Object)null || _birthBuffer == null) { return false; } RenderTexture mainTex = instance.mainTex; RenderTexture depthBuffer = instance.depthBuffer; if ((Object)(object)mainTex == (Object)null || (Object)(object)depthBuffer == (Object)null || (Object)(object)instance.viewNormal == (Object)null || (Object)(object)instance.reusableBufferA == (Object)null) { return false; } int num2 = _birth.Length; int num3 = 0; int num4 = Mathf.Min(num2, Mathf.Max(16, s.bloodMaxStains)); int num5 = _newest; while (num3 < num4) { float num6 = time - _birth[num5]; if (num6 > num || num6 < -0.5f) { break; } num3++; num5 = ((num5 == 0) ? (num2 - 1) : (num5 - 1)); } if (num3 == 0) { return false; } FreshStains = num3; int num7 = ((_newest - num3 + 1) % num2 + num2) % num2; if (_dirtyMax >= _dirtyMin) { int num8 = Mathf.Clamp(_dirtyMin, 0, num2 - 1); int num9 = Mathf.Clamp(_dirtyMax, 0, num2 - 1); _birthBuffer.SetData((Array)_birth, num8, num8, num9 - num8 + 1); _dirtyMin = int.MaxValue; _dirtyMax = -1; } int num10 = ((!s.bloodFullRes && traceW > 0) ? Mathf.Clamp(traceW, 64, ((Texture)mainTex).width) : ((Texture)mainTex).width); int num11 = ((!s.bloodFullRes && traceH > 0) ? Mathf.Clamp(traceH, 64, ((Texture)mainTex).height) : ((Texture)mainTex).height); if ((Object)(object)_mask == (Object)null || ((Texture)_mask).width != num10 || ((Texture)_mask).height != num11 || !_mask.IsCreated()) { if ((Object)(object)_mask != (Object)null) { _mask.Release(); Object.Destroy((Object)(object)_mask); } _mask = new RenderTexture(num10, num11, 0, (RenderTextureFormat)16, (RenderTextureReadWrite)1) { name = "UltraRT Blood Wetness", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; _mask.Create(); } Mesh optimizedBloodMesh = owner.optimizedBloodMesh; if (_args == null) { _args = new ComputeBuffer(1, 20, (ComputeBufferType)256) { name = "UltraRT Blood Args" }; } _argData[0] = optimizedBloodMesh.GetIndexCount(0); _argData[1] = (uint)num3; _argData[2] = optimizedBloodMesh.GetIndexStart(0); _argData[3] = optimizedBloodMesh.GetBaseVertex(0); _argData[4] = 0u; _args.SetData((Array)_argData); Matrix4x4 val = GL.GetGPUProjectionMatrix(cam.projectionMatrix, true) * cam.worldToCameraMatrix; Material mat = _mat; mat.SetBuffer(IdInstance, owner.instanceBuffer); mat.SetBuffer(IdParent, owner.parentBuffer); mat.SetBuffer(IdBirth, _birthBuffer); Texture val2 = (owner.stainMat.HasProperty(IdAtlas) ? owner.stainMat.GetTexture(IdAtlas) : null); mat.SetTexture(IdAtlas, (Texture)(((Object)(object)val2 != (Object)null) ? ((object)val2) : ((object)Texture2D.whiteTexture))); mat.SetMatrix(IdVP, val); mat.SetMatrix(IdInvVP, ((Matrix4x4)(ref val)).inverse); mat.SetVector(IdParams, new Vector4((float)num7, (float)num2, time, 0f)); mat.SetVector(IdParams2, new Vector4(Mathf.Max(0f, s.bloodWetTime), num, Shader.GetGlobalFloat("_StainWarping"), Shader.GetGlobalFloat("_TextureWarping"))); mat.SetVector(IdScreen, new Vector4(1f / (float)num10, 1f / (float)num11, (float)((Texture)mainTex).width / (float)num10, (float)((Texture)mainTex).height / (float)num11)); cmd.SetGlobalTexture(IdDepth, RenderTargetIdentifier.op_Implicit((Texture)(object)depthBuffer), (RenderTextureSubElement)1); cmd.SetGlobalTexture(IdNormal, RenderTargetIdentifier.op_Implicit((Texture)(object)instance.viewNormal)); cmd.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)_mask)); cmd.ClearRenderTarget(false, true, Color.clear); cmd.DrawMeshInstancedIndirect(optimizedBloodMesh, 0, mat, 0, _args, 0); _cameraTargets[0] = RenderTargetIdentifier.op_Implicit((Texture)(object)mainTex); _cameraTargets[1] = RenderTargetIdentifier.op_Implicit((Texture)(object)instance.reusableBufferA); _cameraTargets[2] = RenderTargetIdentifier.op_Implicit((Texture)(object)instance.viewNormal); cmd.SetRenderTarget(_cameraTargets, RenderTargetIdentifier.op_Implicit((Texture)(object)depthBuffer)); if (_logged < 6 && Time.frameCount % 60 == 0) { _logged++; _log.LogInfo((object)string.Format("Wet blood: {0} fresh stains (slots {1}..{2} of {3}), atlas {4}, mesh '{5}' {6} indices", num3, num7, _newest, num2, ((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "MISSING", ((Object)optimizedBloodMesh).name, optimizedBloodMesh.GetIndexCount(0))); } return true; } public void Dispose() { if ((Object)(object)_owner != (Object)null) { _owner.StainsCleared -= Forget; } _owner = null; ComputeBuffer birthBuffer = _birthBuffer; if (birthBuffer != null) { birthBuffer.Release(); } ComputeBuffer args = _args; if (args != null) { args.Release(); } if ((Object)(object)_mask != (Object)null) { _mask.Release(); Object.Destroy((Object)(object)_mask); _mask = null; } if ((Object)(object)_mat != (Object)null) { Object.Destroy((Object)(object)_mat); } if (Instance == this) { Instance = null; } } } internal sealed class CombatLights { private sealed class Beam { public LineRenderer Lr; public RevolverBeam Rb; public ContinuousBeam Cb; public float Age; public float RealAge; public float Width0; public Color Hue; public float Gain; public float RangeGain; public int Id; public bool Ready; public string Name; } private enum FlashKind : byte { Parry, Bolt } private struct Flash { public FlashKind Kind; public Vector3 A; public Vector3 B; public Color Hue; public float Intensity; public float Range; public float Radius; public float Age; public float RealAge; public float Seed; public int Id; public bool Unshadowed; } public EffectLightSettings Settings; private readonly ManualLogSource _log; private readonly List<Beam> _beams = new List<Beam>(32); private readonly HashSet<int> _beamIds = new HashSet<int>(); private readonly List<LineRenderer> _tmpLines = new List<LineRenderer>(8); private readonly Vector3[] _pts = (Vector3[])(object)new Vector3[32]; private const int MaxBeams = 256; private const int MaxLineCandidates = 512; private readonly float[] _lineDist = new float[512]; private readonly int[] _lineKey = new int[512]; public Func<Texture, Color> TexAverage; private readonly List<Flash> _flashes = new List<Flash>(8); private int _nextFlashId = 1; internal static readonly List<Vector3> PendingParries = new List<Vector3>(4); internal static readonly List<Vector3> PendingStrikes = new List<Vector3>(4); internal static readonly List<LightningStrikeDecorative_Animated> Armed = new List<LightningStrikeDecorative_Animated>(4); internal static readonly List<LightningStrikeDecorative> PendingDecor = new List<LightningStrikeDecorative>(4); private readonly List<float> _armedAge = new List<float>(4); private static readonly FieldRef<LightningStrikeDecorative_Animated, Light> FlashField = SafeFieldRef<LightningStrikeDecorative_Animated, Light>("flash"); private static readonly FieldRef<LightningStrikeDecorative_Animated, AnimatedTexture> AnimField = SafeFieldRef<LightningStrikeDecorative_Animated, AnimatedTexture>("lightningAnim"); private static readonly FieldRef<LightningStrikeDecorative, Light> DecorFlashField = SafeFieldRef<LightningStrikeDecorative, Light>("flash"); private static readonly FieldRef<LightningStrikeDecorative, SpriteRenderer> DecorSpriteField = SafeFieldRef<LightningStrikeDecorative, SpriteRenderer>("lightning"); private int _sceneHandle = -1; private float _holdUntil = -1f; private float _holdStart = -1f; private int _logBeams; private int _logBolts; private int _logParries; private int _logSustained; private int _lastPacked; internal static readonly List<LightningStrikeDecorative_Animated> ForcedBolts = new List<LightningStrikeDecorative_Animated>(2); internal static readonly List<LightningStrikeDecorative> ForcedDecor = new List<LightningStrikeDecorative>(2); private static readonly Color BoltHue = new Color(0.72f, 0.84f, 1f); private float _nextLineLog; private int _lineLogs; public int Packed => _lastPacked; public int ActiveBeams => _beams.Count; public int ActiveFlashes => _flashes.Count; public bool HoldExposure { get { float realtimeSinceStartup = Time.realtimeSinceStartup; if (!Settings.flashHoldsExposure || realtimeSinceStartup > _holdUntil) { _holdStart = -1f; return false; } if (_holdStart < 0f) { _holdStart = realtimeSinceStartup; } return realtimeSinceStartup - _holdStart < 1f; } } private static FieldRef<T, F> SafeFieldRef<T, F>(string name) where T : class { try { return AccessTools.FieldRefAccess<T, F>(name); } catch (Exception) { return null; } } public CombatLights(ManualLogSource log, EffectLightSettings settings) { _log = log; Settings = settings; } public void Clear() { _beams.Clear(); _beamIds.Clear(); _flashes.Clear(); _logSustained = 0; PendingParries.Clear(); PendingStrikes.Clear(); Armed.Clear(); _armedAge.Clear(); ForcedBolts.Clear(); PendingDecor.Clear(); ForcedDecor.Clear(); _holdUntil = -1f; _holdStart = -1f; } public void OnSpawn(GameObject go) { if (Settings.beamLights <= 0f || (Object)(object)go == (Object)null) { return; } go.GetComponentsInChildren<LineRenderer>(true, _tmpLines); foreach (LineRenderer tmpLine in _tmpLines) { if ((Object)(object)tmpLine == (Object)null) { continue; } RevolverBeam component = ((Component)tmpLine).GetComponent<RevolverBeam>(); if ((Object)(object)component != (Object)null) { AddBeam(tmpLine, component, null); continue; } ContinuousBeam component2 = ((Component)tmpLine).GetComponent<ContinuousBeam>(); if ((Object)(object)component2 != (Object)null) { AddBeam(tmpLine, null, component2); } } } private void CollectSceneBeams() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) int num = 0; ContinuousBeam[] array = Object.FindObjectsOfType<ContinuousBeam>(true); foreach (ContinuousBeam val in array) { if ((Object)(object)val != (Object)null) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { AddBeam(((Component)val).GetComponent<LineRenderer>(), null, val); num++; } } } if (num > 0) { _log.LogInfo((object)$"Combat lights: {num} ContinuousBeams in the scene (tracked {_beams.Count}, cap {256})"); } } private void AddBeam(LineRenderer lr, RevolverBeam rb, ContinuousBeam cb) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0064: Expected I4, but got Unknown //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_00ef: 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_015c: 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_0178: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)lr == (Object)null || _beams.Count >= 256) { return; } int instanceID = ((Object)lr).GetInstanceID(); if (!_beamIds.Add(instanceID)) { return; } float num = 1f; float rangeGain = 1f; if ((Object)(object)rb != (Object)null) { BeamType beamType = rb.beamType; switch (beamType - 1) { case 0: num = 2.5f; rangeGain = 1.5f; break; case 1: num = 2f; rangeGain = 1.3f; break; case 2: num = 1.2f; break; } if (rb.strongAlt) { num *= 1.4f; } } else { num = 1.2f; } Color val = BeamHue(lr, ((Object)(object)cb != (Object)null) ? TexAverage : null); _beams.Add(new Beam { Lr = lr, Rb = rb, Cb = cb, Id = instanceID, Gain = num, RangeGain = rangeGain, Hue = val, Name = ((Object)lr).name }); if ((Object)(object)cb != (Object)null && _logSustained++ < 12) { _log.LogInfo((object)($"Combat lights: sustained beam '{BoltPath(((Component)lr).transform)}' width {cb.originalWidth:F2}, hue ({val.r:F2}, {val.g:F2}, {val.b:F2}), " + string.Format("material '{0}', active {1}", ((Object)(object)((Renderer)lr).sharedMaterial != (Object)null) ? ((Object)((Renderer)lr).sharedMaterial).name : "-", ((Component)lr).gameObject.activeInHierarchy))); } } private static Color BeamHue(LineRenderer lr, Func<Texture, Color> texAverage = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) Color white = Color.white; bool flag = false; try { Color startColor = lr.startColor; Color endColor = lr.endColor; white = new Color((startColor.r * startColor.a + endColor.r * endColor.a) * 0.5f, (startColor.g * startColor.a + endColor.g * endColor.a) * 0.5f, (startColor.b * startColor.a + endColor.b * endColor.a) * 0.5f, 1f); Material sharedMaterial = ((Renderer)lr).sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null) { if (sharedMaterial.HasProperty("_TintColor")) { white *= sharedMaterial.GetColor("_TintColor"); } else if (sharedMaterial.HasProperty("_Color")) { white *= sharedMaterial.GetColor("_Color"); } if (sharedMaterial.HasProperty("_EmissiveColor")) { Color color = sharedMaterial.GetColor("_EmissiveColor"); if (Mx(color) > 0.05f) { white *= color; } } Texture val = ((texAverage != null) ? sharedMaterial.mainTexture : null); if ((Object)(object)val != (Object)null) { Color val2 = texAverage(val); float num = Mx(val2); if (num > 0.001f) { val2 *= 1f / num; white *= new Color(Mathf.Pow(val2.r, 4f), Mathf.Pow(val2.g, 4f), Mathf.Pow(val2.b, 4f), 1f); flag = true; } } } } catch (Exception) { white = Color.white; } float num2 = Mx(white); if (num2 < 0.001f) { return new Color(1f, 0.9f, 0.7f); } white *= 1f / num2; if (!flag) { return Color.Lerp(white, Color.white, 0.15f); } return white; } private static float Mx(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return Mathf.Max(c.r, Mathf.Max(c.g, c.b)); } internal static Vector3 ParryPoint(float ahead) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) CameraController instance = MonoSingleton<CameraController>.Instance; Transform val = (((Object)(object)instance != (Object)null) ? ((Component)instance).transform : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : null)); if ((Object)(object)val == (Object)null) { return Vector3.zero; } float num = ahead; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val.position, val.forward, ref val2, ahead + 0.3f, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1)), (QueryTriggerInteraction)1)) { num = Mathf.Max(0.3f, ((RaycastHit)(ref val2)).distance - 0.3f); } return val.position + val.forward * num; } internal static void TriggerParry() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) PendingParries.Add(ParryPoint(1.2f)); } public void Update() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); int handle = ((Scene)(ref activeScene)).handle; if (handle != _sceneHandle) { Clear(); _sceneHandle = handle; if (Settings.beamLights > 0f) { try { CollectSceneBeams(); } catch (Exception ex) { _log.LogWarning((object)("Combat lights: scene beams: " + ex.Message)); } } try { LogSceneBolts(); } catch (Exception ex2) { _log.LogWarning((object)("Combat lights: scene bolts: " + ex2.Message)); } } float deltaTime = Time.deltaTime; float unscaledDeltaTime = Time.unscaledDeltaTime; bool flag = Time.timeScale <= 0f; EffectLightSettings settings = Settings; while (_armedAge.Count < Armed.Count) { _armedAge.Add(0f); } for (int num = Armed.Count - 1; num >= 0; num--) { LightningStrikeDecorative_Animated val = Armed[num]; _armedAge[num] += unscaledDeltaTime; bool flag2 = (Object)(object)val == (Object)null || _armedAge[num] > 6f || settings.lightningFlash <= 0f; if (!flag2) { Light val2 = ((FlashField != null) ? FlashField.Invoke(val) : null); if ((Object)(object)val2 == (Object)null) { flag2 = true; } else if (val2.intensity > 0f) { StartBolt(val); flag2 = true; } } if (flag2) { Armed.RemoveAt(num); _armedAge.RemoveAt(num); } } for (int num2 = _flashes.Count - 1; num2 >= 0; num2--) { Flash value = _flashes[num2]; value.RealAge += unscaledDeltaTime; value.Age += ((value.Kind == FlashKind.Parry) ? unscaledDeltaTime : (flag ? 0f : deltaTime)); float num3 = ((value.Kind == FlashKind.Parry) ? (settings.parryHold + settings.parryFade * 2f) : (settings.lightningFade * 2.5f)); if (value.Age > num3 || value.RealAge > Mathf.Max(num3 * 2f, 1f)) { _flashes.RemoveAt(num2); } else { _flashes[num2] = value; } } for (int num4 = _beams.Count - 1; num4 >= 0; num4--) { Beam beam = _beams[num4]; if ((Object)(object)beam.Lr == (Object)null || ((Object)(object)beam.Rb == (Object)null && (Object)(object)beam.Cb == (Object)null)) { RemoveBeam(num4); } else if ((Object)(object)beam.Rb != (Object)null) { if (!beam.Ready) { if ((Object)(object)beam.Rb.cc == (Object)null) { beam.RealAge += unscaledDeltaTime; if (beam.RealAge > 1f) { RemoveBeam(num4); } } else { beam.Ready = true; beam.Age = 0f; beam.RealAge = 0f; beam.Width0 = Mathf.Max(beam.Lr.widthMultiplier, 0.0001f); if (_logBeams++ < 10) { int positionCount = beam.Lr.positionCount; float num5 = ((positionCount >= 2) ? Vector3.Distance(Pt(beam.Lr, 0), Pt(beam.Lr, positionCount - 1)) : 0f); _log.LogInfo((object)(string.Format("Combat lights: beam '{0}' {1}{2}{3} ", beam.Name, beam.Rb.beamType, beam.Rb.strongAlt ? " strong" : "", beam.Rb.fake ? " fake" : "") + string.Format("points {0}, length {1:F1} m, width {2:F2}, hue ({3:F2}, {4:F2}, {5:F2}), material '{6}'", positionCount, num5, beam.Width0, beam.Hue.r, beam.Hue.g, beam.Hue.b, ((Object)(object)((Renderer)beam.Lr).sharedMaterial != (Object)null) ? ((Object)((Renderer)beam.Lr).sharedMaterial).name : "-"))); } } } else { beam.Age += (flag ? 0f : deltaTime); beam.RealAge += unscaledDeltaTime; if (beam.Age > settings.beamFade || beam.RealAge > Mathf.Max(settings.beamFade * 4f, 0.6f)) { RemoveBeam(num4); } } } } DrainPending(); } private void DrainPending() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) EffectLightSettings settings = Settings; for (int i = 0; i < PendingParries.Count; i++) { if (settings.parryLight <= 0f) { break; } Vector3 val = PendingParries[i]; if (!(val == Vector3.zero)) { AddFlash(new Flash { Kind = FlashKind.Parry, A = val, B = val, Hue = new Color(settings.parryColorR, settings.parryColorG, settings.parryColorB), Radius = 0.08f }); if (_logParries++ < 6) { _log.LogInfo((object)$"Combat lights: parry burst at ({val.x:F1}, {val.y:F1}, {val.z:F1}), timeScale {Time.timeScale:F2}"); } } } PendingParries.Clear(); for (int j = 0; j < PendingStrikes.Count; j++) { if (settings.lightningFlash <= 0f) { break; } Vector3 val2 = PendingStrikes[j]; AddFlash(new Flash { Kind = FlashKind.Bolt, A = val2, B = val2 + Vector3.up * 40f, Hue = BoltHue, Radius = 0.3f, Seed = Random.value }); if (_logBolts++ < 8) { _log.LogInfo((object)$"Combat lights: explosive lightning strike at ({val2.x:F1}, {val2.y:F1}, {val2.z:F1})"); } } PendingStrikes.Clear(); foreach (LightningStrikeDecorative_Animated forcedBolt in ForcedBolts) { if ((Object)(object)forcedBolt != (Object)null) { StartBolt(forcedBolt); } } ForcedBolts.Clear(); foreach (LightningStrikeDecorative item in PendingDecor) { if ((Object)(object)item != (Object)null) { StartDecorBolt(item); } } PendingDecor.Clear(); foreach (LightningStrikeDecorative item2 in ForcedDecor) { if ((Object)(object)item2 != (Object)null) { StartDecorBolt(item2); } } ForcedDecor.Clear(); } private void LogSceneBolts() { //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) LightningStrikeDecorative[] array = Object.FindObjectsOfType<LightningStrikeDecorative>(true); LightningStrikeDecorative_Animated[] array2 = Object.FindObjectsOfType<LightningStrikeDecorative_Animated>(true); if (array.Length == 0 && array2.Length == 0) { return; } StringBuilder stringBuilder = new StringBuilder($"Combat lights: decorative bolts in the scene: {array2.Length} animated, {array.Length} plain"); for (int i = 0; i < array.Length && i < 6; i++) { LightningStrikeDecorative val = array[i]; Light val2 = ((DecorFlashField != null) ? DecorFlashField.Invoke(val) : null); SpriteRenderer val3 = ((DecorSpriteField != null) ? DecorSpriteField.Invoke(val) : null); Vector3 position = ((Component)val).transform.position; stringBuilder.Append($"; '{BoltPath(((Component)val).transform)}' at ({position.x:F0}, {position.y:F0}, {position.z:F0})"); if ((Object)(object)val2 != (Object)null) { stringBuilder.Append($" flash {val2.type} range {val2.range:F0} colour ({val2.color.r:F2}, {val2.color.g:F2}, {val2.color.b:F2}) at ({((Component)val2).transform.position.x:F0}, {((Component)val2).transform.position.y:F0}, {((Component)val2).transform.position.z:F0})"); } if ((Object)(object)val3 != (Object)null) { Bounds bounds = ((Renderer)val3).bounds; stringBuilder.Append($" sprite y {((Bounds)(ref bounds)).min.y:F0}..{((Bounds)(ref bounds)).max.y:F0} colour ({val3.color.r:F2}, {val3.color.g:F2}, {val3.color.b:F2})"); } } for (int j = 0; j < array2.Length && j < 8; j++) { LightningStrikeDecorative_Animated val4 = array2[j]; Light val5 = ((FlashField != null) ? FlashField.Invoke(val4) : null); Vector3 position2 = ((Component)val4).transform.position; stringBuilder.Append($"; animated '{BoltPath(((Component)val4).transform)}' at ({position2.x:F0}, {position2.y:F0}, {position2.z:F0})"); if ((Object)(object)val5 != (Object)null) { stringBuilder.Append($" flash '{BoltPath(((Component)val5).transform)}' shadows {val5.shadows}"); } } _log.LogInfo((object)stringBuilder.ToString()); } private static string BoltPath(Transform t) { string text = ((Object)t).name; Transform parent = t.parent; while ((Object)(object)parent != (Object)null) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } private void StartDecorBolt(LightningStrikeDecorative bolt) { //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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_00e2: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0228: 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_0126: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) if (Settings.lightningFlash <= 0f) { return; } SpriteRenderer val = ((DecorSpriteField != null) ? DecorSpriteField.Invoke(bolt) : null); Light val2 = ((DecorFlashField != null) ? DecorFlashField.Invoke(bolt) : null); Vector3 position = default(Vector3); Vector3 val3 = default(Vector3); if ((Object)(object)val != (Object)null) { Bounds bounds = ((Renderer)val).bounds; ((Vector3)(ref position))..ctor(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).center.z); ((Vector3)(ref val3))..ctor(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.y, ((Bounds)(ref bounds)).center.z); } else { position = ((Component)bolt).transform.position; val3 = position + Vector3.up * 40f; } Color val4 = BoltHue; if ((Object)(object)val2 != (Object)null) { Color color = val2.color; float num = Mx(color); float num2 = Mathf.Min(color.r, Mathf.Min(color.g, color.b)); if (num > 0.001f && (num - num2) / num > 0.25f) { val4 = Color.Lerp(color * (1f / num), Color.white, 0.15f); } } AddFlash(new Flash { Kind = FlashKind.Bolt, A = position, B = val3, Hue = val4, Radius = 0.5f, Seed = Random.value, Unshadowed = InsideScene() }); if (_logBolts++ < 8) { _log.LogInfo((object)($"Combat lights: decorative bolt '{((Object)bolt).name}' base ({position.x:F0}, {position.y:F0}, {position.z:F0}) top y {val3.y:F0}, hue ({val4.r:F2}, {val4.g:F2}, {val4.b:F2}); " + (((Object)(object)val2 != (Object)null) ? $"game flash {val2.type} I {val2.intensity:F1} range {val2.range:F0}" : "no game flash"))); } } private void StartBolt(LightningStrikeDecorative_Animated bolt) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00c2: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_005e: 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_007d: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) if (!(Settings.lightningFlash <= 0f)) { AnimatedTexture val = ((AnimField != null) ? AnimField.Invoke(bolt) : null); Renderer val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Renderer>() : null); Vector3 position = default(Vector3); Vector3 val3 = default(Vector3); if ((Object)(object)val2 != (Object)null) { Bounds bounds = val2.bounds; ((Vector3)(ref position))..ctor(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).center.z); ((Vector3)(ref val3))..ctor(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.y, ((Bounds)(ref bounds)).center.z); } else { position = ((Component)bolt).transform.position; val3 = position + Vector3.up * 60f; } bool flag = InsideScene(); AddFlash(new Flash { Kind = FlashKind.Bolt, A = position, B = val3, Hue = BoltHue, Radius = 0.5f, Seed = Random.value, Unshadowed = flag }); if (_logBolts++ < 8) { Light val4 = ((FlashField != null) ? FlashField.Invoke(bolt) : null); _log.LogInfo((object)(string.Format("Combat lights: lightning bolt '{0}' base ({1:F0}, {2:F0}, {3:F0}) top y {4:F0}{5}; ", ((Object)bolt).name, position.x, position.y, position.z, val3.y, flag ? ", unshadowed" : "") + (((Object)(object)val4 != (Object)null) ? $"game flash {val4.type} I {val4.intensity:F1} range {val4.range:F0} colour ({val4.color.r:F2}, {val4.color.g:F2}, {val4.color.b:F2}) at ({((Component)val4).transform.position.x:F0}, {((Component)val4).transform.position.y:F0}, {((Component)val4).transform.position.z:F0})" : "no game flash"))); } } } private bool InsideScene() { string lightningInsideScenes = Settings.lightningInsideScenes; if (string.IsNullOrEmpty(lightningInsideScenes)) { return false; } string currentScene; try { currentScene = SceneHelper.CurrentScene; } catch (Exception) { return false; } string[] array = lightningInsideScenes.Split(','); foreach (string text in array) { if (text.Trim().Length > 0 && string.Equals(text.Trim(), currentScene, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private void AddFlash(Flash f) { f.Id = 1813643264 + (_nextFlashId++ & 0xFFFF) * 8; if (_flashes.Count >= 8) { _flashes.RemoveAt(0); } _flashes.Add(f); } private void RemoveBeam(int i) { _beamIds.Remove(_beams[i].Id); _beams.RemoveAt(i); } private static Vector3 Pt(LineRenderer lr, int i) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Vector3 position = lr.GetPosition(i); if (!lr.useWorldSpace) { return ((Component)lr).transform.TransformPoint(position); } return position; } public int Append(Vector4[] data, uint[] masks, Light[] packed, int[] ids, float[] medium, int count, int max, int reserve, Vector3 camPos) { //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0249: 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_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) DrainPending(); int num = count; EffectLightSettings settings = Settings; int num2 = Mathf.Max(num, max - Mathf.Max(0, reserve)); bool flag = false; try { foreach (Flash flash in _flashes) { if (flash.Kind == FlashKind.Parry) { float num3 = ((flash.Age <= settings.parryHold) ? 1f : Mathf.Exp((0f - (flash.Age - settings.parryHold)) / Mathf.Max(settings.parryFade / 3f, 0.001f))) * settings.parryLight * settings.parryIntensity; if (!(num3 < 0.02f) && count < num2) { Pack(data, masks, packed, ids, medium, num, ref count, flash.A, settings.parryRange, flash.Hue * num3, flash.Radius, flash.Id, settings.parryMedium); flag = true; } continue; } float num4 = Mathf.Max(settings.lightningFade / 3f, 0.001f); float num5 = 0.055f + 0.03f * flash.Seed; float num6 = 0.12f + 0.04f * flash.Seed; float num7 = Mathf.Exp((0f - flash.Age) / num4); if (flash.Age > num5) { num7 = Mathf.Max(num7, 0.75f * Mathf.Exp((0f - (flash.Age - num5)) / num4)); } if (flash.Age > num6) { num7 = Mathf.Max(num7, 0.45f * Mathf.Exp((0f - (flash.Age - num6)) / num4)); } float num8 = num7 * settings.lightningFlash * settings.lightningIntensity * (flash.Unshadowed ? Mathf.Max(0f, settings.lightningInsideGain) : 1f); if (num8 < 0.02f) { continue; } Vector3 val = Vector3.Lerp(flash.A, flash.B, 0.35f); float range = Mathf.Max(settings.lightningMinRange, Vector3.Distance(val, camPos) * settings.lightningRangePerDistance); for (int i = 0; i < 3; i++) { if (count >= num2) { break; } Pack(data, masks, packed, ids, medium, num, ref count, Vector3.Lerp(flash.A, flash.B, i switch { 1 => 0.6f, 0 => 0.35f, _ => 0.85f, }), range, flash.Hue * (num8 / 3f), flash.Radius, flash.Id + i, settings.lightningMedium, flash.Unshadowed); } flag = true; } if (settings.beamLights > 0f && settings.beamLines) { PackLines(camPos, data, masks, packed, ids, medium, num, ref count, Mathf.Min(num2, count + Mathf.Max(0, settings.lineMaxLights))); } if (settings.beamLights > 0f) { float cullDistance = settings.cullDistance; int num9 = Mathf.Min(num2, count + Mathf.Max(0, settings.beamMaxLights)); for (int num10 = _beams.Count - 1; num10 >= 0 && count < num9; num10--) { Beam beam = _beams[num10]; LineRenderer lr = beam.Lr; if (((Object)(object)beam.Cb != (Object)null && settings.beamLines) || (Object)(object)lr == (Object)null || !((Renderer)lr).enabled || !((Component)lr).gameObject.activeInHierarchy) { continue; } float num12; if ((Object)(object)beam.Rb != (Object)null) { if (!beam.Ready) { continue; } float num11 = Mathf.Clamp01(beam.Age / Mathf.Max(settings.beamFade, 0.001f)); num12 = (1f - num11) * (1f - num11) * Mathf.Clamp01(lr.widthMultiplier / beam.Width0 * 1.5f); } else { if (beam.Width0 <= 0f) { beam.Width0 = Mathf.Max(lr.widthMultiplier, 0.0001f); } if (lr.widthMultiplier > beam.Width0) { beam.Width0 = lr.widthMultiplier; } num12 = Mathf.Clamp01(lr.widthMultiplier / beam.Width0); } float num13 = num12 * beam.Gain * settings.beamLights * settings.beamIntensity; if (num13 < 0.02f) { continue; } int num14 = Mathf.Min(lr.positionCount, _pts.Length); if (num14 < 2) { continue; } for (int j = 0; j < num14; j++) { _pts[j] = Pt(lr, j); } flag |= (Object)(object)beam.Rb != (Object)null; for (int k = 0; k + 1 < num14; k++) { if (count >= num9) { break; } PackSegment(beam, k, _pts[k], _pts[k + 1], num13, camPos, cullDistance, data, masks, packed, ids, medium, num, ref count, num9); } } } } catch (Exception ex) { _log.LogWarning((object)("Combat lights: " + ex.Message)); } if (flag) { _holdUntil = Time.realtimeSinceStartup + Mathf.Max(0f, settings.exposureHoldTail); } _lastPacked = count - num; return count; } private void PackLines(Vector3 camPos, Vector4[] data, uint[] masks, Light[] packed, int[] ids, float[] medium, int first, ref int count, int cap) { //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) EffectLightSettings settings = Settings; float num = settings.lineCull * settings.lineCull; int num2 = 0; for (int i = 0; i < _beams.Count; i++) { if (num2 >= 512) { break; } Beam beam = _beams[i]; if ((Object)(object)beam.Cb == (Object)null) { continue; } LineRenderer lr = beam.Lr; if ((Object)(object)lr == (Object)null || !((Renderer)lr).enabled || !((Component)lr).gameObject.activeInHierarchy) { continue; } if (lr.widthMultiplier > beam.Width0) { beam.Width0 = lr.widthMultiplier; } float num3 = LineWidth0(beam); if (lr.widthMultiplier < num3 * 0.02f) { continue; } int num4 = Mathf.Min(lr.positionCount, _pts.Length); if (num4 < 2) { continue; } Vector3 a = Pt(lr, 0); for (int j = 0; j + 1 < num4; j++) { if (num2 >= 512) { break; } Vector3 val = Pt(lr, j + 1); float num5 = SegDist2(camPos, a, val); if (num5 <= num) { _lineDist[num2] = num5; _lineKey[num2] = (i << 5) | j; num2++; } a = val; } } if (num2 == 0) { return; } int num6 = count; if (num2 > cap - count) { Array.Sort(_lineDist, _lineKey, 0, num2); } for (int k = 0; k < num2; k++) { if (count >= cap) { break; } Beam beam2 = _beams[_lineKey[k] >> 5]; int num7 = _lineKey[k] & 0x1F; LineRenderer lr2 = beam2.Lr; float num8 = LineWidth0(beam2); float num9 = Mathf.Clamp01(lr2.widthMultiplier / num8) * beam2.Gain * settings.beamLights * settings.lineIntensity; if (num9 < 0.02f) { continue; } Vector3 val2 = Pt(lr2, num7); Vector3 val3 = Pt(lr2, num7 + 1); Vector3 val4 = val3 - val2; if (!(((Vector3)(ref val4)).sqrMagnitude < 0.0001f)) { float num10 = Mathf.Max(0.5f, settings.lineRange * Mathf.Sqrt(Mathf.Max(num8, 0.05f) / 0.35f)); LightOverrides.PackLine(val2, val3, 0f, 0f, 0f, out var centre, out var l, out var l2); int num11 = count * 4; Color val5 = beam2.Hue * num9; data[num11] = new Vector4(centre.x, centre.y, centre.z, num10); data[num11 + 1] = new Vector4(val5.r, val5.g, val5.b, 0f); data[num11 + 2] = l; data[num11 + 3] = l2; masks[count] = uint.MaxValue; packed[count] = null; ids[count] = beam2.Id * 31 + num7 * 7 + 1006632960; if (medium != null && count < medium.Length) { medium[count] = settings.lineMedium; } count++; } } float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup >= _nextLineLog && _lineLogs < 20) { _nextLineLog = realtimeSinceStartup + 10f; _lineLogs++; _log.LogInfo((object)($"Combat lights: {count - num6} line lights packed ({num2} beam segments within {settings.lineCull:F0} m, " + $"slots from {num6}, cap {cap})")); } } private static float LineWidth0(Beam b) { return Mathf.Max((b.Cb.originalWidth > 0f) ? b.Cb.originalWidth : b.Width0, 0.0001f); } private static float SegDist2(Vector3 p, Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = b - a; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; float num = ((sqrMagnitude > 1E-08f) ? Mathf.Clamp01(Vector3.Dot(p - a, val) / sqrMagnitude) : 0f); Vector3 val2 = a + val * num - p; return ((Vector3)(ref val2)).sqrMagnitude; } private void PackSegment(Beam b, int sg, Vector3 a, Vector3 c, float k, Vector3 camPos, float cull, Vector4[] data, uint[] masks, Light[] packed, int[] ids, float[] medium, int first, ref int count, int cap) { //IL_0007: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_012b: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0181: 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) EffectLightSettings settings = Settings; Vector3 val = c - a; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.05f) { return; } Vector3 val2 = val / magnitude; Vector3 val3 = a - camPos; float num = Vector3.Dot(val3, val2); float num2 = ((Vector3)(ref val3)).sqrMagnitude - cull * cull; float num3 = num * num - num2; if (num3 <= 0f) { return; } float num4 = Mathf.Sqrt(num3); float num5 = Mathf.Max(0f, 0f - num - num4); float num6 = Mathf.Min(magnitude, 0f - num + num4); if (sg == 0) { Vector3 val4 = a - camPos; if (((Vector3)(ref val4)).sqrMagnitude < 4f) { num5 = Mathf.Max(num5, Mathf.Min(1.5f, magnitude * 0.5f)); } } float num7 = num6 - num5; if (num7 <= 0.05f) { return; } int num8 = ((num7 < 1f) ? 1 : ((num7 < 3f) ? 2 : Mathf.Clamp(Mathf.CeilToInt(num7 / Mathf.Max(settings.beamSpacing, 0.5f)) + 1, 3, 6))); float num9 = num7 / (float)num8; float range = Mathf.Max(settings.beamRange, num9 * 1.2f) * b.RangeGain; Color c2 = b.Hue * k; for (int i = 0; i < num8; i++) { if (count >= cap) { break; } Vector3 p = a + val2 * (num5 + ((float)i + 0.5f) * num9); int id = b.Id * 31 + sg * 7 + i + 989855744; Pack(data, masks, packed, ids, medium, first, ref count, p, range, c2, 0.12f, id, settings.beamMedium); } } private static void Pack(Vector4[] data, uint[] masks, Light[] packed, int[] ids, float[] medium, int first, ref int count, Vector3 p, float range, Color c, float radius, int id, float med, bool unshadowed = false) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) int num = count * 4; data[num] = new Vector4(p.x, p.y, p.z, Mathf.Max(range, 0.1f)); data[num + 1] = new Vector4(c.r, c.g, c.b, 0f); data[num + 2] = new Vector4(0f, -1f, 0f, Mathf.Max(radius, 0.01f)); data[num + 3] = new Vector4(-1f, 1f, unshadowed ? 0.75f : 0f, 0f); masks[count] = uint.MaxValue; packed[count] = null; ids[count] = id; if (medium != null && count < medium.Length) { medium[count] = med; } count++; } } internal static class CombatHooks { public static bool Parry; public static bool Lightning; public static int Parries; public static int Strikes; public static string Hooked = ""; public static string Errors = ""; public static void Patch(Harmony harmony) { Try(harmony, typeof(TimeController), "ParryFlash", "ParryFlashPostfix", prefix: false, "parry"); Try(harmony, typeof(LightningStrikeDecorative_Animated), "FlashStart", "FlashStartPostfix", prefix: false, "bolt"); Try(harmony, typeof(LightningStrikeExplosive), "Start", "ExplosiveStartPrefix", prefix: true, "strike"); Try(harmony, typeof(LightningStrikeDecorative), "FlashStart", "DecorFlashStartPostfix", prefix: false, "decorative bolt"); } private static void Try(Harmony harmony, Type type, string method, string hook, bool prefix, string label) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(type, method, (Type[])null, (Type[])null); if (methodInfo == null) { Errors = Errors + " " + label + ": " + type.Name + "." + method + " not found;"; } else { HarmonyMethod val = new HarmonyMethod(typeof(CombatHooks).GetMethod(hook, BindingFlags.Static | BindingFlags.NonPublic)); if (prefix) { harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Hooked = Hooked + ((Hooked.Length > 0) ? ", " : "") + label; } } catch (Exception ex) { Errors = Errors + " " + label + ": " + ex.Message + ";"; } } private static void ParryFlashPostfix() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) try { if (Parry && CombatLights.PendingParries.Count < 4) { Parries++; CombatLights.PendingParries.Add(CombatLights.ParryPoint(1.2f)); } } catch (Exception) { } } private static void FlashStartPostfix(Lightning