Decompiled source of Blood System v3.0.0

BepInEx\plugins\invent60-BloodSystem\BloodSystem.dll

Decompiled a day ago
using System;
using System.Collections;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("BloodSystem")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b555e65fc56492e6223c1cdbf338c67680516dc6")]
[assembly: AssemblyProduct("BloodSystem")]
[assembly: AssemblyTitle("BloodSystem")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BloodSystem;

internal struct DotData
{
	public Vector3 Pos;

	public Vector3 Norm;

	public float R;

	public float Dark;

	public Vector3 TanNorm;

	public Vector3 ElongDir;

	public float Elongation;

	public DotData(Vector3 pos, Vector3 norm, float r, float dark, Vector3 tanNorm, Vector3 elongDir, float elongation)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0020: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		Pos = pos;
		Norm = norm;
		R = r;
		Dark = dark;
		TanNorm = tanNorm;
		ElongDir = elongDir;
		Elongation = elongation;
	}
}
[BepInPlugin("h3vr.invent60.bloodsystem", "Blood System", "3.0.0")]
public class BloodSystemPlugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	internal static BloodSystemPlugin _instance;

	internal static ConfigEntry<bool> CfgEnabled;

	internal static ConfigEntry<float> CfgLifetime;

	internal static ConfigEntry<int> CfgRayCount;

	internal static ConfigEntry<float> CfgConeAngle;

	internal static ConfigEntry<float> CfgDotSize;

	internal static ConfigEntry<float> CfgRange;

	internal static ConfigEntry<string> CfgProjectionMode;

	internal static ConfigEntry<float> CfgSpeedRatio;

	internal static ConfigEntry<float> CfgSpeedBias;

	internal static ConfigEntry<float> CfgDotScaleMax;

	internal static ConfigEntry<float> CfgDotScaleRange;

	internal static ConfigEntry<int> CfgGibRayCount;

	internal static readonly Color _mustardFallback = new Color(0.9f, 0.8f, 0f, 1f);

	internal static readonly Dictionary<Color, Material> _matCache = new Dictionary<Color, Material>();

	private static Shader _bloodShader;

	private static bool _bloodShaderSearched;

	internal static Material _decalSourceMat;

	internal static bool _decalSourceSearched;

	internal static bool _dbgDotLogged;

	internal static bool _dbgDecalLogged;

	private static Texture2D _decalTex;

	private static Texture2D _hardCircleTex;

	private static Texture2D _firstBloodTex;

	private static Texture2D _normalMapTex;

	private static readonly Dictionary<Color, Texture2D> _coloredTexCache = new Dictionary<Color, Texture2D>();

	private static Vector2[] _splatterUVs;

	private static float[] _cumWeights;

	private static float[] _splatterDarks;

	private static Vector3[] _splatterNormals;

	private static readonly Vector3 _tanLight;

	private static ParticleSystem _pelletPS;

	private static ParticleSystem _fogPS;

	private static Material _fogMat;

	private static Material _pelletMat;

	private static Material _dotBaseMat;

	private static Mesh _dotQuadMesh;

	private static ParticleSystem _flyingDotPS;

	private static Particle[] _flyBuf;

	private static Particle[] _flyMergeBuf;

	private static bool _ngaChecked;

	private static bool _ngaKetchup;

	private static Color _ngaColor;

	private static FieldInfo _fiMustard;

	private static bool _mustardFieldSearched;

	internal static bool _alloyGrabPending;

	private static bool _dbgDropLogged;

	private static string AlloyMatCachePath => Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "alloy_mat.cache");

	private void Awake()
	{
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Expected O, but got Unknown
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: 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_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0325: Expected O, but got Unknown
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: 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_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_0398: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Expected O, but got Unknown
		//IL_0499: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		_instance = this;
		CfgEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Blood", "Enabled", true, "Toggle all blood effects.");
		CfgLifetime = ((BaseUnityPlugin)this).Config.Bind<float>("Blood", "Lifetime seconds", 30f, "How long splash and drip stains last before despawning.");
		CfgRayCount = ((BaseUnityPlugin)this).Config.Bind<int>("Blood", "Max rays per shot", 3000, "Maximum splash ray count. Capped to the actual number of image pixels if fewer.");
		CfgConeAngle = ((BaseUnityPlugin)this).Config.Bind<float>("Blood", "Cone half-angle", 10f, "Half-angle in degrees of the splash cone.");
		CfgDotSize = ((BaseUnityPlugin)this).Config.Bind<float>("Blood", "Dot base radius", 0.008f, "Base radius of each splash dot in metres. Scales linearly to 3x at 20 metres.");
		CfgRange = ((BaseUnityPlugin)this).Config.Bind<float>("Blood", "Range metres", 50f, "Maximum splash distance in metres.");
		CfgProjectionMode = ((BaseUnityPlugin)this).Config.Bind<string>("Blood", "Projection Mode", "Animated", "How splash dots appear. Animated: dots fly from wound to wall in real-time (best visuals, most FPS cost). Delayed: dots appear all at once after a timed delay with no animation (moderate). Immediate: dots appear instantly with no delay and no animation (cheapest, best for low-end systems).");
		CfgSpeedRatio = ((BaseUnityPlugin)this).Config.Bind<float>("Blood", "Projection Speed Ratio", 2f, "Multiplies bullet exit speed to calculate how fast splash dots travel toward the wall. Higher = faster animation, less time spread between near and far dots. Default 2.");
		CfgSpeedBias = ((BaseUnityPlugin)this).Config.Bind<float>("Blood", "Projection Speed Bias", 10f, "Flat metres-per-second added to projection speed after the ratio multiply. Prevents dots from moving too slowly for low-velocity bullets. Default 10.");
		CfgDotScaleMax = ((BaseUnityPlugin)this).Config.Bind<float>("Blood", "Dot Max Scale", 5f, "Maximum size multiplier applied to splash dots at Dot Scale Range distance. 5 means dots at full range are 5x the base radius. Default 5.");
		CfgDotScaleRange = ((BaseUnityPlugin)this).Config.Bind<float>("Blood", "Dot Scale Range metres", 50f, "Distance in metres at which splash dots reach their maximum size (Dot Max Scale). Dots near the wound start at Dot Base Radius and grow linearly to this range. Default 50.");
		CfgGibRayCount = ((BaseUnityPlugin)this).Config.Bind<int>("Blood", "Gib Ray Count", 200, "Number of rays fired in random 360-degree directions when a segment explodes. Lower values improve FPS in gib-heavy fights. Capped by image pixel count. Default 200.");
		_decalTex = MakeSoftCircle(96);
		_hardCircleTex = MakeHardCircle(64);
		TryLoadFromBundle();
		Shader val = Shader.Find("Sprites/Default");
		if (val != null)
		{
			_dotBaseMat = new Material(val);
			_dotBaseMat.mainTexture = (Texture)(object)_decalTex;
		}
		_dotQuadMesh = new Mesh();
		_dotQuadMesh.vertices = (Vector3[])(object)new Vector3[4]
		{
			new Vector3(-0.5f, -0.5f, 0f),
			new Vector3(0.5f, -0.5f, 0f),
			new Vector3(0.5f, 0.5f, 0f),
			new Vector3(-0.5f, 0.5f, 0f)
		};
		_dotQuadMesh.uv = (Vector2[])(object)new Vector2[4]
		{
			new Vector2(0f, 0f),
			new Vector2(1f, 0f),
			new Vector2(1f, 1f),
			new Vector2(0f, 1f)
		};
		_dotQuadMesh.triangles = new int[6] { 0, 2, 3, 0, 1, 2 };
		_dotQuadMesh.RecalculateBounds();
		GameObject val2 = new GameObject("FlyingDotPS");
		Object.DontDestroyOnLoad((Object)val2);
		_flyingDotPS = val2.AddComponent<ParticleSystem>();
		MainModule main = _flyingDotPS.main;
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f);
		((MainModule)(ref main)).startSpeed = new MinMaxCurve(0f);
		((MainModule)(ref main)).startSize = new MinMaxCurve(0.02f);
		((MainModule)(ref main)).loop = false;
		((MainModule)(ref main)).playOnAwake = false;
		((MainModule)(ref main)).maxParticles = 8000;
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
		EmissionModule emission = _flyingDotPS.emission;
		((EmissionModule)(ref emission)).enabled = false;
		((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(0f);
		((Component)_flyingDotPS).GetComponent<ParticleSystemRenderer>().renderMode = (ParticleSystemRenderMode)0;
		List<Texture2D> list = LoadAllPngs();
		if (list.Count > 0)
		{
			_firstBloodTex = list[0];
			BuildSampleDataFromAll(list);
			Log.LogInfo((object)("[BloodSystem] " + list.Count + " PNG(s) loaded. CDF points=" + ((_splatterUVs != null) ? _splatterUVs.Length.ToString() : "0")));
		}
		else
		{
			BuildFallbackGrid(200);
			Log.LogWarning((object)"[BloodSystem] No PNG found in plugin folder — using uniform fallback grid.");
		}
		_fogMat = BuildSprayMaterial();
		_pelletMat = BuildSprayMaterial();
		if (_flyingDotPS != null && _pelletMat != null)
		{
			((Renderer)((Component)_flyingDotPS).GetComponent<ParticleSystemRenderer>()).material = _pelletMat;
		}
		BuildSprayPSes();
		new Harmony("h3vr.invent60.bloodsystem").PatchAll(typeof(BloodSystemPatches));
		Log.LogInfo((object)("[BloodSystem] 3.0.0 loaded. FieldsOK=" + BloodSystemPatches.Ok));
	}

	private static List<Texture2D> LoadAllPngs()
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		List<Texture2D> list = new List<Texture2D>();
		try
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			List<string> list2 = new List<string>(Directory.GetFiles(directoryName, "*.png"));
			list2.AddRange(Directory.GetFiles(directoryName, "*.jpg"));
			list2.AddRange(Directory.GetFiles(directoryName, "*.jpeg"));
			foreach (string item in list2)
			{
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (val.LoadImage(File.ReadAllBytes(item)))
				{
					((Texture)val).filterMode = (FilterMode)2;
					string text = Path.GetFileNameWithoutExtension(item).ToLower();
					if (text.Contains("normal") || text.Contains("norm"))
					{
						_normalMapTex = val;
						Log.LogInfo((object)("[BloodSystem] NormalMap=" + Path.GetFileName(item)));
					}
					else
					{
						list.Add(val);
					}
				}
			}
		}
		catch (Exception ex)
		{
			Log.LogWarning((object)("[BloodSystem] LoadAllPngs: " + ex.Message));
		}
		return list;
	}

	private static Vector3 LookupNormal(Vector2 uv)
	{
		//IL_001c: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		if (_normalMapTex == null)
		{
			return new Vector3(0f, 0f, 1f);
		}
		float num = uv.x * 0.5f + 0.5f;
		float num2 = uv.y * 0.5f + 0.5f;
		int num3 = Mathf.Clamp(Mathf.RoundToInt(num * (float)(((Texture)_normalMapTex).width - 1)), 0, ((Texture)_normalMapTex).width - 1);
		int num4 = Mathf.Clamp(Mathf.RoundToInt(num2 * (float)(((Texture)_normalMapTex).height - 1)), 0, ((Texture)_normalMapTex).height - 1);
		Color pixel = _normalMapTex.GetPixel(num3, num4);
		Vector3 val = new Vector3(pixel.r * 2f - 1f, pixel.g * 2f - 1f, Mathf.Abs(pixel.b * 2f - 1f));
		return ((Vector3)(ref val)).normalized;
	}

	private static Texture2D MakeSoftCircle(int size)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
		float num = (float)(size - 1) * 0.5f;
		Color[] array = (Color[])(object)new Color[size * size];
		for (int i = 0; i < size; i++)
		{
			for (int j = 0; j < size; j++)
			{
				float num2 = ((float)j - num) / num;
				float num3 = ((float)i - num) / num;
				float num4 = num2 * num2 + num3 * num3;
				float num5 = ((num4 > 1f) ? 0f : Mathf.Clamp01(Mathf.Exp((0f - num4) * 3.5f)));
				array[i * size + j] = new Color(1f, 1f, 1f, num5);
			}
		}
		val.SetPixels(array);
		val.Apply();
		return val;
	}

	private static Texture2D MakeHardCircle(int size)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
		float num = (float)(size - 1) * 0.5f;
		Color[] array = (Color[])(object)new Color[size * size];
		for (int i = 0; i < size; i++)
		{
			for (int j = 0; j < size; j++)
			{
				float num2 = ((float)j - num) / num;
				float num3 = ((float)i - num) / num;
				float num4 = ((num2 * num2 + num3 * num3 <= 1f) ? 1f : 0f);
				array[i * size + j] = new Color(1f, 1f, 1f, num4);
			}
		}
		val.SetPixels(array);
		val.Apply();
		return val;
	}

	private static Texture2D GetColoredTex(Color col)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_00d3: 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_008c: 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_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		if (_coloredTexCache.TryGetValue(col, out var value) && value != null)
		{
			return value;
		}
		int num = 96;
		value = new Texture2D(num, num, (TextureFormat)4, false);
		float num2 = (float)(num - 1) * 0.5f;
		Color[] array = (Color[])(object)new Color[num * num];
		for (int i = 0; i < num; i++)
		{
			for (int j = 0; j < num; j++)
			{
				float num3 = ((float)j - num2) / num2;
				float num4 = ((float)i - num2) / num2;
				float num5 = num3 * num3 + num4 * num4;
				float num6 = ((num5 > 1f) ? 0f : Mathf.Clamp01(Mathf.Exp((0f - num5) * 3.5f)));
				array[i * num + j] = new Color(col.r, col.g, col.b, num6);
			}
		}
		value.SetPixels(array);
		value.Apply();
		((Texture)value).filterMode = (FilterMode)2;
		_coloredTexCache[col] = value;
		return value;
	}

	private static void BuildSampleDataFromAll(List<Texture2D> textures)
	{
		//IL_009e: 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_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_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		List<Vector2> list = new List<Vector2>();
		List<float> list2 = new List<float>();
		List<Vector3> list3 = new List<Vector3>();
		List<float> list4 = new List<float>();
		float num = 0f;
		foreach (Texture2D texture in textures)
		{
			int width = ((Texture)texture).width;
			int height = ((Texture)texture).height;
			Color[] pixels = texture.GetPixels();
			float num2 = (float)width / (float)height;
			List<Vector2> list5 = new List<Vector2>(width * height / 4);
			List<float> list6 = new List<float>(width * height / 4);
			List<float> list7 = new List<float>(width * height / 4);
			float num3 = 0f;
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					Color val = pixels[i * width + j];
					float num4 = val.r * 0.299f + val.g * 0.587f + val.b * 0.114f;
					float num5 = val.a * (1f - num4);
					if (!(num5 < 0.02f))
					{
						float num6;
						float num7;
						if (num2 >= 1f)
						{
							num6 = (float)j / (float)(width - 1) * 2f - 1f;
							num7 = ((float)i / (float)(height - 1) * 2f - 1f) / num2;
						}
						else
						{
							num6 = ((float)j / (float)(width - 1) * 2f - 1f) * num2;
							num7 = (float)i / (float)(height - 1) * 2f - 1f;
						}
						list5.Add(new Vector2(num6, num7));
						list6.Add(1f - num4);
						list7.Add(num5);
						num3 += num5;
					}
				}
			}
			if (!(num3 < 0.001f) && list5.Count != 0)
			{
				float num8 = 1f / num3;
				for (int k = 0; k < list5.Count; k++)
				{
					num += list7[k] * num8;
					list.Add(list5[k]);
					list2.Add(list6[k]);
					list3.Add(LookupNormal(list5[k]));
					list4.Add(num);
				}
			}
		}
		_splatterUVs = list.ToArray();
		_splatterDarks = list2.ToArray();
		_splatterNormals = list3.ToArray();
		_cumWeights = list4.ToArray();
	}

	private static void BuildFallbackGrid(int side)
	{
		//IL_002a: 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)
		//IL_007b: 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)
		List<Vector2> list = new List<Vector2>(side * side);
		List<float> list2 = new List<float>(side * side);
		List<Vector3> list3 = new List<Vector3>(side * side);
		new Vector3(0f, 0f, 1f);
		Vector2 val = default(Vector2);
		for (int i = 0; i < side; i++)
		{
			for (int j = 0; j < side; j++)
			{
				((Vector2)(ref val))..ctor((float)j / (float)(side - 1) * 2f - 1f, (float)i / (float)(side - 1) * 2f - 1f);
				list.Add(val);
				list2.Add(0.8f);
				list3.Add(LookupNormal(val));
			}
		}
		_splatterUVs = list.ToArray();
		_splatterDarks = list2.ToArray();
		_splatterNormals = list3.ToArray();
		_cumWeights = new float[0];
	}

	private static void SampleSplatter(out Vector2 uv, out float dark, out Vector3 tanNorm)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: 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)
		if (_splatterUVs == null || _splatterUVs.Length == 0)
		{
			uv = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
			dark = 0.8f;
			tanNorm = new Vector3(0f, 0f, 1f);
			return;
		}
		int num;
		if (_cumWeights == null || _cumWeights.Length == 0)
		{
			num = Random.Range(0, _splatterUVs.Length);
		}
		else
		{
			float num2 = Random.Range(0f, _cumWeights[_cumWeights.Length - 1]);
			int num3 = 0;
			int num4 = _cumWeights.Length - 1;
			while (num3 < num4)
			{
				int num5 = num3 + num4 >> 1;
				if (_cumWeights[num5] < num2)
				{
					num3 = num5 + 1;
				}
				else
				{
					num4 = num5;
				}
			}
			num = num3;
		}
		uv = _splatterUVs[num];
		dark = ((_splatterDarks != null && num < _splatterDarks.Length) ? _splatterDarks[num] : 0.8f);
		tanNorm = (Vector3)((_splatterNormals != null && num < _splatterNormals.Length) ? _splatterNormals[num] : new Vector3(0f, 0f, 1f));
	}

	private static void TryLoadFromBundle()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Expected O, but got Unknown
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Expected O, but got Unknown
		Shader val = Shader.Find("Alloy/Core");
		if (val != null)
		{
			Material val2 = new Material(val);
			val2.renderQueue = 3000;
			val2.EnableKeyword("EFFECT_BUMP");
			val2.EnableKeyword("_ALPHAPREMULTIPLY_ON");
			val2.EnableKeyword("_RIM_ON");
			if (val2.HasProperty("_SrcBlend"))
			{
				val2.SetInt("_SrcBlend", 1);
			}
			if (val2.HasProperty("_DstBlend"))
			{
				val2.SetInt("_DstBlend", 10);
			}
			if (val2.HasProperty("_ZWrite"))
			{
				val2.SetInt("_ZWrite", 0);
			}
			if (val2.HasProperty("_Mode"))
			{
				val2.SetFloat("_Mode", 3f);
			}
			val2.SetInt("_Cull", 0);
			_decalSourceMat = val2;
			_decalSourceSearched = true;
			Log.LogInfo((object)"[BloodSystem] Alloy/Core hardcoded transparent: rq=3000 EFFECT_BUMP _ALPHAPREMULTIPLY_ON _RIM_ON");
			return;
		}
		try
		{
			string alloyMatCachePath = AlloyMatCachePath;
			if (!File.Exists(alloyMatCachePath))
			{
				return;
			}
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			string[] array = File.ReadAllLines(alloyMatCachePath);
			foreach (string text in array)
			{
				int num = text.IndexOf('=');
				if (num >= 0)
				{
					dictionary[text.Substring(0, num).Trim()] = text.Substring(num + 1).Trim();
				}
			}
			if (!dictionary.TryGetValue("shaderName", out var value))
			{
				return;
			}
			Shader val3 = Shader.Find(value);
			if (val3 == null)
			{
				Log.LogWarning((object)("[BloodSystem] Cache shader not found: " + value));
				return;
			}
			Material val4 = new Material(val3);
			if (dictionary.TryGetValue("renderQueue", out var value2))
			{
				val4.renderQueue = int.Parse(value2);
			}
			if (dictionary.TryGetValue("_SrcBlend", out value2) && val4.HasProperty("_SrcBlend"))
			{
				val4.SetInt("_SrcBlend", int.Parse(value2));
			}
			if (dictionary.TryGetValue("_DstBlend", out value2) && val4.HasProperty("_DstBlend"))
			{
				val4.SetInt("_DstBlend", int.Parse(value2));
			}
			if (dictionary.TryGetValue("_ZWrite", out value2) && val4.HasProperty("_ZWrite"))
			{
				val4.SetInt("_ZWrite", int.Parse(value2));
			}
			if (dictionary.TryGetValue("_Mode", out value2) && val4.HasProperty("_Mode"))
			{
				val4.SetFloat("_Mode", float.Parse(value2));
			}
			if (dictionary.TryGetValue("keywords", out value2) && !string.IsNullOrEmpty(value2))
			{
				array = value2.Split(new char[1] { ',' });
				foreach (string text2 in array)
				{
					if (!string.IsNullOrEmpty(text2.Trim()))
					{
						val4.EnableKeyword(text2.Trim());
					}
				}
			}
			val4.SetInt("_Cull", 0);
			_decalSourceMat = val4;
			_decalSourceSearched = true;
			Log.LogInfo((object)("[BloodSystem] Cache loaded: " + value + " rq=" + val4.renderQueue));
		}
		catch (Exception ex)
		{
			Log.LogWarning((object)("[BloodSystem] TryLoadFromCache: " + ex.Message));
		}
	}

	internal static void SaveAlloyCacheToFile(Material mat)
	{
		try
		{
			List<string> list = new List<string>
			{
				"shaderName=" + ((Object)mat.shader).name,
				"renderQueue=" + mat.renderQueue,
				"keywords=" + string.Join(",", mat.shaderKeywords)
			};
			string[] array = new string[3] { "_SrcBlend", "_DstBlend", "_ZWrite" };
			foreach (string text in array)
			{
				if (mat.HasProperty(text))
				{
					list.Add(text + "=" + mat.GetInt(text));
				}
			}
			array = new string[2] { "_Mode", "_Cutoff" };
			foreach (string text2 in array)
			{
				if (mat.HasProperty(text2))
				{
					list.Add(text2 + "=" + mat.GetFloat(text2).ToString("F3"));
				}
			}
			File.WriteAllLines(AlloyMatCachePath, list.ToArray());
			Log.LogInfo((object)("[BloodSystem] Cache saved: " + ((Object)mat.shader).name + " kws=" + string.Join(",", mat.shaderKeywords)));
		}
		catch (Exception ex)
		{
			Log.LogWarning((object)("[BloodSystem] SaveAlloyCache: " + ex.Message));
		}
	}

	internal static IEnumerator TryGrabAlloyFromScene()
	{
		_alloyGrabPending = true;
		yield return null;
		if (_decalSourceMat != null)
		{
			_alloyGrabPending = false;
			yield break;
		}
		Renderer val = null;
		int num = -1;
		int num2 = 0;
		try
		{
			Renderer[] array = Object.FindObjectsOfType<Renderer>();
			foreach (Renderer val2 in array)
			{
				if (val2 == null)
				{
					continue;
				}
				Material sharedMaterial = val2.sharedMaterial;
				if (sharedMaterial == null || sharedMaterial.shader == null)
				{
					continue;
				}
				string name = ((Object)sharedMaterial.shader).name;
				if (name.IndexOf("Alloy", StringComparison.OrdinalIgnoreCase) >= 0 && name.IndexOf("Additive", StringComparison.OrdinalIgnoreCase) < 0)
				{
					num2++;
					int num3 = 0;
					if (name == "Alloy/Core")
					{
						num3 += 100;
					}
					if (sharedMaterial.renderQueue > 2000)
					{
						num3 += 50;
					}
					Log.LogInfo((object)("[BloodSystem] Alloy candidate: shader=" + name + " rq=" + sharedMaterial.renderQueue + " score=" + num3 + " obj=" + ((Object)((Component)val2).gameObject).name));
					if (num3 > num)
					{
						num = num3;
						val = val2;
					}
				}
			}
		}
		catch (Exception ex)
		{
			Log.LogWarning((object)("[BloodSystem] TryGrabAlloyFromScene: " + ex.Message));
		}
		Log.LogInfo((object)("[BloodSystem] AlloyGrab: candidates=" + num2 + " bestScore=" + num));
		if (val != null)
		{
			_decalSourceMat = new Material(val.sharedMaterial);
			_decalSourceMat.SetInt("_Cull", 0);
			_decalSourceSearched = true;
			_matCache.Clear();
			Log.LogInfo((object)("[BloodSystem] Alloy mat GRABBED: " + ((Object)_decalSourceMat.shader).name + " rq=" + _decalSourceMat.renderQueue));
			SaveAlloyCacheToFile(_decalSourceMat);
		}
		else
		{
			Log.LogWarning((object)"[BloodSystem] No Alloy renderer found — shoot a wall, then a sosig.");
		}
		_alloyGrabPending = false;
	}

	internal static Material GetBloodMat(Color col)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		if (_matCache.TryGetValue(col, out var value) && value != null)
		{
			return value;
		}
		if (_decalSourceMat == null)
		{
			return null;
		}
		value = new Material(_decalSourceMat);
		if (_decalTex != null)
		{
			value.mainTexture = (Texture)(object)_decalTex;
		}
		ApplyBloodProps(value, col);
		_matCache[col] = value;
		return value;
	}

	private static void ApplyBloodProps(Material m, Color col)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		if (m.HasProperty("_Color"))
		{
			m.SetColor("_Color", col);
		}
		if (m.HasProperty("_Metal"))
		{
			m.SetFloat("_Metal", 0f);
		}
		if (m.HasProperty("_Specularity"))
		{
			m.SetFloat("_Specularity", 0f);
		}
		if (m.HasProperty("_Roughness"))
		{
			m.SetFloat("_Roughness", 0.8f);
		}
		m.DisableKeyword("_RIM_ON");
		if (m.HasProperty("_EmissionColor"))
		{
			m.SetColor("_EmissionColor", Color.black);
		}
		m.DisableKeyword("_EMISSION");
		m.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)4;
		if (m.HasProperty("_SrcBlend"))
		{
			m.SetInt("_SrcBlend", 5);
		}
		if (m.HasProperty("_DstBlend"))
		{
			m.SetInt("_DstBlend", 10);
		}
		m.DisableKeyword("_ALPHAPREMULTIPLY_ON");
		m.EnableKeyword("_ALPHABLEND_ON");
		if (m.HasProperty("_Metallic"))
		{
			m.SetFloat("_Metallic", 0f);
		}
		if (m.HasProperty("_Smoothness"))
		{
			m.SetFloat("_Smoothness", 0.1f);
		}
		if (m.HasProperty("_SpecColor"))
		{
			m.SetColor("_SpecColor", Color.black);
		}
		if (m.HasProperty("_Shininess"))
		{
			m.SetFloat("_Shininess", 0.05f);
		}
	}

	private static Material BuildSprayMaterial()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		Shader val = Shader.Find("Sprites/Default");
		if (val == null)
		{
			val = Shader.Find("Particles/Additive");
		}
		if (val == null)
		{
			return null;
		}
		Material val2 = new Material(val);
		if (_firstBloodTex != null)
		{
			val2.mainTexture = (Texture)(object)_firstBloodTex;
		}
		return val2;
	}

	private static void SetParticleFadeMode(Material mat)
	{
		mat.SetFloat("_Mode", 2f);
		mat.EnableKeyword("_ALPHABLEND_ON");
		mat.DisableKeyword("_ALPHATEST_ON");
		mat.DisableKeyword("_ALPHAPREMULTIPLY_ON");
		mat.SetInt("_SrcBlend", 5);
		mat.SetInt("_DstBlend", 10);
		mat.SetInt("_ZWrite", 0);
		mat.renderQueue = 3000;
	}

	private void BuildSprayPSes()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: 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_009c: 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)
		//IL_00bf: 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_00eb: 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_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: 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)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Expected O, but got Unknown
		//IL_01f6: 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_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		Gradient val = new Gradient();
		val.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)
		});
		GameObject val2 = new GameObject("BSPellet");
		Object.DontDestroyOnLoad((Object)val2);
		val2.SetActive(false);
		_pelletPS = val2.AddComponent<ParticleSystem>();
		MainModule main = _pelletPS.main;
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.2f, 0.35f);
		((MainModule)(ref main)).startSpeed = new MinMaxCurve(1f, 5f);
		((MainModule)(ref main)).startSize = new MinMaxCurve(0.013f, 0.05f);
		((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
		((MainModule)(ref main)).maxParticles = 3000;
		((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
		((MainModule)(ref main)).loop = false;
		((MainModule)(ref main)).playOnAwake = false;
		((MainModule)(ref main)).duration = 0.5f;
		((MainModule)(ref main)).startColor = new MinMaxGradient(_mustardFallback);
		EmissionModule emission = _pelletPS.emission;
		((EmissionModule)(ref emission)).enabled = true;
		((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(0f);
		ShapeModule shape = _pelletPS.shape;
		((ShapeModule)(ref shape)).enabled = true;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
		((ShapeModule)(ref shape)).angle = 15f;
		((ShapeModule)(ref shape)).radius = 0.02f;
		ColorOverLifetimeModule colorOverLifetime = _pelletPS.colorOverLifetime;
		((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
		((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val);
		ParticleSystemRenderer component = ((Component)_pelletPS).GetComponent<ParticleSystemRenderer>();
		if ((Object)(object)component != (Object)null && _pelletMat != null)
		{
			((Renderer)component).material = _pelletMat;
		}
		val2.SetActive(true);
		GameObject val3 = new GameObject("BSFog");
		Object.DontDestroyOnLoad((Object)val3);
		val3.SetActive(false);
		_fogPS = val3.AddComponent<ParticleSystem>();
		MainModule main2 = _fogPS.main;
		((MainModule)(ref main2)).startLifetime = new MinMaxCurve(0.2f, 0.35f);
		((MainModule)(ref main2)).startSpeed = new MinMaxCurve(1f, 5f);
		((MainModule)(ref main2)).startSize = new MinMaxCurve(0.047f, 0.15f);
		((MainModule)(ref main2)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
		((MainModule)(ref main2)).maxParticles = 1200;
		((MainModule)(ref main2)).gravityModifier = MinMaxCurve.op_Implicit(0f);
		((MainModule)(ref main2)).loop = false;
		((MainModule)(ref main2)).playOnAwake = false;
		((MainModule)(ref main2)).duration = 0.5f;
		((MainModule)(ref main2)).startColor = new MinMaxGradient(_mustardFallback);
		EmissionModule emission2 = _fogPS.emission;
		((EmissionModule)(ref emission2)).enabled = true;
		((EmissionModule)(ref emission2)).rateOverTime = new MinMaxCurve(0f);
		ShapeModule shape2 = _fogPS.shape;
		((ShapeModule)(ref shape2)).enabled = true;
		((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)4;
		((ShapeModule)(ref shape2)).angle = 15f;
		((ShapeModule)(ref shape2)).radius = 0.03f;
		ColorOverLifetimeModule colorOverLifetime2 = _fogPS.colorOverLifetime;
		((ColorOverLifetimeModule)(ref colorOverLifetime2)).enabled = true;
		((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = new MinMaxGradient(val);
		ParticleSystemRenderer component2 = ((Component)_fogPS).GetComponent<ParticleSystemRenderer>();
		if ((Object)(object)component2 != (Object)null && _fogMat != null)
		{
			((Renderer)component2).material = _fogMat;
		}
		val3.SetActive(true);
	}

	internal static void SpawnProjection(Vector3 exitPt, Vector3 projDir, Sosig srcSosig, float bulletSpeed, bool gib = false)
	{
		//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_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_0061: 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_007f: 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_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: 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_00ca: 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_00d6: 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_00df: 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_00e8: 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_00ef: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: 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_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_074a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0312: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_063c: Unknown result type (might be due to invalid IL or missing references)
		//IL_043a: Unknown result type (might be due to invalid IL or missing references)
		//IL_044c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0450: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0722: Unknown result type (might be due to invalid IL or missing references)
		if (!CfgEnabled.Value)
		{
			return;
		}
		try
		{
			Color sosigBloodColor = GetSosigBloodColor(srcSosig);
			Vector3 normalized = ((Vector3)(ref projDir)).normalized;
			float num = Mathf.Tan(CfgConeAngle.Value * ((float)Math.PI / 180f));
			float value = CfgRange.Value;
			float num2 = Mathf.Max(1f, bulletSpeed * CfgSpeedRatio.Value) + CfgSpeedBias.Value;
			Vector3 val = Vector3.Cross((Mathf.Abs(Vector3.Dot(normalized, Vector3.up)) > 0.99f) ? Vector3.forward : Vector3.up, normalized);
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			Vector3 val2 = Vector3.Cross(normalized, normalized2);
			float num3 = Random.Range(0f, (float)Math.PI * 2f);
			float num4 = Mathf.Cos(num3);
			float num5 = Mathf.Sin(num3);
			Vector3 val3 = normalized2 * num4 + val2 * num5;
			Vector3 val4 = val2 * num4 - normalized2 * num5;
			normalized2 = val3;
			val2 = val4;
			bool flag = string.Equals(CfgProjectionMode.Value, "Animated", StringComparison.OrdinalIgnoreCase);
			bool flag2 = string.Equals(CfgProjectionMode.Value, "Immediate", StringComparison.OrdinalIgnoreCase);
			float value2 = CfgDotScaleMax.Value;
			float num6 = (value2 - 1f) / Mathf.Max(0.1f, CfgDotScaleRange.Value);
			int num7 = ((_splatterUVs != null && _splatterUVs.Length != 0) ? _splatterUVs.Length : int.MaxValue);
			int num8 = (gib ? Mathf.Min(Mathf.Max(1, CfgGibRayCount.Value), num7) : Mathf.Min(Mathf.Max(1, CfgRayCount.Value), num7));
			Dictionary<int, List<DotData>> dictionary = new Dictionary<int, List<DotData>>();
			Dictionary<int, Dictionary<Transform, List<DotData>>> dictionary2 = new Dictionary<int, Dictionary<Transform, List<DotData>>>();
			if (_flyBuf == null || _flyBuf.Length < num8)
			{
				_flyBuf = (Particle[])(object)new Particle[num8];
			}
			int num9 = 0;
			Color32 startColor = Color32.op_Implicit(sosigBloodColor);
			RaycastHit val7 = default(RaycastHit);
			for (int i = 0; i < num8; i++)
			{
				SampleSplatter(out var uv, out var dark, out var tanNorm);
				Vector3 val5;
				if (!gib)
				{
					val = normalized + normalized2 * uv.x * num + val2 * uv.y * num;
					val5 = ((Vector3)(ref val)).normalized;
				}
				else
				{
					val5 = Random.onUnitSphere;
				}
				Vector3 val6 = val5;
				if (!Physics.Raycast(exitPt + val6 * 0.15f, val6, ref val7, value) || IsSourceSosig(((RaycastHit)(ref val7)).collider, srcSosig) || (Object)(object)((Component)((RaycastHit)(ref val7)).collider).GetComponentInParent<SosigWeapon>() != (Object)null)
				{
					continue;
				}
				float num10 = CfgDotSize.Value * Mathf.Clamp(1f + ((RaycastHit)(ref val7)).distance * num6, 1f, value2);
				int key = Mathf.FloorToInt(((RaycastHit)(ref val7)).distance / num2 / 0.025f);
				float num11 = Mathf.Abs(Vector3.Dot(val6, ((RaycastHit)(ref val7)).normal));
				float elongation = Mathf.Clamp(1f / Mathf.Max(0.15f, num11), 1f, 8f);
				Vector3 elongDir = val6 - Vector3.Dot(val6, ((RaycastHit)(ref val7)).normal) * ((RaycastHit)(ref val7)).normal;
				if (((Vector3)(ref elongDir)).sqrMagnitude > 0.001f)
				{
					((Vector3)(ref elongDir)).Normalize();
				}
				else
				{
					elongDir = normalized2;
				}
				Rigidbody attachedRigidbody = ((RaycastHit)(ref val7)).collider.attachedRigidbody;
				Transform val8 = (((Object)(object)attachedRigidbody != (Object)null) ? ((Component)attachedRigidbody).transform : null);
				DotData item = new DotData(((RaycastHit)(ref val7)).point, ((RaycastHit)(ref val7)).normal, num10, dark, tanNorm, elongDir, elongation);
				if ((Object)(object)val8 == (Object)null)
				{
					if (!dictionary.ContainsKey(key))
					{
						dictionary[key] = new List<DotData>();
					}
					dictionary[key].Add(item);
				}
				else
				{
					if (!dictionary2.ContainsKey(key))
					{
						dictionary2[key] = new Dictionary<Transform, List<DotData>>();
					}
					if (!dictionary2[key].ContainsKey(val8))
					{
						dictionary2[key][val8] = new List<DotData>();
					}
					dictionary2[key][val8].Add(item);
				}
				if (flag && _flyingDotPS != null && num9 < _flyBuf.Length)
				{
					float num12 = ((RaycastHit)(ref val7)).distance / num2;
					((Particle)(ref _flyBuf[num9])).position = exitPt;
					((Particle)(ref _flyBuf[num9])).velocity = val6 * num2;
					((Particle)(ref _flyBuf[num9])).startLifetime = num12;
					((Particle)(ref _flyBuf[num9])).remainingLifetime = num12;
					((Particle)(ref _flyBuf[num9])).startSize = num10 * 2f;
					((Particle)(ref _flyBuf[num9])).startColor = startColor;
					num9++;
				}
			}
			if (dictionary.Count == 0 && dictionary2.Count == 0)
			{
				return;
			}
			if (flag && _flyingDotPS != null && num9 > 0)
			{
				int particles = _flyingDotPS.GetParticles(_flyMergeBuf);
				int num13 = Mathf.Min(particles + num9, _flyMergeBuf.Length);
				Array.Copy(_flyMergeBuf, 0, _flyMergeBuf, 0, particles);
				int num14 = Mathf.Min(num9, num13 - particles);
				Array.Copy(_flyBuf, 0, _flyMergeBuf, particles, num14);
				_flyingDotPS.SetParticles(_flyMergeBuf, particles + num14);
				if (!_flyingDotPS.isPlaying)
				{
					_flyingDotPS.Play();
				}
			}
			if (!_dbgDotLogged)
			{
				_dbgDotLogged = true;
				Log.LogInfo((object)("[BloodSystem] First projection: " + num9 + " particles speed=" + num2.ToString("F1") + " N=" + num8 + " mode=" + CfgProjectionMode.Value));
			}
			if (flag2)
			{
				List<DotData> list = new List<DotData>();
				foreach (KeyValuePair<int, List<DotData>> item2 in dictionary)
				{
					list.AddRange(item2.Value);
				}
				if (list.Count > 0)
				{
					BuildDotMesh(list, null, sosigBloodColor);
				}
				Dictionary<Transform, List<DotData>> dictionary3 = new Dictionary<Transform, List<DotData>>();
				foreach (KeyValuePair<int, Dictionary<Transform, List<DotData>>> item3 in dictionary2)
				{
					foreach (KeyValuePair<Transform, List<DotData>> item4 in item3.Value)
					{
						if (!dictionary3.ContainsKey(item4.Key))
						{
							dictionary3[item4.Key] = new List<DotData>();
						}
						dictionary3[item4.Key].AddRange(item4.Value);
					}
				}
				{
					foreach (KeyValuePair<Transform, List<DotData>> item5 in dictionary3)
					{
						if (item5.Key != null && (Object)(object)item5.Key != (Object)null)
						{
							BuildDotMesh(item5.Value, item5.Key, sosigBloodColor);
						}
					}
					return;
				}
			}
			((MonoBehaviour)_instance).StartCoroutine(DoDelayedSpawn(dictionary, dictionary2, sosigBloodColor, 0.025f));
		}
		catch (Exception ex)
		{
			Log.LogError((object)("[BloodSystem] SpawnProjection: " + ex));
		}
	}

	private static IEnumerator DoDelayedSpawn(Dictionary<int, List<DotData>> staticBins, Dictionary<int, Dictionary<Transform, List<DotData>>> dynBins, Color col, float binSize)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		List<int> list = new List<int>(staticBins.Keys);
		foreach (int key in dynBins.Keys)
		{
			if (!list.Contains(key))
			{
				list.Add(key);
			}
		}
		list.Sort();
		float num = 0f;
		foreach (int b in list)
		{
			float t = (float)b * binSize;
			float num2 = t - num;
			if (num2 > 0.001f)
			{
				yield return (object)new WaitForSeconds(num2);
				num = t;
			}
			if (staticBins.TryGetValue(b, out var value) && value.Count > 0)
			{
				BuildDotMesh(value, null, col);
			}
			if (!dynBins.TryGetValue(b, out var value2))
			{
				continue;
			}
			foreach (KeyValuePair<Transform, List<DotData>> item in value2)
			{
				if (item.Key != null && (Object)(object)item.Key != (Object)null)
				{
					BuildDotMesh(item.Value, item.Key, col);
				}
			}
		}
	}

	internal static void SpawnBloodSpray(Vector3 pos, Vector3 fwd, Color col, bool explode = false, float speedScale = 1f)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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_0067: 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)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: 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_0184: Unknown result type (might be due to invalid IL or missing references)
		if (!CfgEnabled.Value)
		{
			return;
		}
		Quaternion rotation = Quaternion.LookRotation(fwd);
		float num = (explode ? Mathf.Clamp(speedScale, 0.5f, 2.5f) : 1f);
		if (_pelletPS != null)
		{
			((Component)_pelletPS).transform.position = pos;
			((Component)_pelletPS).transform.rotation = rotation;
			MainModule main = _pelletPS.main;
			((MainModule)(ref main)).startColor = new MinMaxGradient(col);
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.2f * num, 0.35f * num);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(1f * num, 5f * num);
			ShapeModule shape = _pelletPS.shape;
			if (explode)
			{
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
				((ShapeModule)(ref shape)).radius = 0.05f;
			}
			else
			{
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
				((ShapeModule)(ref shape)).angle = 15f;
				((ShapeModule)(ref shape)).radius = 0.02f;
			}
			_pelletPS.Emit(explode ? 1000 : 500);
		}
		if (_fogPS != null)
		{
			((Component)_fogPS).transform.position = pos;
			((Component)_fogPS).transform.rotation = rotation;
			MainModule main2 = _fogPS.main;
			((MainModule)(ref main2)).startColor = new MinMaxGradient(col);
			((MainModule)(ref main2)).startLifetime = new MinMaxCurve(0.2f * num, 0.35f * num);
			((MainModule)(ref main2)).startSpeed = new MinMaxCurve(1f * num, 5f * num);
			ShapeModule shape2 = _fogPS.shape;
			if (explode)
			{
				((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)0;
				((ShapeModule)(ref shape2)).radius = 0.05f;
			}
			else
			{
				((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)4;
				((ShapeModule)(ref shape2)).angle = 15f;
				((ShapeModule)(ref shape2)).radius = 0.03f;
			}
			_fogPS.Emit(explode ? 400 : 200);
		}
	}

	internal static void SpawnDripStain(Vector3 pos, Vector3 normal, Color col, float scale = 1f)
	{
		//IL_0000: 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_003b: 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_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: 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_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_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Expected O, but got Unknown
		//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_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: 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_00e7: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Expected O, but got Unknown
		Material bloodMat = GetBloodMat(col);
		if (bloodMat != null)
		{
			float num = Random.Range(0.015f, 0.04f) * scale;
			Vector3 val = ((Mathf.Abs(Vector3.Dot(normal, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up);
			Quaternion val2 = Quaternion.LookRotation(-normal, val) * Quaternion.Euler(0f, 0f, Random.Range(0f, 360f));
			Vector3 val3 = val2 * Vector3.right * num;
			Vector3 val4 = val2 * Vector3.up * num;
			Vector3 val5 = pos + normal * 0.003f;
			Mesh val6 = new Mesh();
			val6.vertices = (Vector3[])(object)new Vector3[4]
			{
				val5 - val3 - val4,
				val5 + val3 - val4,
				val5 + val3 + val4,
				val5 - val3 + val4
			};
			val6.uv = (Vector2[])(object)new Vector2[4]
			{
				new Vector2(0f, 0f),
				new Vector2(1f, 0f),
				new Vector2(1f, 1f),
				new Vector2(0f, 1f)
			};
			val6.colors = (Color[])(object)new Color[4] { col, col, col, col };
			val6.triangles = new int[6] { 0, 2, 3, 0, 1, 2 };
			val6.RecalculateBounds();
			val6.RecalculateNormals();
			GameObject val7 = new GameObject("DS");
			val7.AddComponent<MeshFilter>().mesh = val6;
			MeshRenderer obj = val7.AddComponent<MeshRenderer>();
			((Renderer)obj).material = bloodMat;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			Object.Destroy((Object)val7, CfgLifetime.Value);
		}
	}

	internal unsafe static void SpawnBloodDrops(Vector3 pos, Vector3 outward, Color col, int count)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_0033: 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_0043: 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_008b: 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: 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_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: 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_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_0067: 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)
		//IL_01d2: Expected O, but got Unknown
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Expected O, but got Unknown
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		if (CfgEnabled.Value && _instance != null)
		{
			Vector3 val = ((((Vector3)(ref outward)).sqrMagnitude > 0.001f) ? ((Vector3)(ref outward)).normalized : Vector3.up);
			Vector3 val2 = pos + val * 0.08f;
			if (!_dbgDropLogged)
			{
				_dbgDropLogged = true;
				ManualLogSource log = Log;
				string text = count.ToString();
				Vector3 val3 = val2;
				log.LogInfo((object)("[BloodSystem] SpawnBloodDrops count=" + text + " pos=" + ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString()));
			}
			GameObject val4 = new GameObject("BDrp");
			val4.transform.position = val2;
			val4.transform.rotation = Quaternion.LookRotation(val);
			ParticleSystem obj = val4.AddComponent<ParticleSystem>();
			MainModule main = obj.main;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.5f, 3.5f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.3f, 1.5f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.008f, 0.025f);
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(1f);
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).maxParticles = 64;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).startColor = new MinMaxGradient(col);
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).enabled = true;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 55f;
			((ShapeModule)(ref shape)).radius = 0.02f;
			EmissionModule emission = obj.emission;
			((EmissionModule)(ref emission)).enabled = true;
			((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(0f);
			ParticleSystemRenderer component = ((Component)obj).GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)component != (Object)null && _pelletMat != null)
			{
				Material val5 = new Material(_pelletMat);
				val5.color = col;
				((Renderer)component).material = val5;
			}
			obj.Play();
			obj.Emit(count);
			Object.Destroy((Object)val4, 6f);
			((MonoBehaviour)_instance).StartCoroutine(DoDropStains(val2, col, count));
		}
	}

	private static IEnumerator DoDropStains(Vector3 pos, Color col, int count)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit h = default(RaycastHit);
		if (Physics.Raycast(pos + Vector3.up * 0.05f, Vector3.down, ref h, 5f) && !((Object)(object)((RaycastHit)(ref h)).collider.attachedRigidbody != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref h)).collider).GetComponentInParent<SosigLink>() != (Object)null))
		{
			float num = Mathf.Clamp(Mathf.Sqrt(2f * Mathf.Max(0.01f, ((RaycastHit)(ref h)).distance) / 9.81f), 0.1f, 3.5f);
			yield return (object)new WaitForSeconds(num);
			Vector3 point = ((RaycastHit)(ref h)).point;
			Vector3 normal = ((RaycastHit)(ref h)).normal;
			int num2 = Mathf.Min(count, 8);
			for (int i = 0; i < num2; i++)
			{
				Vector2 val = Random.insideUnitCircle * 0.12f;
				SpawnGrowingStain(point + new Vector3(val.x, 0f, val.y), normal, col);
			}
		}
	}

	internal static void SpawnGrowingStain(Vector3 pos, Vector3 normal, Color col)
	{
		//IL_0000: 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_003f: Expected O, but got Unknown
		//IL_0061: 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_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_001e: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: 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_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Expected O, but got Unknown
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0214: 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_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Expected O, but got Unknown
		Material bloodMat = GetBloodMat(col);
		Material val;
		if (bloodMat == null)
		{
			if (_pelletMat == null)
			{
				return;
			}
			val = new Material(_pelletMat);
			val.color = col;
			if (_hardCircleTex != null)
			{
				val.mainTexture = (Texture)(object)_hardCircleTex;
			}
		}
		else
		{
			val = new Material(bloodMat);
			if (_hardCircleTex != null)
			{
				val.mainTexture = (Texture)(object)_hardCircleTex;
			}
		}
		float num = Random.Range(0.025f, 0.07f);
		Vector3 val2 = ((Mathf.Abs(Vector3.Dot(normal, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up);
		Quaternion rotation = Quaternion.LookRotation(-normal, val2) * Quaternion.Euler(0f, 0f, Random.Range(0f, 360f));
		Mesh val3 = new Mesh();
		val3.vertices = (Vector3[])(object)new Vector3[4]
		{
			new Vector3(-1f, -1f, 0f),
			new Vector3(1f, -1f, 0f),
			new Vector3(1f, 1f, 0f),
			new Vector3(-1f, 1f, 0f)
		};
		val3.uv = (Vector2[])(object)new Vector2[4]
		{
			new Vector2(0f, 0f),
			new Vector2(1f, 0f),
			new Vector2(1f, 1f),
			new Vector2(0f, 1f)
		};
		val3.colors = (Color[])(object)new Color[4] { col, col, col, col };
		val3.triangles = new int[6] { 0, 2, 3, 0, 1, 2 };
		val3.RecalculateBounds();
		val3.RecalculateNormals();
		GameObject val4 = new GameObject("GS");
		val4.transform.position = pos + normal * 0.003f;
		val4.transform.rotation = rotation;
		val4.transform.localScale = Vector3.one * num;
		val4.AddComponent<MeshFilter>().mesh = val3;
		MeshRenderer obj = val4.AddComponent<MeshRenderer>();
		((Renderer)obj).material = val;
		((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)obj).receiveShadows = false;
		val4.AddComponent<GrowingStain>();
		Object.Destroy((Object)val4, CfgLifetime.Value);
	}

	private unsafe static void BuildDotMesh(List<DotData> dots, Transform parent, Color col)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Expected O, but got Unknown
		//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: Expected O, but got Unknown
		//IL_0119: 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_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: 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_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: 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_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_031c: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0324: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: 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_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0462: Unknown result type (might be due to invalid IL or missing references)
		//IL_0467: Unknown result type (might be due to invalid IL or missing references)
		//IL_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_0486: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04be: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
		if (dots.Count == 0)
		{
			return;
		}
		Material bloodMat = GetBloodMat(col);
		Log.LogInfo((object)("[BloodSystem] BuildDotMesh " + dots.Count + " mat=" + ((bloodMat != null) ? ((Object)bloodMat.shader).name : "NULL")));
		if (bloodMat == null)
		{
			return;
		}
		int count = dots.Count;
		Color val10 = default(Color);
		for (int i = 0; i < count; i += 16383)
		{
			int num = Mathf.Min(16383, count - i);
			Vector3[] array = (Vector3[])(object)new Vector3[num * 4];
			Vector2[] array2 = (Vector2[])(object)new Vector2[num * 4];
			Color[] array3 = (Color[])(object)new Color[num * 4];
			int[] array4 = new int[num * 6];
			for (int j = 0; j < num; j++)
			{
				DotData dotData = dots[i + j];
				Vector3 norm = dotData.Norm;
				float r = dotData.R;
				Vector3 elongDir = dotData.ElongDir;
				Vector3 val = Vector3.Cross(norm, elongDir);
				if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
				{
					Vector3 val2 = ((Mathf.Abs(Vector3.Dot(norm, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up);
					val = Vector3.Cross(norm, val2);
				}
				((Vector3)(ref val)).Normalize();
				Vector3 val3 = elongDir * (r * dotData.Elongation);
				Vector3 val4 = val * r;
				Vector3 val5 = dotData.Pos + norm * 0.003f;
				Vector3 val6 = val5 - val3 - val4;
				Vector3 val7 = val5 + val3 - val4;
				Vector3 val8 = val5 + val3 + val4;
				Vector3 val9 = val5 - val3 + val4;
				if ((Object)(object)parent != (Object)null)
				{
					val6 = parent.InverseTransformPoint(val6);
					val7 = parent.InverseTransformPoint(val7);
					val8 = parent.InverseTransformPoint(val8);
					val9 = parent.InverseTransformPoint(val9);
				}
				float num2 = Mathf.Lerp(0.4f, 1f, dotData.Dark);
				float num3 = Mathf.Clamp01(dotData.TanNorm.x * _tanLight.x + dotData.TanNorm.y * _tanLight.y + dotData.TanNorm.z * _tanLight.z);
				float num4 = Mathf.Lerp(0.5f, 1f, num3);
				float num5 = num2 * num4;
				((Color)(ref val10))..ctor(col.r * num5, col.g * num5, col.b * num5, 1f);
				int num6 = j * 4;
				array[num6] = val6;
				array[num6 + 1] = val7;
				array[num6 + 2] = val8;
				array[num6 + 3] = val9;
				array2[num6] = new Vector2(0f, 0f);
				array2[num6 + 1] = new Vector2(1f, 0f);
				array2[num6 + 2] = new Vector2(1f, 1f);
				array2[num6 + 3] = new Vector2(0f, 1f);
				array3[num6] = (array3[num6 + 1] = (array3[num6 + 2] = (array3[num6 + 3] = val10)));
				int num7 = j * 6;
				array4[num7] = num6;
				array4[num7 + 1] = num6 + 2;
				array4[num7 + 2] = num6 + 3;
				array4[num7 + 3] = num6;
				array4[num7 + 4] = num6 + 1;
				array4[num7 + 5] = num6 + 2;
			}
			Mesh val11 = new Mesh();
			val11.vertices = array;
			val11.uv = array2;
			val11.colors = array3;
			val11.triangles = array4;
			val11.RecalculateBounds();
			val11.RecalculateNormals();
			GameObject val12 = new GameObject("BD");
			if ((Object)(object)parent != (Object)null)
			{
				val12.transform.SetParent(parent, false);
			}
			val12.AddComponent<MeshFilter>().mesh = val11;
			MeshRenderer obj = val12.AddComponent<MeshRenderer>();
			((Renderer)obj).material = bloodMat;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			Object.Destroy((Object)(object)val12, CfgLifetime.Value);
			if (!_dbgDotLogged && dots.Count > 0)
			{
				_dbgDotLogged = true;
				DotData dotData2 = dots[0];
				Vector3 val13 = (((Object)(object)parent != (Object)null) ? parent.TransformPoint(array[0]) : array[0]);
				ManualLogSource log = Log;
				string[] obj2 = new string[12]
				{
					"[BloodSystem] DBG dot[0] worldPos=", null, null, null, null, null, null, null, null, null,
					null, null
				};
				Vector3 val14 = val13;
				obj2[1] = ((object)(*(Vector3*)(&val14))/*cast due to .constrained prefix*/).ToString();
				obj2[2] = " r=";
				obj2[3] = dotData2.R.ToString();
				obj2[4] = " norm=";
				val14 = dotData2.Norm;
				obj2[5] = ((object)(*(Vector3*)(&val14))/*cast due to .constrained prefix*/).ToString();
				obj2[6] = " matShader=";
				obj2[7] = ((Object)bloodMat.shader).name;
				obj2[8] = " matColor=";
				obj2[9] = ((object)bloodMat.GetColor("_Color")/*cast due to .constrained prefix*/).ToString();
				obj2[10] = " hasTex=";
				obj2[11] = (bloodMat.mainTexture != null).ToString();
				log.LogInfo((object)string.Concat(obj2));
			}
		}
	}

	internal unsafe static Color GetSosigBloodColor(Sosig s)
	{
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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)
		if (!_ngaChecked)
		{
			_ngaChecked = true;
			try
			{
				if (Chainloader.PluginInfos.TryGetValue("NGA.SosigIntegrityConfigs", out var value) && value.Instance != null)
				{
					BaseUnityPlugin instance = value.Instance;
					if (instance != null)
					{
						ConfigEntry<bool> val = default(ConfigEntry<bool>);
						if (instance.Config.TryGetEntry<bool>("Sosig Body.Colour", "Ketchup", ref val) && val.Value)
						{
							_ngaKetchup = true;
							ConfigEntry<string> val2 = default(ConfigEntry<string>);
							if (instance.Config.TryGetEntry<string>("Sosig Body.Colour", "Mustard Colour", ref val2))
							{
								Color val3 = default(Color);
								_ngaColor = (ColorUtility.TryParseHtmlString(val2.Value, ref val3) ? val3 : _mustardFallback);
							}
							else
							{
								_ngaColor = _mustardFallback;
							}
						}
						ManualLogSource log = Log;
						string text = _ngaKetchup.ToString();
						Color ngaColor = _ngaColor;
						log.LogInfo((object)("[BloodSystem] NGA ketchup=" + text + " col=" + ((object)(*(Color*)(&ngaColor))/*cast due to .constrained prefix*/).ToString()));
					}
				}
				else
				{
					Log.LogInfo((object)"[BloodSystem] NGA SosigIntegrityConfigs not present.");
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("[BloodSystem] NGA check: " + ex.Message));
			}
		}
		if (_ngaKetchup)
		{
			return _ngaColor;
		}
		if (!_mustardFieldSearched)
		{
			_mustardFieldSearched = true;
			_fiMustard = typeof(Sosig).GetField("Mustard", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if ((object)_fiMustard == null)
			{
				FieldInfo[] fields = typeof(Sosig).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (fieldInfo.FieldType.Name == "Color" && fieldInfo.Name.ToLower().Contains("mustard"))
					{
						_fiMustard = fieldInfo;
						break;
					}
				}
			}
			Log.LogInfo((object)("[BloodSystem] Mustard field=" + (((object)_fiMustard != null) ? _fiMustard.Name : "not found")));
		}
		if (s != null && (object)_fiMustard != null)
		{
			try
			{
				return (Color)_fiMustard.GetValue(s);
			}
			catch
			{
			}
		}
		return _mustardFallback;
	}

	internal static IEnumerator TagGibsDeferred(Vector3 pos, Sosig src)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		yield return null;
		Collider[] array = Physics.OverlapSphere(pos, 8f);
		foreach (Collider val in array)
		{
			if ((Object)(object)((Component)val).GetComponentInParent<SosigLink>() != (Object)null)
			{
				continue;
			}
			Rigidbody attachedRigidbody = val.attachedRigidbody;
			if (!((Object)(object)attachedRigidbody == (Object)null))
			{
				SosigGibTag sosigGibTag = ((Component)attachedRigidbody).GetComponent<SosigGibTag>();
				if ((Object)(object)sosigGibTag == (Object)null)
				{
					sosigGibTag = ((Component)attachedRigidbody).gameObject.AddComponent<SosigGibTag>();
				}
				sosigGibTag.SourceSosig = src;
			}
		}
	}

	internal static bool IsSourceSosig(Collider col, Sosig src)
	{
		if (src == null)
		{
			return false;
		}
		SosigLink componentInParent = ((Component)col).GetComponentInParent<SosigLink>();
		if ((Object)(object)componentInParent != (Object)null && componentInParent.S != null && componentInParent.S == src)
		{
			return true;
		}
		if (((Component)col).transform.IsChildOf(((Component)src).transform))
		{
			return true;
		}
		Rigidbody attachedRigidbody = col.attachedRigidbody;
		if ((Object)(object)attachedRigidbody != (Object)null)
		{
			SosigGibTag component = ((Component)attachedRigidbody).GetComponent<SosigGibTag>();
			if ((Object)(object)component != (Object)null && component.SourceSosig == src)
			{
				return true;
			}
		}
		return false;
	}

	static BloodSystemPlugin()
	{
		//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_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = new Vector3(0.5f, 0.5f, 0.707f);
		_tanLight = ((Vector3)(ref val)).normalized;
		_flyBuf = (Particle[])(object)new Particle[4000];
		_flyMergeBuf = (Particle[])(object)new Particle[8000];
	}
}
public class SosigGibTag : MonoBehaviour
{
	public Sosig SourceSosig;
}
public class GrowingStain : MonoBehaviour
{
	private float _startScale;

	private float _t;

	private bool _done;

	private const float GrowTime = 1.5f;

	private void Start()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		_startScale = ((Component)this).transform.localScale.x;
	}

	private void Update()
	{
		//IL_0049: 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)
		if (!_done)
		{
			_t += Time.deltaTime;
			float num = _startScale * Mathf.Lerp(1f, 1.5f, Mathf.Clamp01(_t / 1.5f));
			((Component)this).transform.localScale = Vector3.one * num;
			if (_t >= 1.5f)
			{
				_done = true;
			}
		}
	}
}
public class SplatterTracker : MonoBehaviour
{
	public Vector3 LastBulletDir;

	public float LastBulletSpeed = 400f;

	public bool PendingBlood;

	public Vector3 PendingExitPt;

	public Vector3 PendingStrikeDir;

	public Sosig PendingSrc;

	public Color PendingCol;

	public Vector3 PendingEntryPt;
}
public class VanillaDripStainer : MonoBehaviour
{
	private ParticleSystem _ps;

	private Particle[] _buf;

	private Sosig _sosig;

	private int _skip;

	private void Start()
	{
		//IL_002d: 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)
		_ps = ((Component)this).GetComponent<ParticleSystem>();
		_sosig = ((Component)this).GetComponentInParent<Sosig>();
		if ((Object)(object)_ps != (Object)null)
		{
			MainModule main = _ps.main;
			_buf = (Particle[])(object)new Particle[Mathf.Max(((MainModule)(ref main)).maxParticles, 64)];
		}
	}

	private void Update()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Invalid comparison between Unknown and I4
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: 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_012a: Unknown result type (migh