Decompiled source of Low Health Indicator v1.3.0

LowHealthIndicator.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("0.0.0.0")]
[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 LowHealthIndicator
{
	public enum IndicatorType
	{
		FlashingHeart,
		BeatingHeart,
		PixelHeart,
		HeartMonitor,
		RedHalo,
		WarningText
	}
	public enum IndicatorLocation
	{
		AboveHead,
		NearHealthBar,
		TopCenter,
		TopLeft,
		TopRight,
		ScreenCenter,
		BottomCenter,
		BottomLeft,
		BottomRight
	}
	public enum ThresholdMode
	{
		HitPoints,
		PercentOfMax
	}
	public enum SoundType
	{
		None,
		Heartbeat,
		DeepThump,
		RetroBeep,
		SoftPing,
		Alarm
	}
	[BepInPlugin("YouDied.LowHealthIndicator", "Low Health Indicator", "1.3.0")]
	public class LowHealthIndicatorPlugin : BaseUnityPlugin
	{
		public const string ModGUID = "YouDied.LowHealthIndicator";

		public const string ModName = "Low Health Indicator";

		public const string ModVersion = "1.3.0";

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<int> _threshold;

		private ConfigEntry<ThresholdMode> _thresholdMode;

		private ConfigEntry<bool> _requireNoFood;

		private ConfigEntry<bool> _hideWithHud;

		private ConfigEntry<KeyboardShortcut> _previewKey;

		private ConfigEntry<IndicatorType> _type;

		private ConfigEntry<IndicatorLocation> _location;

		private ConfigEntry<bool> _addHalo;

		private ConfigEntry<int> _size;

		private ConfigEntry<int> _offsetX;

		private ConfigEntry<int> _offsetY;

		private ConfigEntry<int> _headHeight;

		private ConfigEntry<int> _opacity;

		private ConfigEntry<Color> _color;

		private ConfigEntry<string> _warningText;

		private ConfigEntry<int> _bpm;

		private ConfigEntry<bool> _speedUp;

		private ConfigEntry<bool> _animate;

		private ConfigEntry<int> _haloIntensity;

		private ConfigEntry<int> _haloThickness;

		private ConfigEntry<SoundType> _soundType;

		private ConfigEntry<int> _soundVolume;

		private ConfigEntry<int> _soundEveryNBeats;

		private ConfigEntry<bool> _muteInMenus;

		private bool _active;

		private float _prevPhase;

		private int _beatCount;

		private AudioSource _audio;

		private bool _mixerAssigned;

		private AudioClip _clip;

		private SoundType _clipType;

		private bool _preview;

		private float _phase;

		private float _severity;

		private Texture2D _heartFill;

		private Texture2D _heartOutline;

		private Texture2D _heartShine;

		private Texture2D _pixFill;

		private Texture2D _pixOutline;

		private Texture2D _pixShine;

		private Texture2D _glow;

		private Texture2D _ecg;

		private Texture2D _halo;

		private int _haloBuiltFor = -1;

		private GUIStyle _textStyle;

		private Hud _cachedHud;

		private RectTransform _healthRect;

		private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4];

		private static readonly string[] HealthFieldNames = new string[4] { "m_healthPanel", "m_healthBarRoot", "m_healthBarFast", "m_healthBarSlow" };

		private static MethodInfo _hudUserHidden;

		private static bool _hudUserHiddenLooked;

		private void Awake()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Expected O, but got Unknown
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Expected O, but got Unknown
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Expected O, but got Unknown
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Expected O, but got Unknown
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Expected O, but got Unknown
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Expected O, but got Unknown
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "Enabled", true, "Master switch for the low health indicator.");
			_threshold = ((BaseUnityPlugin)this).Config.Bind<int>("1 - General", "HealthThreshold", 25, new ConfigDescription("Show the indicator when health is at or below this value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 200), Array.Empty<object>()));
			_thresholdMode = ((BaseUnityPlugin)this).Config.Bind<ThresholdMode>("1 - General", "ThresholdMode", ThresholdMode.HitPoints, "HitPoints = threshold is raw health (25 = 25 HP). PercentOfMax = threshold is a percent of max health.");
			_requireNoFood = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "RequireAllFoodGone", true, "Only show the indicator when every food slot is empty. Turn off to warn on low health alone.");
			_hideWithHud = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "HideWhenHudHidden", true, "Hide the indicator when the HUD is hidden (Ctrl+F3).");
			_previewKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("1 - General", "PreviewKey", new KeyboardShortcut((KeyCode)104, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Toggles a preview of the indicator so you can set it up without starving yourself.");
			_type = ((BaseUnityPlugin)this).Config.Bind<IndicatorType>("2 - Indicator", "IndicatorType", IndicatorType.BeatingHeart, "FlashingHeart, BeatingHeart, PixelHeart, HeartMonitor (ECG strip), RedHalo (screen edge glow only), WarningText.");
			_location = ((BaseUnityPlugin)this).Config.Bind<IndicatorLocation>("2 - Indicator", "Location", IndicatorLocation.NearHealthBar, "Where the indicator is drawn. Ignored for RedHalo.");
			_addHalo = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Indicator", "AlsoShowRedHalo", false, "Add the red screen edge glow on top of whatever indicator type is chosen.");
			_size = ((BaseUnityPlugin)this).Config.Bind<int>("2 - Indicator", "Size", 56, new ConfigDescription("Indicator size in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(16, 256), Array.Empty<object>()));
			_offsetX = ((BaseUnityPlugin)this).Config.Bind<int>("2 - Indicator", "OffsetX", -3, new ConfigDescription("Screen locations only: nudge left (-) or right (+) in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-800, 800), Array.Empty<object>()));
			_offsetY = ((BaseUnityPlugin)this).Config.Bind<int>("2 - Indicator", "OffsetY", -39, new ConfigDescription("Screen locations only: nudge up (-) or down (+) in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-800, 800), Array.Empty<object>()));
			_headHeight = ((BaseUnityPlugin)this).Config.Bind<int>("2 - Indicator", "AboveHeadHeight", 60, new ConfigDescription("AboveHead only: how far above your head the heart floats, in centimetres. It follows your head when standing, running, jumping, sitting or crouching. OffsetX/OffsetY are not used for AboveHead.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 200), Array.Empty<object>()));
			_opacity = ((BaseUnityPlugin)this).Config.Bind<int>("2 - Indicator", "Opacity", 61, new ConfigDescription("Indicator opacity percent.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 100), Array.Empty<object>()));
			_color = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Indicator", "Color", new Color(0.86f, 0.05f, 0.07f, 1f), "Indicator color (heart, ECG line, text and halo).");
			_warningText = ((BaseUnityPlugin)this).Config.Bind<string>("2 - Indicator", "WarningText", "LOW HEALTH - EAT SOMETHING!", "Message shown when IndicatorType is WarningText.");
			_bpm = ((BaseUnityPlugin)this).Config.Bind<int>("3 - Heartbeat", "BeatsPerMinute", 60, new ConfigDescription("Flash / beat speed.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(30, 200), Array.Empty<object>()));
			_animate = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Heartbeat", "Animate", true, "Beat / flash / pulse the indicator. Turn off for a steady, non-moving indicator (sound still plays on the beat).");
			_speedUp = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Heartbeat", "SpeedUpAsHealthDrops", true, "Heartbeat speeds up (up to double) the closer you get to zero health.");
			_haloIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("4 - Red Halo", "HaloIntensity", 23, new ConfigDescription("Strength of the screen edge glow, percent.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 100), Array.Empty<object>()));
			_haloThickness = ((BaseUnityPlugin)this).Config.Bind<int>("4 - Red Halo", "HaloSize", 12, new ConfigDescription("Size of the red halo: how far the glow reaches in from the screen edges, percent. 5 = thin edge, 95 = nearly the whole screen.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 95), Array.Empty<object>()));
			_soundType = ((BaseUnityPlugin)this).Config.Bind<SoundType>("5 - Sound", "SoundType", SoundType.Heartbeat, "Optional warning sound, played in time with the heartbeat. None = silent. Heartbeat, DeepThump, RetroBeep (8-bit), SoftPing, Alarm.");
			_soundVolume = ((BaseUnityPlugin)this).Config.Bind<int>("5 - Sound", "Volume", 32, new ConfigDescription("Sound volume percent. Also follows the game's own volume settings.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			_soundEveryNBeats = ((BaseUnityPlugin)this).Config.Bind<int>("5 - Sound", "PlayEveryNBeats", 1, new ConfigDescription("1 = every beat, 2 = every other beat, and so on.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
			_muteInMenus = ((BaseUnityPlugin)this).Config.Bind<bool>("5 - Sound", "MuteInMenus", false, "Stay quiet while the Esc menu is open.");
			_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
			_audio.playOnAwake = false;
			_audio.spatialBlend = 0f;
			_audio.loop = false;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Low Health Indicator 1.3.0 loaded.");
		}

		private void Update()
		{
			//IL_0015: 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)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				KeyboardShortcut value = _previewKey.Value;
				if (((KeyboardShortcut)(ref value)).IsDown() && !TextInputActive())
				{
					_preview = !_preview;
					((Character)localPlayer).Message((MessageType)1, _preview ? "Low Health Indicator: preview ON" : "Low Health Indicator: preview OFF", 0, (Sprite)null, false);
				}
			}
			_active = false;
			if (!_enabled.Value || (Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead())
			{
				return;
			}
			if (_preview)
			{
				_active = true;
				_severity = 0.5f;
			}
			else
			{
				float health = ((Character)localPlayer).GetHealth();
				float num = ((_thresholdMode.Value == ThresholdMode.HitPoints) ? ((float)_threshold.Value) : (((Character)localPlayer).GetMaxHealth() * (float)Mathf.Clamp(_threshold.Value, 1, 100) / 100f));
				bool flag = health > 0f && health <= num;
				bool flag2 = !_requireNoFood.Value || localPlayer.GetFoods().Count == 0;
				_active = flag && flag2;
				_severity = ((num > 0f) ? Mathf.Clamp01(1f - health / num) : 0f);
			}
			if (_active)
			{
				float num2 = (float)_bpm.Value * (_speedUp.Value ? (1f + _severity) : 1f);
				_prevPhase = _phase;
				_phase = (_phase + Time.unscaledDeltaTime * num2 / 60f) % 1f;
				bool num3;
				if (!(_prevPhase <= _phase))
				{
					if (_prevPhase < 0.08f)
					{
						goto IL_01fc;
					}
					num3 = _phase >= 0.08f;
				}
				else
				{
					if (!(_prevPhase < 0.08f))
					{
						return;
					}
					num3 = _phase >= 0.08f;
				}
				if (!num3)
				{
					return;
				}
				goto IL_01fc;
			}
			_phase = 0f;
			_prevPhase = 0f;
			_beatCount = 0;
			return;
			IL_01fc:
			if (_beatCount % _soundEveryNBeats.Value == 0)
			{
				PlayBeatSound();
			}
			_beatCount++;
		}

		private void PlayBeatSound()
		{
			SoundType value = _soundType.Value;
			if (value == SoundType.None || _soundVolume.Value <= 0 || (Object)(object)_audio == (Object)null || (_muteInMenus.Value && Menu.IsVisible()) || (_hideWithHud.Value && HudHidden()))
			{
				return;
			}
			if ((Object)(object)_clip == (Object)null || _clipType != value)
			{
				if ((Object)(object)_clip != (Object)null)
				{
					Object.Destroy((Object)(object)_clip);
				}
				_clip = SoundFactory.Build(value);
				_clipType = value;
			}
			if (!((Object)(object)_clip == (Object)null))
			{
				if (!_mixerAssigned && (Object)(object)AudioMan.instance != (Object)null)
				{
					_audio.outputAudioMixerGroup = AudioMan.instance.m_guiMixer;
					_mixerAssigned = true;
				}
				_audio.PlayOneShot(_clip, (float)_soundVolume.Value / 100f);
			}
		}

		private void OnGUI()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//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_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: 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)
			if (!_active || (int)Event.current.type != 7 || (_hideWithHud.Value && HudHidden()))
			{
				return;
			}
			EnsureTextures();
			GUI.depth = -1000;
			Color color = GUI.color;
			float num = (float)_opacity.Value / 100f;
			bool flag = !_animate.Value;
			float num2 = Beat(_phase);
			float num3 = Flash(_phase);
			IndicatorType value = _type.Value;
			if (value == IndicatorType.RedHalo || _addHalo.Value)
			{
				DrawHalo(flag ? 1f : num2);
			}
			if (value != IndicatorType.RedHalo && TryGetAnchor(out var center))
			{
				float num4 = _size.Value;
				switch (value)
				{
				case IndicatorType.FlashingHeart:
					if (flag)
					{
						num3 = 1f;
					}
					DrawGlow(center, num4 * 1.7f, num * num3 * 0.45f);
					DrawLayered(center, num4, num * num3, _heartOutline, _heartFill, _heartShine);
					break;
				case IndicatorType.BeatingHeart:
					if (flag)
					{
						DrawGlow(center, num4 * 1.7f, num * 0.4f);
						DrawLayered(center, num4, num, _heartOutline, _heartFill, _heartShine);
					}
					else
					{
						DrawGlow(center, num4 * (1.5f + 0.5f * num2), num * num2 * 0.55f);
						DrawLayered(center, num4 * (1f + 0.22f * num2), num * (0.75f + 0.25f * num2), _heartOutline, _heartFill, _heartShine);
					}
					break;
				case IndicatorType.PixelHeart:
				{
					float num5 = ((flag || _phase < 0.55f) ? 1f : 0.18f);
					DrawLayered(center, num4 * (1f + (flag ? 0f : (0.08f * num2))), num * num5, _pixOutline, _pixFill, _pixShine);
					break;
				}
				case IndicatorType.HeartMonitor:
					DrawMonitor(center, num4, num, flag ? 0f : num2, flag);
					break;
				case IndicatorType.WarningText:
					DrawWarningText(center, num4, num * (flag ? 1f : num3));
					break;
				}
			}
			GUI.color = color;
		}

		private void DrawLayered(Vector2 c, float size, float alpha, Texture2D outline, Texture2D fill, Texture2D shine)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_002e: 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_004f: 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_005f: 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_006c: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			Rect val = new Rect(c.x - size / 2f, c.y - size / 2f, size, size);
			Color value = _color.Value;
			GUI.color = new Color(0f, 0f, 0f, alpha * 0.9f);
			GUI.DrawTexture(val, (Texture)(object)outline, (ScaleMode)2, true);
			GUI.color = new Color(value.r, value.g, value.b, alpha);
			GUI.DrawTexture(val, (Texture)(object)fill, (ScaleMode)2, true);
			GUI.color = new Color(1f, 1f, 1f, alpha * 0.55f);
			GUI.DrawTexture(val, (Texture)(object)shine, (ScaleMode)2, true);
		}

		private void DrawGlow(Vector2 c, float size, float alpha)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (!(alpha <= 0.01f))
			{
				Color value = _color.Value;
				GUI.color = new Color(value.r, value.g, value.b, alpha);
				GUI.DrawTexture(new Rect(c.x - size / 2f, c.y - size / 2f, size, size), (Texture)(object)_glow, (ScaleMode)0, true);
			}
		}

		private void DrawHalo(float beat)
		{
			//IL_0060: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (_haloBuiltFor != _haloThickness.Value)
			{
				if ((Object)(object)_halo != (Object)null)
				{
					Object.Destroy((Object)(object)_halo);
				}
				_halo = TextureFactory.Halo((float)_haloThickness.Value / 100f);
				_haloBuiltFor = _haloThickness.Value;
			}
			Color value = _color.Value;
			float num = (float)_haloIntensity.Value / 100f * (0.4f + 0.6f * beat);
			GUI.color = new Color(value.r, value.g, value.b, num);
			GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_halo, (ScaleMode)0, true);
		}

		private void DrawMonitor(Vector2 c, float s, float opacity, float beat, bool steady)
		{
			//IL_001c: 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_0044: 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_00a3: 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_00be: 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_00c5: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			float num = s * 3.2f;
			float num2 = s * 0.7f;
			float num3 = num2 + 6f + num;
			float num4 = c.x - num3 / 2f;
			Vector2 c2 = default(Vector2);
			((Vector2)(ref c2))..ctor(num4 + num2 / 2f, c.y);
			DrawLayered(c2, num2 * (1f + 0.2f * beat), opacity, _heartOutline, _heartFill, _heartShine);
			Rect val = new Rect(num4 + num2 + 6f, c.y - s / 2f, num, s);
			GUI.color = new Color(0f, 0f, 0f, 0.5f * opacity);
			GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture);
			Color value = _color.Value;
			GUI.color = new Color(value.r, value.g, value.b, opacity);
			GUI.DrawTextureWithTexCoords(val, (Texture)(object)_ecg, new Rect(steady ? 0f : _phase, 0f, 2f, 1f), true);
		}

		private void DrawWarningText(Vector2 c, float s, float alpha)
		{
			//IL_0052: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0032: Expected O, but got Unknown
			if (_textStyle == null)
			{
				_textStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1,
					wordWrap = false
				};
			}
			_textStyle.fontSize = Mathf.Max(10, Mathf.RoundToInt(s / 2.4f));
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(c.x - 600f, c.y - s / 2f, 1200f, s);
			Rect val2 = new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, ((Rect)(ref val)).width, ((Rect)(ref val)).height);
			Color value = _color.Value;
			GUI.color = new Color(0f, 0f, 0f, alpha * 0.85f);
			GUI.Label(val2, _warningText.Value, _textStyle);
			GUI.color = new Color(value.r, value.g, value.b, alpha);
			GUI.Label(val, _warningText.Value, _textStyle);
		}

		private bool TryGetAnchor(out Vector2 center)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_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_00aa: 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_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			float num = _size.Value;
			float num2 = 24f + num / 2f;
			float num3 = Screen.width;
			float num4 = Screen.height;
			center = Vector2.zero;
			switch (_location.Value)
			{
			case IndicatorLocation.AboveHead:
				if (!TryAboveHead(out center))
				{
					return false;
				}
				break;
			case IndicatorLocation.NearHealthBar:
			{
				if (TryHealthBarRect(out var guiRect))
				{
					center = new Vector2(((Rect)(ref guiRect)).xMax + num * 0.75f, ((Rect)(ref guiRect)).center.y);
				}
				else
				{
					center = new Vector2(num3 * 0.2f, num4 - 90f);
				}
				break;
			}
			case IndicatorLocation.TopCenter:
				center = new Vector2(num3 / 2f, num2 + 40f);
				break;
			case IndicatorLocation.TopLeft:
				center = new Vector2(num2, num2);
				break;
			case IndicatorLocation.TopRight:
				center = new Vector2(num3 - num2, num2);
				break;
			case IndicatorLocation.ScreenCenter:
				center = new Vector2(num3 / 2f, num4 / 2f - num * 1.5f);
				break;
			case IndicatorLocation.BottomCenter:
				center = new Vector2(num3 / 2f, num4 - num2 - 60f);
				break;
			case IndicatorLocation.BottomLeft:
				center = new Vector2(num2, num4 - num2);
				break;
			case IndicatorLocation.BottomRight:
				center = new Vector2(num3 - num2, num4 - num2);
				break;
			}
			float num5 = num / 2f;
			if (_type.Value == IndicatorType.HeartMonitor)
			{
				num5 = num * 2f;
			}
			else if (_type.Value == IndicatorType.WarningText)
			{
				num5 = num * 4f;
			}
			if (_location.Value == IndicatorLocation.TopLeft || _location.Value == IndicatorLocation.BottomLeft)
			{
				center.x = Mathf.Max(center.x, 24f + num5);
			}
			if (_location.Value == IndicatorLocation.TopRight || _location.Value == IndicatorLocation.BottomRight)
			{
				center.x = Mathf.Min(center.x, num3 - 24f - num5);
			}
			if (_location.Value != IndicatorLocation.AboveHead)
			{
				center += new Vector2((float)_offsetX.Value, (float)_offsetY.Value);
			}
			return true;
		}

		private bool TryAboveHead(out Vector2 center)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			center = Vector2.zero;
			Player localPlayer = Player.m_localPlayer;
			Camera main = Camera.main;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)main == (Object)null)
			{
				return false;
			}
			Vector3 val = ((Character)localPlayer).GetHeadPoint() + Vector3.up * ((float)_headHeight.Value / 100f);
			Vector3 val2 = main.WorldToScreenPoint(val);
			if (val2.z <= 0f)
			{
				return false;
			}
			center = new Vector2(val2.x, (float)Screen.height - val2.y);
			return true;
		}

		private bool TryHealthBarRect(out Rect guiRect)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			guiRect = default(Rect);
			Hud instance = Hud.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return false;
			}
			if ((Object)(object)_cachedHud != (Object)(object)instance || (Object)(object)_healthRect == (Object)null)
			{
				_cachedHud = instance;
				_healthRect = null;
				string[] healthFieldNames = HealthFieldNames;
				foreach (string name in healthFieldNames)
				{
					FieldInfo field = typeof(Hud).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field == null)
					{
						continue;
					}
					object value = field.GetValue(instance);
					RectTransform val = (RectTransform)((value is RectTransform) ? value : null);
					if ((Object)(object)val == (Object)null)
					{
						Component val2 = (Component)((value is Component) ? value : null);
						if (val2 != null && (Object)(object)val2 != (Object)null)
						{
							val = val2.GetComponent<RectTransform>();
						}
					}
					if ((Object)(object)val == (Object)null)
					{
						GameObject val3 = (GameObject)((value is GameObject) ? value : null);
						if (val3 != null && (Object)(object)val3 != (Object)null)
						{
							val = val3.GetComponent<RectTransform>();
						}
					}
					if ((Object)(object)val != (Object)null)
					{
						_healthRect = val;
						break;
					}
				}
			}
			if ((Object)(object)_healthRect == (Object)null || !((Component)_healthRect).gameObject.activeInHierarchy)
			{
				return false;
			}
			Canvas componentInParent = ((Component)_healthRect).GetComponentInParent<Canvas>();
			Camera val4 = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
			_healthRect.GetWorldCorners(Corners);
			float num = float.MaxValue;
			float num2 = float.MaxValue;
			float num3 = float.MinValue;
			float num4 = float.MinValue;
			for (int j = 0; j < 4; j++)
			{
				Vector2 val5 = RectTransformUtility.WorldToScreenPoint(val4, Corners[j]);
				num = Mathf.Min(num, val5.x);
				num3 = Mathf.Max(num3, val5.x);
				num2 = Mathf.Min(num2, val5.y);
				num4 = Mathf.Max(num4, val5.y);
			}
			if (num3 - num < 1f || num4 - num2 < 1f)
			{
				return false;
			}
			guiRect = Rect.MinMaxRect(num, (float)Screen.height - num4, num3, (float)Screen.height - num2);
			return true;
		}

		private static float Gauss(float p, float c, float w)
		{
			float num = (p - c) / w;
			return Mathf.Exp((0f - num) * num);
		}

		private static float Beat(float p)
		{
			return Mathf.Max(Gauss(p, 0.1f, 0.05f), 0.65f * Gauss(p, 0.28f, 0.05f));
		}

		private static float Flash(float p)
		{
			float num = 0.5f + 0.5f * Mathf.Cos((float)Math.PI * 2f * (p - 0.1f));
			return 0.15f + 0.85f * Mathf.Pow(num, 0.6f);
		}

		private static bool TextInputActive()
		{
			if ((!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !TextInput.IsVisible())
			{
				return Menu.IsVisible();
			}
			return true;
		}

		private static bool HudHidden()
		{
			if (!_hudUserHiddenLooked)
			{
				_hudUserHiddenLooked = true;
				_hudUserHidden = typeof(Hud).GetMethod("IsUserHidden", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
			}
			try
			{
				return _hudUserHidden != null && (bool)_hudUserHidden.Invoke(null, null);
			}
			catch
			{
				return false;
			}
		}

		private void EnsureTextures()
		{
			if (!((Object)(object)_heartFill != (Object)null))
			{
				TextureFactory.SmoothHeart(128, out _heartFill, out _heartOutline, out _heartShine);
				TextureFactory.PixelHeart(out _pixFill, out _pixOutline, out _pixShine);
				_glow = TextureFactory.Glow(64);
				_ecg = TextureFactory.Ecg(256, 64);
			}
		}

		private void OnDestroy()
		{
			Texture2D[] array = (Texture2D[])(object)new Texture2D[9] { _heartFill, _heartOutline, _heartShine, _pixFill, _pixOutline, _pixShine, _glow, _ecg, _halo };
			foreach (Texture2D val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
			if ((Object)(object)_clip != (Object)null)
			{
				Object.Destroy((Object)(object)_clip);
			}
		}
	}
	internal static class SoundFactory
	{
		private const int Rate = 44100;

		public static AudioClip Build(SoundType type)
		{
			float[] array;
			switch (type)
			{
			case SoundType.Heartbeat:
				array = Heartbeat();
				break;
			case SoundType.RetroBeep:
				array = RetroBeep();
				break;
			case SoundType.SoftPing:
				array = SoftPing();
				break;
			case SoundType.Alarm:
				array = Alarm();
				break;
			case SoundType.DeepThump:
				array = DeepThump();
				break;
			default:
				return null;
			}
			Normalize(array, 0.85f);
			AudioClip obj = AudioClip.Create("LowHealthIndicator_" + type, array.Length, 1, 44100, false);
			obj.SetData(array, 0);
			((Object)obj).hideFlags = (HideFlags)61;
			return obj;
		}

		private static float[] Buffer(float seconds)
		{
			return new float[Mathf.CeilToInt(seconds * 44100f)];
		}

		private static void Normalize(float[] d, float peak)
		{
			float num = 0f;
			for (int i = 0; i < d.Length; i++)
			{
				num = Mathf.Max(num, Mathf.Abs(d[i]));
			}
			if (!(num <= 0f))
			{
				float num2 = peak / num;
				for (int j = 0; j < d.Length; j++)
				{
					d[j] *= num2;
				}
			}
		}

		private static void AddThump(float[] d, float start, float amp, float f0, float f1, float dur, float decay)
		{
			int num = Mathf.RoundToInt(start * 44100f);
			int num2 = Mathf.RoundToInt(dur * 44100f);
			float num3 = 0f;
			Random random = new Random(1234 + num);
			float num4 = 0f;
			for (int i = 0; i < num2 && num + i < d.Length; i++)
			{
				float num5 = (float)i / 44100f;
				float num6 = num5 / dur;
				float num7 = Mathf.Lerp(f0, f1, num6);
				num3 += (float)Math.PI * 2f * num7 / 44100f;
				float num8 = Mathf.Clamp01(num5 / 0.004f) * Mathf.Exp((0f - num5) * decay);
				float num9 = Mathf.Sin(num3) + 0.35f * Mathf.Sin(num3 * 2f) * Mathf.Exp((0f - num5) * decay * 2f);
				num4 += 0.08f * ((float)random.NextDouble() * 2f - 1f - num4);
				float num10 = num4 * Mathf.Exp((0f - num5) * 220f) * 2.5f;
				d[num + i] += amp * (num8 * num9 + num10);
			}
		}

		private static float[] Heartbeat()
		{
			float[] array = Buffer(0.5f);
			AddThump(array, 0f, 1f, 75f, 42f, 0.22f, 22f);
			AddThump(array, 0.17f, 0.7f, 85f, 48f, 0.22f, 26f);
			return array;
		}

		private static float[] DeepThump()
		{
			float[] array = Buffer(0.45f);
			AddThump(array, 0f, 1f, 62f, 34f, 0.42f, 12f);
			return array;
		}

		private static float[] RetroBeep()
		{
			float[] array = Buffer(0.16f);
			for (int i = 0; i < array.Length; i++)
			{
				float num = (float)i / 44100f;
				float num2 = ((Mathf.Repeat(num * 1175f, 1f) < 0.5f) ? 1f : (-1f));
				float num3 = Mathf.Clamp01(1f - num / 0.16f);
				num3 = Mathf.Floor(num3 * 15f) / 15f;
				array[i] = num2 * num3 * 0.6f;
			}
			return array;
		}

		private static float[] SoftPing()
		{
			float[] array = Buffer(0.7f);
			for (int i = 0; i < array.Length; i++)
			{
				float num = (float)i / 44100f;
				float num2 = Mathf.Clamp01(num / 0.005f) * Mathf.Exp((0f - num) * 7f);
				array[i] = num2 * (Mathf.Sin((float)Math.PI * 1320f * num) + 0.3f * Mathf.Sin((float)Math.PI * 2640f * num) * Mathf.Exp((0f - num) * 6f));
			}
			return array;
		}

		private static float[] Alarm()
		{
			float[] array = Buffer(0.28f);
			for (int i = 0; i < array.Length; i++)
			{
				float num = (float)i / 44100f;
				bool flag = num < 0.13f;
				float num2 = (flag ? num : (num - 0.14f));
				if (!(num2 < 0f))
				{
					float num3 = (flag ? 880f : 660f);
					float num4 = Mathf.Repeat(num2 * num3, 1f);
					float num5 = 4f * Mathf.Abs(num4 - 0.5f) - 1f;
					float num6 = Mathf.Clamp01(num2 / 0.004f) * Mathf.Clamp01((0.13f - num2) / 0.02f);
					array[i] = num5 * num6;
				}
			}
			return array;
		}
	}
	internal static class TextureFactory
	{
		private static readonly string[] PixelPattern = new string[8] { ".XX...XX.", "XXXX.XXXX", "XXXXXXXXX", "XXXXXXXXX", ".XXXXXXX.", "..XXXXX..", "...XXX...", "....X...." };

		private static Texture2D NewTex(int w, int h, FilterMode filter, TextureWrapMode wrap = (TextureWrapMode)1)
		{
			//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_000a: 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_0011: 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_0020: Expected O, but got Unknown
			return new Texture2D(w, h, (TextureFormat)4, false)
			{
				filterMode = filter,
				wrapMode = wrap,
				hideFlags = (HideFlags)61
			};
		}

		private static Texture2D FromAlpha(float[] alpha, int w, int h, FilterMode filter, TextureWrapMode wrap = (TextureWrapMode)1)
		{
			//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)
			Color32[] array = (Color32[])(object)new Color32[w * h];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(Mathf.Clamp01(alpha[i]) * 255f));
			}
			Texture2D obj = NewTex(w, h, filter, wrap);
			obj.SetPixels32(array);
			obj.Apply(false, false);
			return obj;
		}

		private static bool InHeart(float x, float y)
		{
			float num = x * x + y * y - 1f;
			return num * num * num - x * x * y * y * y <= 0f;
		}

		public static void SmoothHeart(int n, out Texture2D fill, out Texture2D outline, out Texture2D shine)
		{
			float[] array = new float[n * n];
			float[] array2 = new float[n * n];
			float[] array3 = new float[n * n];
			float num = 0.0625f;
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					int num2 = 0;
					int num3 = 0;
					int num4 = 0;
					for (int k = 0; k < 4; k++)
					{
						for (int l = 0; l < 4; l++)
						{
							float num5 = ((float)j + ((float)l + 0.5f) / 4f) / (float)n;
							float num6 = ((float)i + ((float)k + 0.5f) / 4f) / (float)n;
							float num7 = (num5 - 0.5f) * 2.9f;
							float num8 = (num6 - 0.5f) * 2.9f + 0.14f;
							bool num9 = InHeart(num7, num8);
							if (num9)
							{
								num2++;
							}
							if (InHeart(num7 / 1.13f, num8 / 1.13f))
							{
								num3++;
							}
							float num10 = (num7 + 0.42f) / 0.22f;
							float num11 = (num8 - 0.52f) / 0.13f;
							if (num9 && num10 * num10 + num11 * num11 <= 1f)
							{
								num4++;
							}
						}
					}
					int num12 = i * n + j;
					array[num12] = (float)num2 * num;
					array2[num12] = (float)num3 * num;
					array3[num12] = (float)num4 * num;
				}
			}
			fill = FromAlpha(array, n, n, (FilterMode)1, (TextureWrapMode)1);
			outline = FromAlpha(array2, n, n, (FilterMode)1, (TextureWrapMode)1);
			shine = FromAlpha(array3, n, n, (FilterMode)1, (TextureWrapMode)1);
		}

		public static void PixelHeart(out Texture2D fill, out Texture2D outline, out Texture2D shine)
		{
			int length = PixelPattern[0].Length;
			int num = PixelPattern.Length;
			int num2 = length + 2;
			int num3 = num + 2;
			int num4 = Mathf.Max(num2, num3);
			int num5 = (num4 - num2) / 2;
			int num6 = (num4 - num3) / 2;
			bool[,] array = new bool[num4, num4];
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < length; j++)
				{
					if (PixelPattern[i][j] == 'X')
					{
						array[j + 1 + num5, num4 - 1 - (i + 1 + num6)] = true;
					}
				}
			}
			float[] array2 = new float[num4 * num4];
			float[] array3 = new float[num4 * num4];
			float[] array4 = new float[num4 * num4];
			for (int k = 0; k < num4; k++)
			{
				for (int l = 0; l < num4; l++)
				{
					int num7 = k * num4 + l;
					if (array[l, k])
					{
						array2[num7] = 1f;
						array3[num7] = 1f;
						continue;
					}
					for (int m = -1; m <= 1; m++)
					{
						if (array3[num7] != 0f)
						{
							break;
						}
						for (int n = -1; n <= 1; n++)
						{
							if (n == 0 || m == 0)
							{
								int num8 = l + n;
								int num9 = k + m;
								if (num8 >= 0 && num9 >= 0 && num8 < num4 && num9 < num4 && array[num8, num9])
								{
									array3[num7] = 1f;
									break;
								}
							}
						}
					}
				}
			}
			int[,] array5 = new int[3, 2]
			{
				{ 1, 1 },
				{ 1, 2 },
				{ 2, 1 }
			};
			for (int num10 = 0; num10 < array5.GetLength(0); num10++)
			{
				int num11 = array5[num10, 1] + 1 + num5;
				int num12 = num4 - 1 - (array5[num10, 0] + 1 + num6);
				array4[num12 * num4 + num11] = 1f;
			}
			fill = FromAlpha(array2, num4, num4, (FilterMode)0, (TextureWrapMode)1);
			outline = FromAlpha(array3, num4, num4, (FilterMode)0, (TextureWrapMode)1);
			shine = FromAlpha(array4, num4, num4, (FilterMode)0, (TextureWrapMode)1);
		}

		public static Texture2D Glow(int n)
		{
			float[] array = new float[n * n];
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					float num = ((float)j + 0.5f) / (float)n * 2f - 1f;
					float num2 = ((float)i + 0.5f) / (float)n * 2f - 1f;
					float num3 = Mathf.Clamp01(Mathf.Sqrt(num * num + num2 * num2));
					array[i * n + j] = (1f - num3) * (1f - num3);
				}
			}
			return FromAlpha(array, n, n, (FilterMode)1, (TextureWrapMode)1);
		}

		public static Texture2D Halo(float thickness)
		{
			float num = Mathf.Clamp(1f - thickness, 0.05f, 0.95f);
			float[] array = new float[65536];
			for (int i = 0; i < 256; i++)
			{
				for (int j = 0; j < 256; j++)
				{
					float num2 = ((float)j + 0.5f) / 256f * 2f - 1f;
					float num3 = ((float)i + 0.5f) / 256f * 2f - 1f;
					float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3);
					float num5 = Mathf.Clamp01((Mathf.Lerp(Mathf.Max(Mathf.Abs(num2), Mathf.Abs(num3)), num4, 0.5f) - num) / (1f - num));
					array[i * 256 + j] = num5 * num5 * (3f - 2f * num5);
				}
			}
			return FromAlpha(array, 256, 256, (FilterMode)1, (TextureWrapMode)1);
		}

		private static float G(float p, float c, float w)
		{
			float num = (p - c) / w;
			return Mathf.Exp((0f - num) * num);
		}

		private static float EcgValue(float p)
		{
			return 0.4f + 0.08f * G(p, 0.18f, 0.035f) - 0.07f * G(p, 0.36f, 0.012f) + 0.52f * G(p, 0.4f, 0.014f) - 0.16f * G(p, 0.44f, 0.014f) + 0.14f * G(p, 0.64f, 0.05f);
		}

		public static Texture2D Ecg(int w, int h)
		{
			float[] array = new float[w * h];
			for (int i = 0; i < w; i++)
			{
				float num = EcgValue((float)i / (float)w) * (float)(h - 4) + 2f;
				float num2 = EcgValue((float)(i + 1) / (float)w) * (float)(h - 4) + 2f;
				float num3 = Mathf.Min(num, num2) - 1.4f;
				float num4 = Mathf.Max(num, num2) + 1.4f;
				for (int j = 0; j < h; j++)
				{
					float num5 = (float)j + 0.5f;
					float num6 = ((num5 < num3) ? (num3 - num5) : ((num5 > num4) ? (num5 - num4) : 0f));
					float num7 = Mathf.Clamp01(1f - num6);
					if (num7 > array[j * w + i])
					{
						array[j * w + i] = num7;
					}
				}
			}
			return FromAlpha(array, w, h, (FilterMode)1, (TextureWrapMode)0);
		}
	}
}