using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using PluginConfig.API; using PluginConfig.API.Fields; using Unity.Mathematics; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [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("CustomBloodColor")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CustomBloodColor")] [assembly: AssemblyTitle("CustomBloodColor")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace CustomBloodColor { [BepInPlugin("scout.ultrakill.custombloodcolor", "Custom Blood Color", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__22_0; public static PostBoolValueChangeEvent <>9__23_0; public static PostColorValueChangeEvent <>9__23_1; public static PostFloatSliderValueChangeEvent <>9__23_2; public static PostBoolValueChangeEvent <>9__23_3; internal void b__22_0(Scene s, LoadSceneMode m) { StainDecals.ClearForNewLevel(); } internal void b__23_0(bool _) { BloodRecolor.ReapplyParticles(); StainDecals.Recolor(); } internal void b__23_1(Color _) { BloodRecolor.ReapplyParticles(); StainDecals.Recolor(); } internal void b__23_2(float v, Tuple b) { StainDecals.Recolor(); } internal void b__23_3(bool _) { StainDecals.Recolor(); } } public const string PluginGuid = "scout.ultrakill.custombloodcolor"; public const string PluginName = "Custom Blood Color"; public const string PluginVersion = "1.2.0"; internal static ManualLogSource Log; public static Plugin me; public static PluginConfigurator config; public static BoolField masterEnabled; public static ColorField bloodColor; public static FloatSliderField bloodAlpha; public static BoolField litDecals; public static bool Enabled => masterEnabled != null && masterEnabled.value; public static bool RecolorStains => Enabled; public static bool RecolorVignette => Enabled; public static Color Current => (Color)((bloodColor != null) ? bloodColor.value : new Color(1f, 0f, 0f)); public static float Alpha => (bloodAlpha != null) ? bloodAlpha.value : 1f; public static bool LitDecals => litDecals != null && litDecals.value; private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) me = this; Log = ((BaseUnityPlugin)this).Logger; new Harmony("scout.ultrakill.custombloodcolor").PatchAll(); SetupConfig(); SceneManager.sceneLoaded += delegate { StainDecals.ClearForNewLevel(); }; Log.LogMessage((object)"Custom Blood Color v1.2.0 loaded."); } private void SetupConfig() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //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_0153: Expected O, but got Unknown //IL_0172: 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_017d: Expected O, but got Unknown config = PluginConfigurator.Create("Custom Blood Color", "scout.custombloodcolor"); Sprite val = LoadIcon("icon.png"); if ((Object)(object)val != (Object)null) { config.image = val; } masterEnabled = new BoolField(config.rootPanel, "Mod Enabled", "masterEnabled", true); bloodColor = new ColorField(config.rootPanel, "Blood Color", "bloodColor", new Color(0f, 0.75f, 0f)); bloodAlpha = new FloatSliderField(config.rootPanel, "Alpha Stains", "bloodAlpha", new Tuple(0f, 1f), 1f, 2); litDecals = new BoolField(config.rootPanel, "Lit Stains", "litDecals", false); BoolField obj = masterEnabled; object obj2 = <>c.<>9__23_0; if (obj2 == null) { PostBoolValueChangeEvent val2 = delegate { BloodRecolor.ReapplyParticles(); StainDecals.Recolor(); }; <>c.<>9__23_0 = val2; obj2 = (object)val2; } obj.postValueChangeEvent += (PostBoolValueChangeEvent)obj2; ColorField obj3 = bloodColor; object obj4 = <>c.<>9__23_1; if (obj4 == null) { PostColorValueChangeEvent val3 = delegate { BloodRecolor.ReapplyParticles(); StainDecals.Recolor(); }; <>c.<>9__23_1 = val3; obj4 = (object)val3; } obj3.postValueChangeEvent += (PostColorValueChangeEvent)obj4; FloatSliderField obj5 = bloodAlpha; object obj6 = <>c.<>9__23_2; if (obj6 == null) { PostFloatSliderValueChangeEvent val4 = delegate { StainDecals.Recolor(); }; <>c.<>9__23_2 = val4; obj6 = (object)val4; } obj5.postValueChangeEvent += (PostFloatSliderValueChangeEvent)obj6; BoolField obj7 = litDecals; object obj8 = <>c.<>9__23_3; if (obj8 == null) { PostBoolValueChangeEvent val5 = delegate { StainDecals.Recolor(); }; <>c.<>9__23_3 = val5; obj8 = (object)val5; } obj7.postValueChangeEvent += (PostBoolValueChangeEvent)obj8; } private Sprite LoadIcon(string fileName) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), fileName); if (!File.Exists(path)) { return null; } byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, array); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } internal static class BloodRecolor { private class Cache { public Color startColor; public bool hadColorOverLife; public MinMaxGradient origFade; public MinMaxGradient whiteFade; } private static readonly Dictionary cache = new Dictionary(); private static readonly Dictionary graySprites = new Dictionary(); public static void ApplyToSplatter(Bloodsplatter bs) { if (!((Object)(object)bs == (Object)null)) { ParticleSystem[] componentsInChildren = ((Component)bs).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ApplyToSystem(componentsInChildren[i]); } } } private static void ApplyToSystem(ParticleSystem ps) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ps == (Object)null) { return; } if (!cache.TryGetValue(ps, out Cache value)) { value = new Cache(); MainModule main = ps.main; Cache obj = value; MinMaxGradient startColor = ((MainModule)(ref main)).startColor; obj.startColor = ((MinMaxGradient)(ref startColor)).color; ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime; value.hadColorOverLife = ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled; value.origFade = ((ColorOverLifetimeModule)(ref colorOverLifetime)).color; value.whiteFade = BuildWhitened(colorOverLifetime); cache[ps] = value; } MainModule main2 = ps.main; ColorOverLifetimeModule colorOverLifetime2 = ps.colorOverLifetime; if (Plugin.Enabled) { Color current = Plugin.Current; current.a = 1f; ((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(current); if (value.hadColorOverLife) { ((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = value.whiteFade; } } else { ((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(value.startColor); if (value.hadColorOverLife) { ((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = value.origFade; } } } private static MinMaxGradient BuildWhitened(ColorOverLifetimeModule col) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0044: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00a5: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) Gradient val = null; try { MinMaxGradient color = ((ColorOverLifetimeModule)(ref col)).color; val = ((MinMaxGradient)(ref color)).gradient; } catch { val = null; } if (val == null || val.colorKeys == null || val.colorKeys.Length == 0) { Gradient val2 = new Gradient(); val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0f, 1f) }); return new MinMaxGradient(val2); } GradientColorKey[] colorKeys = val.colorKeys; for (int i = 0; i < colorKeys.Length; i++) { colorKeys[i].color = Color.white; } Gradient val3 = new Gradient(); val3.SetKeys(colorKeys, val.alphaKeys); return new MinMaxGradient(val3); } public static void ReapplyParticles() { Bloodsplatter[] array = Resources.FindObjectsOfTypeAll(); for (int i = 0; i < array.Length; i++) { ApplyToSplatter(array[i]); } } public static Sprite ToGrayscale(Sprite original) { //IL_0039: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)original == (Object)null) { return null; } if (graySprites.TryGetValue(original, out Sprite value)) { return value; } Sprite val = original; try { Texture texture = (Texture)(object)original.texture; Rect textureRect = original.textureRect; int num = Mathf.RoundToInt(((Rect)(ref textureRect)).width); int num2 = Mathf.RoundToInt(((Rect)(ref textureRect)).height); RenderTexture temporary = RenderTexture.GetTemporary(texture.width, texture.height, 0, (RenderTextureFormat)0); Graphics.Blit(texture, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val2 = new Texture2D(num, num2, (TextureFormat)4, false); val2.ReadPixels(new Rect(((Rect)(ref textureRect)).x, ((Rect)(ref textureRect)).y, (float)num, (float)num2), 0, 0); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color[] pixels = val2.GetPixels(); for (int i = 0; i < pixels.Length; i++) { float num3 = pixels[i].r * 0.299f + pixels[i].g * 0.587f + pixels[i].b * 0.114f; pixels[i] = new Color(num3, num3, num3, pixels[i].a); } val2.SetPixels(pixels); val2.Apply(); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(original.pivot.x / (float)num, original.pivot.y / (float)num2); val = Sprite.Create(val2, new Rect(0f, 0f, (float)num, (float)num2), val3, original.pixelsPerUnit); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Grayscale of hurt sprite failed, leaving it red: " + ex.Message)); } graySprites[original] = val; return val; } } internal static class StainDecals { private const int MaxDecalCap = 5000; private const float BaseSize = 2.8f; private const float ShapeBoost = 1.8f; private const string AtlasProp = "_SplatterAtlas"; private static Color[] lightMul; private static Light[] lights; private static bool lightsCached; private static Sprite[] shapes; private static bool ready; private const float MaxPlaceDistance = 300f; private static int maxDecals; private static GameObject[] pool; private static SpriteRenderer[] renderers; private static int nextSlot; private static Transform root; private static readonly Vector3[] shDir = (Vector3[])(object)new Vector3[1]; private static readonly Color[] shCol = (Color[])(object)new Color[1]; public static void OnStain(Vector3 pos, Vector3 norm, Transform parent) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) BloodsplatterManager instance = MonoSingleton.Instance; if ((Object)(object)instance == (Object)null) { return; } if (!ready) { BuildShapes(instance); } if (!ready) { return; } Transform player = GetPlayer(); if ((Object)(object)player != (Object)null) { Vector3 val = pos - player.position; if (((Vector3)(ref val)).sqrMagnitude > 90000f) { return; } } Place(pos, (((Vector3)(ref norm)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref norm)).normalized : Vector3.up, parent); } private static Color SampleLighting(Vector3 pos, Vector3 normal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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_0226: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Invalid comparison between Unknown and I4 //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) Color val = RenderSettings.ambientLight; try { SphericalHarmonicsL2 val2 = default(SphericalHarmonicsL2); LightProbes.GetInterpolatedProbe(pos, (Renderer)null, ref val2); shDir[0] = normal; ((SphericalHarmonicsL2)(ref val2)).Evaluate(shDir, shCol); val += shCol[0]; } catch { } if (!lightsCached) { lightsCached = true; lights = Object.FindObjectsOfType(); } if (lights != null) { for (int i = 0; i < lights.Length; i++) { Light val3 = lights[i]; if ((Object)(object)val3 == (Object)null || !((Behaviour)val3).isActiveAndEnabled || val3.intensity <= 0f) { continue; } if ((int)val3.type == 1) { float num = Mathf.Max(0f, Vector3.Dot(normal, -((Component)val3).transform.forward)); val += val3.color * (val3.intensity * num); continue; } Vector3 val4 = ((Component)val3).transform.position - pos; float magnitude = ((Vector3)(ref val4)).magnitude; if (!(magnitude > val3.range) && !(magnitude < 0.0001f)) { float num2 = 1f - magnitude / val3.range; float num3 = Mathf.Max(0f, Vector3.Dot(normal, val4 / magnitude)); val += val3.color * (val3.intensity * num3 * num2 * num2); } } } return new Color(Mathf.Clamp(Mathf.Max(val.r, 0.22f), 0f, 1.6f), Mathf.Clamp(Mathf.Max(val.g, 0.22f), 0f, 1.6f), Mathf.Clamp(Mathf.Max(val.b, 0.22f), 0f, 1.6f), 1f); } private static Color Tinted(Color baseCol, float alpha, Color mul) { //IL_0028: 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_0035: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0019: 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_0058: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.LitDecals) { return new Color(baseCol.r, baseCol.g, baseCol.b, alpha); } return new Color(baseCol.r * mul.r, baseCol.g * mul.g, baseCol.b * mul.b, alpha); } private static Transform GetPlayer() { try { NewMovement instance = MonoSingleton.Instance; return ((Object)(object)instance != (Object)null) ? ((Component)instance).transform : null; } catch { return null; } } private static void Place(Vector3 point, Vector3 normal, Transform parent) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0154: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: 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_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) if (pool == null) { return; } int num = nextSlot; nextSlot = (nextSlot + 1) % maxDecals; GameObject val = pool[num]; SpriteRenderer val2 = renderers[num]; if ((Object)(object)val == (Object)null) { val = new GameObject("CBC_StainDecal"); if ((Object)(object)root != (Object)null) { val.transform.SetParent(root, false); } val2 = val.AddComponent(); pool[num] = val; renderers[num] = val2; } val2.sprite = shapes[Random.Range(0, shapes.Length)]; Color val3 = SampleLighting(point, normal); if (lightMul != null && num < lightMul.Length) { lightMul[num] = val3; } val2.color = Tinted(Plugin.Current, Plugin.Alpha, val3); Vector3 val4 = ((Mathf.Abs(Vector3.Dot(normal, Vector3.up)) > 0.99f) ? Vector3.forward : Vector3.up); Transform transform = val.transform; transform.SetParent(((Object)(object)parent != (Object)null) ? parent : root, true); transform.position = point + normal * 0.02f; transform.rotation = Quaternion.LookRotation(normal, val4) * Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)); float num2 = 2.8f * Random.Range(0.6f, 1.2f); Vector3 val5 = (((Object)(object)transform.parent != (Object)null) ? transform.parent.lossyScale : Vector3.one); transform.localScale = new Vector3(num2 / Mathf.Max(0.0001f, Mathf.Abs(val5.x)), num2 / Mathf.Max(0.0001f, Mathf.Abs(val5.y)), num2 / Mathf.Max(0.0001f, Mathf.Abs(val5.z))); val.SetActive(true); } public static void Recolor() { //IL_0022: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (pool == null) { return; } bool flag = Plugin.Enabled && Plugin.RecolorStains; Color current = Plugin.Current; float alpha = Plugin.Alpha; for (int i = 0; i < maxDecals; i++) { if (!((Object)(object)renderers[i] == (Object)null)) { if (!flag) { pool[i].SetActive(false); continue; } Color mul = ((lightMul != null && i < lightMul.Length) ? lightMul[i] : Color.white); renderers[i].color = Tinted(current, alpha, mul); } } } public static void ClearForNewLevel() { lightsCached = false; lights = null; if (pool == null) { return; } for (int i = 0; i < maxDecals; i++) { if ((Object)(object)pool[i] != (Object)null) { pool[i].SetActive(false); } } nextSlot = 0; } private static void BuildShapes(BloodsplatterManager bsm) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_00ab: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020c: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)root == (Object)null) { GameObject val = new GameObject("CBC_StainRoot"); Object.DontDestroyOnLoad((Object)(object)val); root = val.transform; } maxDecals = 5000; try { float floatLocal = MonoSingleton.Instance.GetFloatLocal("bloodStainMax", 100000f); maxDecals = Mathf.Clamp((int)floatLocal, 100, 5000); } catch { } pool = (GameObject[])(object)new GameObject[maxDecals]; renderers = (SpriteRenderer[])(object)new SpriteRenderer[maxDecals]; lightMul = (Color[])(object)new Color[maxDecals]; for (int i = 0; i < maxDecals; i++) { lightMul[i] = Color.white; } Material stainMat = bsm.stainMat; Texture val2 = (((Object)(object)stainMat != (Object)null && stainMat.HasProperty("_SplatterAtlas")) ? stainMat.GetTexture("_SplatterAtlas") : null); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)"No splatter atlas, stain decals disabled."); return; } int width = val2.width; int height = val2.height; RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, (RenderTextureFormat)0); Graphics.Blit(val2, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val3 = new Texture2D(width, height, (TextureFormat)4, false); val3.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0); val3.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); int num = ((height <= 0 || width % height != 0) ? 1 : (width / height)); int num2 = width / num; Color[] pixels = val3.GetPixels(); shapes = (Sprite[])(object)new Sprite[num]; for (int j = 0; j < num; j++) { Texture2D val4 = new Texture2D(num2, height, (TextureFormat)4, false); ((Texture)val4).filterMode = (FilterMode)0; ((Texture)val4).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[num2 * height]; for (int k = 0; k < height; k++) { for (int l = 0; l < num2; l++) { Color val5 = pixels[k * width + (j * num2 + l)]; float num3 = Mathf.Clamp01(Mathf.Max(val5.r, Mathf.Max(val5.g, val5.b)) * 1.8f); array[k * num2 + l] = new Color(1f, 1f, 1f, num3); } } val4.SetPixels(array); val4.Apply(); shapes[j] = Sprite.Create(val4, new Rect(0f, 0f, (float)num2, (float)height), new Vector2(0.5f, 0.5f), (float)height); } Object.Destroy((Object)(object)val3); ready = true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Building stain decals failed: " + ex.Message)); } } } [HarmonyPatch(typeof(Bloodsplatter), "OnEnable")] internal static class Patch_Bloodsplatter_OnEnable { private static void Postfix(Bloodsplatter __instance) { BloodRecolor.ApplyToSplatter(__instance); } } [HarmonyPatch] internal static class Patch_BloodsplatterManager_CreateBloodstain { private class Sig { public bool ok; public int pos = -1; public int norm = -1; public int parent = -1; public int parentObj = -1; } private static readonly Dictionary sigs = new Dictionary(); private static IEnumerable TargetMethods() { List list = new List(); foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(typeof(BloodsplatterManager))) { if (declaredMethod.Name == "CreateBloodstain") { list.Add(declaredMethod); } } return list; } private static string Describe(MethodBase m) { ParameterInfo[] parameters = m.GetParameters(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(m.Name).Append("("); for (int i = 0; i < parameters.Length; i++) { if (i > 0) { stringBuilder.Append(", "); } stringBuilder.Append(parameters[i].ParameterType.Name).Append(" ").Append(parameters[i].Name); if (parameters[i].IsOptional) { stringBuilder.Append("=opt"); } } return stringBuilder.Append(")").ToString(); } private static bool IsVec(Type t) { return t == typeof(float3) || t == typeof(Vector3); } private static Sig GetSig(MethodBase m) { if (sigs.TryGetValue(m, out Sig value)) { return value; } value = new Sig(); ParameterInfo[] parameters = m.GetParameters(); for (int i = 0; i < parameters.Length; i++) { if (IsVec(parameters[i].ParameterType)) { if (value.pos < 0) { value.pos = i; } else if (value.norm < 0) { value.norm = i; } } else if (parameters[i].ParameterType == typeof(int) && value.norm >= 0 && value.parent < 0) { value.parent = i; } else if (typeof(BloodstainParent).IsAssignableFrom(parameters[i].ParameterType) && value.parentObj < 0) { value.parentObj = i; } } value.ok = value.pos >= 0 && value.norm >= 0; sigs[m] = value; if (!value.ok) { Plugin.Log.LogWarning((object)("Unreadable overload left to vanilla: " + Describe(m))); } return value; } private static bool Prefix(object[] __args, MethodBase __originalMethod) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled || !Plugin.RecolorStains) { return true; } if (__args == null) { return true; } Sig sig = GetSig(__originalMethod); if (!sig.ok) { return true; } if (sig.pos >= __args.Length || sig.norm >= __args.Length) { return true; } Vector3 val = AsVector3(__args[sig.pos]); Vector3 val2 = AsVector3(__args[sig.norm]); BloodstainParent val3 = (BloodstainParent)((sig.parentObj >= 0 && sig.parentObj < __args.Length) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val3 != (Object)null) { Transform transform = ((Component)val3).transform; StainDecals.OnStain(transform.position + transform.rotation * val, transform.rotation * val2, transform); return false; } int num = ((sig.parent >= 0 && sig.parent < __args.Length && __args[sig.parent] is int) ? ((int)__args[sig.parent]) : 0); if (num > 0) { return true; } StainDecals.OnStain(val, val2, null); return false; } private static Vector3 AsVector3(object o) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (o is float3) { return float3.op_Implicit((float3)o); } if (!(o is Vector3 result)) { return Vector3.zero; } return result; } } [HarmonyPatch(typeof(ScreenBlood), "Start")] internal static class Patch_ScreenBlood_Start { private static void Postfix(ScreenBlood __instance) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled || !Plugin.RecolorVignette) { return; } Image component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null)) { Sprite val = BloodRecolor.ToGrayscale(component.sprite); if ((Object)(object)val != (Object)null) { component.sprite = val; } Color current = Plugin.Current; current.a = ((Graphic)component).color.a; ((Graphic)component).color = current; Traverse.Create((object)__instance).Field("clr").SetValue((object)current); } } } }