Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ImmersiveVisorFork v1.0.1
ImmersiveVisorFork.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Mathematics; using UnityEngine; using UnityEngine.Experimental.Rendering; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using Woecust.ImmersiveVisor.Config; using Woecust.ImmersiveVisor.Patches; using Woecust.ImmersiveVisor.PostProcessing; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ImmersiveVisorFork")] [assembly: AssemblyDescription("Immersive Visor for Lethal Company - v81 fork by SleepyMiles, original by Woecust")] [assembly: AssemblyProduct("ImmersiveVisorFork")] [assembly: AssemblyCompany("SleepyMiles")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Woecust.ImmersiveVisor { public static class ForkAssets { public static Shader BlurShader; public static Shader FlakesShader; public static Shader WeatherShader; public static bool Loaded { get { if ((Object)(object)BlurShader != (Object)null && (Object)(object)FlakesShader != (Object)null) { return (Object)(object)WeatherShader != (Object)null; } return false; } } public static void Load(string bundlePath) { if (!File.Exists(bundlePath)) { Plugin.Log.LogWarning((object)("ImmersiveVisorFork bundle not found: " + bundlePath)); return; } AssetBundle val = AssetBundle.LoadFromFile(bundlePath); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)("Could not load ImmersiveVisorFork bundle: " + bundlePath)); return; } BlurShader = val.LoadAsset<Shader>("Assets/ImmersiveVisorFork/Shaders/VisorForkBlur.shader"); FlakesShader = val.LoadAsset<Shader>("Assets/ImmersiveVisorFork/Shaders/VisorForkFlakes.shader"); WeatherShader = val.LoadAsset<Shader>("Assets/ImmersiveVisorFork/Shaders/VisorForkWeather.shader"); Plugin.Log.LogInfo((object)$"ImmersiveVisorFork bundle loaded. Blur: {State(BlurShader)}, Flakes: {State(FlakesShader)}, Weather: {State(WeatherShader)}"); } private static string State(Shader s) { if (!((Object)(object)s == (Object)null)) { if (!s.isSupported) { return "NOT SUPPORTED"; } return "OK"; } return "MISSING"; } } public static class ForkNoise { private static Texture2D hi; private static Texture2D mid; private static Texture2D lo; public static Texture2D Hi { get { if ((Object)(object)hi == (Object)null) { hi = Make(11, 256, 1.2f); } return hi; } } public static Texture2D Mid { get { if ((Object)(object)mid == (Object)null) { mid = Make(23, 128, 2f); } return mid; } } public static Texture2D Lo { get { if ((Object)(object)lo == (Object)null) { lo = Make(37, 128, 4.5f); } return lo; } } private static Texture2D Make(int seed, int size, float sigma) { //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown Random random = new Random(seed); float[] array = new float[size * size]; for (int i = 0; i < array.Length; i++) { array[i] = (float)random.NextDouble(); } int num = Mathf.CeilToInt(sigma * 3f); float[] array2 = new float[num * 2 + 1]; float num2 = 0f; for (int j = -num; j <= num; j++) { array2[j + num] = Mathf.Exp((float)(-(j * j)) / (2f * sigma * sigma)); num2 += array2[j + num]; } for (int k = 0; k < array2.Length; k++) { array2[k] /= num2; } float[] array3 = new float[array.Length]; for (int l = 0; l < size; l++) { for (int m = 0; m < size; m++) { float num3 = 0f; for (int n = -num; n <= num; n++) { num3 += array[l * size + ((m + n) % size + size) % size] * array2[n + num]; } array3[l * size + m] = num3; } } float num4 = float.MaxValue; float num5 = float.MinValue; for (int num6 = 0; num6 < size; num6++) { for (int num7 = 0; num7 < size; num7++) { float num8 = 0f; for (int num9 = -num; num9 <= num; num9++) { num8 += array3[((num6 + num9) % size + size) % size * size + num7] * array2[num9 + num]; } array[num6 * size + num7] = num8; if (num8 < num4) { num4 = num8; } if (num8 > num5) { num5 = num8; } } } Texture2D val = new Texture2D(size, size, (TextureFormat)63, false, true); ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)1; ((Object)val).name = "ImmersiveVisorForkNoise" + seed; byte[] array4 = new byte[array.Length]; for (int num10 = 0; num10 < array.Length; num10++) { array4[num10] = (byte)Mathf.Clamp(Mathf.RoundToInt((array[num10] - num4) / (num5 - num4) * 255f), 0, 255); } val.LoadRawTextureData(array4); val.Apply(false, true); Object.DontDestroyOnLoad((Object)(object)val); return val; } } public static class ForkWater { public const float FlipY = 1f; public const float HeightGain = 1.6f; private static Material mat; private static ComputeBuffer buffer; private static MaterialPropertyBlock block; public static bool HasWater { get { if ((Object)(object)VisorWeatherState.Instance != (Object)null && VisorWeatherState.Instance.HasWater) { return (Object)(object)ForkAssets.FlakesShader != (Object)null; } return false; } } public static void DrawHeights(CommandBuffer cmd, RenderTexture target) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_00b4: 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_0143: Unknown result type (might be due to invalid IL or missing references) if (HasWater) { VisorWeatherState instance = VisorWeatherState.Instance; if ((Object)(object)mat == (Object)null) { mat = new Material(ForkAssets.FlakesShader); } if (buffer == null) { buffer = new ComputeBuffer(256, 64, (ComputeBufferType)16); } if (block == null) { block = new MaterialPropertyBlock(); } int gpuCount = instance.GpuCount; if (gpuCount > 0) { buffer.SetData((Array)instance.Gpu, 0, 0, gpuCount); block.Clear(); block.SetBuffer("_Flakes", buffer); block.SetVector("_ScreenPx", new Vector4((float)((Texture)target).width, (float)((Texture)target).height, 0f, 0f)); block.SetFloat("_Lens", 0.55f); block.SetFloat("_SnowSoft", 0.25f); block.SetFloat("_FlipY", 1f); block.SetFloat("_OwnWater", 0f); block.SetFloat("_HeightGain", 1.6f); block.SetTexture("_NoiseHi", (Texture)(object)ForkNoise.Hi); cmd.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)target)); cmd.DrawProcedural(Matrix4x4.identity, mat, 2, (MeshTopology)0, 6, gpuCount, block); } } } } public class VisorWeatherState : MonoBehaviour { public struct FlakeGpu { public Vector2 pos; public float r; public float pop; public float s; public float w; public float slide; public float seed; public Vector3 amp; public Vector3 phase; public Vector2 pad; } private class Flake { public float x; public float y; public float r; public float age; public float stick; public float melt; public float dry; public float seed; public bool slide; public Vector3 amp; public Vector3 phase; } public const int MaxFlakes = 256; public static VisorWeatherState Instance; private static readonly FieldRef<SteamValveHazard, bool> ValveBurst = AccessTools.FieldRefAccess<SteamValveHazard, bool>("valveHasBurst"); private static readonly FieldRef<SteamValveHazard, bool> ValveRepaired = AccessTools.FieldRefAccess<SteamValveHazard, bool>("valveHasBeenRepaired"); public readonly FlakeGpu[] Gpu = new FlakeGpu[256]; public int GpuCount; public float Frost; public float Fog; public float Breath; public float FogTime; public bool HasWater; private readonly List<Flake> flakes = new List<Flake>(); private float time; private float breathTime; private float roofTimer; private bool underRoof; private float valveTimer; private SteamValveHazard[] valves = (SteamValveHazard[])(object)new SteamValveHazard[0]; private float exposure; private float gustWait = 20f; private float gustLeft; private float gustLength = 1f; private Vector3 lastPos; private bool haveLastPos; public bool HasEffect { get { if (GpuCount <= 0 && !(Frost > 0.001f) && !(Fog > 0.001f)) { return Breath > 0.001f; } return true; } } private void Awake() { Instance = this; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private static float Smooth(float e0, float e1, float x) { float num = Mathf.Clamp01((x - e0) / (e1 - e0)); return num * num * (3f - 2f * num); } private void Clear() { flakes.Clear(); exposure = 0f; GpuCount = 0; HasWater = false; Frost = 0f; Fog = 0f; Breath = 0f; } private void Update() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Invalid comparison between Unknown and I4 //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Invalid comparison between Unknown and I4 //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Invalid comparison between Unknown and I4 //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Invalid comparison between Unknown and I4 //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if ((Object)(object)val == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null) { Clear(); return; } if (val.isPlayerDead) { Clear(); haveLastPos = false; return; } float deltaTime = Time.deltaTime; time += deltaTime; FogTime += deltaTime; Camera gameplayCamera = val.gameplayCamera; Vector3 position = ((Component)gameplayCamera).transform.position; float num; if (!haveLastPos || !(deltaTime > 0f)) { num = 0f; } else { Vector3 val2 = position - lastPos; num = ((Vector3)(ref val2)).magnitude / deltaTime; } float num2 = num; if (num2 > 30f) { num2 = 0f; } lastPos = position; haveLastPos = true; SelectableLevel currentLevel = StartOfRound.Instance.currentLevel; bool flag = (Object)(object)currentLevel != (Object)null && currentLevel.levelIncludesSnowFootprints; bool flag2 = !val.isInsideFactory && !val.isInHangarShipRoom && !StartOfRound.Instance.inShipPhase; roofTimer -= deltaTime; if (roofTimer <= 0f) { roofTimer = 0.25f; underRoof = Physics.Linecast(position, position + Vector3.up * 100f, 256, (QueryTriggerInteraction)1); } LevelWeatherType val3 = (LevelWeatherType)((!((Object)(object)TimeOfDay.Instance != (Object)null)) ? (-1) : ((int)TimeOfDay.Instance.currentLevelWeather)); bool flag3 = (int)val3 == 1 || (int)val3 == 2 || (int)val3 == 4; bool flag4 = flag2 && !underRoof && !val.isUnderwater; bool flag5 = flag3 && flag4; bool flag6 = VisorConfig.SnowShow && flag && flag4 && !flag3; if (flag6) { exposure += deltaTime; } else { exposure = Mathf.Max(0f, exposure - deltaTime * 3f); } float num3 = Smooth(0f, Mathf.Max(0.5f, VisorConfig.SnowHeavyTime), exposure); if (flag6) { float num4 = 0.55f + 0.65f * Mathf.Clamp01(((Component)gameplayCamera).transform.forward.y + 0.35f) + Mathf.Clamp01(num2 / 6f) * 0.4f; int num5 = Mathf.FloorToInt(7f * Mathf.Max(0f, VisorConfig.SnowAmount) * num4 * (1f + (Mathf.Max(1f, VisorConfig.SnowHeavyMultiplier) - 1f) * num3) * GustFactor(deltaTime) * deltaTime + Random.value); for (int i = 0; i < num5; i++) { if (flakes.Count >= 256) { break; } Spawn(); } } float num6 = ((gameplayCamera.aspect > 0.1f) ? gameplayCamera.aspect : 1.7777778f); int num7 = 0; bool hasWater = false; float num8 = (flag5 ? 3f : 1f); FlakeGpu flakeGpu = default(FlakeGpu); for (int num9 = flakes.Count - 1; num9 >= 0; num9--) { Flake flake = flakes[num9]; flake.age += deltaTime * num8; float age = flake.age; if (age > flake.stick + flake.melt + flake.dry) { flakes.RemoveAt(num9); } else { float num10 = Smooth(0f, 0.12f, age); float num11 = 1f - Smooth(flake.stick, flake.stick + flake.melt, age); float num12 = Smooth(flake.stick, flake.stick + flake.melt * 0.8f, age) * (1f - Smooth(flake.stick + flake.melt, flake.stick + flake.melt + flake.dry, age)); float num13 = 0f; if (flake.slide && age > flake.stick + flake.melt * 0.6f) { num13 = Mathf.Pow(age - flake.stick - flake.melt * 0.6f, 1.5f) * 9f; } if (num7 < 256) { flakeGpu.pos = new Vector2(flake.x, flake.y + num13 / 960f * num6); flakeGpu.r = flake.r; flakeGpu.pop = 1f + 0.18f * (1f - Smooth(0f, 0.18f, age)); flakeGpu.s = num10 * num11; flakeGpu.w = num12; if (num12 > 0.001f) { hasWater = true; } flakeGpu.slide = (flake.slide ? 1f : 0f); flakeGpu.seed = flake.seed; flakeGpu.amp = flake.amp; flakeGpu.phase = flake.phase; flakeGpu.pad = Vector2.zero; Gpu[num7++] = flakeGpu; } } } GpuCount = num7; HasWater = hasWater; if (VisorConfig.FrostShow && flag6 && num3 > 0.5f) { Frost = Mathf.MoveTowards(Frost, Mathf.Clamp01(VisorConfig.FrostMax), deltaTime * Mathf.Clamp01(VisorConfig.FrostMax) / Mathf.Max(1f, VisorConfig.FrostBuildTime)); } else { Frost = Mathf.MoveTowards(Frost, 0f, deltaTime / (flag5 ? 4f : ((flag2 && flag) ? 30f : 12f))); } float num14 = 0f; if (VisorConfig.FogShow) { if (flag2 && (Object)(object)TimeOfDay.Instance != (Object)null && (int)TimeOfDay.Instance.currentLevelWeather == 3) { num14 = Mathf.Clamp01(VisorConfig.FogWeather); } if (val.isInsideFactory) { valveTimer -= deltaTime; if (valveTimer <= 0f) { valveTimer = 1f; valves = Object.FindObjectsOfType<SteamValveHazard>(); } for (int j = 0; j < valves.Length; j++) { SteamValveHazard val4 = valves[j]; if (!((Object)(object)val4 == (Object)null) && ValveBurst.Invoke(val4) && !ValveRepaired.Invoke(val4)) { float num15 = Vector3.Distance(((Component)val4).transform.position, position); if (num15 < 5f) { num14 = Mathf.Max(num14, Mathf.Clamp01(VisorConfig.FogSteam) * (1f - num15 / 5f * 0.5f)); } } } } } float num16; if (num14 > Fog) { num16 = 1f / Mathf.Max(0.1f, VisorConfig.FogInTime); } else { num16 = 1f / Mathf.Max(0.1f, VisorConfig.FogOutTime); if (val.isInHangarShipRoom) { num16 *= Mathf.Max(0.1f, VisorConfig.FogShipClear); } if (val.isSprinting) { num16 *= Mathf.Clamp(VisorConfig.FogSprintClear, 0.1f, 1f); } } Fog = Mathf.MoveTowards(Fog, num14, num16 * deltaTime); if (VisorConfig.BreathShow && flag && !val.isInsideFactory && !val.isInHangarShipRoom && !val.isUnderwater) { float num17 = (val.isSprinting ? 1.6f : 3.2f); breathTime += deltaTime; float x = breathTime % num17 / num17; Breath = Smooth(0f, 0.08f, x) * (1f - Smooth(0.08f, 0.6f, x)) * Mathf.Clamp01(VisorConfig.BreathStrength); } else { Breath = Mathf.MoveTowards(Breath, 0f, deltaTime * 2f); } } private float GustFactor(float dt) { if (!VisorConfig.SnowGusts) { gustLeft = 0f; return 1f; } if (gustLeft > 0f) { gustLeft -= dt; float x = 1f - gustLeft / gustLength; return 1f + 1.6f * Smooth(0f, 0.25f, x) * (1f - Smooth(0.7f, 1f, x)); } gustWait -= dt; if (gustWait <= 0f) { gustLength = Random.Range(4f, 7f); gustLeft = gustLength; gustWait = Random.Range(15f, 35f); } return 1f; } private void Spawn() { //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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) bool flag = Random.value < 0.15f; Flake flake = new Flake(); flake.x = Random.Range(0.02f, 0.98f); flake.y = Random.Range(0.02f, 0.98f); flake.r = Random.Range(9f, 17f) * (flag ? 1.7f : 1f) * Mathf.Max(0.1f, VisorConfig.SnowFlakeSize); flake.age = 0f; float num = (flake.x - 0.5f) * 1.6f; float num2 = flake.y - 0.5f; float num3 = Mathf.Lerp(0.33f, 1f, Smooth(0.12f, 0.42f, Mathf.Sqrt(num * num + num2 * num2))); flake.stick = Random.Range(1.6f, 3.2f) * Mathf.Max(0.05f, VisorConfig.SnowStickTime) * num3; flake.melt = Random.Range(1.4f, 2.4f) * Mathf.Max(0.05f, VisorConfig.SnowMeltTime) * Mathf.Lerp(0.6f, 1f, num3); flake.dry = Random.Range(2.5f, 4.5f) * Mathf.Max(0.05f, VisorConfig.SnowMeltTime); flake.slide = flake.r > 22f && Random.value < 0.7f; flake.amp = new Vector3(Random.Range(0.06f, 0.16f), Random.Range(0.06f, 0.16f), Random.Range(0.06f, 0.16f)); flake.phase = new Vector3(Random.Range(0f, 6.2832f), Random.Range(0f, 6.2832f), Random.Range(0f, 6.2832f)); flake.seed = Random.Range(0, 100000); flakes.Add(flake); } } [BepInPlugin("ImmersiveVisor", "ImmersiveVisorFork", "1.0.1")] public class Plugin : BaseUnityPlugin { public const string Version = "1.0.1"; private const string Guid = "ImmersiveVisor"; private const string Name = "ImmersiveVisor"; public static Plugin Instance; internal static ManualLogSource Log; private void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown Instance = this; Log = new ManualLogSource("ImmersiveVisorLogSource"); Logger.Sources.Add((ILogSource)(object)Log); Log.LogInfo((object)"Mod Loading..."); ConfigLoader.Load(); HDRPChanges.Load(); AssetBundle assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "immersivevisor")); ShaderLoader.LoadAssets(assetBundle); RaindropSolver.LoadAssets(assetBundle); Visor.LoadAssets(assetBundle); ForkAssets.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "immersivevisorfork")); Harmony.CreateAndPatchAll(typeof(PlayerControllerBPatch), (string)null); Harmony.CreateAndPatchAll(typeof(StartOfRoundPatch), (string)null); Harmony.CreateAndPatchAll(typeof(TimeOfDayPatch), (string)null); Harmony.CreateAndPatchAll(typeof(EnemyAIPatch), (string)null); Log.LogInfo((object)"Mod Loaded"); } public static bool IsModdedWith(string guid) { return Chainloader.PluginInfos.ContainsKey(guid); } } public static class PluginInfo { public const string PLUGIN_GUID = "ImmersiveVisor"; public const string PLUGIN_NAME = "ImmersiveVisorFork"; public const string PLUGIN_VERSION = "1.0.1"; } public sealed class Visor : MonoBehaviour { private const float PhysicalVisorDefaultScale = 0.24f; public static Visor Instance; private static AudioClip[] visorBreakSfx; private static GameObject physicalVisorPrefab; private static Material physicalVisorMat; private static readonly int VisorFOV = Shader.PropertyToID("_FieldOfView"); private PlayerControllerB player; private bool wasDead; private Transform physicalVisor; private OccludeAudio rainAmbienceOcclude; private VisorRaindrop raindrop; private VisorCrack visorCrack; private VisorBloodSplatter visorBlood; private VisorRim visorRim; private List<Camera> renderClearList; private bool isRaining; private bool wasTerminalMenu; private float visorTerminalLerp; private bool hideRimInTerminal; public Dictionary<Camera, VisorRainState> VisorRainStates { get; private set; } public static void LoadAssets(AssetBundle assetBundle) { visorBreakSfx = (AudioClip[])(object)new AudioClip[2]; visorBreakSfx[0] = assetBundle.LoadAsset<AudioClip>("Assets/Audio/sfx_visor_crack_hard.wav"); visorBreakSfx[1] = assetBundle.LoadAsset<AudioClip>("Assets/Audio/sfx_visor_crack_light.wav"); physicalVisorPrefab = assetBundle.LoadAsset<GameObject>("Assets/Prefabs/PhysicalVisor.prefab"); physicalVisorMat = assetBundle.LoadAsset<Material>("Assets/Materials/FirstPersonProjection.mat"); } public void Start() { //IL_013c: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020b: 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_023a: 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_0248: 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) if ((Object)(object)Instance == (Object)null) { Instance = this; } else { Object.Destroy((Object)(object)this); } player = GameNetworkManager.Instance.localPlayerController; rainAmbienceOcclude = GameObject.Find("Systems/GameSystems/TimeAndWeather/RainParticleContainer/RainAmbience").GetComponent<OccludeAudio>(); VisorRainStates = new Dictionary<Camera, VisorRainState>(); renderClearList = new List<Camera>(); HDAdditionalCameraData component = GameObject.Find("Systems/UI/UICamera").GetComponent<HDAdditionalCameraData>(); ((BitArray128)(ref component.renderingPathCustomFrameSettingsOverrideMask.mask))[15u] = true; ((BitArray128)(ref component.renderingPathCustomFrameSettingsOverrideMask.mask))[39u] = true; ((FrameSettings)(ref component.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)15, true); ((FrameSettings)(ref component.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)39, false); HDAdditionalCameraData component2 = ((Component)player.gameplayCamera).GetComponent<HDAdditionalCameraData>(); if (((BitArray128)(ref component2.renderingPathCustomFrameSettingsOverrideMask.mask))[6u] && !((FrameSettings)(ref component2.renderingPathCustomFrameSettings)).IsEnabled((FrameSettingsField)6)) { ((FrameSettings)(ref component2.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)6, true); GameObject.Find("Systems/Rendering/CustomPass").SetActive(false); } physicalVisor = Object.Instantiate<GameObject>(physicalVisorPrefab).transform; physicalVisor.SetParent(((Component)this).transform); physicalVisor.GetChild(0).localEulerAngles = new Vector3(90f, 0f, 0f); physicalVisor.localScale = new Vector3(0.24f, 0.24f, 0.24f); CustomPassVolume obj = ((Component)physicalVisor).gameObject.AddComponent<CustomPassVolume>(); obj.isGlobal = false; obj.priority = 64f; obj.targetCamera = player.gameplayCamera; obj.injectionPoint = (CustomPassInjectionPoint)0; CustomPass obj2 = obj.AddPassOfType<DrawRenderersCustomPass>(); DrawRenderersCustomPass val = (DrawRenderersCustomPass)(object)((obj2 is DrawRenderersCustomPass) ? obj2 : null); BackupFrameBufferPass backupFrameBufferPass = obj.AddPassOfType<BackupFrameBufferPass>() as BackupFrameBufferPass; ((CustomPass)val).name = "GetVisorRim"; ((CustomPass)val).targetColorBuffer = (TargetBuffer)1; ((CustomPass)val).targetDepthBuffer = (TargetBuffer)2; ((CustomPass)val).clearFlags = (ClearFlag)0; ((CustomPass)val).clearFlags = (ClearFlag)(((CustomPass)val).clearFlags | 1); val.renderQueueType = (RenderQueueType)2; val.layerMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "HelmetVisor" })); val.overrideMode = (OverrideMaterialMode)1; val.overrideMaterial = physicalVisorMat; val.overrideMaterialPassName = "MotionVectors"; val.sortingCriteria = (SortingCriteria)0; ((CustomPass)backupFrameBufferPass).name = "WriteVisorRim"; ((CustomPass)backupFrameBufferPass).targetColorBuffer = (TargetBuffer)2; ((CustomPass)backupFrameBufferPass).targetDepthBuffer = (TargetBuffer)2; ((CustomPass)backupFrameBufferPass).clearFlags = (ClearFlag)0; backupFrameBufferPass.outputRenderTexture = VisorPostProcessingHelper.GetVisorRimMask(); VisorPostProcessingHelper.PlayerCamera = player.gameplayCamera; GameObject val2 = new GameObject("ImmersiveVisorPostProcessing"); val2.transform.parent = GameObject.Find("Systems/Rendering").transform; Volume obj3 = val2.AddComponent<Volume>(); obj3.priority = 421f; VolumeProfile val3 = ScriptableObject.CreateInstance<VolumeProfile>(); ((Object)val3).name = "VisorPostProcessProfile"; raindrop = val3.Add<VisorRaindrop>(true); ((Object)raindrop).name = "VisorRaindrop"; ((VolumeParameter<bool>)(object)raindrop.enabled).value = VisorConfig.RaindropShow; ((VolumeParameter<bool>)(object)raindrop.specular).value = VisorConfig.RaindropSpecular; ((VolumeParameter<bool>)(object)raindrop.shadow).value = VisorConfig.RaindropShadow; ((VolumeParameter<float>)(object)raindrop.dryTime).value = VisorConfig.RaindropDryTime; ((VolumeParameter<int>)(object)raindrop.pixelated).value = VisorConfig.PixelatedRain; visorRim = val3.Add<VisorRim>(true); ((Object)visorRim).name = "VisorRim"; ((VolumeParameter<bool>)(object)visorRim.visible).value = VisorConfig.RimShow && !VisorConfig.RimPhysical; visorCrack = val3.Add<VisorCrack>(true); ((Object)visorCrack).name = "VisorCrack"; ((VolumeParameter<bool>)(object)visorCrack.enabled).value = VisorConfig.CrackShow; ((VolumeParameter<int>)(object)visorCrack.pixelated).value = VisorConfig.PixelatedCrack; visorBlood = val3.Add<VisorBloodSplatter>(true); ((Object)visorBlood).name = "VisorBloodSplatter"; ((VolumeParameter<bool>)(object)visorBlood.enabled).value = VisorConfig.BloodShow; ((VolumeParameter<float>)(object)visorBlood.lifeTime).value = VisorConfig.BloodLifeTime; ((VolumeParameter<int>)(object)visorBlood.pixelated).value = VisorConfig.PixelatedBlood; ((VolumeParameter<float>)(object)visorBlood.fadeOut).value = VisorConfig.BloodDryTime; VisorWeather visorWeather = val3.Add<VisorWeather>(true); ((Object)visorWeather).name = "VisorWeather"; ((VolumeParameter<bool>)(object)visorWeather.enabled).value = true; if ((Object)(object)((Component)this).gameObject.GetComponent<VisorWeatherState>() == (Object)null) { ((Component)this).gameObject.AddComponent<VisorWeatherState>(); } obj3.sharedProfile = val3; if (VisorConfig.PixelateAuto) { int height = ((Texture)player.gameplayCamera.targetTexture).height; ((VolumeParameter<int>)(object)raindrop.pixelated).value = height; ((VolumeParameter<int>)(object)visorCrack.pixelated).value = height; ((VolumeParameter<int>)(object)visorBlood.pixelated).value = height; } hideRimInTerminal = Plugin.IsModdedWith("wijes.desktop.terminal"); Plugin.Log.LogInfo((object)"Immersive Visor Initialized"); } internal static void UpdateGameCracks(PlayerControllerB who) { try { if ((Object)(object)HUDManager.Instance != (Object)null && (Object)(object)who != (Object)null && !who.isPlayerDead) { HUDManager.Instance.SetCracksOnVisor((float)who.health); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Updating the game's visor cracks: " + ex.Message)); } } public void Repair() { Plugin.Log.LogInfo((object)"Visor Repaired"); ((VolumeParameter<int>)(object)visorCrack.crackLevel).value = 0; } public void Damage(CauseOfDeath cause) { int value = ((VolumeParameter<int>)(object)visorCrack.crackLevel).value; ClampedIntParameter crackLevel = visorCrack.crackLevel; int health = player.health; int value2 = ((health <= 35) ? 2 : ((health <= 75) ? 1 : ((VolumeParameter<int>)(object)visorCrack.crackLevel).value)); ((VolumeParameter<int>)(object)crackLevel).value = value2; if (((VolumeParameter<int>)(object)visorCrack.crackLevel).value > 0 && value != ((VolumeParameter<int>)(object)visorCrack.crackLevel).value) { HUDManager.Instance.UIAudio.PlayOneShot(visorBreakSfx[((VolumeParameter<int>)(object)visorCrack.crackLevel).value - 1], VisorConfig.CrackVolume); Plugin.Log.LogInfo((object)$"Visor Damaged : level {((VolumeParameter<int>)(object)visorCrack.crackLevel).value}"); } } public void AddCamera(Camera camera) { if (VisorRainStates.TryGetValue(camera, out var _)) { VisorRainStates.Remove(camera); } VisorRainStates.Add(camera, new VisorRainState(camera)); } public void QueueRenderClear(Camera camera) { renderClearList.Add(camera); } public void LateUpdate() { RimUpdate(); ((VolumeParameter<bool>)(object)visorBlood.enabled).value = VisorConfig.BloodShow; ((VolumeParameter<bool>)(object)visorCrack.enabled).value = VisorConfig.CrackShow; bool isPlayerDead = player.isPlayerDead; if (isPlayerDead) { ((VolumeParameter<int>)(object)visorCrack.crackLevel).value = 0; } else if (wasDead) { UpdateGameCracks(player); } else if (player.health >= 60 && (Object)(object)HUDManager.Instance != (Object)null && (Object)(object)HUDManager.Instance.visorCracksObject != (Object)null && HUDManager.Instance.visorCracksObject.activeSelf) { UpdateGameCracks(player); } wasDead = isPlayerDead; if (VisorConfig.PixelateAuto) { int height = ((Texture)player.gameplayCamera.targetTexture).height; ((VolumeParameter<int>)(object)raindrop.pixelated).value = height; ((VolumeParameter<int>)(object)visorCrack.pixelated).value = height; ((VolumeParameter<int>)(object)visorBlood.pixelated).value = height; } else { ((VolumeParameter<int>)(object)raindrop.pixelated).value = VisorConfig.PixelatedRain; ((VolumeParameter<int>)(object)visorCrack.pixelated).value = VisorConfig.PixelatedCrack; ((VolumeParameter<int>)(object)visorBlood.pixelated).value = VisorConfig.PixelatedBlood; } } public void FixedUpdate() { RaindropUpdate(); } private void RaindropUpdate() { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 if (!VisorConfig.RaindropShow) { ((VolumeParameter<bool>)(object)raindrop.enabled).value = false; return; } LevelWeatherType currentLevelWeather = TimeOfDay.Instance.currentLevelWeather; bool flag = (int)currentLevelWeather == 1 || (int)currentLevelWeather == 2 || (int)currentLevelWeather == 4 || ((Component)rainAmbienceOcclude).gameObject.activeInHierarchy; RemoveNullKeys(); if (isRaining != flag) { if (!flag) { foreach (KeyValuePair<Camera, VisorRainState> visorRainState in VisorRainStates) { visorRainState.Value.ForceStop(); raindrop.Clear(visorRainState.Key); } } isRaining = flag; } if (isRaining) { bool flag2 = true; foreach (VisorRainState value in VisorRainStates.Values) { value.Update(); if (value.IsRainVisible) { flag2 = false; } } ((VolumeParameter<bool>)(object)raindrop.enabled).value = !flag2; } foreach (Camera renderClear in renderClearList) { raindrop.Clear(renderClear); } renderClearList.Clear(); } private void RimUpdate() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) if (!VisorConfig.RimShow) { ((Component)physicalVisor).gameObject.SetActive(false); ((VolumeParameter<bool>)(object)visorRim.visible).value = false; return; } ((VolumeParameter<bool>)(object)visorRim.visible).value = !player.isPlayerDead && !VisorConfig.RimPhysical; ((Component)physicalVisor).gameObject.SetActive(((Component)player.localVisor).gameObject.activeInHierarchy && VisorConfig.RimPhysical && (!hideRimInTerminal || !player.inTerminalMenu)); if (VisorConfig.RimPhysical) { physicalVisor.position = ((Component)player.gameplayCamera).transform.position; physicalVisor.rotation = player.localVisor.rotation; Vector3 localScale = default(Vector3); ((Vector3)(ref localScale))..ctor(0.24f * (VisorConfig.RimStretch / 1.77f), 0.24f, 0.24f); physicalVisor.localScale = localScale; if (wasTerminalMenu != player.inTerminalMenu) { visorTerminalLerp = 0f; wasTerminalMenu = player.inTerminalMenu; } if (visorTerminalLerp < 1f) { float num = physicalVisorMat.GetFloat(VisorFOV); num = Mathf.Lerp(num, player.inTerminalMenu ? 55f : 60f, 1f - Mathf.Pow(1f - visorTerminalLerp, 2f)); physicalVisorMat.SetFloat(VisorFOV, num); } visorTerminalLerp = Mathf.Min(1f, visorTerminalLerp + Time.deltaTime); } else if (player.isInHangarShipRoom) { float num2 = (player.inTerminalMenu ? visorRim.offset.min : visorRim.offset.max); ((VolumeParameter<float>)(object)visorRim.offset).value = Mathf.MoveTowards(((VolumeParameter<float>)(object)visorRim.offset).value, num2, 0.3f * Time.deltaTime); } } private void RemoveNullKeys() { Dictionary<Camera, VisorRainState> visorRainStates = VisorRainStates.Where(delegate(KeyValuePair<Camera, VisorRainState> pair) { KeyValuePair<Camera, VisorRainState> keyValuePair = pair; return (Object)(object)keyValuePair.Key != (Object)null; }).ToDictionary((KeyValuePair<Camera, VisorRainState> pair) => pair.Key, (KeyValuePair<Camera, VisorRainState> pair) => pair.Value); VisorRainStates = visorRainStates; } } public class VisorRainState { private const float CeilingCheckInterval = 0.75f; private const float RaindropLifeTime = 1.5f; private readonly Camera camera; private readonly bool isPlayerView; public Vector3 Forward; public float Intensity; public bool IsRainVisible; private float timeSinceRaindrop; private float rainCheckTimer; private bool isRainOccluded; public VisorRainState(Camera camera) { this.camera = camera; isPlayerView = (Object)(object)camera == (Object)(object)GameNetworkManager.Instance.localPlayerController.gameplayCamera; } public void Update() { //IL_009b: 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) bool flag = isPlayerView && GameNetworkManager.Instance.localPlayerController.isPlayerDead; if (rainCheckTimer <= 0f) { if (isPlayerView) { isRainOccluded = GameNetworkManager.Instance.localPlayerController.isInsideFactory || LineCastForCeiling(); } else { isRainOccluded = LineCastForCeiling(); } rainCheckTimer = 0.75f; } timeSinceRaindrop = ((!isRainOccluded) ? 0f : (timeSinceRaindrop + Time.deltaTime)); Forward = ((Component)camera).transform.forward; float num = (isPlayerView ? (1.5f + VisorConfig.RaindropDryTime * 2f) : 3f); bool flag2 = timeSinceRaindrop < num && !flag; if (IsRainVisible != flag2) { if (!flag2) { Visor.Instance.QueueRenderClear(camera); } IsRainVisible = flag2; } if (IsRainVisible) { Intensity = (isRainOccluded ? 0f : Mathf.Clamp01(Intensity + 2f * Time.deltaTime)); } rainCheckTimer -= Time.deltaTime; } public void ForceStop() { IsRainVisible = false; Intensity = 0f; } private bool LineCastForCeiling() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002f: Unknown result type (might be due to invalid IL or missing references) return Physics.Linecast(((Component)camera).transform.position, ((Component)camera).transform.position + Vector3.up * 100f, 256, (QueryTriggerInteraction)1); } } } namespace Woecust.ImmersiveVisor.PostProcessing { public class BackupFrameBufferPass : CustomPass { [Header("Output")] public RenderTexture outputRenderTexture; protected override bool executeInSceneView => true; protected override void Execute(CustomPassContext ctx) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_001f: 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_0035: 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_0046: 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) if (!((Object)(object)outputRenderTexture == (Object)null)) { Vector4 rtHandleScale = RTHandles.rtHandleProperties.rtHandleScale; ctx.cmd.Blit(RTHandle.op_Implicit(ctx.customColorBuffer.Value), RenderTargetIdentifier.op_Implicit((Texture)(object)outputRenderTexture), new Vector2(rtHandleScale.x, rtHandleScale.y), Vector2.zero, 0, 0); } } } public static class HDRPChanges { public static void Load() { try { Type? type = typeof(HDRenderPipelineAsset).Assembly.GetType("UnityEngine.Rendering.HighDefinition.HDRenderPipelineGlobalSettings"); object value = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy).GetValue(null); ((List<string>)type.GetField("afterPostProcessCustomPostProcesses", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy).GetValue(value)).Add(typeof(VisorRim).AssemblyQualifiedName); List<string> obj = (List<string>)type.GetField("beforePostProcessCustomPostProcesses", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy).GetValue(value); obj.Add(typeof(VisorRaindrop).AssemblyQualifiedName); obj.Add(typeof(VisorCrack).AssemblyQualifiedName); obj.Add(typeof(VisorBloodSplatter).AssemblyQualifiedName); obj.Add(typeof(VisorWeather).AssemblyQualifiedName); } catch (Exception ex) { Plugin.Log.LogError((object)"Error while patching HDRP!"); Plugin.Log.LogError((object)ex); } } } public class RaindropSolver { public struct RenderInfo { private int Width; private int Height; private int Scale; public int ScaledWidth; public int ScaledHeight; public RenderInfo(int width, int height, int scale) { Width = width; Height = height; Scale = scale; ScaledHeight = Mathf.CeilToInt((float)(520 * Scale) * 0.01f); ScaledWidth = Mathf.CeilToInt(520f * ((float)width / (float)height) * (float)Scale * 0.01f); } public bool Update(int width, int height, int scale) { bool result = Height != height || Width != width || Scale != scale; Width = width; Height = height; Scale = scale; ScaledHeight = Mathf.CeilToInt((float)(520 * Scale) * 0.01f); ScaledWidth = Mathf.CeilToInt(520f * ((float)width / (float)height) * (float)Scale * 0.01f); return result; } } private struct Particle { public float2 position; public float2 velocity; public float size; public float lifetime; public Particle(float2 _position) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) position = _position; velocity = float2.zero; size = 0f; lifetime = 0f; } } private const int RenderHeight = 520; private static readonly int _bounds = Shader.PropertyToID("bounds"); private static readonly int _particleSize = Shader.PropertyToID("particleSize"); private static readonly int _smoothDistance = Shader.PropertyToID("smoothDistance"); private static readonly int _timeStep = Shader.PropertyToID("timeStep"); private static readonly int _gravity = Shader.PropertyToID("gravity"); private static readonly int _staticTime = Shader.PropertyToID("staticTime"); private static readonly int _dynamicTime = Shader.PropertyToID("dynamicTime"); private static readonly int _staticLifetime = Shader.PropertyToID("staticLifetime"); private static readonly int _lifeTimeMultiplier = Shader.PropertyToID("lifeTimeMultiplier"); private static ComputeShader computeAsset; private readonly ComputeShader compute; private static int spawnStaticParticlesKernel; private static int spawnDynamicParticlesKernel; private static int staticApplyExternalForceKernel; private static int dynamicApplyExternalForceKernel; private static int drawRainTexKernel; private ComputeBuffer spawnTimesStaticBuffer; private ComputeBuffer spawnTimesDynamicBuffer; private ComputeBuffer staticParticlesBuffer; private ComputeBuffer dynamicParticlesBuffer; private const int StaticParticleCount = 384; private const int DynamicParticleCount = 8; private const float StaticTimerTimeStep = 0.0026041667f; private const float DynamicTimerTimeStep = 0.125f; public RenderInfo CurrentRenderInfo; public RenderTexture RainMap; private RenderTexture dropMap; private RenderTexture trailMap; private float staticTimer; private float dynamicTimer; private float deltaTime; public static void LoadAssets(AssetBundle assetBundle) { computeAsset = assetBundle.LoadAsset<ComputeShader>("Assets/Scripts/PostProcessing/Raindrop/Resources/CSRaindrop.compute"); } public RaindropSolver(int scrWidth, int scrHeight, int renderScale) { compute = Object.Instantiate<ComputeShader>(computeAsset); CurrentRenderInfo = new RenderInfo(scrWidth, scrHeight, renderScale); spawnStaticParticlesKernel = compute.FindKernel("SpawnStaticParticles"); spawnDynamicParticlesKernel = compute.FindKernel("SpawnDynamicParticles"); staticApplyExternalForceKernel = compute.FindKernel("StaticApplyExternalForce"); dynamicApplyExternalForceKernel = compute.FindKernel("DynamicApplyExternalForce"); drawRainTexKernel = compute.FindKernel("DrawRainMask"); SetRenderTextures(drawRainTexKernel); SetBuffers(spawnStaticParticlesKernel, spawnDynamicParticlesKernel, staticApplyExternalForceKernel, dynamicApplyExternalForceKernel, drawRainTexKernel); } private void SetRenderTextures(params int[] kernels) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00ef: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown if ((Object)(object)dropMap != (Object)null) { dropMap.Release(); } dropMap = new RenderTexture(CurrentRenderInfo.ScaledWidth, CurrentRenderInfo.ScaledHeight, 0, (RenderTextureFormat)28) { enableRandomWrite = true, autoGenerateMips = true, useMipMap = false }; dropMap.Create(); if ((Object)(object)trailMap != (Object)null) { trailMap.Release(); } trailMap = new RenderTexture(CurrentRenderInfo.ScaledWidth, CurrentRenderInfo.ScaledHeight, 0, (RenderTextureFormat)28) { enableRandomWrite = true, autoGenerateMips = true, useMipMap = false }; trailMap.Create(); if ((Object)(object)RainMap != (Object)null) { RainMap.Release(); } RainMap = new RenderTexture(CurrentRenderInfo.ScaledWidth, CurrentRenderInfo.ScaledHeight, 0, (RenderTextureFormat)28) { enableRandomWrite = true, autoGenerateMips = true, useMipMap = false }; RainMap.Create(); foreach (int num in kernels) { compute.SetTexture(num, "rainMap", (Texture)(object)RainMap); compute.SetTexture(num, "dropMap", (Texture)(object)dropMap); compute.SetTexture(num, "trailMap", (Texture)(object)trailMap); } } private void SetBuffers(params int[] kernels) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown int num = Marshal.SizeOf(typeof(Particle)); Particle[] array = new Particle[384]; Particle[] array2 = new Particle[8]; staticTimer = -0.1f; dynamicTimer = -0.1f; float[] array3 = new float[384]; for (int i = 0; i < 384; i++) { array3[i] = 0.0026041667f * (float)i; array[i] = new Particle(new float2(-9999f, -9999f)); } float[] array4 = new float[8]; for (int j = 0; j < 8; j++) { array4[j] = 0.125f * (float)j; array2[j] = new Particle(new float2(-9999f, -9999f)); } staticParticlesBuffer = new ComputeBuffer(384, num); staticParticlesBuffer.SetData((Array)array); dynamicParticlesBuffer = new ComputeBuffer(8, num); dynamicParticlesBuffer.SetData((Array)array2); spawnTimesStaticBuffer = new ComputeBuffer(384, 4); spawnTimesStaticBuffer.SetData((Array)array3); spawnTimesDynamicBuffer = new ComputeBuffer(8, 4); spawnTimesDynamicBuffer.SetData((Array)array4); foreach (int num2 in kernels) { compute.SetBuffer(num2, "staticParticles", staticParticlesBuffer); compute.SetBuffer(num2, "dynamicParticles", dynamicParticlesBuffer); compute.SetBuffer(num2, "spawnTimesStatic", spawnTimesStaticBuffer); compute.SetBuffer(num2, "spawnTimesDynamic", spawnTimesDynamicBuffer); } compute.SetInt("numStatic", 384); compute.SetInt("numDynamic", 8); } public void UpdateProperties(float intensity, int2 renderSize, int renderScale, float particleSize, float smoothDistance, int staticDropRate, int dynamicDropRate, float staticDropLifetime, float dryTime, float3 headForward, float travelTime) { //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) //IL_002e: 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) if (CurrentRenderInfo.Update(renderSize.x, renderSize.y, renderScale)) { SetRenderTextures(drawRainTexKernel); } float num = Vector3.Dot(Vector3.up, float3.op_Implicit(headForward)); float num2 = ((num < -0.5f) ? 0f : 1f); float num3 = num2 * ((num > 0.8f) ? 0f : 1f); float num4 = ((num2 * intensity > 0f) ? 1f : (staticDropLifetime / dryTime)); staticTimer += Time.deltaTime * 0.0026041667f * intensity * (float)staticDropRate * num2; dynamicTimer += Time.deltaTime * 0.125f * intensity * (float)dynamicDropRate * num3; deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f; compute.SetFloats(_bounds, new float[2] { CurrentRenderInfo.ScaledWidth, CurrentRenderInfo.ScaledHeight }); compute.SetFloat(_particleSize, particleSize); compute.SetFloat(_smoothDistance, smoothDistance); compute.SetFloat(_staticTime, staticTimer); compute.SetFloat(_dynamicTime, dynamicTimer); compute.SetFloat(_timeStep, Time.deltaTime); compute.SetFloat(_staticLifetime, staticDropLifetime); compute.SetFloat(_lifeTimeMultiplier, num4); compute.SetFloat(_gravity, (0f - (float)CurrentRenderInfo.ScaledHeight) / travelTime); } public void CalcRainMap() { ComputeDispatch(spawnStaticParticlesKernel, 384); ComputeDispatch(spawnDynamicParticlesKernel, 8); ComputeDispatch(staticApplyExternalForceKernel, 384); ComputeDispatch(dynamicApplyExternalForceKernel, 8); ComputeDispatch(drawRainTexKernel, dropMap); } public void ClearRenderTextures() { VisorPostProcessingHelper.ClearOutRenderTexture(RainMap); VisorPostProcessingHelper.ClearOutRenderTexture(trailMap); VisorPostProcessingHelper.ClearOutRenderTexture(dropMap); } public void Release() { spawnTimesStaticBuffer.Release(); spawnTimesDynamicBuffer.Release(); staticParticlesBuffer.Release(); dynamicParticlesBuffer.Release(); } private void ComputeDispatch(int kernel, int length) { //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_0011: Unknown result type (might be due to invalid IL or missing references) int3 threadGroups = GetThreadGroups(kernel); compute.Dispatch(kernel, Mathf.CeilToInt((float)length / (float)threadGroups.x), 1, 1); } private void ComputeDispatch(int kernel, RenderTexture texture) { //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_0016: 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) int3 threadGroups = GetThreadGroups(kernel); compute.Dispatch(kernel, Mathf.CeilToInt((float)((Texture)texture).width / (float)threadGroups.x), Mathf.CeilToInt((float)((Texture)texture).height / (float)threadGroups.y), 1); } private int3 GetThreadGroups(int kernel) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) uint num = default(uint); uint num2 = default(uint); uint num3 = default(uint); compute.GetKernelThreadGroupSizes(kernel, ref num, ref num2, ref num3); return new int3((int)num, (int)num2, (int)num3); } } public static class ShaderLoader { public static Shader DrawRaindropsShader; public static Shader GaussianBlurImageShader; public static Shader LevelImageShader; public static Shader DrawScreenShader; public static Shader DrawVisorCrackShader; public static Shader RimShader; public static Shader DrawBloodShader; public static Shader DrawBloodCanvasShader; public static Texture Level1Color; public static Texture Level2Color; public static Texture Level1Normal; public static Texture Level2Normal; public static Texture bloodRound0; public static Texture bloodRound1; public static Texture bloodRound2; public static Texture bloodRound3; public static void LoadAssets(AssetBundle assetBundle) { DrawRaindropsShader = assetBundle.LoadAsset<Shader>("Assets/Scripts/PostProcessing/Raindrop/Shaders/DrawRaindrops.shader"); GaussianBlurImageShader = assetBundle.LoadAsset<Shader>("Assets/Scripts/PostProcessing/Raindrop/Shaders/GaussianBlurImage.shader"); LevelImageShader = assetBundle.LoadAsset<Shader>("Assets/Scripts/PostProcessing/Raindrop/Shaders/LevelImage.shader"); DrawScreenShader = assetBundle.LoadAsset<Shader>("Assets/Scripts/PostProcessing/Raindrop/Shaders/DrawScreen.shader"); RimShader = assetBundle.LoadAsset<Shader>("Assets/Scripts/PostProcessing/VisorRim/Shaders/VisorRim.shader"); DrawBloodShader = assetBundle.LoadAsset<Shader>("Assets/Scripts/PostProcessing/BloodSplatter/Shaders/DrawVisorBlood.shader"); DrawBloodCanvasShader = assetBundle.LoadAsset<Shader>("Assets/Scripts/PostProcessing/BloodSplatter/Shaders/DrawBloodOnCanvas.shader"); DrawVisorCrackShader = assetBundle.LoadAsset<Shader>("Assets/Scripts/PostProcessing/VisorCrack/Shaders/DrawVisorCrack.shader"); Level1Color = assetBundle.LoadAsset<Texture>("Assets/Textures/Cracks/cracks_left_color.png"); Level2Color = assetBundle.LoadAsset<Texture>("Assets/Textures/Cracks/cracks_right_color.png"); Level1Normal = assetBundle.LoadAsset<Texture>("Assets/Textures/Cracks/cracks_left_normal.png"); Level2Normal = assetBundle.LoadAsset<Texture>("Assets/Textures/Cracks/cracks_right_normal.png"); bloodRound0 = assetBundle.LoadAsset<Texture>("Assets/Textures/BloodDecals/Splatter_round_0.png"); bloodRound1 = assetBundle.LoadAsset<Texture>("Assets/Textures/BloodDecals/Splatter_round_1.png"); bloodRound2 = assetBundle.LoadAsset<Texture>("Assets/Textures/BloodDecals/Splatter_round_2.png"); bloodRound3 = assetBundle.LoadAsset<Texture>("Assets/Textures/BloodDecals/Splatter_round_3.png"); } } public static class ShaderParams { public static readonly int MainTex = Shader.PropertyToID("_MainTex"); public static readonly int CullMask = Shader.PropertyToID("_CullMask"); public static readonly int PixelSize = Shader.PropertyToID("_PixelSize"); public static readonly int Opacity = Shader.PropertyToID("_Opacity"); public static readonly int Offset = Shader.PropertyToID("_Offset"); public static readonly int AspectRatio = Shader.PropertyToID("_AspectRatio"); public static readonly int Mode = Shader.PropertyToID("_ViewMode"); public static readonly int LifeTime = Shader.PropertyToID("_LifeTime"); public static readonly int Distortion = Shader.PropertyToID("_Distortion"); public static readonly int OutBlack = Shader.PropertyToID("_OutBlack"); public static readonly int OutWhite = Shader.PropertyToID("_OutWhite"); public static readonly int InWhite = Shader.PropertyToID("_InWhite"); public static readonly int InBlack = Shader.PropertyToID("_InBlack"); public static readonly int Level1Color = Shader.PropertyToID("_Level1Color"); public static readonly int Level2Color = Shader.PropertyToID("_Level2Color"); public static readonly int Level1Normal = Shader.PropertyToID("_Level1Normal"); public static readonly int Level2Normal = Shader.PropertyToID("_Level2Normal"); public static readonly int CrackLevel = Shader.PropertyToID("_CrackLevel"); public static readonly int RainTex = Shader.PropertyToID("_RainTex"); public static readonly int RainTexTexelSize = Shader.PropertyToID("_RainTex_TexelSize"); public static readonly int Specular = Shader.PropertyToID("_Specular"); public static readonly int Shadow = Shader.PropertyToID("_Shadow"); public static readonly int BloodDecal = Shader.PropertyToID("_Decal"); public static readonly int BloodEraser = Shader.PropertyToID("_Eraser"); public static readonly int PositionX = Shader.PropertyToID("_PositionX"); public static readonly int PositionY = Shader.PropertyToID("_PositionY"); public static readonly int Rotation = Shader.PropertyToID("_Rotation"); public static readonly int DecalSize = Shader.PropertyToID("_DecalSize"); public static readonly int FadeOut = Shader.PropertyToID("_FadeOut"); public static readonly int DecalCanvas = Shader.PropertyToID("_DecalCanvas"); public static readonly int DecalColor = Shader.PropertyToID("_DecalColor"); public static readonly int DrawNew = Shader.PropertyToID("_DrawNew"); } public enum ViewMode { Image, Normal, Height } [Serializable] public sealed class ViewModeParameter : VolumeParameter<ViewMode> { public ViewModeParameter(ViewMode value, bool overrideState = false) : base(value, overrideState) { } } [Serializable] [VolumeComponentMenu("Post-processing/Custom/VisorBloodSplatter")] public sealed class VisorBloodSplatter : CustomPostProcessVolumeComponent, IPostProcessComponent { [Tooltip("Controls the intensity of the effect.")] public BoolParameter enabled = new BoolParameter(false, false); public ColorParameter color = new ColorParameter(new Color(0.3679245f, 0f, 0f, 1f), false); public ClampedFloatParameter maxOpacity = new ClampedFloatParameter(0.8f, 0f, 1f, false); public FloatParameter fadeOut = new FloatParameter(3f, false); public FloatParameter lifeTime = new FloatParameter(5f, false); public FloatParameter size = new FloatParameter(1.4f, false); public IntParameter pixelated = new IntParameter(0, false); private Material bloodMat; private Material canvasMat; private Material drawScreenMat; private bool allMatLoaded; private Texture[] splatters; private RenderTexture decalCanvas; public override CustomPostProcessInjectionPoint injectionPoint => (CustomPostProcessInjectionPoint)1; public bool IsActive() { if (allMatLoaded && ((VolumeParameter<bool>)(object)enabled).value && Application.isPlaying) { return (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null; } return false; } public override void Setup() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown bloodMat = new Material(ShaderLoader.DrawBloodShader); canvasMat = new Material(ShaderLoader.DrawBloodCanvasShader); drawScreenMat = new Material(ShaderLoader.DrawScreenShader); allMatLoaded = (Object)(object)bloodMat != (Object)null && (((Object)(object)canvasMat != (Object)null) & ((Object)(object)drawScreenMat != (Object)null)); } public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination) { //IL_0137: 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_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_026e: 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_00c7: Expected O, but got Unknown if (!IsActive()) { return; } bool flag = (Object)(object)camera.camera == (Object)(object)GameNetworkManager.Instance.localPlayerController.gameplayCamera; if ((Object)(object)camera.camera.targetTexture == (Object)null || !flag) { drawScreenMat.SetTexture(ShaderParams.MainTex, RTHandle.op_Implicit(source)); HDUtils.DrawFullScreen(cmd, drawScreenMat, destination, (MaterialPropertyBlock)null, 0); return; } if (splatters == null) { splatters = (Texture[])(object)new Texture[4] { ShaderLoader.bloodRound0, ShaderLoader.bloodRound1, ShaderLoader.bloodRound2, ShaderLoader.bloodRound3 }; } if ((Object)(object)decalCanvas == (Object)null) { decalCanvas = new RenderTexture(Screen.width, Screen.height, 0, (RenderTextureFormat)23, (RenderTextureReadWrite)1); } RenderTexture temporary = RenderTexture.GetTemporary(((Texture)decalCanvas).width, ((Texture)decalCanvas).height, 0, (RenderTextureFormat)23, (RenderTextureReadWrite)1); (bool, Vector2) tuple = VisorPostProcessingHelper.CheckSplat(); VisorPostProcessingHelper.CheckBloodWipe(decalCanvas); canvasMat.SetTexture(ShaderParams.BloodDecal, splatters[Random.Range(0, 3)]); canvasMat.SetTexture(ShaderParams.BloodEraser, (Texture)(object)VisorPostProcessingHelper.GetRaindropMask()); canvasMat.SetFloat(ShaderParams.PositionX, tuple.Item2.x); canvasMat.SetFloat(ShaderParams.PositionY, tuple.Item2.y); canvasMat.SetFloat(ShaderParams.Rotation, Random.value * 360f); canvasMat.SetFloat(ShaderParams.Opacity, ((VolumeParameter<float>)(object)maxOpacity).value); canvasMat.SetFloat(ShaderParams.DecalSize, 1f / ((VolumeParameter<float>)(object)size).value); canvasMat.SetFloat(ShaderParams.FadeOut, ((VolumeParameter<float>)(object)fadeOut).value); canvasMat.SetFloat(ShaderParams.LifeTime, ((VolumeParameter<float>)(object)lifeTime).value); canvasMat.SetInt(ShaderParams.DrawNew, tuple.Item1 ? 1 : 0); cmd.Blit((Texture)(object)decalCanvas, RenderTargetIdentifier.op_Implicit((Texture)(object)temporary), canvasMat); cmd.Blit((Texture)(object)temporary, RenderTargetIdentifier.op_Implicit((Texture)(object)decalCanvas)); bloodMat.SetTexture(ShaderParams.MainTex, RTHandle.op_Implicit(source)); bloodMat.SetTexture(ShaderParams.DecalCanvas, (Texture)(object)decalCanvas); bloodMat.SetColor(ShaderParams.DecalColor, ((VolumeParameter<Color>)(object)color).value); bloodMat.SetInt(ShaderParams.PixelSize, ((VolumeParameter<int>)(object)pixelated).value); HDUtils.DrawFullScreen(cmd, bloodMat, destination, (MaterialPropertyBlock)null, 0); RenderTexture.ReleaseTemporary(temporary); } public override void Cleanup() { CoreUtils.Destroy((Object)(object)bloodMat); CoreUtils.Destroy((Object)(object)canvasMat); } } [Serializable] [VolumeComponentMenu("Post-processing/Custom/VisorCrack")] public sealed class VisorCrack : CustomPostProcessVolumeComponent, IPostProcessComponent { [Tooltip("Controls the intensity of the effect.")] public BoolParameter enabled = new BoolParameter(false, false); public ClampedIntParameter crackLevel = new ClampedIntParameter(0, 0, 2, false); public ClampedFloatParameter colorOpacity = new ClampedFloatParameter(0f, 0f, 1f, false); public ClampedFloatParameter distortion = new ClampedFloatParameter(0.2f, 0f, 1f, false); public IntParameter pixelated = new IntParameter(0, false); public ViewModeParameter viewMode = new ViewModeParameter(ViewMode.Image); private Material crackMat; private Material drawScreenMat; private bool allMatLoaded; public override CustomPostProcessInjectionPoint injectionPoint => (CustomPostProcessInjectionPoint)1; public bool IsActive() { if (allMatLoaded && ((VolumeParameter<bool>)(object)enabled).value && ((VolumeParameter<int>)(object)crackLevel).value > 0) { return (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null; } return false; } public override void Setup() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown crackMat = new Material(ShaderLoader.DrawVisorCrackShader); drawScreenMat = new Material(ShaderLoader.DrawScreenShader); allMatLoaded = (Object)(object)crackMat != (Object)null && (Object)(object)drawScreenMat != (Object)null; } public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination) { if (IsActive()) { bool flag = (Object)(object)camera.camera == (Object)(object)GameNetworkManager.Instance.localPlayerController.gameplayCamera; if ((Object)(object)camera.camera.targetTexture == (Object)null || !flag) { drawScreenMat.SetTexture(ShaderParams.MainTex, RTHandle.op_Implicit(source)); HDUtils.DrawFullScreen(cmd, drawScreenMat, destination, (MaterialPropertyBlock)null, 0); return; } crackMat.SetTexture(ShaderParams.MainTex, RTHandle.op_Implicit(source)); crackMat.SetTexture(ShaderParams.Level1Color, ShaderLoader.Level1Color); crackMat.SetTexture(ShaderParams.Level2Color, ShaderLoader.Level2Color); crackMat.SetTexture(ShaderParams.Level1Normal, ShaderLoader.Level1Normal); crackMat.SetTexture(ShaderParams.Level2Normal, ShaderLoader.Level2Normal); crackMat.SetFloat(ShaderParams.PixelSize, (float)((VolumeParameter<int>)(object)pixelated).value); crackMat.SetFloat(ShaderParams.Opacity, ((VolumeParameter<float>)(object)colorOpacity).value); crackMat.SetFloat(ShaderParams.Distortion, ((VolumeParameter<float>)(object)distortion).value); crackMat.SetInt(ShaderParams.Mode, (int)((VolumeParameter<ViewMode>)viewMode).value); crackMat.SetInt(ShaderParams.CrackLevel, ((VolumeParameter<int>)(object)crackLevel).value); HDUtils.DrawFullScreen(cmd, crackMat, destination, (MaterialPropertyBlock)null, 0); } } public override void Cleanup() { CoreUtils.Destroy((Object)(object)crackMat); CoreUtils.Destroy((Object)(object)drawScreenMat); } } public static class VisorPostProcessingHelper { private const float MaxSplatDistance = 3f; private const float Randomness = 0.1f; public static Camera PlayerCamera; private static RenderTexture visorRimMask; private static RenderTexture raindropMask; private static Vector2 lastSplatPosition; private static bool splatQueued; private static bool wipeQueued; public static void Blur(CommandBuffer cmd, RenderTexture target, Material blurMat) { //IL_0013: 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_003f: 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_0078: Unknown result type (might be due to invalid IL or missing references) RenderTexture val = RenderTexture.GetTemporary(((Texture)target).width, ((Texture)target).height, target.depth, target.format); RenderTexture val2 = RenderTexture.GetTemporary(((Texture)target).width, ((Texture)target).height, target.depth, target.format); cmd.Blit((Texture)(object)target, RenderTargetIdentifier.op_Implicit((Texture)(object)val)); for (int i = 0; i < 3; i++) { val2.DiscardContents(); ((Texture)val).filterMode = (FilterMode)1; cmd.Blit((Texture)(object)val, RenderTargetIdentifier.op_Implicit((Texture)(object)val2), blurMat, i); RenderTexture obj = val2; val2 = val; val = obj; } cmd.Blit((Texture)(object)val, RenderTargetIdentifier.op_Implicit((Texture)(object)target)); RenderTexture.ReleaseTemporary(val); RenderTexture.ReleaseTemporary(val2); } public static void RequestSplat(Vector3 bloodSource, float forcedRandomness = 0.1f) { //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_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) //IL_0030: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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) float num = Vector3.Distance(((Component)PlayerCamera).transform.position, bloodSource); Vector3 forward = ((Component)PlayerCamera).transform.forward; Vector3 val = bloodSource - ((Component)PlayerCamera).transform.position; float num2 = Vector3.Dot(forward, ((Vector3)(ref val)).normalized); bool flag = num <= 3f && num2 >= -0.2f; Plugin.Log.LogInfo((object)$"Blood splat requested - {flag} - Source : {bloodSource} - Distance : {num} - Dot : {num2}"); if (flag) { splatQueued = true; lastSplatPosition = Vector2.op_Implicit(PlayerCamera.WorldToViewportPoint(bloodSource)); lastSplatPosition += new Vector2((Random.value * 2f - 1f) * forcedRandomness, (Random.value * 2f - 1f) * forcedRandomness); } } public static (bool, Vector2) CheckSplat() { //IL_0005: 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_0040: 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) (bool, Vector2) result = (splatQueued, lastSplatPosition); if (result.Item1) { Plugin.Log.LogInfo((object)$"Blood splat checked true: {lastSplatPosition}"); } splatQueued = false; lastSplatPosition = Vector2.zero; return result; } public static void RequestWipe() { wipeQueued = true; } public static void CheckBloodWipe(RenderTexture decalCanvas) { if (wipeQueued) { ClearOutRenderTexture(decalCanvas); wipeQueued = false; } } public static void ClearOutRenderTexture(RenderTexture renderTexture) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) RenderTexture active = RenderTexture.active; RenderTexture.active = renderTexture; GL.Clear(true, true, Color.clear); RenderTexture.active = active; } public static void BlitRaindropMask(CommandBuffer cmd, RenderTexture texture) { //IL_002d: 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_0026: Expected O, but got Unknown if ((Object)(object)raindropMask == (Object)null) { raindropMask = new RenderTexture(((Texture)texture).width, ((Texture)texture).height, 0, (RenderTextureFormat)28); } cmd.Blit((Texture)(object)texture, RenderTargetIdentifier.op_Implicit((Texture)(object)raindropMask)); } public static RenderTexture GetRaindropMask() { return raindropMask; } public static RenderTexture GetVisorRimMask() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if ((Object)(object)visorRimMask == (Object)null) { visorRimMask = new RenderTexture(Screen.width / 2, Screen.height / 2, (GraphicsFormat)8, (GraphicsFormat)0); } return visorRimMask; } } [Serializable] [VolumeComponentMenu("Post-processing/Custom/VisorRaindrop")] public sealed class VisorRaindrop : CustomPostProcessVolumeComponent, IPostProcessComponent { [Header("General")] public BoolParameter enabled = new BoolParameter(false, false); public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f, false); public ViewModeParameter viewMode = new ViewModeParameter(ViewMode.Image); [Header("Spawn Settings")] public ClampedIntParameter staticDropRate = new ClampedIntParameter(128, 0, 128, false); public ClampedIntParameter dynamicDropRate = new ClampedIntParameter(1, 0, 8, false); public ClampedFloatParameter staticDropLifetime = new ClampedFloatParameter(1.5f, 0.1f, 2f, false); public ClampedFloatParameter travelTime = new ClampedFloatParameter(1.1f, 0.1f, 1.25f, false); public FloatParameter dryTime = new FloatParameter(1f, false); [Header("Render Settings")] public ClampedIntParameter renderScale = new ClampedIntParameter(50, 10, 100, false); public MinIntParameter pixelated = new MinIntParameter(0, 0, false); public BoolParameter specular = new BoolParameter(true, false); public BoolParameter shadow = new BoolParameter(true, false); public FloatParameter distortion = new FloatParameter(0.2f, false); public ClampedFloatParameter particleSize = new ClampedFloatParameter(0.018f, 0f, 0.1f, false); public ClampedFloatParameter smoothDistance = new ClampedFloatParameter(0.032f, 0f, 0.1f, false); [Header("Level Height")] public ClampedFloatParameter inBlack = new ClampedFloatParameter(100f, 0f, 255f, false); public ClampedFloatParameter inWhite = new ClampedFloatParameter(255f, 0f, 255f, false); public ClampedFloatParameter outWhite = new ClampedFloatParameter(220f, 0f, 255f, false); public ClampedFloatParameter outBlack = new ClampedFloatParameter(6f, 0f, 255f, false); private bool allMatLoaded; private Material drawRaindropsMat; private Material blurMat; private Material levelMat; private Material drawScreenMat; private Dictionary<Camera, RaindropSolver> solvers; public override CustomPostProcessInjectionPoint injectionPoint => (CustomPostProcessInjectionPoint)1; public bool IsActive() { if (allMatLoaded && (((VolumeParameter<bool>)(object)enabled).value || ForkWater.HasWater) && Application.isPlaying) { return (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null; } return false; } public override void Setup() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown drawRaindropsMat = new Material(ShaderLoader.DrawRaindropsShader); blurMat = new Material(ShaderLoader.GaussianBlurImageShader); levelMat = new Material(ShaderLoader.LevelImageShader); drawScreenMat = new Material(ShaderLoader.DrawScreenShader); allMatLoaded = (Object)(object)drawRaindropsMat != (Object)null && (Object)(object)blurMat != (Object)null && (Object)(object)levelMat != (Object)null && (Object)(object)drawScreenMat != (Object)null; } public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination) { //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_0213: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) if (!IsActive()) { return; } bool flag = (Object)(object)camera.camera == (Object)(object)GameNetworkManager.Instance.localPlayerController.gameplayCamera; if ((Object)(object)camera.camera.targetTexture == (Object)null || (VisorConfig.RaindropOnlyMainCam && !flag)) { drawScreenMat.SetTexture(ShaderParams.MainTex, RTHandle.op_Implicit(source)); HDUtils.DrawFullScreen(cmd, drawScreenMat, destination, (MaterialPropertyBlock)null, 0); return; } if (solvers == null) { solvers = new Dictionary<Camera, RaindropSolver>(); } if (!solvers.TryGetValue(camera.camera, out var value)) { RenderTexture targetTexture = camera.camera.targetTexture; int num = ((VolumeParameter<int>)(object)renderScale).value; if ((Object)(object)camera.camera != (Object)(object)GameNetworkManager.Instance.localPlayerController.gameplayCamera) { num = 25; } value = new RaindropSolver(((Texture)targetTexture).width, ((Texture)targetTexture).height, num); solvers.Add(camera.camera, value); Visor.Instance.AddCamera(camera.camera); Plugin.Log.LogInfo((object)$"New RaindropSolver instance created : {((Object)camera.camera).name} - {((Texture)targetTexture).width} / {((Texture)targetTexture).height}"); } float num2 = (((VolumeParameter<bool>)(object)enabled).value ? (Visor.Instance.VisorRainStates[camera.camera].Intensity * VisorConfig.RaindropIntensity) : 0f); Vector3 forward = Visor.Instance.VisorRainStates[camera.camera].Forward; int2 renderSize = default(int2); ((int2)(ref renderSize))..ctor(((Texture)camera.camera.targetTexture).width, ((Texture)camera.camera.targetTexture).height); if (flag) { value.UpdateProperties(num2, renderSize, ((VolumeParameter<int>)(object)renderScale).value, ((VolumeParameter<float>)(object)particleSize).value, ((VolumeParameter<float>)(object)smoothDistance).value, ((VolumeParameter<int>)(object)staticDropRate).value, ((VolumeParameter<int>)(object)dynamicDropRate).value, 1f, ((VolumeParameter<float>)(object)dryTime).value, float3.op_Implicit(forward), ((VolumeParameter<float>)(object)travelTime).value); } else { value.UpdateProperties(num2, renderSize, 16, 0.02f, 0.04f, 32, ((VolumeParameter<int>)(object)dynamicDropRate).value, ((VolumeParameter<float>)(object)staticDropLifetime).value, ((VolumeParameter<float>)(object)dryTime).value, float3.op_Implicit(forward), 1f); } value.CalcRainMap(); int scaledWidth = value.CurrentRenderInfo.ScaledWidth; int scaledHeight = value.CurrentRenderInfo.ScaledHeight; RenderTexture temporary = RenderTexture.GetTemporary(scaledWidth, scaledHeight, 0, (RenderTextureFormat)28); RenderTexture temporary2 = RenderTexture.GetTemporary(scaledWidth, scaledHeight, 0, (RenderTextureFormat)28, (RenderTextureReadWrite)1); cmd.Blit((Texture)(object)value.RainMap, RenderTargetIdentifier.op_Implicit((Texture)(object)temporary)); if (flag) { ForkWater.DrawHeights(cmd, temporary); } VisorPostProcessingHelper.Blur(cmd, temporary, blurMat); levelMat.SetFloat(ShaderParams.InBlack, ((VolumeParameter<float>)(object)inBlack).value); levelMat.SetFloat(ShaderParams.InWhite, ((VolumeParameter<float>)(object)inWhite).value); levelMat.SetFloat(ShaderParams.OutWhite, ((VolumeParameter<float>)(object)outWhite).value); levelMat.SetFloat(ShaderParams.OutBlack, ((VolumeParameter<float>)(object)outBlack).value); cmd.Blit((Texture)(object)temporary, RenderTargetIdentifier.op_Implicit((Texture)(object)temporary2), levelMat); if (VisorConfig.BloodShow) { VisorPostProcessingHelper.BlitRaindropMask(cmd, temporary2); } drawRaindropsMat.SetTexture(ShaderParams.MainTex, RTHandle.op_Implicit(source)); drawRaindropsMat.SetTexture(ShaderParams.RainTex, (Texture)(object)temporary2); drawRaindropsMat.SetTexture(ShaderParams.CullMask, (Texture)(object)VisorPostProcessingHelper.GetVisorRimMask()); drawRaindropsMat.SetVector(ShaderParams.RainTexTexelSize, new Vector4((float)((Texture)temporary2).width, (float)((Texture)temporary2).height, 0f, 0f)); drawRaindropsMat.SetFloat(ShaderParams.Distortion, ((VolumeParameter<float>)(object)distortion).value); drawRaindropsMat.SetFloat(ShaderParams.PixelSize, (float)((VolumeParameter<int>)(object)pixelated).value); drawRaindropsMat.SetInt(ShaderParams.Mode, (int)((VolumeParameter<ViewMode>)viewMode).value); drawRaindropsMat.SetInt(ShaderParams.Specular, ((VolumeParameter<bool>)(object)specular).value ? 1 : 0); drawRaindropsMat.SetInt(ShaderParams.Shadow, ((VolumeParameter<bool>)(object)shadow).value ? 1 : 0); HDUtils.DrawFullScreen(cmd, drawRaindropsMat, destination, (MaterialPropertyBlock)null, 0); RenderTexture.ReleaseTemporary(temporary); RenderTexture.ReleaseTemporary(temporary2); } public void Clear(Camera camera) { if (solvers != null && solvers.TryGetValue(camera, out var value)) { value.ClearRenderTextures(); } } public override void Cleanup() { if (solvers != null) { foreach (RaindropSolver value in solvers.Values) { value.Release(); } solvers.Clear(); } CoreUtils.Destroy((Object)(object)drawRaindropsMat); CoreUtils.Destroy((Object)(object)blurMat); CoreUtils.Destroy((Object)(object)levelMat); CoreUtils.Destroy((Object)(object)drawScreenMat); } } [Serializable] [VolumeComponentMenu("Post-processing/Custom/VisorRim")] public sealed class VisorRim : CustomPostProcessVolumeComponent, IPostProcessComponent { public BoolParameter visible = new BoolParameter(false, false); public ClampedFloatParameter offset = new ClampedFloatParameter(0f, -0.055f, 0f, false); public ClampedFloatParameter opacity = new ClampedFloatParameter(0.8f, 0f, 1f, false); private Material rimMat; private Material drawScreenMat; private bool allMatLoaded; public override CustomPostProcessInjectionPoint injectionPoint => (CustomPostProcessInjectionPoint)2; public bool IsActive() { if (allMatLoaded && ((VolumeParameter<bool>)(object)visible).value && ((VolumeParameter<float>)(object)opacity).value > 0f) { return (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null; } return false; } public override void Setup() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown rimMat = new Material(ShaderLoader.RimShader); drawScreenMat = new Material(ShaderLoader.DrawScreenShader); allMatLoaded = (Object)(object)rimMat != (Object)null && (Object)(object)drawScreenMat != (Object)null; } public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination) { if (IsActive()) { if ((Object)(object)camera.camera.targetTexture == (Object)null || (Object)(object)camera.camera != (Object)(object)GameNetworkManager.Instance.localPlayerController.gameplayCamera) { drawScreenMat.SetTexture(ShaderParams.MainTex, RTHandle.op_Implicit(source)); HDUtils.DrawFullScreen(cmd, drawScreenMat, destination, (MaterialPropertyBlock)null, 0); return; } rimMat.SetTexture(ShaderParams.MainTex, RTHandle.op_Implicit(source)); rimMat.SetFloat(ShaderParams.Opacity, ((VolumeParameter<float>)(object)opacity).value); rimMat.SetFloat(ShaderParams.AspectRatio, VisorConfig.RimStretch); rimMat.SetFloat(ShaderParams.Offset, ((VolumeParameter<float>)(object)offset).value); HDUtils.DrawFullScreen(cmd, rimMat, destination, (MaterialPropertyBlock)null, 0); } } public override void Cleanup() { CoreUtils.Destroy((Object)(object)rimMat); CoreUtils.Destroy((Object)(object)drawScreenMat); } } [Serializable] [VolumeComponentMenu("Post-processing/Custom/VisorWeather")] public sealed class VisorWeather : CustomPostProcessVolumeComponent, IPostProcessComponent { public BoolParameter enabled = new BoolParameter(false, false); private Material blurMat; private Material flakeMat; private Material weatherMat; private ComputeBuffer flakeBuffer; private RenderTexture map0; private RenderTexture map1; private RenderTexture half; private RenderTexture halfTmp; private RenderTexture quarter; private RenderTexture quarterTmp; private RenderTexture glowQ; private RenderTexture eighth; private RenderTexture eighthTmp; private RenderTexture glow; private int rtW; private int rtH; private readonly MaterialPropertyBlock[] blocks = (MaterialPropertyBlock[])(object)new MaterialPropertyBlock[24]; private int blockIndex; private static readonly int MainTexId = Shader.PropertyToID("_MainTex"); private static readonly int SrcTexId = Shader.PropertyToID("_SrcTex"); private static readonly int DirId = Shader.PropertyToID("_Dir"); private static readonly int ThresholdId = Shader.PropertyToID("_Threshold"); public override CustomPostProcessInjectionPoint injectionPoint => (CustomPostProcessInjectionPoint)1; public bool IsActive() { if ((Object)(object)weatherMat != (Object)null && ((VolumeParameter<bool>)(object)enabled).value && (Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null && (Object)(object)VisorWeatherState.Instance != (Object)null) { return VisorWeatherState.Instance.HasEffect; } return false; } public override void Setup() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown if (ForkAssets.Loaded) { blurMat = new Material(ForkAssets.BlurShader); flakeMat = new Material(ForkAssets.FlakesShader); weatherMat = new Material(ForkAssets.WeatherShader); flakeBuffer = new ComputeBuffer(256, 64, (ComputeBufferType)16); for (int i = 0; i < blocks.Length; i++) { blocks[i] = new MaterialPropertyBlock(); } } } private MaterialPropertyBlock Block() { MaterialPropertyBlock obj = blocks[blockIndex++ % blocks.Length]; obj.Clear(); return obj; } private static RenderTexture MakeRT(int w, int h, RenderTextureFormat fmt, string name) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown RenderTexture val = new RenderTexture(Mathf.Max(1, w), Mathf.Max(1, h), 0, fmt, (RenderTextureReadWrite)1) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, name = "ImmersiveVisorFork_" + name }; val.Create(); return val; } private void FreeRTs() { RenderTexture[] array = (RenderTexture[])(object)new RenderTexture[10] { map0, map1, half, halfTmp, quarter, quarterTmp, glowQ, eighth, eighthTmp, glow }; foreach (RenderTexture val in array) { if ((Object)(object)val != (Object)null) { val.Release(); CoreUtils.Destroy((Object)(object)val); } } map0 = (map1 = (half = (halfTmp = (quarter = (quarterTmp = (glowQ = (eighth = (eighthTmp = (glow = null))))))))); } private void EnsureRTs(int w, int h) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)map0 != (Object)null) || rtW != w || rtH != h) { FreeRTs(); rtW = w; rtH = h; RenderTextureFormat fmt = (RenderTextureFormat)(SystemInfo.SupportsRenderTextureFormat((RenderTextureFormat)13) ? 13 : 2); map0 = MakeRT(w, h, (RenderTextureFormat)2, "Map0"); map1 = MakeRT(w, h, fmt, "Map1"); half = MakeRT(w / 2, h / 2, (RenderTextureFormat)2, "Half"); halfTmp = MakeRT(w / 2, h / 2, (RenderTextureFormat)2, "HalfTmp"); quarter = MakeRT(w / 4, h / 4, (RenderTextureFormat)2, "Quarter"); quarterTmp = MakeRT(w / 4, h / 4, (RenderTextureFormat)2, "QuarterTmp"); glowQ = MakeRT(w / 4, h / 4, (RenderTextureFormat)2, "GlowQ"); eighth = MakeRT(w / 8, h / 8, (RenderTextureFormat)2, "Eighth"); eighthTmp = MakeRT(w / 8, h / 8, (RenderTextureFormat)2, "EighthTmp"); glow = MakeRT(w / 8, h / 8, (RenderTextureFormat)2, "Glow"); } } private void Pass(CommandBuffer cmd, RenderTexture src, RenderTexture dst, int pass) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) MaterialPropertyBlock val = Block(); val.SetTexture(SrcTexId, (Texture)(object)src); CoreUtils.DrawFullScreen(cmd, blurMat, RenderTargetIdentifier.op_Implicit((Texture)(object)dst), val, pass); } private void Blur(CommandBuffer cmd, RenderTexture rt, RenderTexture tmp, float spread) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) MaterialPropertyBlock val = Block(); val.SetTexture(SrcTexId, (Texture)(object)rt); val.SetVector(DirId, new Vector4(spread / (float)((Texture)rt).width, 0f, 0f, 0f)); CoreUtils.DrawFullScreen(cmd, blurMat, RenderTargetIdentifier.op_Implicit((Texture)(object)tmp), val, 2); val = Block(); val.SetTexture(SrcTexId, (Texture)(object)tmp); val.SetVector(DirId, new Vector4(0f, spread / (float)((Texture)rt).height, 0f, 0f)); CoreUtils.DrawFullScreen(cmd, blurMat, RenderTargetIdentifier.op_Implicit((Texture)(object)rt), val, 3); } public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: 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_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)weatherMat == (Object)null) { return; } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; VisorWeatherState instance = VisorWeatherState.Instance; MaterialPropertyBlock val = Block(); val.SetTexture(MainTexId, RTHandle.op_Implicit(source)); if ((Object)(object)localPlayerController == (Object)null || (Object)(object)instance == (Object)null || (Object)(object)camera.camera != (Object)(object)localPlayerController.gameplayCamera) { HDUtils.DrawFullScreen(cmd, weatherMat, destination, val, 1); return; } int actualWidth = camera.actualWidth; int actualHeight = camera.actualHeight; EnsureRTs(actualWidth, actualHeight); float num = Mathf.Max(1f, (float)actualWidth / 960f); MaterialPropertyBlock val2 = Block(); val2.SetTexture(MainTexId, RTHandle.op_Implicit(source)); CoreUtils.DrawFullScreen(cmd, blurMat, RenderTargetIdentifier.op_Implicit((Texture)(object)half), val2, 0); Blur(cmd, half, halfTmp, 1.24f * num); Pass(cmd, half, quarter, 1); Blur(cmd, quarter, quarterTmp, 1.47f * num); Pass(cmd, quarter, eighth, 1); Blur(cmd, eighth, eighthTmp, 2.5f * num); Blur(cmd, eighth, eighthTmp, 2.5f * num); bool flag = instance.Fog > 0.001f || instance.Breath > 0.001f; if (flag) { MaterialPropertyBlock val3 = Block(); val3.SetTexture(SrcTexId, (Texture)(object)quarter); val3.SetFloat(ThresholdId, 0.45f); CoreUtils.DrawFullScreen(cmd, blurMat, RenderTargetIdentifier.op_Implicit((Texture)(object)glowQ), val3, 4); Pass(cmd, glowQ, glow, 1); Blur(cmd, glow, eighthTmp, 1.9f * num); } int gpuCount = instance.GpuCount; if (gpuCount > 0) { flakeBuffer.SetData((Array)instance.Gpu, 0, 0, gpuCount); MaterialPropertyBlock val4 = Block(); val4.SetBuffer("_Flakes", flakeBuffer); val4.SetVector("_ScreenPx", new Vector4((float)actualWidth, (float)actualHeight, 0f, 0f)); val4.SetFloat("_Lens", 0.55f); val4.SetFloat("_SnowSoft", 0.25f); val4.SetTexture("_NoiseHi", (Texture)(object)ForkNoise.Hi); val4.SetFloat("_FlipY", 0f); val4.SetFloat("_OwnWater", 0f); val4.SetFloat("_HeightGain", 1f); cmd.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)map0)); cmd.ClearRenderTarget(false, true, Color.clear); cmd.DrawProcedural(Matrix4x4.identity, flakeMat, 0, (MeshTopology)0, 6, gpuCount, val4); } val.SetTexture("_Map0", (Texture)(object)map0); val.SetTexture("_Map1", (Texture)(object)map1); val.SetTexture("_BlurSmall", (Texture)(object)half); val.SetTexture("_BlurLarge", (Texture)(object)quarter); val.SetTexture("_AmbTex", (Texture)(object)eighth); val.SetTexture("_GlowTex", (Texture)(flag ? ((object)glow) : ((object)Texture2D.blackTexture))); val.SetTexture("_NoiseHi", (Texture)(object)ForkNoise.Hi); val.SetTexture("_NoiseMid", (Texture)(object)ForkNoise.Mid); val.SetTexture("_NoiseLo", (Texture)(object)ForkNoise.Lo); val.SetVector("_ScreenPx", new Vector4((float)actualWidth, (float)actualHeight, 0f, 0f)); val.SetFloat("_Rim", 0.2f); val.SetFloat("_Spec", 0.85f); val.SetFloat("_SnowGain", 1.15f); val.SetFloat("_SnowFloor", 0.3f); val.SetFloat("_SnowOp", Mathf.Clamp01(VisorConfig.SnowOpacity)); val.SetFloat("_SnowUnder", 0.5f); val.SetFloat("_FogOp", 0.92f); val.SetFloat("_HasFlakes", (gpuCount > 0) ? 1f : 0f); val.SetFloat("_Frost", instance.Frost); val.SetFloat("_Fog", FogMask(instance.Fog)); val.SetFloat("_Breath", instance.Breath); val.SetFloat("_FogTime", instance.FogTime); HDUtils.DrawFullScreen(cmd, weatherMat, destination, val, 0); } private static float FogMask(float f) { if (f < 0.005f) { return 0f; } f = Mathf.Clamp01(f); return Mathf.Clamp01(((1.1607f * f - 1.5713f) * f + 1.016f) * f + 0.3278f); } public override void Cleanup() { FreeRTs(); if (flakeBuffer != null) { flakeBuffer.Release(); flakeBuffer = null; } CoreUtils.Destroy((Object)(object)blurMat); CoreUtils.Destroy((Object)(object)flakeMat); CoreUtils.Destroy((Object)(object)weatherMat); } } } namespace Woecust.ImmersiveVisor.Patches { [HarmonyPatch(typeof(EnemyAI))] internal class EnemyAIPatch { [HarmonyPatch("HitEnemy")] [HarmonyPostfix] private static void HitEnemyPatch(EnemyAI __instance) { //IL_0029: