Decompiled source of Blood Gore Edition v1.0.0

plugins/BloodGore/BloodGore.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RTM.UISystem;
using UnityEngine;
using Voxels.TowerDefense;
using Voxels.TowerDefense.SpriteMagic;
using Voxels.TowerDefense.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("BloodGore")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BloodGore")]
[assembly: AssemblyTitle("BloodGore")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BloodGore;

[BepInPlugin("fr.natchoum.badnorth.bloodgore", "Blood Gore Édition", "1.0.0")]
public class BloodGorePlugin : BaseUnityPlugin
{
	public const string Guid = "fr.natchoum.badnorth.bloodgore";

	internal static ManualLogSource Log;

	internal static string ModDir;

	internal static ConfigEntry<bool> Enabled;

	internal static ConfigEntry<float> Intensity;

	internal static ConfigEntry<float> DismemberChance;

	internal static ConfigEntry<bool> WaterBlood;

	internal static ConfigEntry<float> WaterBloodDuration;

	internal static ConfigEntry<bool> GroundBlood;

	internal static ConfigEntry<bool> DarkBlood;

	internal static ConfigEntry<Color> BloodColor;

	internal static ConfigEntry<bool> MenuLogo;

	internal static ConfigEntry<float> MenuLogoScale;

	internal static ConfigEntry<KeyCode> ToggleKey;

	private void Awake()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Expected O, but got Unknown
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Expected O, but got Unknown
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Expected O, but got Unknown
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Expected O, but got Unknown
		//IL_0218: 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_023b: 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_0249: Expected O, but got Unknown
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		ModDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Active", true, "Active ou désactive tout le gore (aussi avec la touche F10 en jeu).");
		Intensity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Intensite", 1.5f, new ConfigDescription("Quantité de sang (1 = déjà très sanglant, 2 = carnage, 3 = boucherie).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 3f), new object[0]));
		DismemberChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ChanceDemembrement", 0.45f, new ConfigDescription("Probabilité qu'une mort démembre / décapite l'unité (les gros impacts démembrent toujours).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0]));
		WaterBlood = ((BaseUnityPlugin)this).Config.Bind<bool>("Eau", "SangDansLEau", true, "Le sang coule dans la mer et la tache en rouge.");
		WaterBloodDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Eau", "DureeTachesEau", 45f, new ConfigDescription("Durée (secondes) avant que les nappes de sang dans l'eau ne se dissipent.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 300f), new object[0]));
		GroundBlood = ((BaseUnityPlugin)this).Config.Bind<bool>("Sol", "TachesAuSol", true, "Les gouttes de sang tachent l'herbe et la roche là où elles tombent.");
		DarkBlood = ((BaseUnityPlugin)this).Config.Bind<bool>("Sang", "SangRetravaille", true, "Remplace la couleur du sang du jeu par un rouge sombre et épais.");
		BloodColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Sang", "CouleurSang", new Color(0.55f, 0.02f, 0.03f, 1f), "Couleur du sang retravaillé (RGBA 0-1).");
		MenuLogo = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu", "LogoMenu", true, "Affiche le logo « Blood Gore Édition » sur l'écran titre et le menu principal.");
		MenuLogoScale = ((BaseUnityPlugin)this).Config.Bind<float>("Menu", "TailleLogo", 1f, new ConfigDescription("Taille du logo dans le menu.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.4f, 2f), new object[0]));
		ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToucheActivation", (KeyCode)291, "Touche pour activer / désactiver le gore en jeu.");
		new Harmony("fr.natchoum.badnorth.bloodgore").PatchAll(typeof(BloodGorePlugin).Assembly);
		GameObject val = new GameObject("BloodGoreManager")
		{
			hideFlags = (HideFlags)61
		};
		Object.DontDestroyOnLoad((Object)val);
		val.AddComponent<GoreFX>();
		val.AddComponent<MenuLogo>();
		Log.LogInfo((object)("Blood Gore Édition chargé (intensité " + Intensity.Value + ", dossier : " + ModDir + ")"));
	}
}
public class GoreFX : MonoBehaviour
{
	private struct Fountain
	{
		public Agent agent;

		public Vector3 pos;

		public Vector3 dir;

		public float until;

		public float acc;

		public float rate;
	}

	private struct PaintReq
	{
		public Vector3 pos;

		public float size;

		public bool decal;
	}

	internal static GoreFX Instance;

	public const float WaterLevel = -0.105f;

	private static readonly FieldInfo bloodDecalField = AccessTools.Field(typeof(Death), "bloodDecal");

	private ParticleSystem drops;

	private ParticleSystem gibs;

	private Particle[] buffer = (Particle[])(object)new Particle[4096];

	private bool ready;

	private float nextInitTry;

	private Island island;

	private Transform runContainer;

	private bool hadContainer;

	private readonly List<Fountain> fountains = new List<Fountain>();

	private readonly Queue<PaintReq> paintQueue = new Queue<PaintReq>();

	private float toastUntil;

	private GUIStyle toastStyle;

	private static readonly Color32[] BloodCols = (Color32[])(object)new Color32[5]
	{
		new Color32((byte)120, (byte)4, (byte)6, byte.MaxValue),
		new Color32((byte)150, (byte)8, (byte)10, byte.MaxValue),
		new Color32((byte)95, (byte)2, (byte)4, byte.MaxValue),
		new Color32((byte)175, (byte)14, (byte)16, byte.MaxValue),
		new Color32((byte)70, (byte)0, (byte)2, byte.MaxValue)
	};

	private static readonly Color32[] FleshCols = (Color32[])(object)new Color32[7]
	{
		new Color32((byte)150, (byte)30, (byte)30, byte.MaxValue),
		new Color32((byte)190, (byte)60, (byte)55, byte.MaxValue),
		new Color32((byte)110, (byte)10, (byte)12, byte.MaxValue),
		new Color32((byte)225, (byte)170, (byte)140, byte.MaxValue),
		new Color32((byte)235, (byte)225, (byte)205, byte.MaxValue),
		new Color32((byte)120, (byte)120, (byte)128, byte.MaxValue),
		new Color32((byte)80, (byte)60, (byte)45, byte.MaxValue)
	};

	private static readonly Color32[] SkinCols = (Color32[])(object)new Color32[3]
	{
		new Color32((byte)232, (byte)184, (byte)150, byte.MaxValue),
		new Color32((byte)214, (byte)160, (byte)125, byte.MaxValue),
		new Color32((byte)190, (byte)140, (byte)105, byte.MaxValue)
	};

	internal static bool Active
	{
		get
		{
			if (!BloodGorePlugin.Enabled.Value)
			{
				return false;
			}
			UserSettings userSettings = Profile.userSettings;
			if (userSettings != null)
			{
				return userSettings.showBlood;
			}
			return true;
		}
	}

	private static float I => BloodGorePlugin.Intensity.Value;

	internal Transform Container => runContainer;

	private void Awake()
	{
		Instance = this;
	}

	private bool EnsureReady()
	{
		if (ready && (Object)(object)drops != (Object)null && (Object)(object)gibs != (Object)null)
		{
			return true;
		}
		ready = false;
		if (Time.unscaledTime < nextInitTry)
		{
			return false;
		}
		nextInitTry = Time.unscaledTime + 1f;
		Material val = null;
		Material[] array = Resources.FindObjectsOfTypeAll<Material>();
		foreach (Material val2 in array)
		{
			if ((Object)(object)val2 != (Object)null && ((Object)val2).name == "SquareParticle")
			{
				val = val2;
				break;
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			array = Resources.FindObjectsOfTypeAll<Material>();
			foreach (Material val3 in array)
			{
				if ((Object)(object)val3 != (Object)null && (((Object)val3).name == "BloodSplash" || ((Object)val3).name == "DustParticles"))
				{
					val = val3;
					break;
				}
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			return false;
		}
		drops = MakeSystem("BloodGore_Drops", val, 6000, 2f, collide: true, 0f, 0.05f);
		gibs = MakeSystem("BloodGore_Gibs", val, 900, 2.2f, collide: true, 0.3f, 0.45f);
		ready = true;
		BloodGorePlugin.Log.LogInfo((object)("Systèmes de sang prêts (matériau : " + ((Object)val).name + ", calque Blood = " + LayerMaster.blood.id + ")"));
		return true;
	}

	private ParticleSystem MakeSystem(string name, Material mat, int max, float gravity, bool collide, float bounce, float dampen)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_0087: 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_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_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_00d2: 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_00fd: 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_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		((Object)val).hideFlags = (HideFlags)52;
		Object.DontDestroyOnLoad((Object)(object)val);
		int id = LayerMaster.blood.id;
		if (id >= 0)
		{
			val.layer = id;
		}
		ParticleSystem val2 = val.AddComponent<ParticleSystem>();
		val2.Stop(true, (ParticleSystemStopBehavior)0);
		MainModule main = val2.main;
		((MainModule)(ref main)).loop = true;
		((MainModule)(ref main)).playOnAwake = false;
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).maxParticles = max;
		((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(gravity);
		((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(2f);
		((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
		((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.05f);
		((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0;
		EmissionModule emission = val2.emission;
		((EmissionModule)(ref emission)).enabled = false;
		ShapeModule shape = val2.shape;
		((ShapeModule)(ref shape)).enabled = false;
		if (collide)
		{
			CollisionModule collision = val2.collision;
			((CollisionModule)(ref collision)).enabled = true;
			((CollisionModule)(ref collision)).type = (ParticleSystemCollisionType)1;
			((CollisionModule)(ref collision)).mode = (ParticleSystemCollisionMode)0;
			((CollisionModule)(ref collision)).quality = (ParticleSystemCollisionQuality)1;
			((CollisionModule)(ref collision)).bounce = MinMaxCurve.op_Implicit(bounce);
			((CollisionModule)(ref collision)).dampen = MinMaxCurve.op_Implicit(dampen);
			((CollisionModule)(ref collision)).lifetimeLoss = MinMaxCurve.op_Implicit((bounce > 0f) ? 0f : 1f);
			((CollisionModule)(ref collision)).radiusScale = 0.5f;
			int num = -1;
			LayerRef[] array = (LayerRef[])(object)new LayerRef[8]
			{
				LayerMaster.enBodies,
				LayerMaster.viBodies,
				LayerMaster.enShields,
				LayerMaster.viShields,
				LayerMaster.enProjectiles,
				LayerMaster.viProjectiles,
				LayerMaster.blood,
				LayerMaster.landings
			};
			for (int i = 0; i < array.Length; i++)
			{
				int id2 = array[i].id;
				if (id2 >= 0)
				{
					num &= ~(1 << id2);
				}
			}
			((CollisionModule)(ref collision)).collidesWith = LayerMask.op_Implicit(num);
			((CollisionModule)(ref collision)).sendCollisionMessages = bounce <= 0f;
			if (bounce <= 0f)
			{
				val.AddComponent<DropCollision>().ps = val2;
			}
		}
		ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
		component.renderMode = (ParticleSystemRenderMode)0;
		((Renderer)component).sharedMaterial = mat;
		component.sortingFudge = -2f;
		component.minParticleSize = 0f;
		component.maxParticleSize = 0.5f;
		val2.Play();
		return val2;
	}

	internal void TrackIsland(Agent agent)
	{
		try
		{
			if ((Object)(object)agent == (Object)null || (Object)(object)agent.faction == (Object)null)
			{
				return;
			}
			Island val = ((IslandComponent)agent.faction).island;
			if (!((Object)(object)val == (Object)null))
			{
				if ((Object)(object)val != (Object)(object)island)
				{
					island = val;
					runContainer = val.runContainer;
					hadContainer = (Object)(object)runContainer != (Object)null;
				}
				else if ((Object)(object)runContainer == (Object)null && (Object)(object)val.runContainer != (Object)null)
				{
					runContainer = val.runContainer;
					hadContainer = true;
				}
			}
		}
		catch
		{
		}
	}

	internal void Spurt(Vector3 pos, Vector3 dir, int count, float speed, float spread = 0.6f)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//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)
		//IL_004a: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		if (Active && EnsureReady())
		{
			count = Mathf.RoundToInt((float)count * I);
			if (((Vector3)(ref dir)).sqrMagnitude < 0.0001f)
			{
				dir = Vector3.up;
			}
			((Vector3)(ref dir)).Normalize();
			EmitParams val = default(EmitParams);
			for (int i = 0; i < count; i++)
			{
				Vector3 val2 = dir + Random.insideUnitSphere * spread + Vector3.up * Random.Range(0.1f, 0.7f);
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				((EmitParams)(ref val)).position = pos + Random.insideUnitSphere * 0.02f;
				((EmitParams)(ref val)).velocity = normalized * speed * Random.Range(0.35f, 1.15f);
				((EmitParams)(ref val)).startSize = Random.Range(0.018f, 0.05f) * ((Random.value < 0.12f) ? 1.6f : 1f);
				((EmitParams)(ref val)).startLifetime = Random.Range(1.2f, 2.4f);
				((EmitParams)(ref val)).startColor = BloodCols[Random.Range(0, BloodCols.Length)];
				((EmitParams)(ref val)).rotation = Random.Range(0f, 360f);
				drops.Emit(val, 1);
			}
		}
	}

	internal void Gibs(Vector3 pos, Vector3 dir, int count, float speed)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: 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_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)
		//IL_0062: 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_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_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_0093: 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_00aa: 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_0145: Unknown result type (might be due to invalid IL or missing references)
		if (Active && EnsureReady())
		{
			count = Mathf.RoundToInt((float)count * Mathf.Sqrt(I));
			EmitParams val = default(EmitParams);
			for (int i = 0; i < count; i++)
			{
				Vector3 val2 = ((Vector3)(ref dir)).normalized * 0.6f + Random.insideUnitSphere + Vector3.up * Random.Range(0.5f, 1.3f);
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				((EmitParams)(ref val)).position = pos + Random.insideUnitSphere * 0.04f;
				((EmitParams)(ref val)).velocity = normalized * speed * Random.Range(0.4f, 1.1f);
				((EmitParams)(ref val)).startSize = Random.Range(0.025f, 0.06f);
				((EmitParams)(ref val)).startLifetime = Random.Range(6f, 11f) * Mathf.Clamp(I, 1f, 2f);
				((EmitParams)(ref val)).startColor = FleshCols[Random.Range(0, FleshCols.Length)];
				((EmitParams)(ref val)).rotation = Random.Range(0f, 360f);
				((EmitParams)(ref val)).angularVelocity = Random.Range(-720f, 720f);
				gibs.Emit(val, 1);
			}
		}
	}

	internal void Decapitate(Agent agent, Vector3 neck, Vector3 dir)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_006c: 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_0088: 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_011b: 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_0134: 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_0184: 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_0191: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: 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_0227: Unknown result type (might be due to invalid IL or missing references)
		if (Active && EnsureReady())
		{
			EmitParams val = default(EmitParams);
			Vector3 val2 = ((Vector3)(ref dir)).normalized * 0.5f + Vector3.up * 1.4f + Random.insideUnitSphere * 0.3f;
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			((EmitParams)(ref val)).position = neck + Vector3.up * 0.03f;
			((EmitParams)(ref val)).velocity = normalized * Random.Range(2.2f, 3.2f);
			((EmitParams)(ref val)).startSize = 0.075f * Mathf.Max(0.6f, ((Object)(object)agent != (Object)null) ? agent.scale : 1f);
			((EmitParams)(ref val)).startLifetime = 12f;
			((EmitParams)(ref val)).startColor = SkinCols[Random.Range(0, SkinCols.Length)];
			((EmitParams)(ref val)).rotation = Random.Range(0f, 360f);
			((EmitParams)(ref val)).angularVelocity = Random.Range(-540f, 540f);
			gibs.Emit(val, 1);
			((EmitParams)(ref val)).position = ((EmitParams)(ref val)).position + Vector3.up * 0.02f;
			((EmitParams)(ref val)).startSize = ((EmitParams)(ref val)).startSize * 0.7f;
			((EmitParams)(ref val)).startColor = ((Random.value < 0.5f) ? new Color32((byte)110, (byte)110, (byte)118, byte.MaxValue) : new Color32((byte)150, (byte)95, (byte)40, byte.MaxValue));
			((EmitParams)(ref val)).velocity = ((EmitParams)(ref val)).velocity * 1.05f;
			gibs.Emit(val, 1);
			fountains.Add(new Fountain
			{
				agent = agent,
				pos = neck,
				dir = Vector3.up,
				until = Time.time + Random.Range(1.2f, 2.2f) * Mathf.Clamp(I, 1f, 2f),
				rate = 70f * I
			});
			Spurt(neck, Vector3.up, 26, 2.6f, 0.35f);
		}
	}

	internal void Explode(Vector3 pos, Vector3 dir)
	{
		//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_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		Spurt(pos, dir + Vector3.up, 70, 3.4f, 1.1f);
		Gibs(pos, dir, 16, 2.6f);
		PaintSplash(pos, 0.9f, 5);
	}

	internal void Bleed(Agent agent, Vector3 pos, float seconds, float rate)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		fountains.Add(new Fountain
		{
			agent = agent,
			pos = pos,
			dir = Vector3.up * 0.4f,
			until = Time.time + seconds,
			rate = rate * I
		});
	}

	internal void PaintSplash(Vector3 center, float radius, int stamps)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//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)
		if (Active && BloodGorePlugin.GroundBlood.Value)
		{
			stamps = Mathf.RoundToInt((float)stamps * Mathf.Sqrt(I));
			for (int i = 0; i < stamps; i++)
			{
				Vector2 val = Random.insideUnitCircle * radius;
				paintQueue.Enqueue(new PaintReq
				{
					pos = center + new Vector3(val.x, 0f, val.y),
					size = Random.Range(0.25f, 0.55f),
					decal = (i < 3)
				});
			}
		}
	}

	internal void QueueGroundPaint(Vector3 pos, float size, bool decal)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		if (BloodGorePlugin.GroundBlood.Value && paintQueue.Count <= 200)
		{
			paintQueue.Enqueue(new PaintReq
			{
				pos = pos,
				size = size,
				decal = decal
			});
		}
	}

	internal void ShowToast()
	{
		toastUntil = Time.unscaledTime + 2.5f;
	}

	private void Update()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown(BloodGorePlugin.ToggleKey.Value))
		{
			BloodGorePlugin.Enabled.Value = !BloodGorePlugin.Enabled.Value;
			ShowToast();
			if (!BloodGorePlugin.Enabled.Value)
			{
				ClearAll();
			}
		}
		if (hadContainer && (Object)(object)runContainer == (Object)null)
		{
			hadContainer = false;
			island = null;
			ClearAll();
		}
	}

	private void ClearAll()
	{
		fountains.Clear();
		paintQueue.Clear();
		if ((Object)(object)drops != (Object)null)
		{
			drops.Clear();
		}
		if ((Object)(object)gibs != (Object)null)
		{
			gibs.Clear();
		}
		WaterBlood.ClearAll();
	}

	private void LateUpdate()
	{
		if (!ready || (Object)(object)drops == (Object)null)
		{
			return;
		}
		if (!Active)
		{
			if (drops.particleCount > 0)
			{
				drops.Clear();
			}
			if (gibs.particleCount > 0)
			{
				gibs.Clear();
			}
		}
		else
		{
			UpdateFountains();
			ProcessParticles(drops, isGib: false);
			ProcessParticles(gibs, isGib: true);
			FlushPaint();
		}
	}

	private void UpdateFountains()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_007b: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: 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_00fb: 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_0105: 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_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: 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_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		if (fountains.Count == 0)
		{
			return;
		}
		float time = Time.time;
		EmitParams val = default(EmitParams);
		for (int num = fountains.Count - 1; num >= 0; num--)
		{
			Fountain value = fountains[num];
			if (time > value.until)
			{
				fountains.RemoveAt(num);
			}
			else
			{
				if ((Object)(object)value.agent != (Object)null)
				{
					value.pos = value.agent.chestPos + Vector3.up * 0.06f * value.agent.scale;
				}
				float num2 = 0.55f + 0.45f * Mathf.Abs(Mathf.Sin(time * 9f + (float)num));
				value.acc += value.rate * num2 * Time.deltaTime;
				while (value.acc >= 1f)
				{
					value.acc -= 1f;
					Vector3 val2 = value.dir + Random.insideUnitSphere * 0.35f;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					((EmitParams)(ref val)).position = value.pos;
					((EmitParams)(ref val)).velocity = normalized * Random.Range(0.8f, 2.3f) * (0.5f + num2);
					((EmitParams)(ref val)).startSize = Random.Range(0.015f, 0.04f);
					((EmitParams)(ref val)).startLifetime = Random.Range(1f, 2f);
					((EmitParams)(ref val)).startColor = BloodCols[Random.Range(0, BloodCols.Length)];
					drops.Emit(val, 1);
				}
				fountains[num] = value;
			}
		}
	}

	private void ProcessParticles(ParticleSystem ps, bool isGib)
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: 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_008f: 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_00a2: 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_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: 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_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: 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)
		int particleCount = ps.particleCount;
		if (particleCount == 0)
		{
			return;
		}
		if (buffer.Length < particleCount)
		{
			buffer = (Particle[])(object)new Particle[particleCount * 2];
		}
		particleCount = ps.GetParticles(buffer);
		bool flag = false;
		bool value = BloodGorePlugin.WaterBlood.Value;
		EmitParams val = default(EmitParams);
		int num = 0;
		for (int i = 0; i < particleCount; i++)
		{
			Vector3 position = ((Particle)(ref buffer[i])).position;
			if (position.y < -0.099999994f)
			{
				if (value && ((Particle)(ref buffer[i])).remainingLifetime > 0f)
				{
					WaterBlood.Spill(new Vector3(position.x, -0.105f, position.z), isGib ? 1.6f : 0.35f, runContainer);
				}
				((Particle)(ref buffer[i])).remainingLifetime = -1f;
				flag = true;
			}
			else if (isGib && num < 40)
			{
				Vector3 velocity = ((Particle)(ref buffer[i])).velocity;
				if (((Vector3)(ref velocity)).sqrMagnitude > 0.5f && Random.value < 0.45f)
				{
					num++;
					((EmitParams)(ref val)).position = position;
					((EmitParams)(ref val)).velocity = velocity * 0.15f + Random.insideUnitSphere * 0.2f;
					((EmitParams)(ref val)).startSize = Random.Range(0.012f, 0.028f);
					((EmitParams)(ref val)).startLifetime = Random.Range(0.8f, 1.5f);
					((EmitParams)(ref val)).startColor = BloodCols[Random.Range(0, BloodCols.Length)];
					drops.Emit(val, 1);
				}
			}
		}
		if (flag)
		{
			ps.SetParticles(buffer, particleCount);
		}
	}

	private void FlushPaint()
	{
		//IL_0076: 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_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_008f: 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_00ce: 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_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		if (paintQueue.Count == 0)
		{
			return;
		}
		Island val = island;
		if ((Object)(object)val == (Object)null || (Object)(object)val.painter == (Object)null)
		{
			paintQueue.Clear();
			return;
		}
		int num = 4;
		int num2 = 2;
		SpriteStamp val2 = null;
		try
		{
			object? obj = bloodDecalField?.GetValue(null);
			val2 = (SpriteStamp)((obj is SpriteStamp) ? obj : null);
		}
		catch
		{
		}
		NavPos val3 = default(NavPos);
		while (paintQueue.Count > 0 && num-- > 0)
		{
			PaintReq paintReq = paintQueue.Dequeue();
			try
			{
				val.painter.Paint(new Bounds(paintReq.pos + Vector3.up * 0.15f, Vector3.one * paintReq.size), new Color(0.5f * Mathf.Clamp(I, 0.6f, 1.6f), 0f, 0f, 0f));
				if (!paintReq.decal || num2 <= 0 || !((Object)(object)val2 != (Object)null) || !((Object)(object)val.navMesh != (Object)null))
				{
					continue;
				}
				num2--;
				((NavPos)(ref val3))..ctor(val.navMesh, paintReq.pos, true, 1f);
				if (((NavPos)(ref val3)).valid)
				{
					Vector3 val4 = ((NavPos)(ref val3)).wPos - paintReq.pos;
					if (((Vector3)(ref val4)).sqrMagnitude < 0.09f)
					{
						val2.Stamp(val3, Random.Range(0.6f, 1.4f) * paintReq.size * 2.2f);
					}
				}
			}
			catch (Exception ex)
			{
				BloodGorePlugin.Log.LogDebug((object)("Peinture : " + ex.Message));
				paintQueue.Clear();
				break;
			}
		}
	}

	private void OnGUI()
	{
		//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_0090: 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_00af: 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_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		if (!(Time.unscaledTime > toastUntil))
		{
			if (toastStyle == null)
			{
				toastStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 20,
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				};
				toastStyle.normal.textColor = new Color(1f, 0.85f, 0.85f);
			}
			Rect val = new Rect(((float)Screen.width - 420f) / 2f, 60f, 420f, 40f);
			Color color = GUI.color;
			GUI.color = new Color(0.35f, 0f, 0f, 0.8f);
			GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color;
			GUI.Label(val, "Blood Gore Édition : " + (BloodGorePlugin.Enabled.Value ? "ACTIVÉ" : "désactivé"), toastStyle);
		}
	}
}
public class DropCollision : MonoBehaviour
{
	internal ParticleSystem ps;

	private readonly List<ParticleCollisionEvent> events = new List<ParticleCollisionEvent>();

	private int frame;

	private int budget;

	private void OnParticleCollision(GameObject other)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		GoreFX instance = GoreFX.Instance;
		if ((Object)(object)instance == (Object)null || (Object)(object)ps == (Object)null)
		{
			return;
		}
		if (frame != Time.frameCount)
		{
			frame = Time.frameCount;
			budget = 3;
		}
		if (budget <= 0)
		{
			return;
		}
		int collisionEvents = ParticlePhysicsExtensions.GetCollisionEvents(ps, other, events);
		for (int i = 0; i < collisionEvents; i++)
		{
			if (budget <= 0)
			{
				break;
			}
			ParticleCollisionEvent val = events[i];
			if (!(((ParticleCollisionEvent)(ref val)).normal.y < 0.45f) && !(Random.value > 0.35f))
			{
				budget--;
				val = events[i];
				instance.QueueGroundPaint(((ParticleCollisionEvent)(ref val)).intersection, Random.Range(0.18f, 0.34f), Random.value < 0.25f);
			}
		}
	}
}
public class MenuLogo : MonoBehaviour
{
	private static readonly FieldInfo titleLogo = AccessTools.Field(typeof(AccountLoader), "logoContainer");

	private AccountLoader title;

	private MainMenu mainMenu;

	private RectTransform logo;

	private Rect logoScreen;

	private bool onTitle;

	private bool onMain;

	private float nextCheck;

	private Texture2D tex;

	private bool texTried;

	private float alpha;

	private float drip;

	private Texture2D Tex()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Expected O, but got Unknown
		if ((Object)(object)tex != (Object)null || texTried)
		{
			return tex;
		}
		texTried = true;
		try
		{
			string text = Path.Combine(BloodGorePlugin.ModDir, Path.Combine("textures", "Titre_BloodGore.png"));
			if (File.Exists(text))
			{
				tex = new Texture2D(2, 2, (TextureFormat)4, false);
				ImageConversion.LoadImage(tex, File.ReadAllBytes(text));
				((Texture)tex).filterMode = (FilterMode)1;
				((Texture)tex).wrapMode = (TextureWrapMode)1;
				Object.DontDestroyOnLoad((Object)(object)tex);
			}
			else
			{
				BloodGorePlugin.Log.LogWarning((object)("Logo introuvable : " + text));
			}
		}
		catch (Exception ex)
		{
			BloodGorePlugin.Log.LogWarning((object)("Logo : " + ex.Message));
		}
		return tex;
	}

	private void Update()
	{
		if (Time.unscaledTime < nextCheck)
		{
			return;
		}
		nextCheck = Time.unscaledTime + 0.4f;
		if (!BloodGorePlugin.MenuLogo.Value)
		{
			onTitle = (onMain = false);
			return;
		}
		try
		{
			if ((Object)(object)title == (Object)null)
			{
				title = Object.FindObjectOfType<AccountLoader>();
			}
			if ((Object)(object)mainMenu == (Object)null)
			{
				mainMenu = Object.FindObjectOfType<MainMenu>();
			}
			onTitle = (Object)(object)title != (Object)null && ((UIMenu)title).isOpen && ((Behaviour)title).isActiveAndEnabled;
			onMain = !onTitle && (Object)(object)mainMenu != (Object)null && ((UIMenu)mainMenu).isOpen;
			if (onTitle)
			{
				FindLogo();
			}
		}
		catch
		{
			onTitle = (onMain = false);
		}
	}

	private void FindLogo()
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: 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)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: 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_010a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)logo == (Object)null && (object)titleLogo != null)
		{
			ref RectTransform reference = ref logo;
			object? value = titleLogo.GetValue(title);
			reference = (RectTransform)((value is RectTransform) ? value : null);
		}
		logoScreen = new Rect(0f, 0f, 0f, 0f);
		if (!((Object)(object)logo == (Object)null))
		{
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			logo.GetWorldCorners(array);
			Canvas componentInParent = ((Component)logo).GetComponentInParent<Canvas>();
			Camera obj = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
			Vector2 val = RectTransformUtility.WorldToScreenPoint(obj, array[0]);
			Vector2 val2 = RectTransformUtility.WorldToScreenPoint(obj, array[2]);
			logoScreen = Rect.MinMaxRect(Mathf.Min(val.x, val2.x), (float)Screen.height - Mathf.Max(val.y, val2.y), Mathf.Max(val.x, val2.x), (float)Screen.height - Mathf.Min(val.y, val2.y));
		}
	}

	private void OnGUI()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Invalid comparison between Unknown and I4
		//IL_01ef: 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_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		bool flag = (onTitle || onMain) && BloodGorePlugin.MenuLogo.Value;
		alpha = Mathf.MoveTowards(alpha, flag ? 1f : 0f, Time.unscaledDeltaTime * 2.5f);
		if (alpha <= 0f || (int)Event.current.type != 7)
		{
			return;
		}
		Texture2D val = Tex();
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		float num = (float)((Texture)val).width / (float)((Texture)val).height;
		float value = BloodGorePlugin.MenuLogoScale.Value;
		Rect val2 = default(Rect);
		if (onTitle)
		{
			float num2 = (float)Screen.height * 0.12f * value;
			float num3 = num2 * num;
			if (num3 > (float)Screen.width * 0.7f)
			{
				num3 = (float)Screen.width * 0.7f;
				num2 = num3 / num;
			}
			float num4 = ((((Rect)(ref logoScreen)).width > 1f) ? ((Rect)(ref logoScreen)).center.x : ((float)Screen.width / 2f));
			float num5 = ((((Rect)(ref logoScreen)).height > 1f) ? (((Rect)(ref logoScreen)).yMax - num2 * 0.12f) : ((float)Screen.height * 0.32f));
			drip = Mathf.MoveTowards(drip, 1f, Time.unscaledDeltaTime * 0.8f);
			num5 -= (1f - Mathf.SmoothStep(0f, 1f, drip)) * num2 * 0.25f;
			((Rect)(ref val2))..ctor(num4 - num3 / 2f, num5, num3, num2);
		}
		else
		{
			drip = 0f;
			float num6 = (float)Screen.height * 0.085f * value;
			float num7 = num6 * num;
			((Rect)(ref val2))..ctor((float)Screen.width - num7 - (float)Screen.height * 0.02f, (float)Screen.height * 0.02f, num7, num6);
		}
		Color color = GUI.color;
		GUI.color = new Color(1f, 1f, 1f, alpha);
		GUI.DrawTexture(val2, (Texture)(object)val, (ScaleMode)2, true);
		GUI.color = color;
	}
}
[HarmonyPatch(typeof(Agent), "DealDamage")]
internal static class Patch_DealDamage
{
	private static void Prefix(Agent __instance, out bool __state)
	{
		__state = (Object)(object)__instance != (Object)null && __instance.aliveState != null && __instance.aliveState.active;
	}

	private static void Postfix(Agent __instance, Attack attack, bool __result, bool __state)
	{
		//IL_0024: 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_0062: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//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_0088: 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_00ae: 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_00a1: 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_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GoreFX instance = GoreFX.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)__instance == (Object)null || !GoreFX.Active || attack.ignore)
			{
				return;
			}
			instance.TrackIsland(__instance);
			float num = Mathf.Max(0.5f, __instance.scale);
			Vector3 dir = ((((Vector3)(ref attack.direction)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref attack.direction)).normalized : ((Component)__instance).transform.forward);
			Vector3 val = attack.pos;
			Vector3 chestPos = __instance.chestPos;
			Vector3 val2 = val - chestPos;
			if (((Vector3)(ref val2)).sqrMagnitude > 0.25f * num * num || val == Vector3.zero)
			{
				val = chestPos;
			}
			if (!__state)
			{
				if (((Attack)(ref attack)).damage > 0f)
				{
					instance.Spurt(val, dir, 6, 1.6f);
				}
			}
			else if (__result)
			{
				OnKill(instance, __instance, attack, val, dir, num);
			}
			else if (((Attack)(ref attack)).damage > 0f)
			{
				float num2 = Mathf.Clamp(((Attack)(ref attack)).damage * 3f + ((Attack)(ref attack)).knockback * 0.5f, 0.6f, 2.5f);
				instance.Spurt(val, dir, Mathf.RoundToInt(10f + 8f * num2), 1.6f + 0.6f * num2);
				if (Random.value < 0.3f)
				{
					instance.Gibs(val, dir, 1, 1.4f);
				}
			}
		}
		catch (Exception ex)
		{
			BloodGorePlugin.Log.LogDebug((object)("DealDamage : " + ex.Message));
		}
	}

	private static void OnKill(GoreFX fx, Agent agent, Attack attack, Vector3 hit, Vector3 dir, float sc)
	{
		//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_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_0106: 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_0116: 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_009b: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: 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)
		fx.Spurt(hit, dir, 45, 2.8f, 0.8f);
		fx.Spurt(hit, -dir * 0.3f + Vector3.up, 15, 1.6f, 0.9f);
		if (((Attack)(ref attack)).launchImpulse >= 1.5f || ((Attack)(ref attack)).damage >= 3f || ((Attack)(ref attack)).knockback >= 8f)
		{
			fx.Explode(agent.chestPos, dir);
		}
		else if (Random.value < BloodGorePlugin.DismemberChance.Value)
		{
			Vector3 neck = agent.chestPos + Vector3.up * 0.07f * sc;
			if (Random.value < 0.6f)
			{
				fx.Decapitate(agent, neck, dir);
				return;
			}
			fx.Gibs(hit, dir, 6, 2.2f);
			fx.Spurt(hit, dir, 25, 2.2f, 1f);
			fx.Bleed(agent, hit, 1.6f, 35f);
		}
		else
		{
			fx.Gibs(hit, dir, 2, 1.6f);
			fx.Bleed(agent, hit, 1f, 18f);
		}
	}
}
[HarmonyPatch(typeof(Death), "Die", new Type[] { typeof(NavPos) })]
internal static class Patch_DeathDie
{
	private static void Prefix(Death __instance)
	{
		//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_0048: 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_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GoreFX instance = GoreFX.Instance;
			if (!((Object)(object)instance == (Object)null) && !((Object)(object)__instance == (Object)null) && GoreFX.Active)
			{
				Agent component = ((Component)__instance).GetComponent<Agent>();
				if ((Object)(object)component != (Object)null)
				{
					instance.TrackIsland(component);
				}
				Vector3 position = ((Component)__instance).transform.position;
				instance.Spurt(position + Vector3.up * 0.03f, Vector3.up, 14, 1.1f, 1.2f);
				instance.PaintSplash(position, 0.35f, 4);
				if (position.y < 0.12f && BloodGorePlugin.WaterBlood.Value)
				{
					WaterBlood.Spill(new Vector3(position.x, -0.105f, position.z) + new Vector3(Random.Range(-0.15f, 0.15f), 0f, Random.Range(-0.15f, 0.15f)), 2f, instance.Container);
				}
			}
		}
		catch (Exception ex)
		{
			BloodGorePlugin.Log.LogDebug((object)("Death.Die : " + ex.Message));
		}
	}
}
[HarmonyPatch(typeof(Ragdoller), "Smash")]
internal static class Patch_RagdollSmash
{
	private static void Prefix(Ragdoller __instance, Collision collision)
	{
		//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_0044: 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_0083: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		try
		{
			GoreFX instance = GoreFX.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)__instance == (Object)null || !GoreFX.Active)
			{
				return;
			}
			Agent component = ((Component)__instance).GetComponent<Agent>();
			if (!((Object)(object)component == (Object)null))
			{
				instance.TrackIsland(component);
				Vector3 pos = component.chestPos;
				Vector3 dir = Vector3.up;
				if (collision != null && collision.contacts != null && collision.contacts.Length != 0)
				{
					pos = ((ContactPoint)(ref collision.contacts[0])).point;
					dir = ((ContactPoint)(ref collision.contacts[0])).normal;
				}
				instance.Explode(pos, dir);
			}
		}
		catch (Exception ex)
		{
			BloodGorePlugin.Log.LogDebug((object)("Smash : " + ex.Message));
		}
	}
}
[HarmonyPatch(typeof(Agent), "FinalDeath")]
internal static class Patch_FinalDeath
{
	private static void Prefix(Agent __instance)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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_008c: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GoreFX instance = GoreFX.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)__instance == (Object)null || !GoreFX.Active || !BloodGorePlugin.WaterBlood.Value)
			{
				return;
			}
			Vector3 position = ((Component)__instance).transform.position;
			if (!(position.y > -0.06f) && ((__instance.deadState != null && __instance.deadState.active) || !((NavPos)(ref __instance.navPos)).valid))
			{
				instance.TrackIsland(__instance);
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(position.x, -0.105f, position.z);
				WaterBlood.Spill(val, 3.5f, instance.Container);
				for (int i = 0; i < 2; i++)
				{
					Vector2 val2 = Random.insideUnitCircle * 0.25f;
					WaterBlood.Spill(val + new Vector3(val2.x, 0f, val2.y), 1.2f, instance.Container);
				}
				instance.Spurt(val + Vector3.up * 0.02f, Vector3.up, 18, 1.4f, 0.9f);
			}
		}
		catch (Exception ex)
		{
			BloodGorePlugin.Log.LogDebug((object)("FinalDeath : " + ex.Message));
		}
	}
}
[HarmonyPatch(typeof(ShaderConstants), "SetColors")]
internal static class Patch_BloodColor
{
	private static void Postfix()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		if (BloodGorePlugin.Enabled.Value && BloodGorePlugin.DarkBlood.Value)
		{
			Shader.SetGlobalVector("_BloodColor", Color.op_Implicit(BloodGorePlugin.BloodColor.Value));
		}
	}
}
public class WaterBlood : MonoBehaviour
{
	private const int MaxSlicks = 160;

	private static readonly List<WaterBlood> live = new List<WaterBlood>();

	private static Sprite[] sprites;

	private static Material material;

	private SpriteRenderer sr;

	private float born;

	private float strength;

	private float targetSize;

	private float size;

	private float spin;

	private float seed;

	public static void Spill(Vector3 pos, float amount, Transform parent)
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Expected O, but got Unknown
		//IL_0154: 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_0175: 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)
		if (!GoreFX.Active || !BloodGorePlugin.WaterBlood.Value)
		{
			return;
		}
		amount *= Mathf.Sqrt(BloodGorePlugin.Intensity.Value);
		for (int num = live.Count - 1; num >= 0; num--)
		{
			WaterBlood waterBlood = live[num];
			if ((Object)(object)waterBlood == (Object)null)
			{
				live.RemoveAt(num);
			}
			else
			{
				Vector3 val = ((Component)waterBlood).transform.position - pos;
				val.y = 0f;
				float num2 = waterBlood.size * 0.45f + 0.06f;
				if (((Vector3)(ref val)).sqrMagnitude < num2 * num2 && Time.time - waterBlood.born < BloodGorePlugin.WaterBloodDuration.Value * 0.6f)
				{
					waterBlood.Feed(amount);
					return;
				}
			}
		}
		if (live.Count >= 160)
		{
			WaterBlood waterBlood2 = live[0];
			live.RemoveAt(0);
			if ((Object)(object)waterBlood2 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)waterBlood2).gameObject);
			}
		}
		EnsureAssets();
		GameObject val2 = new GameObject("BloodGore_WaterSlick");
		int id = LayerMaster.blood.id;
		if (id >= 0)
		{
			val2.layer = id;
		}
		if ((Object)(object)parent != (Object)null)
		{
			val2.transform.SetParent(parent, true);
		}
		val2.transform.position = new Vector3(pos.x, -0.100999996f + Random.Range(0f, 0.003f), pos.z);
		val2.transform.rotation = Quaternion.Euler(90f, Random.Range(0f, 360f), 0f);
		WaterBlood waterBlood3 = val2.AddComponent<WaterBlood>();
		waterBlood3.sr = val2.AddComponent<SpriteRenderer>();
		waterBlood3.sr.sprite = sprites[Random.Range(0, sprites.Length)];
		if ((Object)(object)material != (Object)null)
		{
			((Renderer)waterBlood3.sr).sharedMaterial = material;
		}
		((Renderer)waterBlood3.sr).sortingOrder = 40;
		waterBlood3.born = Time.time;
		waterBlood3.seed = Random.value * 10f;
		waterBlood3.spin = Random.Range(-4f, 4f);
		waterBlood3.size = 0.05f;
		waterBlood3.strength = 0f;
		waterBlood3.targetSize = 0f;
		waterBlood3.Feed(amount);
		waterBlood3.Apply();
		live.Add(waterBlood3);
	}

	public static void ClearAll()
	{
		foreach (WaterBlood item in live)
		{
			if ((Object)(object)item != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
		}
		live.Clear();
	}

	private void Feed(float amount)
	{
		strength = Mathf.Min(strength + amount, 6f);
		targetSize = Mathf.Min(0.25f + 0.32f * Mathf.Sqrt(strength), 1.4f);
		born = Mathf.Max(born, Time.time - 3f);
	}

	private void Update()
	{
		float value = BloodGorePlugin.WaterBloodDuration.Value;
		float num = Time.time - born;
		if (num > value || !GoreFX.Active)
		{
			live.Remove(this);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
		else
		{
			size = Mathf.Lerp(size, targetSize * (1f + 0.6f * num / value), Time.deltaTime * 1.6f);
			((Component)this).transform.Rotate(0f, 0f, spin * Time.deltaTime, (Space)1);
			Apply();
		}
	}

	private void Apply()
	{
		//IL_0057: 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_00ba: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		float value = BloodGorePlugin.WaterBloodDuration.Value;
		float num = Time.time - born;
		float num2 = 1f + 0.04f * Mathf.Sin(Time.time * 1.3f + seed);
		((Component)this).transform.localScale = new Vector3(size * num2, size / num2, 1f) / SafeLossy();
		float num3 = Mathf.Clamp01(num / 0.6f);
		float num4 = 1f - Mathf.Clamp01((num - value * 0.45f) / (value * 0.55f));
		float num5 = Mathf.Clamp01(0.35f + 0.12f * strength) * num3 * num4;
		Color value2 = BloodGorePlugin.BloodColor.Value;
		value2 = Color.Lerp(value2, new Color(0.32f, 0.04f, 0.05f), Mathf.Clamp01(num / value));
		value2.a = num5 * 0.85f;
		sr.color = value2;
	}

	private float SafeLossy()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		Transform parent = ((Component)this).transform.parent;
		if ((Object)(object)parent == (Object)null)
		{
			return 1f;
		}
		float x = parent.lossyScale.x;
		if (!(Mathf.Abs(x) < 0.0001f))
		{
			return x;
		}
		return 1f;
	}

	private void OnDestroy()
	{
		live.Remove(this);
	}

	private static void EnsureAssets()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		if (sprites == null)
		{
			sprites = (Sprite[])(object)new Sprite[4];
			for (int i = 0; i < sprites.Length; i++)
			{
				sprites[i] = MakeSlickSprite(1000 + i * 37);
			}
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val != (Object)null)
			{
				material = new Material(val)
				{
					name = "BloodGore_Water",
					renderQueue = 3100
				};
				Object.DontDestroyOnLoad((Object)(object)material);
			}
		}
	}

	private static Sprite MakeSlickSprite(int seed)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		State state = Random.state;
		Random.InitState(seed);
		Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
		{
			wrapMode = (TextureWrapMode)1,
			filterMode = (FilterMode)1,
			name = "BloodGore_Slick" + seed
		};
		float[] array = new float[7];
		float[] array2 = new float[7];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = Random.Range(0.02f, 0.11f) / (1f + (float)i * 0.4f);
			array2[i] = Random.Range(0f, 6.283f);
		}
		Vector3[] array3 = (Vector3[])(object)new Vector3[6];
		for (int j = 0; j < array3.Length; j++)
		{
			float num = Random.Range(0f, 6.283f);
			float num2 = Random.Range(0.55f, 0.8f);
			array3[j] = new Vector3(Mathf.Cos(num) * num2, Mathf.Sin(num) * num2, Random.Range(0.06f, 0.14f));
		}
		Color32[] array4 = (Color32[])(object)new Color32[16384];
		for (int k = 0; k < 128; k++)
		{
			for (int l = 0; l < 128; l++)
			{
				float num3 = ((float)l + 0.5f) / 128f * 2f - 1f;
				float num4 = ((float)k + 0.5f) / 128f * 2f - 1f;
				float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4);
				float num6 = Mathf.Atan2(num4, num3);
				float num7 = 0.62f;
				for (int m = 0; m < array.Length; m++)
				{
					num7 += array[m] * Mathf.Sin(num6 * (float)(m + 2) + array2[m]);
				}
				float num8 = Mathf.Clamp01((num7 - num5) / 0.12f);
				for (int n = 0; n < array3.Length; n++)
				{
					float num9 = Mathf.Sqrt((num3 - array3[n].x) * (num3 - array3[n].x) + (num4 - array3[n].y) * (num4 - array3[n].y));
					num8 = Mathf.Max(num8, Mathf.Clamp01((array3[n].z - num9) / 0.05f) * 0.8f);
				}
				float num10 = 0.85f + 0.15f * Mathf.PerlinNoise(num3 * 4f + (float)seed, num4 * 4f);
				num8 *= Mathf.Lerp(0.55f, 1f, Mathf.Clamp01(1f - num5 / Mathf.Max(num7, 0.01f))) * num10;
				byte b = (byte)(255f * (0.85f + 0.15f * num10));
				array4[k * 128 + l] = new Color32(b, b, b, (byte)(255f * Mathf.Clamp01(num8)));
			}
		}
		val.SetPixels32(array4);
		val.Apply(false, false);
		Object.DontDestroyOnLoad((Object)(object)val);
		Random.state = state;
		Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 128f);
		Object.DontDestroyOnLoad((Object)(object)obj);
		return obj;
	}
}