Please disclose if your mod was created primarily 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 Immersive Visor v0.5.2
ImmersiveVisor.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ImmersiveVisor")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Immersive Visor for Lethal Company")] [assembly: AssemblyFileVersion("0.5.2.0")] [assembly: AssemblyInformationalVersion("0.5.2")] [assembly: AssemblyProduct("ImmersiveVisor")] [assembly: AssemblyTitle("ImmersiveVisor")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.5.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 { [BepInPlugin("ImmersiveVisor", "ImmersiveVisor", "0.5.2")] public class Plugin : BaseUnityPlugin { public const string Version = "0.5.2"; private const string Guid = "ImmersiveVisor"; private const string Name = "ImmersiveVisor"; public static Plugin Instance; internal static ManualLogSource Log; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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); Harmony.CreateAndPatchAll(typeof(PlayerControllerBPatch), (string)null); Harmony.CreateAndPatchAll(typeof(StartOfRoundPatch), (string)null); Harmony.CreateAndPatchAll(typeof(TimeOfDayPatch), (string)null); Harmony.CreateAndPatchAll(typeof(EnemyAI), (string)null); Log.LogInfo((object)"Mod Loaded"); } public static bool IsModdedWith(string guid) { return Chainloader.PluginInfos.ContainsKey(guid); } } 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 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Expected O, but got Unknown 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 val = ((Component)physicalVisor).gameObject.AddComponent<CustomPassVolume>(); val.isGlobal = false; val.priority = 64f; val.targetCamera = player.gameplayCamera; val.injectionPoint = (CustomPassInjectionPoint)0; CustomPass obj = val.AddPassOfType<DrawRenderersCustomPass>(); DrawRenderersCustomPass val2 = (DrawRenderersCustomPass)(object)((obj is DrawRenderersCustomPass) ? obj : null); BackupFrameBufferPass backupFrameBufferPass = val.AddPassOfType<BackupFrameBufferPass>() as BackupFrameBufferPass; ((CustomPass)val2).name = "GetVisorRim"; ((CustomPass)val2).targetColorBuffer = (TargetBuffer)1; ((CustomPass)val2).targetDepthBuffer = (TargetBuffer)2; ((CustomPass)val2).clearFlags = (ClearFlag)0; ((CustomPass)val2).clearFlags = (ClearFlag)(((CustomPass)val2).clearFlags | 1); val2.renderQueueType = (RenderQueueType)2; val2.layerMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "HelmetVisor" })); val2.overrideMode = (OverrideMaterialMode)1; val2.overrideMaterial = physicalVisorMat; val2.overrideMaterialPassName = "MotionVectors"; val2.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 val3 = new GameObject("ImmersiveVisorPostProcessing"); val3.transform.parent = GameObject.Find("Systems/Rendering").transform; Volume val4 = val3.AddComponent<Volume>(); val4.priority = 421f; VolumeProfile val5 = ScriptableObject.CreateInstance<VolumeProfile>(); ((Object)val5).name = "VisorPostProcessProfile"; raindrop = val5.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 = val5.Add<VisorRim>(true); ((Object)visorRim).name = "VisorRim"; ((VolumeParameter<bool>)(object)visorRim.visible).value = VisorConfig.RimShow && !VisorConfig.RimPhysical; visorCrack = val5.Add<VisorCrack>(true); ((Object)visorCrack).name = "VisorCrack"; ((VolumeParameter<bool>)(object)visorCrack.enabled).value = VisorConfig.CrackShow; ((VolumeParameter<int>)(object)visorCrack.pixelated).value = VisorConfig.PixelatedCrack; visorBlood = val5.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; val4.sharedProfile = val5; 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"); } 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; if (1 == 0) { } int value2 = ((health <= 35) ? 2 : ((health <= 75) ? 1 : ((VolumeParameter<int>)(object)visorCrack.crackLevel).value)); if (1 == 0) { } ((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; if (player.isPlayerDead) { ((VolumeParameter<int>)(object)visorCrack.crackLevel).value = 0; } 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected I4, but got Unknown if (!VisorConfig.RaindropShow) { ((VolumeParameter<bool>)(object)raindrop.enabled).value = false; return; } int num = (int)TimeOfDay.Instance.currentLevelWeather; bool flag = (((uint)(num - 1) <= 1u || num == 4) ? true : false); bool flag2 = flag || ((Component)rainAmbienceOcclude).gameObject.activeInHierarchy; RemoveNullKeys(); if (isRaining != flag2) { if (!flag2) { foreach (KeyValuePair<Camera, VisorRainState> visorRainState in VisorRainStates) { visorRainState.Value.ForceStop(); raindrop.Clear(visorRainState.Key); } } isRaining = flag2; } if (isRaining) { bool flag3 = true; foreach (VisorRainState value in VisorRainStates.Values) { value.Update(); if (value.IsRainVisible) { flag3 = false; } } ((VolumeParameter<bool>)(object)raindrop.enabled).value = !flag3; } foreach (Camera renderClear in renderClearList) { raindrop.Clear(renderClear); } renderClearList.Clear(); } private void RimUpdate() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) 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 @float = physicalVisorMat.GetFloat(VisorFOV); @float = Mathf.Lerp(@float, player.inTerminalMenu ? 55f : 60f, 1f - Mathf.Pow(1f - visorTerminalLerp, 2f)); physicalVisorMat.SetFloat(VisorFOV, @float); } visorTerminalLerp = Mathf.Min(1f, visorTerminalLerp + Time.deltaTime); } else if (player.isInHangarShipRoom) { float num = (player.inTerminalMenu ? visorRim.offset.min : visorRim.offset.max); ((VolumeParameter<float>)(object)visorRim.offset).value = Mathf.MoveTowards(((VolumeParameter<float>)(object)visorRim.offset).value, num, 0.3f * Time.deltaTime); } } private void RemoveNullKeys() { Dictionary<Camera, VisorRainState> visorRainStates = VisorRainStates.Where((KeyValuePair<Camera, VisorRainState> pair) => pair.Key != 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_000c: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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); } } public static class PluginInfo { public const string PLUGIN_GUID = "ImmersiveVisor"; public const string PLUGIN_NAME = "ImmersiveVisor"; public const string PLUGIN_VERSION = "0.5.2"; } } 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_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) 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"); PropertyInfo property = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy); object value = property.GetValue(null); FieldInfo field = type.GetField("afterPostProcessCustomPostProcesses", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); List<string> list = (List<string>)field.GetValue(value); list.Add(typeof(VisorRim).AssemblyQualifiedName); field = type.GetField("beforePostProcessCustomPostProcesses", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); list = (List<string>)field.GetValue(value); list.Add(typeof(VisorRaindrop).AssemblyQualifiedName); list.Add(typeof(VisorCrack).AssemblyQualifiedName); list.Add(typeof(VisorBloodSplatter).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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //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) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_003d: 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, (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_0003: 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_0012: 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_0003: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) 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_0017: 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_001f: 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 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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) 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_0006: 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_0045: 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) (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_0010: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (raindropMask == 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (visorRimMask == null) { visorRimMask = new RenderTexture(Screen.width / 2, Screen.height / 2, (GraphicsFormat)8, (GraphicsFormat)0); } return visorRimMask; } } [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() { return allMatLoaded && ((VolumeParameter<bool>)(object)enabled).value && Application.isPlaying && GameNetworkManager.Instance.localPlayerController != null; } public override void Setup() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_0221: 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_0284: 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 (camera.camera.targetTexture == 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 (decalCanvas == 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() { return allMatLoaded && ((VolumeParameter<bool>)(object)enabled).value && ((VolumeParameter<int>)(object)crackLevel).value > 0 && GameNetworkManager.Instance.localPlayerController != null; } public override void Setup() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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 (camera.camera.targetTexture == 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); } } [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() { return allMatLoaded && ((VolumeParameter<bool>)(object)enabled).value && Application.isPlaying && GameNetworkManager.Instance.localPlayerController != null; } public override void Setup() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: 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 (camera.camera.targetTexture == 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 = Visor.Instance.VisorRainStates[camera.camera].Intensity * VisorConfig.RaindropIntensity; 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)); 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); } } 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/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() { return allMatLoaded && ((VolumeParameter<bool>)(object)visible).value && ((VolumeParameter<float>)(object)opacity).value > 0f && GameNetworkManager.Instance.localPlayerController != null; } public override void Setup() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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 (camera.camera.targetTexture == 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); } } } namespace Woecust.ImmersiveVisor.Patches { [HarmonyPatch(typeof(EnemyAI))] internal class EnemyAIPatch { [HarmonyPatch("HitEnemy")] [HarmonyPostfix] private static void HitEnemyPatch(EnemyAI __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (VisorConfig.BloodShow) { Plugin.Log.LogInfo((object)"Splat from enemy"); VisorPostProcessingHelper.RequestSplat(__instance.eye.position); } } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { private static float prevHealth; [HarmonyPatch("ConnectClientToPlayerObject")] [HarmonyPostfix] private static void InitializeVisor(ref PlayerControllerB __instance) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown if (!((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)__instance)) { if ((Object)(object)__instance.localVisor != (Object)null) { ((Component)__instance.localVisor.GetChild(0)).GetComponent<MeshFilter>().mesh = null; ((Renderer)((Component)__instance.localVisor.GetChild(0)).GetComponent<MeshRenderer>()).material = null; ((Renderer)((Component)__instance.localVisor.Find("ScavengerHelmet/Plane")).GetComponent<MeshRenderer>()).materials[0] = null; } if ((Object)(object)Visor.Instance == (Object)null) { GameObject val = new GameObject("ImmersiveVisor", new Type[1] { typeof(Visor) }); val.transform.SetParent(GameObject.Find("Systems/Rendering").transform); } } } [HarmonyPatch("DamagePlayer")] [HarmonyPrefix] private static void CheckHealth(ref PlayerControllerB __instance) { if (!((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)__instance)) { prevHealth = __instance.health; } } [HarmonyPatch("DamagePlayer")] [HarmonyPostfix] private static void DamageVisor(ref PlayerControllerB __instance, ref CauseOfDeath causeOfDeath) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_0009: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) CauseOfDeath val = causeOfDeath; if (val - 9 <= 2) { return; } if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)__instance) { if (VisorConfig.BloodShow) { VisorPostProcessingHelper.RequestSplat(__instance.cameraContainerTransform.position); } return; } if (__instance.isPlayerDead && prevHealth > 0f) { VisorPostProcessingHelper.RequestWipe(); } else if (VisorConfig.BloodShow && VisorConfig.BloodSelf && (float)__instance.health < prevHealth) { VisorPostProcessingHelper.RequestSplat(((Component)__instance.gameplayCamera).transform.position + ((Component)__instance.gameplayCamera).transform.forward * 1f, 0.5f); } Visor.Instance.Damage(causeOfDeath); } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("ReviveDeadPlayers")] [HarmonyPrefix] private static void ReviveDeadPlayersPatch() { if (VisorConfig.CrackRepairDeath && GameNetworkManager.Instance.localPlayerController.isPlayerDead) { Visor.Instance.Repair(); } } } [HarmonyPatch(typeof(TimeOfDay))] internal class TimeOfDayPatch { [HarmonyPatch("OnDayChanged")] [HarmonyPostfix] private static void OnDayChangedPatch() { if (VisorConfig.CrackRepairNewDay) { Visor.Instance.Repair(); } } [HarmonyPatch("SyncNewProfitQuotaClientRpc")] [HarmonyPostfix] private static void SyncNewProfitQuotaClientRpcPatch() { if (VisorConfig.CrackRepairNewQuota) { Visor.Instance.Repair(); } } } } namespace Woecust.ImmersiveVisor.Config { public static class ConfigLoader { public static void Load() { Version version = Version.Parse("0.5.2"); Version version2 = new Version(0, 0, 0); bool flag = File.Exists(((BaseUnityPlugin)Plugin.Instance).Config.ConfigFilePath ?? ""); if (flag) { ConfigEntry<string> val = default(ConfigEntry<string>); if (((BaseUnityPlugin)Plugin.Instance).Config.TryGetEntry<string>("DontTouchThis", "ConfigVersion", ref val)) { version2 = Version.Parse(val.Value); } else { ((BaseUnityPlugin)Plugin.Instance).Config.Bind<string>("DontTouchThis", "ConfigVersion", version2.ToString(), "It can recover itself, but just don't. It's just going to wipe your ImmersiveVisor configs"); } if (version < version2) { ((BaseUnityPlugin)Plugin.Instance).Config.Clear(); Plugin.Log.LogInfo((object)"Downgrade detected, deleting previous config data. But if you touched config version, it's probably a false alarm."); } } ConfigEntry<bool> val2 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("0. General", "RimShow", true, "Make the visor rim visible. This is a post process effect separated from mesh."); ConfigEntry<bool> val3 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("0. General", "CrackShow", true, "Make the visor reactive to total damage taken."); ConfigEntry<bool> val4 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("0. General", "RaindropShow", true, "Raindrops hitting the visor on rainy/stormy/flooded weather."); ConfigEntry<bool> val5 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("0. General", "BloodShow", true, "Blood splatters on screen when someone get damaged near you."); VisorConfig.RimShow = val2.Value; VisorConfig.CrackShow = val3.Value; VisorConfig.RaindropShow = val4.Value; VisorConfig.BloodShow = val5.Value; ConfigEntry<bool> val6 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("1. Visor Rim", "RimPhysical", true, "Use mesh version of visor rim instead of post processing."); ConfigEntry<float> val7 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("1. Visor Rim", "RimStretch", 1.77f, "Stretch the rim to match the size of the screen. Put the aspect ratio of your screen for stretching. 1.77 for no stretch.\n1.33 = 4:3 \n1.77 = 16:9 \n2.33 = 21:9 \n3.55 = 32:9"); VisorConfig.RimPhysical = val6.Value; VisorConfig.RimStretch = val7.Value; ConfigEntry<bool> val8 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("2. Visor Crack", "CrackRepairDeath", true, "Visor gets repaired after dying. Option's here but I recommend not setting this to False."); ConfigEntry<bool> val9 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("2. Visor Crack", "CrackRepairNewDay", true, "Visor gets repaired on a new day. Meaning, when the ship takes off."); ConfigEntry<bool> val10 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("2. Visor Crack", "CrackRepairNewQuota", true, "Visor gets repaired after a quota gets fulfilled."); ConfigEntry<float> val11 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("2. Visor Crack", "CrackVolume", 3f, "Volume for visor break SFX. Default is 3."); VisorConfig.CrackRepairDeath = val8.Value; VisorConfig.CrackRepairNewDay = val9.Value; VisorConfig.CrackRepairNewQuota = val10.Value; VisorConfig.CrackVolume = val11.Value; ConfigEntry<bool> val12 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("3. Screen Raindrop", "RaindropSpecular", true, "Adds specular to raindrops. Turn off for performance."); ConfigEntry<bool> val13 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("3. Screen Raindrop", "RaindropShadow", true, "Adds shadows to raindrops. Turn off for performance."); ConfigEntry<float> val14 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("3. Screen Raindrop", "RaindropDryTime", 4f, "Time in seconds it takes for raindrops to slowly disappear after rain has been occluded."); ConfigEntry<bool> val15 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("3. Screen Raindrop", "RaindropOnlyMainCam", true, "Cameras that are not rendering the screen doesn't display raindrop"); ConfigEntry<float> val16 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("3. Screen Raindrop", "RaindropIntensity", 1f, "Max intensity for raindrop. from 0.2 to 0.0"); VisorConfig.RaindropSpecular = val12.Value; VisorConfig.RaindropShadow = val13.Value; VisorConfig.RaindropDryTime = val14.Value; VisorConfig.RaindropOnlyMainCam = val15.Value; VisorConfig.RaindropIntensity = Mathf.Clamp(val16.Value, 0.2f, 1f); ConfigEntry<bool> val17 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("4. Blood Splatter", "BloodSelf", true, "Taking damage yourself shows splatter."); ConfigEntry<float> val18 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("4. Blood Splatter", "BloodLifeTime", 2f, "Time it takes until splatters starts to disappear."); ConfigEntry<float> val19 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("4. Blood Splatter", "BloodDryTime", 4.2f, "Time it takes for splatters to disappear."); VisorConfig.BloodSelf = val17.Value; VisorConfig.BloodLifeTime = val18.Value; VisorConfig.BloodDryTime = val19.Value; ConfigEntry<bool> val20 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("5. Pixelation", "PixelateAuto", false, "Pixelates all of them to match the pixel size of the game resolution. If you're playing on HD resolution, it's not going to affect much."); ConfigEntry<int> val21 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<int>("5. Pixelation", "PixelatedRain", 0, "Pixelate the rain effect. 0 for no effect. 512 is recommended for vanilla feel."); ConfigEntry<int> val22 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<int>("5. Pixelation", "PixelatedCrack", 0, "Pixelate the rain effect. 0 for no effect. 512 is recommended for vanilla feel."); ConfigEntry<int> val23 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<int>("5. Pixelation", "PixelatedBlood", 0, "Pixelate the rain effect. 0 for no effect. 512 is recommended for vanilla feel."); VisorConfig.PixelateAuto = val20.Value; VisorConfig.PixelatedRain = val21.Value; VisorConfig.PixelatedCrack = val22.Value; VisorConfig.PixelatedBlood = val23.Value; if (flag && version > version2) { ConfigUpdater configUpdater = new ConfigUpdater(); if (!configUpdater.TryUpdate()) { configUpdater.RemoveOrphans(); ((BaseUnityPlugin)Plugin.Instance).Config.Save(); } } ((BaseUnityPlugin)Plugin.Instance).Config.SettingChanged += SettingChanged; } private static void SettingChanged(object sender, SettingChangedEventArgs e) { ConfigDefinition definition = e.ChangedSetting.Definition; FieldInfo field = typeof(VisorConfig).GetField(definition.Key, BindingFlags.Static | BindingFlags.Public); if (field == null) { Plugin.Log.LogError((object)("Changing setting failed! : " + definition.Key)); return; } object obj = Convert.ChangeType(e.ChangedSetting.BoxedValue, field.FieldType); field?.SetValue(null, obj); Plugin.Log.LogInfo((object)$"Config value changed : {definition.Key} - {obj}"); } } public class ConfigUpdater { private static readonly Version latestCfgVersion = new Version(0, 5, 0); private Dictionary<ConfigDefinition, string> orphanEntries; private ConfigEntry<string> cfgEntry; private Version cfgVersion; private Version modVersion; public bool TryUpdate() { if (!((BaseUnityPlugin)Plugin.Instance).Config.TryGetEntry<string>("DontTouchThis", "ConfigVersion", ref cfgEntry)) { Plugin.Log.LogError((object)"Something went wrong. Called update without previous config version existing."); return false; } cfgVersion = Version.Parse(cfgEntry.Value); modVersion = Version.Parse("0.5.2"); if (cfgVersion > latestCfgVersion) { Plugin.Log.LogError((object)"Plugin Config version is higher than latest config version! Writing appropriate version number..."); ((BaseUnityPlugin)Plugin.Instance).Config.Bind<Version>("DontTouchThis", "Config Version", latestCfgVersion, (ConfigDescription)null); return false; } if (cfgVersion == latestCfgVersion) { Plugin.Log.LogInfo((object)"Plugin config version is up to data."); return false; } ((BaseUnityPlugin)Plugin.Instance).Config.Save(); if (NeedUpdateTo(0, 4, 5)) { Update_0_4_5(); } if (NeedUpdateTo(0, 5, 0)) { Update_0_5_0(); } RemoveOrphans(); ((BaseUnityPlugin)Plugin.Instance).Config.Save(); return true; } private bool NeedUpdateTo(int major, int minor, int build) { Version version = new Version(major, minor, build); return modVersion <= version && cfgVersion < version; } private void Update_0_4_5() { TryGetOrphans(out orphanEntries); Plugin.Log.LogInfo((object)"Config Update starting..."); ReplaceEntryValue<bool>("VisorCrack", "0. General", "EnableCrack", "CrackShow"); ReplaceEntryValue<bool>("Raindrop", "0. General", "EnableRaindrop", "RaindropShow"); ReplaceEntryValue<bool>("VisorRim", "0. General", "EnableVisorRim", "RimShow"); ReplaceEntryValue<bool>("BloodSplatter", "0. General", "EnableBloodSplatter", "BloodShow"); ReplaceEntryValue<bool>("VisorCrack", "1. Visor Crack", "RepairOnDeath", "CrackRepairDeath"); ReplaceEntryValue<bool>("VisorCrack", "1. Visor Crack", "RepairOnNewDay", "CrackRepairNewDay"); ReplaceEntryValue<bool>("VisorCrack", "1. Visor Crack", "RepairOnQuotaFulfilled", "CrackRepairNewQuota"); ReplaceEntryValue<float>("VisorCrack", "1. Visor Crack", "VisorBreakSFXVolume", "CrackVolume"); ReplaceEntryValue<bool>("Raindrop", "2. Screen Raindrop", "RaindropSpecular", "RaindropSpecular"); ReplaceEntryValue<bool>("Raindrop", "2. Screen Raindrop", "RaindropShadow", "RaindropShadow"); ReplaceEntryValue<bool>("Raindrop", "2. Screen Raindrop", "OnlyMainCamera", "RaindropOnlyMainCam"); ReplaceEntryValue<float>("Raindrop", "2. Screen Raindrop", "RaindropDryTime", "RaindropDryTime"); ReplaceEntryValue<float>("BloodSplatter", "3. Blood Splatter", "LifeTime", "BloodLifeTime"); ReplaceEntryValue<float>("BloodSplatter", "3. Blood Splatter", "DryTime", "BloodDryTime"); ReplaceEntryValue<bool>("BloodSplatter", "3. Blood Splatter", "ShowSplatterFromSelf", "BloodSelf"); cfgEntry.Value = new Version(0, 4, 5).ToString(); Plugin.Log.LogInfo((object)"Config Updated to 0.4.5 version"); } private void Update_0_5_0() { TryGetOrphans(out orphanEntries); ReplaceEntryValue<bool>("1. Visor Crack", "2. Visor Crack", "CrackRepairDeath", "CrackRepairDeath"); ReplaceEntryValue<bool>("1. Visor Crack", "2. Visor Crack", "CrackRepairNewDay", "CrackRepairNewDay"); ReplaceEntryValue<bool>("1. Visor Crack", "2. Visor Crack", "CrackRepairNewQuota", "CrackRepairNewQuota"); ReplaceEntryValue<float>("1. Visor Crack", "2. Visor Crack", "CrackVolume", "CrackVolume"); ReplaceEntryValue<bool>("2. Screen Raindrop", "3. Screen Raindrop", "RaindropSpecular", "RaindropSpecular"); ReplaceEntryValue<bool>("2. Screen Raindrop", "3. Screen Raindrop", "RaindropShadow", "RaindropShadow"); ReplaceEntryValue<bool>("2. Screen Raindrop", "3. Screen Raindrop", "RaindropOnlyMainCam", "RaindropOnlyMainCam"); ReplaceEntryValue<float>("2. Screen Raindrop", "3. Screen Raindrop", "RaindropDryTime", "RaindropDryTime"); ReplaceEntryValue<float>("2. Screen Raindrop", "3. Screen Raindrop", "RaindropIntensity", "RaindropIntensity"); ReplaceEntryValue<float>("3. Blood Splatter", "4. Blood Splatter", "BloodLifeTime", "BloodLifeTime"); ReplaceEntryValue<float>("3. Blood Splatter", "4. Blood Splatter", "BloodDryTime", "BloodDryTime"); ReplaceEntryValue<bool>("3. Blood Splatter", "4. Blood Splatter", "BloodSelf", "BloodSelf"); ReplaceEntryValue<bool>("4. Pixelation", "5. Pixelation", "PixelateAuto", "PixelateAuto"); ReplaceEntryValue<int>("4. Pixelation", "5. Pixelation", "PixelatedRain", "PixelatedRain"); ReplaceEntryValue<int>("4. Pixelation", "5. Pixelation", "PixelatedCrack", "PixelatedCrack"); ReplaceEntryValue<int>("4. Pixelation", "5. Pixelation", "PixelatedBlood", "PixelatedBlood"); cfgEntry.Value = new Version(0, 5, 0).ToString(); Plugin.Log.LogInfo((object)"Config Updated to 0.5.0 version"); } private bool TryGetOrphans(out Dictionary<ConfigDefinition, string> orphans) { orphans = null; Dictionary<ConfigDefinition, string> value = Traverse.Create((object)((BaseUnityPlugin)Plugin.Instance).Config).Property("OrphanedEntries", (object[])null).GetValue<Dictionary<ConfigDefinition, string>>(); if (value == null) { return false; } orphans = value.ToDictionary((KeyValuePair<ConfigDefinition, string> pair) => pair.Key, (KeyValuePair<ConfigDefinition, string> pair) => pair.Value); return true; } public void RemoveOrphans() { if (!TryGetOrphans(out orphanEntries)) { Plugin.Log.LogInfo((object)"No orphaned entries left."); return; } foreach (KeyValuePair<ConfigDefinition, string> orphanEntry in orphanEntries) { ((BaseUnityPlugin)Plugin.Instance).Config.Bind<string>(orphanEntry.Key, orphanEntry.Value, (ConfigDescription)null); if (((BaseUnityPlugin)Plugin.Instance).Config.Remove(orphanEntry.Key)) { Plugin.Log.LogInfo((object)("Stray config [" + orphanEntry.Key.Section + " | " + orphanEntry.Key.Key + "] removed.")); } } } private void ReplaceEntryValue<T>(string section, string srcKey, string dstKey) where T : new() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown ConfigDefinition val = new ConfigDefinition(section, srcKey); if (orphanEntries.ContainsKey(val)) { orphanEntries.Remove(val); ((BaseUnityPlugin)Plugin.Instance).Config.Bind<T>(val, default(T), (ConfigDescription)null); } ConfigEntry<T> val2 = default(ConfigEntry<T>); bool flag = ((BaseUnityPlugin)Plugin.Instance).Config.TryGetEntry<T>(section, srcKey, ref val2); ConfigEntry<T> val3 = default(ConfigEntry<T>); bool flag2 = ((BaseUnityPlugin)Plugin.Instance).Config.TryGetEntry<T>(section, dstKey, ref val3); if (!flag || !flag2) { if (!flag) { Plugin.Log.LogWarning((object)("Old config not found : " + section + " | " + srcKey)); } if (!flag2) { Plugin.Log.LogWarning((object)("New config not found : " + section + " | " + dstKey)); } } else { val3.Value = val2.Value; ((BaseUnityPlugin)Plugin.Instance).Config.Remove(((ConfigEntryBase)val2).Definition); Plugin.Log.LogInfo((object)("Config Updated : " + section + " | " + srcKey + " -> " + dstKey)); } } private void ReplaceEntryValue<T>(string srcSection, string dstSection, string srcKey, string dstKey) where T : new() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown ConfigDefinition val = new ConfigDefinition(srcSection, srcKey); if (orphanEntries.ContainsKey(val)) { orphanEntries.Remove(val); ((BaseUnityPlugin)Plugin.Instance).Config.Bind<T>(val, default(T), (ConfigDescription)null); } ConfigEntry<T> val2 = default(ConfigEntry<T>); bool flag = ((BaseUnityPlugin)Plugin.Instance).Config.TryGetEntry<T>(srcSection, srcKey, ref val2); ConfigEntry<T> val3 = default(ConfigEntry<T>); bool flag2 = ((BaseUnityPlugin)Plugin.Instance).Config.TryGetEntry<T>(dstSection, dstKey, ref val3); if (!flag || !flag2) { if (!flag) { Plugin.Log.LogWarning((object)("Old config not found : " + srcSection + " | " + srcKey)); } if (!flag2) { Plugin.Log.LogWarning((object)("New config not found : " + dstSection + " | " + dstKey)); } } else { val3.Value = val2.Value; ((BaseUnityPlugin)Plugin.Instance).Config.Remove(((ConfigEntryBase)val2).Definition); Plugin.Log.LogInfo((object)("Config Updated : " + srcSection + " -> " + dstSection + " | " + srcKey + " -> " + dstKey)); } } } public static class VisorConfig { public static bool PixelateAuto; public static int PixelatedRain; public static int PixelatedCrack; public static int PixelatedBlood; public static bool RaindropShow; public static bool RaindropSpecular; public static bool RaindropShadow; public static bool RaindropOnlyMainCam; public static float RaindropDryTime; public static float RaindropIntensity; public static bool CrackShow; public static bool CrackRepairDeath; public static bool CrackRepairNewDay; public static bool CrackRepairNewQuota; public static float CrackVolume; public static bool RimShow; public static bool RimPhysical; public static float RimStretch; public static bool BloodShow; public static bool BloodSelf; public static float BloodLifeTime; public static float BloodDryTime; } }