Decompiled source of BarraVida v1.0.0

plugins\BarraVida.dll

Decompiled 8 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("BarraVida")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BarraVida")]
[assembly: AssemblyTitle("BarraVida")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BarraVida
{
	internal enum HpDamageKind
	{
		UnknownInstant,
		BlackHoleInstant,
		EnvironmentInstant,
		SmokeNoDamage,
		Grenade,
		Bow,
		Rock,
		Missile,
		Spike,
		Roll,
		Meteor,
		Mine,
		Drill,
		Beam
	}
	internal static class DamageTable
	{
		public static int ResolveGrenadeDamage(float dist)
		{
			if (dist <= 1.15f)
			{
				return 5;
			}
			if (dist <= 2.6f)
			{
				return 2;
			}
			return 1;
		}

		public static int GetFlatDamage(HpDamageKind kind)
		{
			return kind switch
			{
				HpDamageKind.Bow => 2, 
				HpDamageKind.Rock => 5, 
				HpDamageKind.Missile => 5, 
				HpDamageKind.Spike => 4, 
				HpDamageKind.Roll => 2, 
				HpDamageKind.Meteor => 5, 
				HpDamageKind.Mine => 5, 
				HpDamageKind.Drill => 3, 
				HpDamageKind.Beam => 3, 
				_ => 0, 
			};
		}

		public static bool GrantsIFrames(HpDamageKind kind)
		{
			if (kind != HpDamageKind.Roll && kind != HpDamageKind.UnknownInstant && kind != HpDamageKind.BlackHoleInstant)
			{
				return kind != HpDamageKind.EnvironmentInstant;
			}
			return false;
		}

		public static bool IsHpDamage(HpDamageKind kind)
		{
			if (kind != HpDamageKind.Grenade && kind != HpDamageKind.Bow && kind != HpDamageKind.Rock && kind != HpDamageKind.Missile && kind != HpDamageKind.Spike && kind != HpDamageKind.Roll && kind != HpDamageKind.Meteor && kind != HpDamageKind.Mine && kind != HpDamageKind.Drill)
			{
				return kind == HpDamageKind.Beam;
			}
			return true;
		}
	}
	internal static class DamageSourceId
	{
		public static HpDamageKind Identify(GameObject go, out float grenadeDist, PlayerCollision victim)
		{
			grenadeDist = 0f;
			if ((Object)(object)go == (Object)null)
			{
				return HpDamageKind.UnknownInstant;
			}
			if ((Object)(object)go.GetComponentInParent<BlackHole>() != (Object)null || (Object)(object)go.GetComponent<BlackHole>() != (Object)null)
			{
				return HpDamageKind.BlackHoleInstant;
			}
			if ((Object)(object)go.GetComponentInParent<SmokeGrenadeExplode2>() != (Object)null || (Object)(object)go.GetComponentInParent<FlammableSmoke>() != (Object)null || (Object)(object)go.GetComponent<FlammableSmoke>() != (Object)null || NameHas(go, "Smoke") || NameHas(go, "FlammableSmoke"))
			{
				return HpDamageKind.SmokeNoDamage;
			}
			if ((Object)(object)go.GetComponentInParent<BeamObject>() != (Object)null || (Object)(object)go.GetComponentInParent<Beam>() != (Object)null || NameHas(go, "Beam"))
			{
				return HpDamageKind.Beam;
			}
			if ((Object)(object)go.GetComponentInParent<Mine>() != (Object)null || NameHas(go, "Mine"))
			{
				return HpDamageKind.Mine;
			}
			if ((Object)(object)go.GetComponentInParent<Missile>() != (Object)null || NameHas(go, "Missile"))
			{
				return HpDamageKind.Missile;
			}
			if ((Object)(object)go.GetComponentInParent<SpikeAttack>() != (Object)null || (Object)(object)go.GetComponentInParent<Spike>() != (Object)null || NameHas(go, "Spike"))
			{
				return HpDamageKind.Spike;
			}
			if (NameHas(go, "Arrow") || NameHas(go, "Bow") || (Object)(object)go.GetComponentInParent<BowTransform>() != (Object)null)
			{
				return HpDamageKind.Bow;
			}
			Ability val = go.GetComponentInParent<Ability>() ?? go.GetComponent<Ability>();
			if ((Object)(object)go.GetComponentInParent<Roll>() != (Object)null || NameHas(go, "Roll") || ((Object)(object)val != (Object)null && NameHas(((Component)val).gameObject, "Roll")))
			{
				return HpDamageKind.Roll;
			}
			if ((Object)(object)go.GetComponentInParent<MeteorSmash>() != (Object)null || NameHas(go, "Meteor"))
			{
				return HpDamageKind.Meteor;
			}
			if ((Object)(object)go.GetComponentInParent<Drill>() != (Object)null || NameHas(go, "Drill"))
			{
				return HpDamageKind.Drill;
			}
			if (NameHas(go, "Rock") || ((Object)(object)val != (Object)null && NameHas(((Component)val).gameObject, "Rock")))
			{
				return HpDamageKind.Rock;
			}
			if (((Object)(object)go.GetComponentInParent<GrenadeExplode>() != (Object)null || (Object)(object)go.GetComponentInParent<Explosion>() != (Object)null || go.layer == LayerMask.NameToLayer("Explosion") || NameHas(go, "Grenade") || NameHas(go, "Explosion")) && !NameHas(go, "Smoke"))
			{
				grenadeDist = EstimateDistance(go, victim);
				return HpDamageKind.Grenade;
			}
			if (go.layer == LayerMask.NameToLayer("Player") && (Object)(object)val != (Object)null && val.KillPlayersOnContact)
			{
				return HpDamageKind.Rock;
			}
			return HpDamageKind.UnknownInstant;
		}

		private static bool NameHas(GameObject go, string token)
		{
			if ((Object)(object)go != (Object)null)
			{
				return ((Object)go).name.IndexOf(token, StringComparison.OrdinalIgnoreCase) >= 0;
			}
			return false;
		}

		private static float EstimateDistance(GameObject source, PlayerCollision victim)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerBody val = (((Object)(object)victim != (Object)null) ? ((Component)victim).GetComponent<PlayerBody>() : null);
				if ((Object)(object)val == (Object)null || (Object)(object)source == (Object)null)
				{
					return 2f;
				}
				Vector3 position = source.transform.position;
				Vec2 position2 = val.position;
				float num = position.x - (float)position2.x;
				float num2 = position.y - (float)position2.y;
				return Mathf.Sqrt(num * num + num2 * num2);
			}
			catch
			{
				return 2f;
			}
		}
	}
	internal class HealthHud : MonoBehaviour
	{
		private Texture2D _white;

		private Texture2D _circle;

		private Texture2D _boplMaster;

		private readonly Dictionary<int, Texture2D> _boplByColor = new Dictionary<int, Texture2D>();

		private GUIStyle _hpStyle;

		private GUIStyle _hpShadow;

		private static readonly Color BlueBorder = new Color(0.1f, 0.32f, 0.62f, 1f);

		private static readonly Color BlueFill = new Color(0.45f, 0.78f, 1f, 1f);

		private static readonly Color BlueFillDeep = new Color(0.32f, 0.62f, 0.95f, 1f);

		private static readonly Color BarTrack = new Color(0.15f, 0.35f, 0.55f, 0.9f);

		private static readonly Color BarGreen = new Color(0.32f, 0.9f, 0.4f, 1f);

		private static readonly Color BarRed = new Color(0.95f, 0.3f, 0.28f, 1f);

		private void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			_white = Solid(Color.white);
			_circle = MakeCircle(128);
			_boplMaster = LoadMasterBopl();
		}

		private void OnGUI()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type != 7 && (int)Event.current.type != 8)
			{
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			string text = ((Scene)(ref activeScene)).name ?? "";
			if (text.IndexOf("CharacterSelect", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("ChSelect", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("MainMenu", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return;
			}
			PlayerHandler val = PlayerHandler.Get();
			if (val == null)
			{
				return;
			}
			List<Player> list;
			try
			{
				list = val.PlayerList();
			}
			catch
			{
				return;
			}
			if (list == null || list.Count == 0)
			{
				return;
			}
			EnsureStyles();
			if ((Object)(object)_boplMaster == (Object)null)
			{
				_boplMaster = LoadMasterBopl();
			}
			int num = 0;
			foreach (Player item in list)
			{
				if (item != null)
				{
					num++;
				}
			}
			if (num == 0)
			{
				return;
			}
			float num2 = 58f;
			float num3 = 148f;
			float barH = 24f;
			float num4 = 66f;
			float num5 = num2 * 0.55f + num3 + 28f;
			float num6 = 12f;
			float num7 = (float)num * num5 + (float)(num - 1) * num6;
			float num8 = ((float)Screen.width - num7) * 0.5f;
			float num9 = (float)Screen.height - num4 - 14f;
			float num10 = num8;
			foreach (Player item2 in list)
			{
				if (item2 != null)
				{
					PlayerHealth playerHealth = PlayerHealth.Find(item2.Id);
					int num11 = (((Object)(object)playerHealth != (Object)null) ? playerHealth.Hp : (item2.IsAlive ? 10 : 0));
					if (!item2.IsAlive && ((Object)(object)playerHealth == (Object)null || playerHealth.Hp <= 0))
					{
						num11 = 0;
					}
					Color playerColor = GetPlayerColor(item2);
					float pct = Mathf.Clamp01((float)num11 / 10f);
					float a = ((num11 <= 0) ? 0.55f : 1f);
					DrawChip(new Rect(num10, num9, num5, num4), num2, num3, barH, playerColor, num11, pct, a);
					num10 += num5 + num6;
				}
			}
		}

		private void DrawChip(Rect chip, float face, float barW, float barH, Color playerCol, int hp, float pct, float a)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0034: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_005a: 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_00cc: 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_0127: 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_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_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: 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_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: 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_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: 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_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			DrawPill(Offset(chip, 2.5f, 3.5f), new Color(0f, 0f, 0f, 0.3f * a));
			DrawPill(chip, MulA(BlueBorder, a));
			Rect r = Inset(chip, 3.5f);
			DrawPill(r, MulA(BlueFill, a));
			DrawPill(new Rect(((Rect)(ref r)).x + 8f, ((Rect)(ref r)).y + ((Rect)(ref r)).height * 0.55f, ((Rect)(ref r)).width - 16f, ((Rect)(ref r)).height * 0.4f), new Color(BlueFillDeep.r, BlueFillDeep.g, BlueFillDeep.b, 0.35f * a));
			DrawPill(new Rect(((Rect)(ref r)).x + 10f, ((Rect)(ref r)).y + 4f, ((Rect)(ref r)).width - 20f, ((Rect)(ref r)).height * 0.22f), new Color(1f, 1f, 1f, 0.28f * a));
			float num = ((Rect)(ref chip)).x + 4f;
			float num2 = ((Rect)(ref chip)).y + (((Rect)(ref chip)).height - face) * 0.5f + 1f;
			Texture2D coloredBopl = GetColoredBopl(playerCol);
			if ((Object)(object)coloredBopl != (Object)null)
			{
				Color color = GUI.color;
				GUI.color = new Color(1f, 1f, 1f, a);
				GUI.DrawTexture(new Rect(num, num2, face, face), (Texture)(object)coloredBopl, (ScaleMode)2, true);
				GUI.color = color;
			}
			float num3 = num + face * 0.72f;
			float num4 = ((Rect)(ref chip)).y + (((Rect)(ref chip)).height - barH) * 0.5f;
			float num5 = ((Rect)(ref chip)).xMax - 12f - num3;
			DrawPill(new Rect(num3 - 2f, num4 - 2f, num5 + 4f, barH + 4f), MulA(BlueBorder, a));
			DrawPill(new Rect(num3, num4, num5, barH), MulA(BarTrack, a));
			if (pct > 0.001f)
			{
				Color c = Color.Lerp(BarRed, BarGreen, pct);
				float num6 = Mathf.Clamp((num5 - 4f) * pct, barH * 0.6f, num5 - 4f);
				DrawPill(new Rect(num3 + 2f, num4 + 2f, num6, barH - 4f), MulA(c, a));
				DrawPill(new Rect(num3 + 5f, num4 + 3f, Mathf.Max(0f, num6 - 8f), (barH - 4f) * 0.36f), new Color(1f, 1f, 1f, 0.4f * a));
			}
			string text = $"{hp}/{10}";
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(num3 + 10f, num4 - 1f, num5 - 12f, barH + 2f);
			Color color2 = GUI.color;
			GUI.color = new Color(1f, 1f, 1f, a);
			GUI.Label(new Rect(((Rect)(ref val)).x + 1f, ((Rect)(ref val)).y + 1f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), text, _hpShadow);
			GUI.Label(val, text, _hpStyle);
			GUI.color = color2;
		}

		private Texture2D GetColoredBopl(Color body)
		{
			//IL_0010: 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)
			if ((Object)(object)_boplMaster == (Object)null)
			{
				return null;
			}
			int key = ColorKey(body);
			if (_boplByColor.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Texture2D val = RecolorBody(_boplMaster, body);
			_boplByColor[key] = val;
			return val;
		}

		private static Texture2D RecolorBody(Texture2D src, Color body)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0026: 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_002d: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_008f: 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_0056: 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_00f4: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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_0177: 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_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: 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_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_01b6: Unknown result type (might be due to invalid IL or missing references)
			int width = ((Texture)src).width;
			int height = ((Texture)src).height;
			Texture2D val = new Texture2D(width, height, (TextureFormat)4, false);
			Color[] pixels = src.GetPixels();
			for (int i = 0; i < pixels.Length; i++)
			{
				Color val2 = pixels[i];
				if (val2.a < 0.05f)
				{
					pixels[i] = new Color(0f, 0f, 0f, 0f);
					continue;
				}
				float num = Mathf.Max(val2.r, Mathf.Max(val2.g, val2.b));
				float num2 = Mathf.Min(val2.r, Mathf.Min(val2.g, val2.b));
				float num3 = num - num2;
				bool flag = num < 0.38f && num3 < 0.25f;
				bool flag2 = num2 > 0.82f && num3 < 0.2f;
				bool flag3 = num < 0.25f;
				bool flag4 = num2 > 0.9f && num3 < 0.12f && val2.a > 0.3f;
				bool flag5 = val2.r > 0.7f && val2.g < 0.55f && val2.b < 0.55f && val2.r > val2.g;
				bool flag6 = val2.r > 0.55f && val2.g > 0.45f && val2.b < 0.55f && val2.r + val2.g > val2.b * 2.1f;
				if (!(flag || flag3) && !(flag2 || flag4) && !flag5 && (flag6 || (!flag && num3 > 0.15f && val2.b < 0.6f)))
				{
					float num4 = Mathf.Clamp01(0.55f + 0.45f * num);
					pixels[i] = new Color(body.r * num4, body.g * num4, body.b * num4, val2.a);
				}
			}
			val.SetPixels(pixels);
			val.Apply(false, false);
			((Texture)val).filterMode = (FilterMode)1;
			return val;
		}

		private static int ColorKey(Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return ((int)(c.r * 255f) << 16) | ((int)(c.g * 255f) << 8) | (int)(c.b * 255f);
		}

		private void DrawPill(Rect r, Color c)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Rect)(ref r)).width < 1f) && !(((Rect)(ref r)).height < 1f))
			{
				float num = Mathf.Min(((Rect)(ref r)).height * 0.5f, ((Rect)(ref r)).width * 0.5f);
				DrawRect(new Rect(((Rect)(ref r)).x + num, ((Rect)(ref r)).y, Mathf.Max(0f, ((Rect)(ref r)).width - num * 2f), ((Rect)(ref r)).height), c);
				DrawCircleTex(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, num * 2f, ((Rect)(ref r)).height), c);
				DrawCircleTex(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - num * 2f, ((Rect)(ref r)).y, num * 2f, ((Rect)(ref r)).height), c);
			}
		}

		private void DrawCircleTex(Rect r, Color c)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)_circle, (ScaleMode)0, true);
			GUI.color = color;
		}

		private void DrawRect(Rect r, Color c)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)_white);
			GUI.color = color;
		}

		private static Rect Inset(Rect r, float i)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref r)).x + i, ((Rect)(ref r)).y + i, ((Rect)(ref r)).width - i * 2f, ((Rect)(ref r)).height - i * 2f);
		}

		private static Rect Offset(Rect r, float x, float y)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref r)).x + x, ((Rect)(ref r)).y + y, ((Rect)(ref r)).width, ((Rect)(ref r)).height);
		}

		private static Color MulA(Color c, float a)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			return new Color(c.r, c.g, c.b, c.a * a);
		}

		private void EnsureStyles()
		{
			//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_0021: 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_0034: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (_hpStyle == null)
			{
				_hpStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 17,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				_hpStyle.normal.textColor = new Color(0.08f, 0.16f, 0.28f, 1f);
				_hpShadow = new GUIStyle(_hpStyle);
				_hpShadow.normal.textColor = new Color(1f, 1f, 1f, 0.4f);
			}
		}

		private static Texture2D LoadMasterBopl()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			try
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BarraVida.Sprites.BoplHud.png");
				if (stream != null)
				{
					using MemoryStream memoryStream = new MemoryStream();
					stream.CopyTo(memoryStream);
					Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
					if (ImageConversion.LoadImage(val, memoryStream.ToArray(), false))
					{
						((Texture)val).filterMode = (FilterMode)1;
						Plugin.Log.LogInfo((object)$"BarraVida: Bopl master {((Texture)val).width}x{((Texture)val).height}");
						return val;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("embed: " + ex.Message));
			}
			try
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				string[] array = new string[2]
				{
					Path.Combine(directoryName, "Sprites", "BoplHud.png"),
					Path.Combine(directoryName, "BoplHud.png")
				};
				foreach (string path in array)
				{
					if (File.Exists(path))
					{
						Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false);
						if (ImageConversion.LoadImage(val2, File.ReadAllBytes(path), false))
						{
							((Texture)val2).filterMode = (FilterMode)1;
							return val2;
						}
					}
				}
			}
			catch
			{
			}
			Plugin.Log.LogError((object)"BarraVida: BoplHud.png missing");
			return null;
		}

		private static Texture2D MakeCircle(int size)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0021: 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_0078: 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;
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num2 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num, num)) / num;
					float num3 = ((num2 <= 0.9f) ? 1f : Mathf.Clamp01(1f - (num2 - 0.9f) / 0.1f));
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num3 * num3));
				}
			}
			val.Apply(false, false);
			((Texture)val).filterMode = (FilterMode)1;
			return val;
		}

		private static Color GetPlayerColor(Player p)
		{
			//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_0083: 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_00ad: 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_004f: 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_00c8: 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)
			try
			{
				Material color = p.Color;
				if ((Object)(object)color != (Object)null)
				{
					if (color.HasProperty("_MainColor"))
					{
						return color.GetColor("_MainColor");
					}
					if (color.HasProperty("_Color"))
					{
						return color.GetColor("_Color");
					}
					return color.color;
				}
			}
			catch
			{
			}
			return (Color)((p.Id % 4) switch
			{
				0 => new Color(1f, 0.86f, 0.18f), 
				1 => new Color(0.35f, 0.78f, 1f), 
				2 => new Color(1f, 0.42f, 0.55f), 
				_ => new Color(0.4f, 0.92f, 0.4f), 
			});
		}

		private static Texture2D Solid(Color c)
		{
			//IL_0004: 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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, c);
			val.Apply(false, true);
			return val;
		}
	}
	[HarmonyPatch(typeof(PlayerCollision), "KillPlayerOnCollision")]
	internal static class KillOnCollisionPatch
	{
		[HarmonyPrefix]
		private static bool Prefix(PlayerCollision __instance, CollisionInformation collision, ref bool __result)
		{
			//IL_0013: 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)
			try
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return true;
				}
				GameObject go = null;
				try
				{
					FixTransform fixTrans = collision.colliderPP.fixTrans;
					if ((Object)(object)fixTrans != (Object)null)
					{
						go = ((Component)fixTrans).gameObject;
					}
				}
				catch
				{
				}
				int playerId = __instance.GetPlayerId();
				int killerId = ResolveKillerId(go);
				SlimeController val = ((Component)__instance).GetComponent<SlimeController>() ?? ((Component)__instance).GetComponentInParent<SlimeController>();
				PlayerHealth playerHealth = (((Object)(object)val != (Object)null) ? PlayerHealth.GetOrCreate(val) : null);
				if (IsSelfHit(playerId, killerId, go, val))
				{
					__result = false;
					return false;
				}
				float grenadeDist;
				HpDamageKind hpDamageKind = DamageSourceId.Identify(go, out grenadeDist, __instance);
				switch (hpDamageKind)
				{
				case HpDamageKind.BlackHoleInstant:
					return true;
				case HpDamageKind.SmokeNoDamage:
					__result = false;
					return false;
				default:
				{
					if ((Object)(object)playerHealth != (Object)null && playerHealth.HasIFrames && hpDamageKind != HpDamageKind.Roll)
					{
						__result = false;
						return false;
					}
					if (!DamageTable.IsHpDamage(hpDamageKind))
					{
						return true;
					}
					if ((Object)(object)val == (Object)null || (Object)(object)playerHealth == (Object)null)
					{
						return true;
					}
					int amount = ((hpDamageKind == HpDamageKind.Grenade) ? DamageTable.ResolveGrenadeDamage(grenadeDist) : DamageTable.GetFlatDamage(hpDamageKind));
					if (playerHealth.TryAbsorbHit(amount, DamageTable.GrantsIFrames(hpDamageKind), killerId) && playerHealth.Hp > 0)
					{
						__result = false;
						return false;
					}
					return true;
				}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("KillOnCollisionPatch: " + ex.Message));
				return true;
			}
		}

		internal static bool IsSelfHit(int victimId, int killerId, GameObject go, SlimeController victimSlime)
		{
			if ((Object)(object)go == (Object)null)
			{
				if (killerId >= 0)
				{
					return killerId == victimId;
				}
				return false;
			}
			Projectile val = go.GetComponentInParent<Projectile>() ?? go.GetComponent<Projectile>();
			if ((Object)(object)val != (Object)null)
			{
				bool flag = false;
				try
				{
					flag = val.GetPlayerId() == victimId || val.PlayerOwnerId == victimId;
				}
				catch
				{
				}
				if (flag)
				{
					try
					{
						if (!val.canHurtOwner)
						{
							return true;
						}
						return false;
					}
					catch
					{
						return true;
					}
				}
			}
			if (killerId >= 0 && killerId == victimId)
			{
				return true;
			}
			SlimeController componentInParent = go.GetComponentInParent<SlimeController>();
			if ((Object)(object)componentInParent != (Object)null && (Object)(object)victimSlime != (Object)null && (Object)(object)componentInParent == (Object)(object)victimSlime)
			{
				return true;
			}
			Mine val2 = go.GetComponentInParent<Mine>() ?? go.GetComponent<Mine>();
			if ((Object)(object)val2 != (Object)null)
			{
				try
				{
					Ability val3 = ((Component)val2).GetComponentInParent<Ability>() ?? go.GetComponentInParent<Ability>();
					if ((Object)(object)val3 != (Object)null && val3.GetPlayerId() == victimId)
					{
						return true;
					}
				}
				catch
				{
				}
			}
			return false;
		}

		internal static int ResolveKillerId(GameObject go)
		{
			if ((Object)(object)go == (Object)null)
			{
				return -1;
			}
			try
			{
				Projectile val = go.GetComponentInParent<Projectile>() ?? go.GetComponent<Projectile>();
				if ((Object)(object)val != (Object)null)
				{
					return val.GetPlayerId();
				}
				Ability componentInParent = go.GetComponentInParent<Ability>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					return componentInParent.GetPlayerId();
				}
				SlimeController componentInParent2 = go.GetComponentInParent<SlimeController>();
				if ((Object)(object)componentInParent2 != (Object)null)
				{
					return componentInParent2.GetPlayerId();
				}
				PlayerCollision componentInParent3 = go.GetComponentInParent<PlayerCollision>();
				if ((Object)(object)componentInParent3 != (Object)null)
				{
					return componentInParent3.GetPlayerId();
				}
			}
			catch
			{
			}
			return -1;
		}
	}
	[HarmonyPatch(typeof(PlayerCollision), "killPlayer")]
	internal static class KillPlayerPatch
	{
		[HarmonyPrefix]
		private static bool Prefix(PlayerCollision __instance, int killerId, bool ignoreInvulnerability, CauseOfDeath causeOfDeath)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			try
			{
				if ((int)causeOfDeath == 3)
				{
					return true;
				}
				if (ignoreInvulnerability)
				{
					return true;
				}
				SlimeController val = ((Component)__instance).GetComponent<SlimeController>() ?? ((Component)__instance).GetComponentInParent<SlimeController>();
				if ((Object)(object)val == (Object)null)
				{
					return true;
				}
				PlayerHealth component = ((Component)val).GetComponent<PlayerHealth>();
				if ((Object)(object)component != (Object)null && component.Hp <= 0)
				{
					return true;
				}
				if ((Object)(object)component != (Object)null && component.HasIFrames)
				{
					if (killerId >= 0)
					{
						__instance.GetPlayerId();
						return false;
					}
					return false;
				}
				if (killerId >= 0 && killerId == __instance.GetPlayerId())
				{
					if ((Object)(object)component != (Object)null && component.Hp <= 0)
					{
						return true;
					}
					return false;
				}
				return true;
			}
			catch
			{
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(GameSessionHandler), "SpawnPlayers")]
	internal static class SpawnPlayersPatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			PlayerHealth.ResetAllToFull();
			AttachAll();
		}

		internal static void AttachAll()
		{
			SlimeController[] array = Object.FindObjectsOfType<SlimeController>();
			for (int i = 0; i < array.Length; i++)
			{
				PlayerHealth.GetOrCreate(array[i]);
			}
		}
	}
	[HarmonyPatch(typeof(GameSessionHandler), "Init")]
	internal static class SessionInitPatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			PlayerHealth.ResetAllToFull();
			SpawnPlayersPatch.AttachAll();
		}
	}
	[HarmonyPatch(typeof(SlimeController), "Init")]
	internal static class SlimeInitPatch
	{
		[HarmonyPostfix]
		private static void Postfix(SlimeController __instance)
		{
			PlayerHealth.GetOrCreate(__instance);
		}
	}
	internal class PlayerHealth : MonoBehaviour
	{
		public const uint IFrameMask = 512u;

		private double _iframeUntilRealtime;

		private float _shakeUntilRealtime;

		private Vector3 _shakeBase;

		private bool _hasShakeBase;

		private SpriteRenderer _sprite;

		private Color _savedSpriteColor = Color.white;

		private Material _mat;

		private Color _savedMain = Color.white;

		private Color _savedShadow = Color.white;

		private bool _hasShadow;

		private bool _savedColors;

		private bool _wasBlinking;

		private SlimeController _slime;

		private static AudioClip _pumClip;

		private static readonly Dictionary<int, PlayerHealth> ById = new Dictionary<int, PlayerHealth>();

		public int Hp { get; private set; } = 10;

		public int PlayerId { get; private set; } = -1;

		public bool HasIFrames
		{
			get
			{
				if (_iframeUntilRealtime > 0.0)
				{
					return (double)Time.realtimeSinceStartup < _iframeUntilRealtime;
				}
				return false;
			}
		}

		public static PlayerHealth GetOrCreate(SlimeController slime)
		{
			if ((Object)(object)slime == (Object)null)
			{
				return null;
			}
			PlayerHealth playerHealth = ((Component)slime).GetComponent<PlayerHealth>();
			if ((Object)(object)playerHealth == (Object)null)
			{
				playerHealth = ((Component)slime).gameObject.AddComponent<PlayerHealth>();
			}
			playerHealth.EnsureBound(slime);
			return playerHealth;
		}

		public static PlayerHealth Find(int playerId)
		{
			if (ById.TryGetValue(playerId, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			return null;
		}

		public static void ResetAllToFull()
		{
			foreach (KeyValuePair<int, PlayerHealth> item in ById)
			{
				if ((Object)(object)item.Value != (Object)null)
				{
					item.Value.ResetFull();
				}
			}
		}

		public void EnsureBound(SlimeController slime)
		{
			_slime = slime;
			PlayerId = slime.GetPlayerId();
			ById[PlayerId] = this;
			if ((Object)(object)_sprite == (Object)null)
			{
				_sprite = slime.GetPlayerSprite();
			}
			if ((Object)(object)_mat == (Object)null)
			{
				try
				{
					_mat = slime.GetPlayerMaterial();
				}
				catch
				{
				}
			}
		}

		public void ResetFull()
		{
			Hp = 10;
			EndIFrames(restoreVisual: true);
		}

		public bool TryAbsorbHit(int amount, bool grantIFrames, int killerId)
		{
			if (amount <= 0)
			{
				return false;
			}
			if (grantIFrames && HasIFrames)
			{
				return true;
			}
			Hp = Mathf.Max(0, Hp - amount);
			Plugin.Log.LogInfo((object)$"BarraVida: P{PlayerId} took {amount} → {Hp}/{10} (killer {killerId}, iframes={3f}s)");
			PlayHitFeedback();
			if (grantIFrames)
			{
				_iframeUntilRealtime = Time.realtimeSinceStartup + 3f;
				ApplyInvuln(on: true);
				_wasBlinking = true;
			}
			if (Hp <= 0)
			{
				EndIFrames(restoreVisual: true);
				return false;
			}
			return true;
		}

		private void PlayHitFeedback()
		{
			_shakeUntilRealtime = Time.realtimeSinceStartup + 0.22f;
			CacheColors(force: true);
			PlayPum();
		}

		private void CacheColors(bool force = false)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00cd: 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_00f5: 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)
			if ((Object)(object)_sprite == (Object)null && (Object)(object)_slime != (Object)null)
			{
				_sprite = _slime.GetPlayerSprite();
			}
			if ((Object)(object)_sprite != (Object)null && (force || !_savedColors))
			{
				_savedSpriteColor = _sprite.color;
				if (_savedSpriteColor.a < 0.05f)
				{
					_savedSpriteColor.a = 1f;
				}
				_shakeBase = ((Component)_sprite).transform.localPosition;
				_hasShakeBase = true;
			}
			if ((Object)(object)_mat != (Object)null && (force || !_savedColors))
			{
				if (_mat.HasProperty("_MainColor"))
				{
					_savedMain = _mat.GetColor("_MainColor");
				}
				if (_mat.HasProperty("_ShadowColor"))
				{
					_savedShadow = _mat.GetColor("_ShadowColor");
					_hasShadow = true;
				}
			}
			_savedColors = true;
		}

		private void RestoreColors()
		{
			//IL_0021: 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_0075: 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)
			if ((Object)(object)_sprite != (Object)null)
			{
				((Renderer)_sprite).enabled = true;
				_sprite.color = _savedSpriteColor;
				if (_hasShakeBase)
				{
					((Component)_sprite).transform.localPosition = _shakeBase;
				}
			}
			if ((Object)(object)_mat != (Object)null)
			{
				if (_mat.HasProperty("_MainColor"))
				{
					_mat.SetColor("_MainColor", _savedMain);
				}
				if (_hasShadow && _mat.HasProperty("_ShadowColor"))
				{
					_mat.SetColor("_ShadowColor", _savedShadow);
				}
			}
			_savedColors = false;
			_wasBlinking = false;
		}

		private void ApplyInvuln(bool on)
		{
			try
			{
				PlayerCollision val = (((Object)(object)_slime != (Object)null) ? _slime.GetPlayerCollision() : null);
				if (!((Object)(object)val == (Object)null))
				{
					val.SetInvulnerable(on, 512u);
				}
			}
			catch
			{
			}
		}

		private void EndIFrames(bool restoreVisual)
		{
			ApplyInvuln(on: false);
			_iframeUntilRealtime = 0.0;
			if (restoreVisual && (_savedColors || _wasBlinking))
			{
				RestoreColors();
			}
		}

		private void LateUpdate()
		{
			//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_00f6: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_sprite == (Object)null && (Object)(object)_slime != (Object)null)
			{
				_sprite = _slime.GetPlayerSprite();
			}
			if ((Object)(object)_mat == (Object)null && (Object)(object)_slime != (Object)null)
			{
				try
				{
					_mat = _slime.GetPlayerMaterial();
				}
				catch
				{
				}
			}
			if (HasIFrames)
			{
				ApplyInvuln(on: true);
				ApplyBlink();
			}
			else if (_wasBlinking || _iframeUntilRealtime > 0.0)
			{
				EndIFrames(restoreVisual: true);
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if ((Object)(object)_sprite != (Object)null && realtimeSinceStartup < _shakeUntilRealtime && _hasShakeBase)
			{
				float num = Mathf.Clamp01(1f - (realtimeSinceStartup - (_shakeUntilRealtime - 0.22f)) / 0.22f);
				((Component)_sprite).transform.localPosition = _shakeBase + Vector2.op_Implicit(Random.insideUnitCircle * 0.08f * num);
			}
			else if ((Object)(object)_sprite != (Object)null && _hasShakeBase && realtimeSinceStartup >= _shakeUntilRealtime)
			{
				((Component)_sprite).transform.localPosition = _shakeBase;
			}
		}

		private void ApplyBlink()
		{
			//IL_0076: 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_00d5: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_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)
			if (!((Object)(object)_sprite == (Object)null))
			{
				if (!_savedColors)
				{
					CacheColors(force: true);
				}
				bool flag = Mathf.FloorToInt((float)((double)Time.realtimeSinceStartup * 6.0)) % 2 == 0;
				((Renderer)_sprite).enabled = true;
				if (!flag)
				{
					_sprite.color = new Color(0.75f, 0.75f, 0.8f, 0.35f);
				}
				else
				{
					_sprite.color = _savedSpriteColor;
				}
				if ((Object)(object)_mat != (Object)null && _mat.HasProperty("_MainColor"))
				{
					_mat.SetColor("_MainColor", flag ? _savedMain : Color.Lerp(_savedMain, new Color(0.7f, 0.7f, 0.75f), 0.85f));
				}
				if (_hasShadow && (Object)(object)_mat != (Object)null && _mat.HasProperty("_ShadowColor"))
				{
					_mat.SetColor("_ShadowColor", flag ? _savedShadow : Color.Lerp(_savedShadow, Color.gray, 0.7f));
				}
				_wasBlinking = true;
			}
		}

		private void OnDestroy()
		{
			if (PlayerId >= 0 && ById.TryGetValue(PlayerId, out var value) && (Object)(object)value == (Object)(object)this)
			{
				ById.Remove(PlayerId);
			}
			ApplyInvuln(on: false);
		}

		private static void PlayPum()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			try
			{
				EnsurePumClip();
				GameObject val = new GameObject("BarraVida_Pum");
				Object.DontDestroyOnLoad((Object)val);
				AudioSource obj = val.AddComponent<AudioSource>();
				obj.clip = _pumClip;
				obj.volume = 0.85f;
				obj.Play();
				Object.Destroy((Object)val, 1.2f);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Pum sound failed: " + ex.Message));
			}
		}

		private static void EnsurePumClip()
		{
			if (!((Object)(object)_pumClip != (Object)null))
			{
				int num = 2646;
				float[] array = new float[num];
				for (int i = 0; i < num; i++)
				{
					float num2 = (float)i / 22050f;
					float num3 = Mathf.Exp(-28f * num2);
					array[i] = num3 * (0.7f * Mathf.Sin((float)Math.PI * 180f * num2) + 0.35f * Mathf.Sin((float)Math.PI * 360f * num2));
				}
				_pumClip = AudioClip.Create("BarraVida_Pum", num, 1, 22050, false);
				_pumClip.SetData(array, 0);
			}
		}
	}
	[BepInPlugin("com.Jero.BarraVida", "BarraVida", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("com.Jero.BarraVida").PatchAll();
			((Component)this).gameObject.AddComponent<HealthHud>();
			Log.LogInfo((object)"BarraVida 1.0.0 loaded — 10 HP, 3s hit i-frames + blink (except Roll), no self-damage.");
		}
	}
	internal static class PluginInfo
	{
		public const string GUID = "com.Jero.BarraVida";

		public const string Name = "BarraVida";

		public const string Version = "1.0.0";

		public const int MaxHp = 10;

		public const float IFrameSeconds = 3f;

		public const float ShakeSeconds = 0.22f;
	}
}