Decompiled source of CFFeedback v1.0.1

BepInEx/plugins/CFFeedback.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CFChallenge.Plugin.Configuration;
using CFChallenge.Plugin.Runtime;
using CFChallenge.Plugin.UI;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CFFeedback")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("CFFeedback")]
[assembly: AssemblyTitle("CFFeedback")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 CFChallenge.Plugin
{
	internal static class BuildVariant
	{
		public static readonly bool SupportsIcons = true;

		public static readonly bool SupportsEnergy = false;

		public static readonly string ResourceFolder = "CFFeedback";
	}
	[BepInPlugin("cn.haix.cffeedback", "CF反馈", "1.0.1")]
	public sealed class CfChallengePlugin : BaseUnityPlugin
	{
		private CfChallengeConfiguration? _configuration;

		private CfChallengeRuntime? _runtime;

		private Harmony? _harmony;

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			_configuration = CfChallengeConfiguration.Bind(((BaseUnityPlugin)this).Config);
			_runtime = new CfChallengeRuntime(_configuration, ((BaseUnityPlugin)this).Logger);
			_runtime.Initialize();
			_harmony = new Harmony("cn.haix.cffeedback");
			_harmony.PatchAll(typeof(CfChallengeHooks).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"CF反馈 1.0.1 loaded.");
		}

		private void Update()
		{
			_runtime?.Update();
		}

		private void OnGUI()
		{
			_runtime?.OnGUI();
		}

		private void OnDestroy()
		{
			_runtime?.Shutdown();
			Harmony? harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			_configuration?.Save();
		}
	}
	internal static class PluginInfo
	{
		public const string Guid = "cn.haix.cffeedback";

		public const string Name = "CF反馈";

		public const string Version = "1.0.1";
	}
}
namespace CFChallenge.Plugin.UI
{
	internal sealed class VanillaBlurBackdrop
	{
		private readonly string _name;

		private readonly ManualLogSource _log;

		private readonly List<Image> _images = new List<Image>();

		private readonly Dictionary<Image, Color> _originalColors = new Dictionary<Image, Color>();

		private GameObject? _canvasObject;

		private RectTransform? _panel;

		private bool _readyLogged;

		public VanillaBlurBackdrop(string name, ManualLogSource log)
		{
			_name = name;
			_log = log;
		}

		public bool Ensure()
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_panel != (Object)null)
			{
				return true;
			}
			if ((Object)(object)_canvasObject != (Object)null)
			{
				Dispose();
			}
			InventorySlot val = ((IEnumerable<InventorySlot>)Resources.FindObjectsOfTypeAll<InventorySlot>()).FirstOrDefault((Func<InventorySlot, bool>)delegate(InventorySlot slot)
			{
				//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)
				if ((Object)(object)slot != (Object)null)
				{
					Scene scene = ((Component)slot).gameObject.scene;
					if (((Scene)(ref scene)).IsValid())
					{
						return ((Component)slot).gameObject.activeInHierarchy;
					}
				}
				return false;
			});
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			try
			{
				object? obj = AccessTools.Field(typeof(InventorySlot), "_slot")?.GetValue(val);
				RectTransform val2 = (RectTransform)((obj is RectTransform) ? obj : null);
				if ((Object)(object)val2 == (Object)null)
				{
					throw new InvalidOperationException("InventorySlot._slot is unavailable.");
				}
				Image sourceBlur = ((IEnumerable<Image>)((Component)val2).GetComponentsInChildren<Image>(true)).FirstOrDefault((Func<Image, bool>)IsOriginalBlurImage);
				Image obj2 = sourceBlur;
				if ((Object)(object)((obj2 != null) ? ((Graphic)obj2).material : null) == (Object)null)
				{
					throw new InvalidOperationException("The active inventory slot has no UIBlur image.");
				}
				Canvas componentInParent = ((Component)val2).GetComponentInParent<Canvas>(true);
				_canvasObject = new GameObject("CFChallenge." + _name + ".BlurCanvas", new Type[2]
				{
					typeof(RectTransform),
					typeof(Canvas)
				});
				ConfigureCanvas(_canvasObject.GetComponent<Canvas>(), componentInParent);
				GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, _canvasObject.transform, false);
				((Object)val3).name = "CFChallenge." + _name + ".BlurPanel";
				_panel = val3.GetComponent<RectTransform>();
				if ((Object)(object)_panel == (Object)null)
				{
					throw new InvalidOperationException("The cloned inventory panel has no RectTransform.");
				}
				_panel.anchorMin = new Vector2(0.5f, 0.5f);
				_panel.anchorMax = new Vector2(0.5f, 0.5f);
				_panel.pivot = new Vector2(0.5f, 0.5f);
				((Transform)_panel).localRotation = Quaternion.identity;
				InventorySlot component = val3.GetComponent<InventorySlot>();
				if ((Object)(object)component != (Object)null)
				{
					((Behaviour)component).enabled = false;
				}
				RawImage[] componentsInChildren = val3.GetComponentsInChildren<RawImage>(true);
				foreach (RawImage obj3 in componentsInChildren)
				{
					((Behaviour)obj3).enabled = false;
					((Graphic)obj3).raycastTarget = false;
				}
				TextMeshProUGUI[] componentsInChildren2 = val3.GetComponentsInChildren<TextMeshProUGUI>(true);
				foreach (TextMeshProUGUI obj4 in componentsInChildren2)
				{
					((Behaviour)obj4).enabled = false;
					((Graphic)obj4).raycastTarget = false;
				}
				Graphic[] componentsInChildren3 = val3.GetComponentsInChildren<Graphic>(true);
				foreach (Graphic obj5 in componentsInChildren3)
				{
					obj5.raycastTarget = false;
					Image val4 = (Image)(object)((obj5 is Image) ? obj5 : null);
					if (val4 != null && (((Behaviour)val4).enabled = IsOriginalBlurImage(val4)))
					{
						_images.Add(val4);
						_originalColors[val4] = ((Graphic)val4).color;
					}
				}
				Renderer[] componentsInChildren4 = val3.GetComponentsInChildren<Renderer>(true);
				for (int num = 0; num < componentsInChildren4.Length; num++)
				{
					componentsInChildren4[num].enabled = false;
				}
				if (_images.Count == 0 || _images.Any((Image image) => (Object)(object)((Graphic)image).material != (Object)(object)((Graphic)sourceBlur).material))
				{
					throw new InvalidOperationException("The cloned panel did not retain the original UIBlur material.");
				}
				((Component)_panel).gameObject.SetActive(false);
				if (!_readyLogged)
				{
					ManualLogSource log = _log;
					string[] obj6 = new string[7]
					{
						"Using original How to Fish UIBlur for ",
						_name,
						": material=",
						((Object)((Graphic)sourceBlur).material).name,
						", shader=",
						null,
						null
					};
					Shader shader = ((Graphic)sourceBlur).material.shader;
					obj6[5] = ((shader != null) ? ((Object)shader).name : null) ?? "none";
					obj6[6] = ".";
					log.LogInfo((object)string.Concat(obj6));
					_readyLogged = true;
				}
				return true;
			}
			catch (Exception ex)
			{
				_log.LogWarning((object)("Could not create original UIBlur panel for " + _name + ": " + ex.Message));
				Dispose();
				return false;
			}
		}

		public void SetScreenRect(Rect rect, float alpha)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00c3: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			if (!Ensure() || (Object)(object)_panel == (Object)null)
			{
				return;
			}
			((Component)_panel).gameObject.SetActive(true);
			_panel.anchoredPosition = new Vector2(((Rect)(ref rect)).center.x - (float)Screen.width * 0.5f, (float)Screen.height * 0.5f - ((Rect)(ref rect)).center.y);
			Rect rect2 = _panel.rect;
			float num = Math.Max(1f, ((Rect)(ref rect2)).width);
			rect2 = _panel.rect;
			float num2 = Math.Max(1f, ((Rect)(ref rect2)).height);
			((Transform)_panel).localScale = new Vector3(((Rect)(ref rect)).width / num, ((Rect)(ref rect)).height / num2, 1f);
			foreach (Image image in _images)
			{
				if (!((Object)(object)image == (Object)null))
				{
					Color value;
					Color val = (_originalColors.TryGetValue(image, out value) ? value : Color.white);
					((Graphic)image).color = new Color(val.r, val.g, val.b, val.a * Mathf.Clamp01(alpha));
				}
			}
		}

		public void Hide()
		{
			if ((Object)(object)_panel != (Object)null)
			{
				((Component)_panel).gameObject.SetActive(false);
			}
		}

		public void Dispose()
		{
			if ((Object)(object)_canvasObject != (Object)null)
			{
				Object.Destroy((Object)(object)_canvasObject);
			}
			_canvasObject = null;
			_panel = null;
			_images.Clear();
			_originalColors.Clear();
		}

		private static void ConfigureCanvas(Canvas target, Canvas? source)
		{
			//IL_0008: 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)
			target.renderMode = (RenderMode)((source != null) ? ((int)source.renderMode) : 0);
			target.worldCamera = ((source != null) ? source.worldCamera : null);
			target.planeDistance = ((source != null) ? source.planeDistance : 100f);
			target.pixelPerfect = source != null && source.pixelPerfect;
			target.additionalShaderChannels = (AdditionalCanvasShaderChannels)((source != null) ? ((int)source.additionalShaderChannels) : 0);
			target.targetDisplay = ((source != null) ? source.targetDisplay : 0);
			target.overrideSorting = true;
			target.sortingLayerID = ((source != null) ? source.sortingLayerID : 0);
			target.sortingOrder = 32737;
		}

		private static bool IsOriginalBlurImage(Image image)
		{
			Material material = ((Graphic)image).material;
			object a;
			if (material == null)
			{
				a = null;
			}
			else
			{
				Shader shader = material.shader;
				a = ((shader != null) ? ((Object)shader).name : null);
			}
			return string.Equals((string?)a, "Shader Graphs/UIBlur", StringComparison.Ordinal);
		}
	}
}
namespace CFChallenge.Plugin.Runtime
{
	internal sealed class CfChallengeAudioLibrary
	{
		private static readonly (string Section, string Key, string DefaultPath)[] ClipMappings = new(string, string, string)[21]
		{
			("Combo", "Combo_Kill", "combo/Combo_Kill.wav"),
			("Combo", "MultiKill_1", ""),
			("Combo", "MultiKill_2", "combo/MultiKill_2.wav"),
			("Combo", "MultiKill_3", "combo/MultiKill_3.wav"),
			("Combo", "MultiKill_4", "combo/MultiKill_4.wav"),
			("Combo", "MultiKill_5", "combo/MultiKill_5.wav"),
			("Combo", "MultiKill_6", "combo/MultiKill_6.wav"),
			("Combo", "MultiKill_7", "combo/MultiKill_7.wav"),
			("Combo", "MultiKill_8", "combo/MultiKill_8.wav"),
			("Character", "Headshot", "character/Headshot.wav"),
			("Character", "Knifekill", "character/Knifekill.wav"),
			("Character", "Grenadekill", "character/Grenadekill.wav"),
			("Character", "Round_start_1", "character/Round_start_1.wav"),
			("Character", "Round_start_2", "character/Round_start_2.wav"),
			("Character", "Round_start_3", "character/Round_start_3.wav"),
			("Character", "Round_start_4", "character/Round_start_4.wav"),
			("Character", "Round_start_5", "character/Round_start_5.wav"),
			("Character", "Round_End_Win", "character/Round_End_Win.wav"),
			("Character", "Round_End_Lose", "character/Round_End_Lose.wav"),
			("Character", "Bomb_Plant", "character/Bomb_Plant.wav"),
			("Character", "GrenadeThrow", "")
		};

		private readonly ManualLogSource _log;

		private readonly Dictionary<string, AudioClip> _clips = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase);

		private readonly ConcurrentPlaybackLimiter _playbackLimiter = new ConcurrentPlaybackLimiter();

		private readonly GameObject _host;

		private readonly AudioSource _localSource;

		private readonly AudioSource _globalSource;

		public CfChallengeAudioLibrary(ManualLogSource log)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			_log = log;
			_host = new GameObject("CFChallengeAudio");
			Object.DontDestroyOnLoad((Object)(object)_host);
			_localSource = _host.AddComponent<AudioSource>();
			_globalSource = _host.AddComponent<AudioSource>();
			ConfigureSource(_localSource);
			ConfigureSource(_globalSource);
		}

		public void Dispose()
		{
			if (_host != null)
			{
				Object.Destroy((Object)(object)_host);
			}
			foreach (AudioClip item in _clips.Values.Distinct())
			{
				Object.Destroy((Object)(object)item);
			}
			_clips.Clear();
			_playbackLimiter.Clear();
		}

		public void LoadPack(string packRoot)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if (!Directory.Exists(packRoot))
			{
				_log.LogWarning((object)("Audio pack folder was not found: " + packRoot));
				return;
			}
			ConfigFile val = new ConfigFile(Path.Combine(packRoot, "config.cfg"), true);
			(string, string, string)[] clipMappings = ClipMappings;
			for (int i = 0; i < clipMappings.Length; i++)
			{
				(string, string, string) tuple = clipMappings[i];
				string item = tuple.Item1;
				string item2 = tuple.Item2;
				string item3 = tuple.Item3;
				string value = val.Bind<string>(item, item2, item3, "WAV path relative to this audio pack for " + item2 + ".").Value;
				string text = ResolvePackFile(packRoot, value, ".wav");
				if (text == null || !File.Exists(text))
				{
					if (!item2.Equals("GrenadeThrow", StringComparison.OrdinalIgnoreCase) && !item2.Equals("MultiKill_1", StringComparison.OrdinalIgnoreCase))
					{
						_log.LogWarning((object)("Audio mapping '" + item2 + "' does not resolve to a WAV inside the selected pack: " + value));
					}
				}
				else
				{
					TryLoadClip(item2, text);
				}
			}
			val.Save();
		}

		public bool TryPlay(string clipName, float volume, bool global, int maxSimultaneousPerClip)
		{
			if (volume <= 0f)
			{
				return false;
			}
			string text = NormalizeName(clipName);
			if (!_clips.TryGetValue(text, out AudioClip value))
			{
				return false;
			}
			AudioSource val = (global ? _globalSource : _localSource);
			if (!((Behaviour)val).isActiveAndEnabled)
			{
				return false;
			}
			string playbackKey = (global ? "global:" : "local:") + text;
			double duration = value.length / Math.Max(0.01f, Math.Abs(val.pitch));
			if (!_playbackLimiter.TryAcquire(playbackKey, AudioSettings.dspTime, duration, maxSimultaneousPerClip))
			{
				return false;
			}
			val.PlayOneShot(value, Mathf.Clamp01(volume));
			return true;
		}

		public bool HasClip(string clipName)
		{
			return _clips.ContainsKey(NormalizeName(clipName));
		}

		private static void ConfigureSource(AudioSource source)
		{
			source.playOnAwake = false;
			source.loop = false;
			source.spatialBlend = 0f;
			source.dopplerLevel = 0f;
			source.priority = 0;
			source.volume = 1f;
		}

		private void TryLoadClip(string logicalName, string path)
		{
			try
			{
				string text = NormalizeName(logicalName);
				AudioClip val = LoadWavClip(path, text);
				if (val == null)
				{
					_log.LogWarning((object)("Skipped unsupported WAV file: " + path));
					return;
				}
				_clips[text] = val;
				_log.LogInfo((object)("Loaded audio mapping '" + logicalName + "' from '" + path + "'."));
			}
			catch (Exception ex)
			{
				_log.LogWarning((object)("Could not load WAV '" + path + "': " + ex.Message));
			}
		}

		internal static string? ResolvePackFile(string packRoot, string relativePath, string requiredExtension)
		{
			if (string.IsNullOrWhiteSpace(relativePath) || Path.IsPathRooted(relativePath))
			{
				return null;
			}
			string text = Path.GetFullPath(packRoot).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) + Path.DirectorySeparatorChar;
			string fullPath = Path.GetFullPath(Path.Combine(text, relativePath));
			if (!fullPath.StartsWith(text, StringComparison.OrdinalIgnoreCase) || !Path.GetExtension(fullPath).Equals(requiredExtension, StringComparison.OrdinalIgnoreCase))
			{
				return null;
			}
			return fullPath;
		}

		private static string NormalizeName(string value)
		{
			return value.Trim().ToLowerInvariant();
		}

		private static AudioClip? LoadWavClip(string path, string clipName)
		{
			byte[] array = File.ReadAllBytes(path);
			if (array.Length < 44)
			{
				return null;
			}
			if (Encoding.ASCII.GetString(array, 0, 4) != "RIFF" || Encoding.ASCII.GetString(array, 8, 4) != "WAVE")
			{
				return null;
			}
			short num = 0;
			short num2 = 0;
			int num3 = 0;
			short num4 = 0;
			int num5 = -1;
			int num6 = 0;
			int num7;
			for (int i = 12; i + 8 <= array.Length; i += 8 + num7 + (num7 & 1))
			{
				string text = Encoding.ASCII.GetString(array, i, 4);
				num7 = BitConverter.ToInt32(array, i + 4);
				int num8 = i + 8;
				if (text == "fmt ")
				{
					num = BitConverter.ToInt16(array, num8);
					num2 = BitConverter.ToInt16(array, num8 + 2);
					num3 = BitConverter.ToInt32(array, num8 + 4);
					num4 = BitConverter.ToInt16(array, num8 + 14);
				}
				else if (text == "data")
				{
					num5 = num8;
					num6 = num7;
					break;
				}
			}
			if (num5 < 0 || num2 <= 0 || num3 <= 0 || num4 <= 0)
			{
				return null;
			}
			int num9 = num4 / 8;
			if (num9 <= 0)
			{
				return null;
			}
			int num10 = num6 / num9;
			float[] array2 = new float[num10];
			if (num == 1 && num4 == 16)
			{
				for (int j = 0; j < num10; j++)
				{
					short num11 = BitConverter.ToInt16(array, num5 + j * 2);
					array2[j] = (float)num11 / 32768f;
				}
			}
			else
			{
				if (num != 3 || num4 != 32)
				{
					return null;
				}
				for (int k = 0; k < num10; k++)
				{
					array2[k] = BitConverter.ToSingle(array, num5 + k * 4);
				}
			}
			int num12 = num10 / num2;
			if (num12 <= 0)
			{
				return null;
			}
			AudioClip obj = AudioClip.Create(clipName, num12, (int)num2, num3, false);
			obj.SetData(array2, 0);
			return obj;
		}
	}
	internal enum AttackKind
	{
		Combo,
		Headshot,
		Knife,
		Grenade
	}
	internal readonly struct IconAnimationFrame
	{
		public float Alpha { get; }

		public float Scale { get; }

		public float Brightness { get; }

		public float ShakeEnvelope { get; }

		public IconAnimationFrame(float alpha, float scale, float brightness, float shakeEnvelope)
		{
			Alpha = alpha;
			Scale = scale;
			Brightness = brightness;
			ShakeEnvelope = shakeEnvelope;
		}
	}
	internal static class CfChallengeBehavior
	{
		private const float EntryScale = 1.5f;

		private const float ExitScale = 0.94f;

		private const float EntryBrightness = 3f;

		private const float SettlePulse = 0.025f;

		private const float ShakeDuration = 0.13f;

		public static int AddBossDamage(ref int remainder, int damage, int chunk)
		{
			if (damage <= 0)
			{
				return 0;
			}
			int num = Math.Max(1, chunk);
			long num2 = (long)Math.Max(0, remainder) + (long)damage;
			int result = (int)Math.Min(2147483647L, num2 / num);
			remainder = (int)(num2 % num);
			return result;
		}

		public static float GetComboKillVolume(bool playsSpecialVoice, bool playsMultiKillVoice)
		{
			if (!playsSpecialVoice)
			{
				if (!playsMultiKillVoice)
				{
					return 1f;
				}
				return 0.5f;
			}
			return 0.3f;
		}

		public static string GetKillIconName(AttackKind kind, int streak)
		{
			return kind switch
			{
				AttackKind.Headshot => "Headshot", 
				AttackKind.Knife => "KnifeKill", 
				AttackKind.Grenade => "GrenadeKill", 
				_ => $"Kill{Math.Clamp(streak, 1, 8)}", 
			};
		}

		public static float GetEnergyGain(int damage, bool isBoss, bool isMelee)
		{
			float num = ((damage >= 200) ? 20f : ((damage >= 20) ? 2f : 1f));
			float num2 = (isMelee ? 5f : 1f);
			float num3 = (isBoss ? 1.5f : 1f);
			return num * num2 * num3;
		}

		public static bool ShouldStartC4(int looseExplosiveCount, int configuredThreshold, bool hasNearbyActiveC4)
		{
			if (!hasNearbyActiveC4)
			{
				return looseExplosiveCount >= Math.Max(1, configuredThreshold);
			}
			return false;
		}

		public static int ScalePositiveDamage(int damage, float multiplier)
		{
			if (damage <= 0)
			{
				return damage;
			}
			return Math.Max(1, (int)Math.Round((float)damage * Math.Max(0f, multiplier)));
		}

		public static int ScaleIncomingDamage(int damage, float multiplier)
		{
			if (damage <= 0)
			{
				return damage;
			}
			return Math.Max(1, (int)Math.Ceiling((float)damage * Math.Clamp(multiplier, 0f, 1f)));
		}

		public static IconAnimationFrame EvaluateIconAnimation(float elapsed, float fadeIn, float hold, float fadeOut)
		{
			float num = Math.Max(0f, elapsed);
			float num2 = Math.Max(0.01f, fadeIn);
			float num3 = Math.Max(0.01f, hold);
			float num4 = Math.Max(0.01f, fadeOut);
			if (num < num2)
			{
				float num5 = Clamp01(num / num2);
				return new IconAnimationFrame(Clamp01(num5 * 3.5f), Lerp(1.5f, 1f, EaseOutCubic(num5)), Lerp(3f, 1f, EaseOut(num5)), 0f);
			}
			if (num < num2 + num3)
			{
				float num6 = num - num2;
				float num7 = 1f - Clamp01(num6 / 0.13f);
				return new IconAnimationFrame(1f, 1f + MathF.Sin(num6 * 78f) * 0.025f * num7, 1f, num7);
			}
			float num8 = Clamp01((num - num2 - num3) / num4);
			return new IconAnimationFrame(1f - num8, Lerp(1f, 0.94f, num8), 1f, 0f);
		}

		private static float Clamp01(float value)
		{
			return Math.Clamp(value, 0f, 1f);
		}

		private static float Lerp(float from, float to, float value)
		{
			return from + (to - from) * Clamp01(value);
		}

		private static float EaseOut(float value)
		{
			return 1f - (1f - value) * (1f - value);
		}

		private static float EaseOutCubic(float value)
		{
			float num = 1f - value;
			return 1f - num * num * num;
		}
	}
	internal sealed class ConcurrentPlaybackLimiter
	{
		private const int HardMaximum = 5;

		private readonly Dictionary<string, List<double>> _activeUntil = new Dictionary<string, List<double>>(StringComparer.OrdinalIgnoreCase);

		public bool TryAcquire(string playbackKey, double now, double duration, int configuredMaximum)
		{
			int num = Math.Clamp(configuredMaximum, 1, 5);
			if (!_activeUntil.TryGetValue(playbackKey, out List<double> value))
			{
				value = new List<double>(num);
				_activeUntil[playbackKey] = value;
			}
			value.RemoveAll((double endTime) => endTime <= now);
			if (value.Count >= num)
			{
				return false;
			}
			value.Add(now + Math.Max(0.01, duration));
			return true;
		}

		public void Clear()
		{
			_activeUntil.Clear();
		}
	}
	internal static class CfChallengeHooks
	{
		[HarmonyPatch(typeof(Creature), "OnStartClient")]
		private static class CreatureStartClientPatch
		{
			[HarmonyPostfix]
			private static void Postfix(Creature __instance)
			{
				CfChallengeRuntime.Current?.RegisterBossCreature(__instance);
			}
		}

		[HarmonyPatch(typeof(Creature), "OnStartServer")]
		private static class CreatureStartServerPatch
		{
			[HarmonyPostfix]
			private static void Postfix(Creature __instance)
			{
				CfChallengeRuntime.Current?.RegisterBossCreature(__instance);
			}
		}

		[HarmonyPatch(typeof(Creature), "OnStopClient")]
		private static class CreatureStopClientPatch
		{
			[HarmonyPrefix]
			private static void Prefix(Creature __instance)
			{
				CfChallengeRuntime.Current?.HandleBossStopped(__instance);
			}
		}

		[HarmonyPatch(typeof(Server), "HitCreature")]
		private static class ServerHitCreaturePatch
		{
			[HarmonyPrefix]
			private static void Prefix(Creature creature, Player playerWhoHit, int damage, Vector3 hitPoint)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				CfChallengeRuntime? current = CfChallengeRuntime.Current;
				if (current != null)
				{
					object obj;
					if (playerWhoHit == null)
					{
						obj = null;
					}
					else
					{
						PlayerHolding holding = playerWhoHit.Holding;
						obj = ((holding != null) ? holding.HeldItem : null);
					}
					current.RecordCreatureHit(creature, playerWhoHit, hitPoint, !(obj is Melee), damage, fromExplosion: false);
				}
			}
		}

		[HarmonyPatch(typeof(Creature), "ObserverHit")]
		private static class CreatureObserverHitPatch
		{
			[HarmonyPrefix]
			private static void Prefix(Creature __instance, Player playerWhoHit, Vector3 pos, Vector3 dir, int damage)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				CfChallengeRuntime.Current?.RecordCreatureHit(__instance, playerWhoHit, pos, rangedHit: true, damage, fromExplosion: false, fromNpc: false, HitEventSource.ObserverHit);
			}
		}

		[HarmonyPatch(typeof(Creature), "ObserverExplosionHit")]
		private static class CreatureObserverExplosionHitPatch
		{
			[HarmonyPrefix]
			private static void Prefix(Creature __instance, Player player, Vector3 dir, int damage)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				CfChallengeRuntime.Current?.RecordCreatureHit(__instance, player, ((Component)__instance).transform.position, rangedHit: false, damage, fromExplosion: true, fromNpc: false, HitEventSource.ObserverExplosionHit);
			}
		}

		[HarmonyPatch(typeof(Creature), "OnDeath")]
		private static class CreatureDeathPatch
		{
			[HarmonyPostfix]
			private static void Postfix(Creature __instance)
			{
				CfChallengeRuntime.Current?.HandleCreatureDeath(__instance);
			}
		}

		[HarmonyPatch(typeof(KillScoreCalculator), "CheckHeadshot")]
		private static class OfficialHeadshotPatch
		{
			[HarmonyPrefix]
			private static void Prefix(out int __state)
			{
				__state = GetOfficialBonusCount();
			}

			[HarmonyPostfix]
			private static void Postfix(Creature creature, int __state)
			{
				int officialBonusCount = GetOfficialBonusCount();
				if (__state >= 0 && officialBonusCount > __state)
				{
					CfChallengeRuntime.Current?.RecordOfficialHeadshot(creature);
				}
			}
		}

		[HarmonyPatch(typeof(Explosive), "OnDrop")]
		private static class ExplosiveDropPatch
		{
			[HarmonyPrefix]
			private static void Prefix(Explosive __instance, out bool __state)
			{
				__state = CfChallengeRuntime.Current?.PrepareExplosiveDrop(__instance) ?? false;
			}

			[HarmonyPostfix]
			private static void Postfix(Explosive __instance, bool __state)
			{
				CfChallengeRuntime.Current?.RegisterExplosiveDrop(__instance, __state);
			}
		}

		[HarmonyPatch(typeof(Item), "DestroyItem")]
		private static class ItemDestroyPatch
		{
			[HarmonyPostfix]
			private static void Postfix(Item __instance)
			{
				Explosive val = (Explosive)(object)((__instance is Explosive) ? __instance : null);
				if (val != null)
				{
					CfChallengeRuntime.Current?.RegisterExplosiveDestroyed(val);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerVitals), "Update")]
		private static class PlayerVitalsNoSkillKeyPatch
		{
			private readonly struct TestingState
			{
				public bool Changed { get; }

				public int Damage { get; }

				public int FullnessLost { get; }

				public TestingState(bool changed, int damage, int fullnessLost)
				{
					Changed = changed;
					Damage = damage;
					FullnessLost = fullnessLost;
				}
			}

			[HarmonyPrefix]
			private static void Prefix(PlayerVitals __instance, out TestingState __state)
			{
				__state = default(TestingState);
				Player localPlayer = Player.LocalPlayer;
				if (!((Object)(object)__instance != (Object)(object)((localPlayer != null) ? localPlayer.Vitals : null)) && Input.GetKeyDown((KeyCode)103) && (object)NoSkillTestingDamageField != null && (object)NoSkillTestingFullnessLostField != null && NoSkillTestingDamageField.GetValue(__instance) is int damage && NoSkillTestingFullnessLostField.GetValue(__instance) is int fullnessLost)
				{
					__state = new TestingState(changed: true, damage, fullnessLost);
					NoSkillTestingDamageField.SetValue(__instance, 0);
					NoSkillTestingFullnessLostField.SetValue(__instance, 0);
				}
			}

			[HarmonyPostfix]
			private static void Postfix(PlayerVitals __instance, TestingState __state)
			{
				if (__state.Changed)
				{
					NoSkillTestingDamageField?.SetValue(__instance, __state.Damage);
					NoSkillTestingFullnessLostField?.SetValue(__instance, __state.FullnessLost);
				}
			}
		}

		private static readonly FieldInfo? KillScoreBonusesField = AccessTools.Field(typeof(KillScoreCalculator), "_bonuses");

		private static readonly FieldInfo? NoSkillTestingDamageField = AccessTools.Field(typeof(PlayerVitals), "_testingDamage");

		private static readonly FieldInfo? NoSkillTestingFullnessLostField = AccessTools.Field(typeof(PlayerVitals), "_testingFullnessLost");

		private static int GetOfficialBonusCount()
		{
			if (!(KillScoreBonusesField?.GetValue(null) is ICollection<Bonus> collection))
			{
				return -1;
			}
			return collection.Count;
		}
	}
	internal enum HitEventSource
	{
		LocalHit,
		ObserverHit,
		ObserverExplosionHit
	}
	internal sealed class IconRequest
	{
		public string Name { get; set; } = string.Empty;

		public Texture2D? Texture { get; set; }

		public string FallbackLabel { get; set; } = string.Empty;

		public float StartedAt { get; set; } = -1f;
	}
	internal sealed class DamageEffect
	{
		public string Label { get; set; } = string.Empty;

		public Texture2D? Texture { get; set; }

		public Vector2 Start { get; set; }

		public Vector2 OutwardControl { get; set; }

		public Vector2 InertialControl { get; set; }

		public Vector2 End { get; set; }

		public float SpawnTime { get; set; }

		public float Duration { get; set; }

		public Color Color { get; set; }
	}
	internal sealed class CreatureHitRecord
	{
		public EntityId CreatureId { get; set; }

		public Player? Attacker { get; set; }

		public AttackKind Kind { get; set; }

		public bool FromExplosion { get; set; }

		public HitEventSource LastSource { get; set; }

		public Vector3 LastPoint { get; set; }

		public bool LastRangedHit { get; set; }

		public float LastHitTime { get; set; }

		public int LastDamage { get; set; }

		public int BossDamageRemainder { get; set; }

		public bool IsBoss { get; set; }

		public bool BossStartAnnounced { get; set; }

		public bool BossEndAnnounced { get; set; }

		public bool OfficialHeadshot { get; set; }

		public bool DeathPending { get; set; }

		public int DeathObservedFrame { get; set; }
	}
	internal sealed class ExplosiveCluster
	{
		public EntityId Id { get; set; }

		public Vector3 Center { get; set; }

		public bool Active { get; set; }

		public HashSet<EntityId> MemberIds { get; } = new HashSet<EntityId>();
	}
	internal sealed class HeldFieldSnapshot
	{
		public Object? Target { get; set; }

		public float? WalkSpeed { get; set; }

		public float? SprintSpeed { get; set; }

		public float? CrouchSpeed { get; set; }

		public int? WeaponAmmo { get; set; }

		public int? MeleeDamage { get; set; }

		public float? CameraFov { get; set; }

		public bool Applied { get; set; }
	}
	internal sealed class CfChallengeRuntime
	{
		private static readonly FieldInfo? WeaponAmmoField = AccessTools.Field(typeof(Weapon), "<Ammo>k__BackingField");

		private static readonly FieldInfo? WeaponQueueReloadField = AccessTools.Field(typeof(Weapon), "_queueReload");

		private static readonly FieldInfo? WeaponIsReloadingField = AccessTools.Field(typeof(Weapon), "_isReloading");

		private static readonly FieldInfo? PlayerWalkSpeedField = AccessTools.Field(typeof(PlayerMovement), "_walkSpeed");

		private static readonly FieldInfo? PlayerSprintSpeedField = AccessTools.Field(typeof(PlayerMovement), "_sprintSpeed");

		private static readonly FieldInfo? PlayerCrouchSpeedField = AccessTools.Field(typeof(PlayerMovement), "_crouchSpeed");

		private static readonly FieldInfo? ExplosiveActivatedField = AccessTools.Field(typeof(Explosive), "_isActivated");

		private readonly CfChallengeConfiguration _config;

		private readonly ManualLogSource _log;

		private readonly CfChallengeAudioLibrary _audio;

		private readonly VanillaBlurBackdrop? _energyBackdrop;

		private readonly Dictionary<string, Texture2D> _icons = new Dictionary<string, Texture2D>(StringComparer.OrdinalIgnoreCase);

		private readonly Dictionary<EntityId, CreatureHitRecord> _hits = new Dictionary<EntityId, CreatureHitRecord>();

		private readonly Dictionary<EntityId, ExplosiveCluster> _clusters = new Dictionary<EntityId, ExplosiveCluster>();

		private readonly Dictionary<EntityId, HeldFieldSnapshot> _snapshots = new Dictionary<EntityId, HeldFieldSnapshot>();

		private readonly HashSet<EntityId> _bossSubscriptions = new HashSet<EntityId>();

		private readonly Dictionary<EntityId, Action> _bossDeathHandlers = new Dictionary<EntityId, Action>();

		private readonly Dictionary<EntityId, Action> _bossRemovedHandlers = new Dictionary<EntityId, Action>();

		private readonly List<DamageEffect> _damageEffects = new List<DamageEffect>();

		private IconRequest? _activeIcon;

		private Texture2D? _roundedMask;

		private Texture2D? _roundedBorderMask;

		private GUIStyle? _roundedStyle;

		private GUIStyle? _roundedBorderStyle;

		private Font? _gameFont;

		private Player? _localPlayer;

		private Camera? _localCamera;

		private float _baseFov;

		private float _energy;

		private bool _boostActive;

		private float _boostEndsAt;

		private float _lastKillAt = -999f;

		private float _nextFontProbeAt;

		private float _nextBossProbeAt;

		private int _comboStreak;

		private bool _disposed;

		public static CfChallengeRuntime? Current { get; private set; }

		public bool IsBoostActive
		{
			get
			{
				if (BuildVariant.SupportsEnergy)
				{
					return _boostActive;
				}
				return false;
			}
		}

		public float BoostWeaponDamageMultiplier => _config.BoostWeaponDamageMultiplier.Value;

		public float BoostMeleeDamageMultiplier => _config.BoostMeleeDamageMultiplier.Value;

		public float BoostWeaponRecoilMultiplier => _config.BoostWeaponRecoilMultiplier.Value;

		public float BoostDamageTakenMultiplier => _config.BoostDamageTakenMultiplier.Value;

		public CfChallengeRuntime(CfChallengeConfiguration config, ManualLogSource log)
		{
			_config = config;
			_log = log;
			_audio = new CfChallengeAudioLibrary(log);
			_energyBackdrop = (BuildVariant.SupportsEnergy ? new VanillaBlurBackdrop("Energy", log) : null);
			Current = this;
		}

		public void Initialize()
		{
			string path = Path.Combine(Paths.PluginPath, BuildVariant.ResourceFolder);
			string packRoot = ResolvePackDirectory(Path.Combine(path, "audio"), _config.AudioPack.Value, "audio");
			_audio.LoadPack(packRoot);
			if (BuildVariant.SupportsIcons)
			{
				string packRoot2 = ResolvePackDirectory(Path.Combine(path, "icons"), _config.IconPack.Value, "icon");
				LoadIconPack(packRoot2);
			}
		}

		public void Shutdown()
		{
			if (_disposed)
			{
				return;
			}
			_disposed = true;
			SetBoostActive(active: false);
			_audio.Dispose();
			_energyBackdrop?.Dispose();
			foreach (Texture2D value in _icons.Values)
			{
				Object.Destroy((Object)(object)value);
			}
			if ((Object)(object)_roundedMask != (Object)null)
			{
				Object.Destroy((Object)(object)_roundedMask);
			}
			if ((Object)(object)_roundedBorderMask != (Object)null)
			{
				Object.Destroy((Object)(object)_roundedBorderMask);
			}
			_icons.Clear();
			_roundedMask = null;
			_roundedBorderMask = null;
			_roundedStyle = null;
			_roundedBorderStyle = null;
			_gameFont = null;
			Current = null;
		}

		public void Update()
		{
			if (!_disposed && _config.Enabled.Value)
			{
				RefreshLocalPlayer();
				DiscoverBossCreatures();
				if (BuildVariant.SupportsEnergy)
				{
					UpdateBoost();
					UpdateDamageEffects();
				}
				FinalizePendingDeaths();
				CleanupExpiredData();
			}
		}

		public void OnGUI()
		{
			if (!BuildVariant.SupportsIcons)
			{
				return;
			}
			if (_disposed || !_config.Enabled.Value || !HasActiveLocalPlayer())
			{
				_energyBackdrop?.Hide();
				return;
			}
			if (BuildVariant.SupportsEnergy)
			{
				DrawBoostSpeedEffect();
				DrawEnergyBar();
			}
			DrawIcon();
			if (BuildVariant.SupportsEnergy)
			{
				DrawBoostingMark();
				DrawDamageEffects();
			}
		}

		public void RegisterBossCreature(Creature creature)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (_disposed || creature == null || (int)creature.BossType != 2)
			{
				return;
			}
			EntityId entityId = ((Object)creature).GetEntityId();
			if (!_bossSubscriptions.Contains(entityId))
			{
				CreatureHitRecord orCreateHitRecord = GetOrCreateHitRecord(creature);
				if (!orCreateHitRecord.BossStartAnnounced)
				{
					orCreateHitRecord.BossStartAnnounced = true;
					PlayRoundStart();
				}
				Action action = delegate
				{
					HandleBossDeath(creature);
				};
				Action action2 = delegate
				{
					HandleBossRemoved(creature);
				};
				creature.OnBossDeath += action;
				creature.OnBossRemoved += action2;
				_bossSubscriptions.Add(entityId);
				_bossDeathHandlers[entityId] = action;
				_bossRemovedHandlers[entityId] = action2;
				_log.LogInfo((object)$"Boss registered for local damage tracking: entity={entityId}.");
			}
		}

		public void UnregisterBossCreature(Creature creature)
		{
			//IL_0005: 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_0011: 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_0044: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			if (creature == null)
			{
				return;
			}
			EntityId entityId = ((Object)creature).GetEntityId();
			if (_bossSubscriptions.Remove(entityId))
			{
				if (_bossDeathHandlers.TryGetValue(entityId, out Action value))
				{
					creature.OnBossDeath -= value;
					_bossDeathHandlers.Remove(entityId);
				}
				if (_bossRemovedHandlers.TryGetValue(entityId, out Action value2))
				{
					creature.OnBossRemoved -= value2;
					_bossRemovedHandlers.Remove(entityId);
				}
			}
		}

		public void HandleBossStopped(Creature creature)
		{
			//IL_000d: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!_disposed && creature != null)
			{
				EntityId entityId = ((Object)creature).GetEntityId();
				if (_bossSubscriptions.Contains(entityId) || (_hits.TryGetValue(entityId, out CreatureHitRecord value) && value.IsBoss))
				{
					HandleBossRemoved(creature);
				}
			}
		}

		public void RecordCreatureHit(Creature creature, Player? attacker, Vector3 point, bool rangedHit, int damage, bool fromExplosion, bool fromNpc = false, HitEventSource source = HitEventSource.LocalHit)
		{
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Invalid comparison between Unknown and I4
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			if (_disposed || !_config.Enabled.Value || creature == null || attacker == null || (Object)(object)attacker != (Object)(object)Player.LocalPlayer || fromNpc || damage <= 0)
			{
				return;
			}
			int num = Math.Min(damage, Math.Max(0, creature.Hp));
			if (num <= 0 && damage > 0)
			{
				num = damage;
			}
			if (num <= 0)
			{
				return;
			}
			CreatureHitRecord orCreateHitRecord = GetOrCreateHitRecord(creature);
			float unscaledTime = Time.unscaledTime;
			AttackKind attackKind = DetermineAttackKind(attacker, fromExplosion);
			bool num2 = (Object)(object)orCreateHitRecord.Attacker == (Object)(object)attacker && orCreateHitRecord.LastDamage == num && unscaledTime - orCreateHitRecord.LastHitTime < 0.08f;
			bool flag = orCreateHitRecord.LastSource == source;
			bool flag2 = source == HitEventSource.LocalHit && orCreateHitRecord.LastSource != HitEventSource.LocalHit;
			if (num2 && !flag)
			{
				if (!orCreateHitRecord.OfficialHeadshot && (flag2 || GetAttackPriority(attackKind) > GetAttackPriority(orCreateHitRecord.Kind)))
				{
					orCreateHitRecord.Kind = attackKind;
					orCreateHitRecord.LastRangedHit = rangedHit;
					orCreateHitRecord.LastSource = source;
				}
				return;
			}
			orCreateHitRecord.Attacker = attacker;
			if (!orCreateHitRecord.OfficialHeadshot)
			{
				orCreateHitRecord.Kind = attackKind;
			}
			orCreateHitRecord.LastDamage = num;
			orCreateHitRecord.LastHitTime = unscaledTime;
			orCreateHitRecord.LastPoint = point;
			orCreateHitRecord.LastRangedHit = rangedHit;
			orCreateHitRecord.LastSource = source;
			orCreateHitRecord.IsBoss = (int)creature.BossType == 2;
			if (orCreateHitRecord.IsBoss && _bossSubscriptions.Contains(orCreateHitRecord.CreatureId))
			{
				HandleBossDamage(creature, num);
			}
			if (BuildVariant.SupportsEnergy && !_boostActive)
			{
				float energyGain = CfChallengeBehavior.GetEnergyGain(num, orCreateHitRecord.IsBoss, attackKind == AttackKind.Knife);
				_energy = Math.Clamp(_energy + energyGain, 0f, Math.Max(1f, _config.BoostEnergyCost.Value));
			}
			if (BuildVariant.SupportsEnergy)
			{
				SpawnDamageEffect(num, orCreateHitRecord.IsBoss);
			}
		}

		public void HandleCreatureDeath(Creature creature)
		{
			//IL_000d: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Invalid comparison between Unknown and I4
			if (!_disposed && creature != null)
			{
				EntityId entityId = ((Object)creature).GetEntityId();
				if (_hits.TryGetValue(entityId, out CreatureHitRecord value) && (Object)(object)value.Attacker == (Object)(object)Player.LocalPlayer && Time.unscaledTime - value.LastHitTime <= 3f)
				{
					value.DeathPending = true;
					value.DeathObservedFrame = Time.frameCount;
				}
				else
				{
					_hits.Remove(entityId);
				}
				if ((int)creature.BossType == 2)
				{
					HandleBossDeath(creature);
				}
			}
		}

		public void RecordOfficialHeadshot(Creature creature)
		{
			//IL_000d: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!_disposed && creature != null)
			{
				EntityId entityId = ((Object)creature).GetEntityId();
				if (_hits.TryGetValue(entityId, out CreatureHitRecord value) && (Object)(object)value.Attacker == (Object)(object)Player.LocalPlayer && value.LastRangedHit)
				{
					value.OfficialHeadshot = true;
					value.Kind = AttackKind.Headshot;
				}
			}
		}

		public void HandleBossDamage(Creature creature, int damage)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!_disposed && creature != null && damage > 0)
			{
				CreatureHitRecord orCreateHitRecord = GetOrCreateHitRecord(creature);
				orCreateHitRecord.IsBoss = true;
				int num = Math.Max(1, _config.BossDamageChunk.Value);
				int remainder = orCreateHitRecord.BossDamageRemainder;
				int num2 = CfChallengeBehavior.AddBossDamage(ref remainder, damage, num);
				orCreateHitRecord.BossDamageRemainder = remainder;
				for (int i = 0; i < num2; i++)
				{
					_log.LogInfo((object)($"Local boss damage chunk reached: entity={orCreateHitRecord.CreatureId}, " + $"chunk={num}, remainder={orCreateHitRecord.BossDamageRemainder}."));
					TryPlayAudio("Combo_Kill", 0.65f, global: false);
					ShowIcon("BossDamage", "1000 DAMAGE");
				}
			}
		}

		public void HandleBossDeath(Creature creature)
		{
			//IL_000d: 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_0019: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			if (_disposed || creature == null)
			{
				return;
			}
			EntityId entityId = ((Object)creature).GetEntityId();
			_hits.TryGetValue(entityId, out CreatureHitRecord value);
			if (_bossSubscriptions.Contains(entityId) || (value != null && value.IsBoss))
			{
				CreatureHitRecord creatureHitRecord = value ?? GetOrCreateHitRecord(creature);
				if (!creatureHitRecord.BossEndAnnounced)
				{
					creatureHitRecord.BossEndAnnounced = true;
					bool flag = TryPlayAudio("Round_End_Win", 1f, global: true);
					_log.LogInfo((object)$"Boss victory announced: entity={entityId}, audioPlayed={flag}.");
					UnregisterBossCreature(creature);
				}
			}
		}

		public void HandleBossRemoved(Creature creature)
		{
			//IL_000d: 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_0019: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			if (_disposed || creature == null)
			{
				return;
			}
			EntityId entityId = ((Object)creature).GetEntityId();
			_hits.TryGetValue(entityId, out CreatureHitRecord value);
			if (_bossSubscriptions.Contains(entityId) || (value != null && value.IsBoss))
			{
				CreatureHitRecord creatureHitRecord = value ?? GetOrCreateHitRecord(creature);
				if (!creatureHitRecord.BossEndAnnounced)
				{
					creatureHitRecord.BossEndAnnounced = true;
					bool flag = TryPlayAudio("Round_End_Lose", 1f, global: true);
					_log.LogInfo((object)$"Boss failure announced: entity={entityId}, audioPlayed={flag}.");
					UnregisterBossCreature(creature);
				}
			}
		}

		public bool PrepareExplosiveDrop(Explosive explosive)
		{
			if (_disposed || explosive == null)
			{
				return false;
			}
			if ((Object)(object)(((Item)explosive).Holder ?? ((Item)explosive).LastPlayer) == (Object)(object)Player.LocalPlayer)
			{
				object obj = ExplosiveActivatedField?.GetValue(explosive);
				if (obj is bool)
				{
					return (bool)obj;
				}
				return false;
			}
			return false;
		}

		public void RegisterExplosiveDrop(Explosive explosive, bool activatedLocalThrow)
		{
			//IL_0046: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			if (_disposed || explosive == null || (Object)(object)(((Item)explosive).LastPlayer ?? ((Item)explosive).Holder) != (Object)(object)Player.LocalPlayer)
			{
				return;
			}
			if (activatedLocalThrow)
			{
				TryPlayAudio("GrenadeThrow", 1f, global: false);
				return;
			}
			EntityId entityId = ((Object)explosive).GetEntityId();
			Vector3 position = ((Component)explosive).transform.position;
			float radius = _config.C4Radius.Value;
			Dictionary<EntityId, Explosive> liveExplosives = (from candidate in Object.FindObjectsByType<Explosive>()
				where candidate != null && IsLocalOwnedExplosive(candidate)
				group candidate by ((Object)candidate).GetEntityId()).ToDictionary((IGrouping<EntityId, Explosive> group) => group.Key, (IGrouping<EntityId, Explosive> group) => group.First());
			liveExplosives[entityId] = explosive;
			ReconcileExplosiveClusters(liveExplosives);
			Explosive value;
			ExplosiveCluster explosiveCluster = _clusters.Values.FirstOrDefault((ExplosiveCluster cluster) => cluster.Active && cluster.MemberIds.Any((EntityId memberId) => liveExplosives.TryGetValue(memberId, out value) && Vector3.Distance(((Component)value).transform.position, position) <= radius));
			bool flag = explosiveCluster != null;
			if (flag)
			{
				explosiveCluster.MemberIds.Add(entityId);
				explosiveCluster.Center = AveragePosition(from id in explosiveCluster.MemberIds.Where(liveExplosives.ContainsKey)
					select ((Component)liveExplosives[id]).transform.position);
				return;
			}
			HashSet<EntityId> assignedIds = new HashSet<EntityId>(_clusters.Values.Where((ExplosiveCluster cluster) => cluster.Active).SelectMany((ExplosiveCluster cluster) => cluster.MemberIds));
			Explosive[] array = (from pair in liveExplosives
				where !assignedIds.Contains(pair.Key) && Vector3.Distance(((Component)pair.Value).transform.position, position) <= radius
				select pair.Value).ToArray();
			if (CfChallengeBehavior.ShouldStartC4(array.Length, _config.C4Threshold.Value, flag))
			{
				ExplosiveCluster explosiveCluster2 = new ExplosiveCluster
				{
					Id = entityId,
					Center = AveragePosition(array.Select((Explosive item) => ((Component)item).transform.position)),
					Active = true
				};
				Explosive[] array2 = array;
				foreach (Explosive val in array2)
				{
					explosiveCluster2.MemberIds.Add(((Object)val).GetEntityId());
				}
				_clusters[explosiveCluster2.Id] = explosiveCluster2;
				TryPlayAudio("Bomb_Plant", 1f, global: true);
			}
		}

		private void ReconcileExplosiveClusters(IReadOnlyDictionary<EntityId, Explosive> liveExplosives)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			ExplosiveCluster[] array = _clusters.Values.ToArray();
			foreach (ExplosiveCluster explosiveCluster in array)
			{
				explosiveCluster.MemberIds.RemoveWhere((EntityId id) => !liveExplosives.ContainsKey(id));
				if (explosiveCluster.MemberIds.Count == 0)
				{
					_clusters.Remove(explosiveCluster.Id);
					continue;
				}
				explosiveCluster.Center = AveragePosition(explosiveCluster.MemberIds.Select((EntityId id) => ((Component)liveExplosives[id]).transform.position));
			}
		}

		public void RegisterExplosiveDestroyed(Explosive explosive)
		{
			//IL_000d: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (_disposed || explosive == null)
			{
				return;
			}
			EntityId entityId = ((Object)explosive).GetEntityId();
			ExplosiveCluster[] array = _clusters.Values.ToArray();
			foreach (ExplosiveCluster explosiveCluster in array)
			{
				if (explosiveCluster.MemberIds.Remove(entityId) && explosiveCluster.MemberIds.Count == 0)
				{
					_clusters.Remove(explosiveCluster.Id);
				}
			}
		}

		public int PrepareWeaponShot(Weapon weapon)
		{
			if (_disposed || !_boostActive || !_config.BoostFreeAmmo.Value || weapon == null || (object)WeaponAmmoField == null)
			{
				if (weapon == null)
				{
					return 0;
				}
				return weapon.Ammo;
			}
			int num = Math.Max(1, weapon.Ammo);
			WeaponAmmoField.SetValue(weapon, num);
			WeaponQueueReloadField?.SetValue(weapon, false);
			WeaponIsReloadingField?.SetValue(weapon, false);
			return num;
		}

		public void RegisterWeaponShot(Weapon weapon, int ammoBefore)
		{
			if (!_disposed && _boostActive && _config.BoostFreeAmmo.Value && weapon != null && (object)WeaponAmmoField != null)
			{
				if (weapon.Ammo < ammoBefore)
				{
					WeaponAmmoField.SetValue(weapon, ammoBefore);
				}
				WeaponQueueReloadField?.SetValue(weapon, false);
				WeaponIsReloadingField?.SetValue(weapon, false);
			}
		}

		public bool ShouldSkipWeaponReload(Weapon weapon)
		{
			if (_disposed || !_boostActive || !_config.BoostFreeAmmo.Value || weapon == null || (Object)(object)((Item)weapon).Holder != (Object)(object)Player.LocalPlayer)
			{
				return false;
			}
			if ((object)WeaponAmmoField != null)
			{
				WeaponAmmoField.SetValue(weapon, Math.Max(1, weapon.Ammo));
			}
			WeaponQueueReloadField?.SetValue(weapon, false);
			WeaponIsReloadingField?.SetValue(weapon, false);
			return true;
		}

		public void ForceAddEnergy(int amount)
		{
			if (BuildVariant.SupportsEnergy && !_boostActive)
			{
				_energy = Math.Clamp(_energy + (float)amount, 0f, Math.Max(1f, _config.BoostEnergyCost.Value));
			}
		}

		private void UpdateBoost()
		{
			if (!_boostActive)
			{
				if (IsBoostRequested() && _energy >= (float)Math.Max(1, _config.BoostEnergyCost.Value))
				{
					SetBoostActive(active: true);
				}
			}
			else if (Time.unscaledTime >= _boostEndsAt)
			{
				_energy = 0f;
				SetBoostActive(active: false);
			}
			else
			{
				ApplyBoostState();
			}
		}

		private void SetBoostActive(bool active)
		{
			if (_boostActive == active)
			{
				if (active)
				{
					ApplyBoostState();
				}
				return;
			}
			_boostActive = active;
			if (active)
			{
				_boostEndsAt = Time.unscaledTime + Math.Max(1f, _config.BoostDurationSeconds.Value);
				ApplyBoostState();
			}
			else
			{
				RestoreBoostState();
			}
		}

		private void ApplyBoostState()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			if (_localPlayer == null)
			{
				return;
			}
			_localCamera = _localPlayer.CurCam;
			if (_localCamera != null)
			{
				HeldFieldSnapshot snapshot = GetSnapshot(((Object)_localCamera).GetEntityId());
				snapshot.Target = (Object?)(object)_localCamera;
				if (!snapshot.CameraFov.HasValue)
				{
					snapshot.CameraFov = _localCamera.fieldOfView;
				}
				_localCamera.fieldOfView = snapshot.CameraFov.Value * _config.BoostFovMultiplier.Value;
			}
			PlayerMovement movement = _localPlayer.Movement;
			if (movement != null)
			{
				HeldFieldSnapshot snapshot2 = GetSnapshot(((Object)movement).GetEntityId());
				snapshot2.Target = (Object?)(object)movement;
				HeldFieldSnapshot heldFieldSnapshot = snapshot2;
				if (!heldFieldSnapshot.WalkSpeed.HasValue)
				{
					float? num = (heldFieldSnapshot.WalkSpeed = ReadFloat(PlayerWalkSpeedField, movement));
				}
				heldFieldSnapshot = snapshot2;
				if (!heldFieldSnapshot.SprintSpeed.HasValue)
				{
					float? num = (heldFieldSnapshot.SprintSpeed = ReadFloat(PlayerSprintSpeedField, movement));
				}
				heldFieldSnapshot = snapshot2;
				if (!heldFieldSnapshot.CrouchSpeed.HasValue)
				{
					float? num = (heldFieldSnapshot.CrouchSpeed = ReadFloat(PlayerCrouchSpeedField, movement));
				}
				if (snapshot2.WalkSpeed.HasValue && (object)PlayerWalkSpeedField != null)
				{
					PlayerWalkSpeedField.SetValue(movement, snapshot2.WalkSpeed.Value * _config.BoostMoveMultiplier.Value);
				}
				if (snapshot2.SprintSpeed.HasValue && (object)PlayerSprintSpeedField != null)
				{
					PlayerSprintSpeedField.SetValue(movement, snapshot2.SprintSpeed.Value * _config.BoostMoveMultiplier.Value);
				}
				if (snapshot2.CrouchSpeed.HasValue && (object)PlayerCrouchSpeedField != null)
				{
					PlayerCrouchSpeedField.SetValue(movement, snapshot2.CrouchSpeed.Value * _config.BoostMoveMultiplier.Value);
				}
			}
			PlayerHolding holding = _localPlayer.Holding;
			Item obj = ((holding != null) ? holding.HeldItem : null);
			Weapon val = (Weapon)(object)((obj is Weapon) ? obj : null);
			if (val != null && (object)WeaponAmmoField != null)
			{
				HeldFieldSnapshot snapshot3 = GetSnapshot(((Object)val).GetEntityId());
				snapshot3.Target = (Object?)(object)val;
				if (!snapshot3.WeaponAmmo.HasValue)
				{
					snapshot3.WeaponAmmo = val.Ammo;
				}
			}
		}

		private void RestoreBoostState()
		{
			foreach (HeldFieldSnapshot value in _snapshots.Values)
			{
				if (value.Target == null)
				{
					continue;
				}
				Object? target = value.Target;
				Camera val = (Camera)(object)((target is Camera) ? target : null);
				if (val != null && value.CameraFov.HasValue)
				{
					val.fieldOfView = value.CameraFov.Value;
					continue;
				}
				Object? target2 = value.Target;
				PlayerMovement val2 = (PlayerMovement)(object)((target2 is PlayerMovement) ? target2 : null);
				if (val2 != null)
				{
					RestoreField(val2, PlayerWalkSpeedField, value.WalkSpeed);
					RestoreField(val2, PlayerSprintSpeedField, value.SprintSpeed);
					RestoreField(val2, PlayerCrouchSpeedField, value.CrouchSpeed);
					continue;
				}
				Object? target3 = value.Target;
				Weapon val3 = (Weapon)(object)((target3 is Weapon) ? target3 : null);
				if (val3 != null && value.WeaponAmmo.HasValue && (object)WeaponAmmoField != null)
				{
					WeaponAmmoField.SetValue(val3, value.WeaponAmmo.Value);
				}
			}
			_snapshots.Clear();
		}

		private static void RestoreField(object target, FieldInfo? field, float? original)
		{
			if ((object)field != null && original.HasValue)
			{
				field.SetValue(target, original.Value);
			}
		}

		private void UpdateDamageEffects()
		{
			float now = Time.unscaledTime;
			_damageEffects.RemoveAll((DamageEffect effect) => now - effect.SpawnTime >= effect.Duration);
		}

		private void FinalizePendingDeaths()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			KeyValuePair<EntityId, CreatureHitRecord>[] array = _hits.Where<KeyValuePair<EntityId, CreatureHitRecord>>((KeyValuePair<EntityId, CreatureHitRecord> pair) => pair.Value.DeathPending && Time.frameCount > pair.Value.DeathObservedFrame).ToArray();
			for (int num = 0; num < array.Length; num++)
			{
				KeyValuePair<EntityId, CreatureHitRecord> keyValuePair = array[num];
				RegisterKill(keyValuePair.Value.Kind);
				_hits.Remove(keyValuePair.Key);
			}
		}

		private void CleanupExpiredData()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			float now = Time.unscaledTime;
			EntityId[] array = (from pair in _hits
				where now - pair.Value.LastHitTime > 20f
				select pair.Key).ToArray();
			foreach (EntityId key in array)
			{
				_hits.Remove(key);
			}
			array = (from pair in _clusters
				where pair.Value.MemberIds.Count == 0
				select pair.Key).ToArray();
			foreach (EntityId key2 in array)
			{
				_clusters.Remove(key2);
			}
		}

		private void DiscoverBossCreatures()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime < _nextBossProbeAt)
			{
				return;
			}
			_nextBossProbeAt = unscaledTime + 0.5f;
			Creature[] array = Object.FindObjectsByType<Creature>();
			foreach (Creature val in array)
			{
				if (val != null && (int)val.BossType == 2)
				{
					RegisterBossCreature(val);
				}
			}
		}

		private void SpawnDamageEffect(int damage, bool boss)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00bf: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00fe: 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_014d: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.5f);
			Rect energyRect = GetEnergyRect();
			Vector2 end = default(Vector2);
			((Vector2)(ref end))..ctor(((Rect)(ref energyRect)).xMax - ((Rect)(ref energyRect)).height - 20f, ((Rect)(ref energyRect)).center.y);
			float x = Random.Range(0f, MathF.PI * 2f);
			float num = Math.Min(Screen.width, Screen.height);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(MathF.Cos(x), MathF.Sin(x));
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(0f - val2.y, val2.x);
			Vector2 outwardControl = val + val2 * num * Random.Range(0.14f, 0.2f);
			Vector2 inertialControl = val + val2 * num * Random.Range(0.25f, 0.34f) + val3 * num * Random.Range(-0.07f, 0.07f);
			_damageEffects.Add(new DamageEffect
			{
				Label = (boss ? $"BossDamage {damage}" : $"+{damage}"),
				Texture = GetIconTexture("AIDamageEffect"),
				Start = val,
				OutwardControl = outwardControl,
				InertialControl = inertialControl,
				End = end,
				SpawnTime = Time.unscaledTime,
				Duration = (boss ? 1.1f : 0.95f),
				Color = (boss ? new Color(0.32f, 0.68f, 0.86f, 0.5f) : new Color(0.28f, 0.58f, 0.82f, 0.5f))
			});
		}

		private void RegisterKill(AttackKind kind)
		{
			float unscaledTime = Time.unscaledTime;
			if (!(unscaledTime - _lastKillAt <= _config.ComboWindowSeconds.Value))
			{
				_comboStreak = 1;
			}
			else
			{
				_comboStreak++;
			}
			_lastKillAt = unscaledTime;
			int num = Math.Clamp(_comboStreak, 1, 8);
			bool flag = num == 1 && kind != AttackKind.Combo;
			string clipName = $"MultiKill_{num}";
			bool flag2 = _audio.HasClip(clipName);
			bool playsMultiKillVoice = num >= 2 || flag2;
			float comboKillVolume = CfChallengeBehavior.GetComboKillVolume(flag, playsMultiKillVoice);
			TryPlayAudio("Combo_Kill", comboKillVolume, global: false);
			if (flag2)
			{
				TryPlayAudio(clipName, 1f, global: false);
			}
			string clipName2 = kind switch
			{
				AttackKind.Headshot => "Headshot", 
				AttackKind.Knife => "Knifekill", 
				AttackKind.Grenade => "Grenadekill", 
				_ => string.Empty, 
			};
			if (flag)
			{
				TryPlayAudio(clipName2, 1f, global: false);
			}
			string killIconName = CfChallengeBehavior.GetKillIconName(kind, num);
			ShowIcon(killIconName, killIconName);
		}

		private void PlayRoundStart()
		{
			int num = Random.Range(1, 6);
			string text = $"Round_start_{num}";
			bool flag = TryPlayAudio(text, 1f, global: true);
			_log.LogInfo((object)$"Boss encounter announced: clip={text}, audioPlayed={flag}.");
		}

		private bool TryPlayAudio(string clipName, float volume, bool global)
		{
			return _audio.TryPlay(clipName, volume, global, _config.MaxSimultaneousPerClip.Value);
		}

		private void ShowIcon(string iconName, string fallbackLabel)
		{
			if (BuildVariant.SupportsIcons)
			{
				_activeIcon = new IconRequest
				{
					Name = iconName,
					Texture = GetIconTexture(iconName),
					FallbackLabel = fallbackLabel,
					StartedAt = Time.unscaledTime
				};
			}
		}

		private void DrawIcon()
		{
			if (_activeIcon != null)
			{
				float num = Time.unscaledTime - _activeIcon.StartedAt;
				float num2 = Math.Max(0.01f, _config.IconFadeInSeconds.Value);
				float num3 = Math.Max(0.01f, _config.IconHoldSeconds.Value);
				float num4 = Math.Max(0.01f, _config.IconFadeOutSeconds.Value);
				if (num >= num2 + num3 + num4)
				{
					_activeIcon = null;
				}
				else
				{
					DrawIconRequest(_activeIcon, num, num2, num3, num4);
				}
			}
		}

		private void DrawIconRequest(IconRequest request, float elapsed, float fadeIn, float hold, float fadeOut)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			IconAnimationFrame iconAnimationFrame = CfChallengeBehavior.EvaluateIconAnimation(elapsed, fadeIn, hold, fadeOut);
			float num = elapsed - fadeIn;
			float num2 = _config.IconShakePixels.Value * iconAnimationFrame.ShakeEnvelope;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(Mathf.Sin(num * 92f) * num2, Mathf.Sin(num * 71f + 1.1f) * num2 * 0.58f);
			float num3 = 110f * _config.IconScale.Value * iconAnimationFrame.Scale;
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor((float)Screen.width * 0.5f - num3 * 0.5f + val.x, (float)Screen.height * _config.IconBottomFraction.Value - num3 * 0.5f + val.y, num3, num3);
			GUI.color = new Color(iconAnimationFrame.Brightness, iconAnimationFrame.Brightness, iconAnimationFrame.Brightness, iconAnimationFrame.Alpha);
			if (request.Texture != null)
			{
				GUI.DrawTexture(val2, (Texture)(object)request.Texture, (ScaleMode)2, true);
			}
			else
			{
				GUI.DrawTexture(val2, (Texture)(object)Texture2D.whiteTexture);
				GUI.color = new Color(1f, 1f, 1f, iconAnimationFrame.Alpha);
				GUI.Label(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).yMax + 4f, ((Rect)(ref val2)).width, 18f), request.FallbackLabel, CenteredStyle());
			}
			GUI.color = Color.white;
		}

		private void DrawEnergyBar()
		{
			//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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			Rect energyRect = GetEnergyRect();
			float height = ((Rect)(ref energyRect)).height;
			float num = Math.Max(0f, (height - ((Rect)(ref energyRect)).height) * 0.5f);
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(((Rect)(ref energyRect)).x - 6f, ((Rect)(ref energyRect)).y - num - 6f, ((Rect)(ref energyRect)).width + 12f, ((Rect)(ref energyRect)).height + num * 2f + 12f);
			if (_energyBackdrop != null && _energyBackdrop.Ensure())
			{
				_energyBackdrop.SetScreenRect(rect, 0.1f);
			}
			Rect rect2 = default(Rect);
			((Rect)(ref rect2))..ctor(((Rect)(ref energyRect)).x, ((Rect)(ref energyRect)).y, ((Rect)(ref energyRect)).width - height - 8f, ((Rect)(ref energyRect)).height);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref rect2)).x + 3f, ((Rect)(ref rect2)).y + 3f, ((Rect)(ref rect2)).width - 6f, ((Rect)(ref rect2)).height - 6f);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(((Rect)(ref energyRect)).xMax - height, ((Rect)(ref energyRect)).center.y - height * 0.5f, height, height);
			DrawRoundedBorder(rect2, new Color(1f, 1f, 1f, 0.9f));
			float num2 = (_boostActive ? Mathf.Clamp01((_boostEndsAt - Time.unscaledTime) / Math.Max(1f, _config.BoostDurationSeconds.Value)) : Mathf.Clamp01(_energy / (float)Math.Max(1, _config.BoostEnergyCost.Value)));
			Rect rect3 = default(Rect);
			((Rect)(ref rect3))..ctor(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width * num2, ((Rect)(ref val)).height);
			DrawRounded(rect3, new Color(0.03f, 0.48f, 0.9f, 0.88f));
			if (((Rect)(ref rect3)).width > 1f)
			{
				float num3 = Math.Min(3f, ((Rect)(ref rect3)).width * 0.15f);
				DrawSolid(new Rect(((Rect)(ref rect3)).x + num3, ((Rect)(ref rect3)).y + 2f, Math.Max(0f, ((Rect)(ref rect3)).width - num3 * 2f), Math.Min(2f, ((Rect)(ref rect3)).height)), new Color(0.82f, 0.97f, 1f, 0.76f));
			}
			bool flag = !_boostActive && _energy >= (float)Math.Max(1, _config.BoostEnergyCost.Value);
			bool num4 = IsBoostKeyHeld();
			Color color = (num4 ? new Color(0.66f, 0.92f, 1f, 0.94f) : (_boostActive ? new Color(0.12f, 0.58f, 0.86f, 0.82f) : (flag ? new Color(0.34f, 0.62f, 0.72f, 0.82f) : new Color(0.42f, 0.44f, 0.46f, 0.68f))));
			Color color2 = ((num4 || _boostActive || flag) ? new Color(0.78f, 0.96f, 1f, 1f) : new Color(1f, 1f, 1f, 0.95f));
			DrawRounded(val2, color);
			DrawRoundedBorder(val2, color2);
			GUI.Label(val2, BoostKeyLabel(), GameCenteredStyle(Math.Max(22, (int)(height * 0.54f))));
		}

		private void DrawBoostSpeedEffect()
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00fd: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			if (_boostActive)
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.5f);
				float num = (float)Math.Min(Screen.width, Screen.height) * 0.28f;
				float num2 = MathF.Sqrt(Screen.width * Screen.width + Screen.height * Screen.height) * 0.58f;
				Vector2 val2 = default(Vector2);
				for (int i = 0; i < 24; i++)
				{
					float x = (float)i * MathF.PI * 2f / 24f + 0.07f;
					((Vector2)(ref val2))..ctor(MathF.Cos(x), MathF.Sin(x));
					float num3 = Mathf.Repeat(Time.unscaledTime * 1.75f + (float)i * 0.137f, 1f);
					float num4 = Mathf.Lerp(num, num2, num3);
					float num5 = Mathf.Lerp(28f, 120f, num3);
					float num6 = Mathf.Sin(num3 * MathF.PI) * 0.28f;
					DrawLine(val + val2 * num4, val + val2 * (num4 + num5), Mathf.Lerp(1f, 3f, num3), new Color(0.62f, 0.9f, 1f, num6));
				}
			}
		}

		private void DrawBoostingMark()
		{
			//IL_0016: 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_00aa: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (_boostActive)
			{
				Texture2D iconTexture = GetIconTexture("BoostingMark");
				Rect energyRect = GetEnergyRect();
				float num = Mathf.Clamp01((_boostEndsAt - Time.unscaledTime) / Math.Max(1f, _config.BoostDurationSeconds.Value));
				float num2 = 180f * _config.IconScale.Value;
				Rect val = new Rect(Mathf.Clamp(((Rect)(ref energyRect)).xMax - num2, 12f, (float)Screen.width - num2 - 12f), Mathf.Clamp(((Rect)(ref energyRect)).y - num2 - 12f, 12f, (float)Screen.height - num2 - 12f), num2, num2);
				GUI.color = new Color(0.7f, 0.94f, 1f, Mathf.Lerp(0.7f, 1f, num));
				GUI.DrawTexture(val, (Texture)(object)iconTexture, (ScaleMode)2, true);
				GUI.color = Color.white;
			}
		}

		private void DrawDamageEffects()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//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_00c8: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: 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_0193: Unknown result type (might be due to invalid IL or missing references)
			Rect val2 = default(Rect);
			foreach (DamageEffect damageEffect in _damageEffects)
			{
				float num = Mathf.Clamp01((Time.unscaledTime - damageEffect.SpawnTime) / Math.Max(0.01f, damageEffect.Duration));
				Vector2 val = CubicBezier(damageEffect.Start, damageEffect.OutwardControl, damageEffect.InertialControl, damageEffect.End, num);
				float num2 = SmoothStep01(num / 0.18f);
				float num3 = 1f - SmoothStep01((num - 0.76f) / 0.24f);
				float num4 = Mathf.Lerp(0.12f, 0.88f, EaseOutCubic(num / 0.22f));
				float num5 = Mathf.Lerp(1f, 0.2f, SmoothStep01((num - 0.32f) / 0.68f));
				float num6 = num4 * num5;
				float num7 = num2 * num3 * damageEffect.Color.a;
				float num8 = _config.IconScale.Value * num6;
				((Rect)(ref val2))..ctor(val.x - 48f * num8, val.y - 14f * num8, 96f * num8, 28f * num8);
				GUI.color = new Color(damageEffect.Color.r, damageEffect.Color.g, damageEffect.Color.b, num7);
				if (damageEffect.Texture != null)
				{
					GUI.DrawTexture(val2, (Texture)(object)damageEffect.Texture, (ScaleMode)2, true);
				}
				else
				{
					GUI.Label(val2, damageEffect.Label, EffectStyle());
				}
			}
			GUI.color = Color.white;
		}

		private static Vector2 CubicBezier(Vector2 start, Vector2 outwardControl, Vector2 inertialControl, Vector2 end, float progress)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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)
			float num = Mathf.Clamp01(progress);
			float num2 = 1f - num;
			return num2 * num2 * num2 * start + 3f * num2 * num2 * num * outwardControl + 3f * num2 * num * num * inertialControl + num * num * num * end;
		}

		private static float SmoothStep01(float value)
		{
			float num = Mathf.Clamp01(value);
			return num * num * (3f - 2f * num);
		}

		private static float EaseOutCubic(float value)
		{
			float num = 1f - Mathf.Clamp01(value);
			return 1f - num * num * num;
		}

		private static float EaseInOutCubic(float value)
		{
			float num = Mathf.Clamp01(value);
			if (!(num < 0.5f))
			{
				return 1f - MathF.Pow(-2f * num + 2f, 3f) * 0.5f;
			}
			return 4f * num * num * num;
		}

		private void RefreshLocalPlayer()
		{
			Player localPlayer = Player.LocalPlayer;
			if (localPlayer == null)
			{
				_localPlayer = null;
				_localCamera = null;
			}
			else if (!((Object)(object)_localPlayer == (Object)(object)localPlayer))
			{
				_localPlayer = localPlayer;
				_localCamera = localPlayer.CurCam;
				Camera? localCamera = _localCamera;
				_baseFov = ((localCamera != null) ? localCamera.fieldOfView : 60f);
			}
		}

		private static AttackKind DetermineAttackKind(Player attacker, bool fromExplosion)
		{
			if (fromExplosion)
			{
				return AttackKind.Grenade;
			}
			PlayerHolding holding = attacker.Holding;
			if (((holding != null) ? holding.HeldItem : null) is Melee)
			{
				return AttackKind.Knife;
			}
			return AttackKind.Combo;
		}

		private CreatureHitRecord GetOrCreateHitRecord(Creature creature)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			EntityId entityId = ((Object)creature).GetEntityId();
			if (!_hits.TryGetValue(entityId, out CreatureHitRecord value))
			{
				value = new CreatureHitRecord
				{
					CreatureId = entityId,
					IsBoss = ((int)creature.BossType == 2)
				};
				_hits[entityId] = value;
			}
			return value;
		}

		private HeldFieldSnapshot GetSnapshot(EntityId id)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!_snapshots.TryGetValue(id, out HeldFieldSnapshot value))
			{
				value = new HeldFieldSnapshot();
				_snapshots[id] = value;
			}
			return value;
		}

		private Texture2D GetIconTexture(string name)
		{
			string key = NormalizeIconName(name);
			if (_icons.TryGetValue(key, out Texture2D value))
			{
				return value;
			}
			value = BuildFallbackIcon(key);
			_icons[key] = value;
			return value;
		}

		private void LoadIconPack(string packRoot)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Expected O, but got Unknown
			if (!Directory.Exists(packRoot))
			{
				_log.LogWarning((object)("Icon pack folder was not found: " + packRoot));
				return;
			}
			ConfigFile val = new ConfigFile(Path.Combine(packRoot, "config.cfg"), true);
			(string, string, string)[] array = new(string, string, string)[14]
			{
				("Kill", "Kill1", "badge_multi1.png"),
				("Kill", "Kill2", "badge_multi2.png"),
				("Kill", "Kill3", "badge_multi3.png"),
				("Kill", "Kill4", "badge_multi4.png"),
				("Kill", "Kill5", "badge_multi5.png"),
				("Kill", "Kill6", "badge_multi6.png"),
				("Kill", "Kill7", "badge_multi6.png"),
				("Kill", "Kill8", "badge_multi6.png"),
				("Special", "Headshot", "badge_headshot.png"),
				("Special", "KnifeKill", "badge_knife.png"),
				("Special", "GrenadeKill", "badge_grenade.png"),
				("Effects", "AIDamageEffect", "AIDamageEffect.png"),
				("Effects", "BossDamage", "BossDamage.png"),
				("Effects", "BoostingMark", "BoostingMark.png")
			};
			for (int i = 0; i < array.Length; i++)
			{
				(string, string, string) tuple = array[i];
				string item = tuple.Item1;
				string item2 = tuple.Item2;
				string item3 = tuple.Item3;
				string value = val.Bind<string>(item, item2, item3, "Image path relative to this icon pack for " + item2 + ".").Value;
				string text = ResolveImagePath(packRoot, value);
				if (text == null || !File.Exists(text))
				{
					_log.LogWarning((object)("Icon mapping '" + item2 + "' does not resolve to an image inside the selected pack: " + value));
					continue;
				}
				try
				{
					Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false);
					if (ImageConversion.LoadImage(val2, File.ReadAllBytes(text)))
					{
						bool flag = ((item == "Kill" || item == "Special") ? true : false);
						if (flag || item2 == "BossDamage")
						{
							val2 = TrimTransparentPadding(val2);
						}
						((Texture)val2).filterMode = (FilterMode)1;
						((Texture)val2).wrapMode = (TextureWrapMode)1;
						_icons[NormalizeIconName(item2)] = val2;
						_log.LogInfo((object)("Loaded icon mapping '" + item2 + "' from '" + text + "'."));
					}
					else
					{
						Object.Destroy((Object)(object)val2);
					}
				}
				catch (Exception ex)
				{
					_log.LogWarning((object)("Could not load icon '" + text + "': " + ex.Message));
				}
			}
			val.Save();
		}

		private static Texture2D TrimTransparentPadding(Texture2D source)
		{
			//IL_00fe: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			Color32[] pixels = source.GetPixels32();
			int num = ((Texture)source).width;
			int num2 = ((Texture)source).height;
			int num3 = -1;
			int num4 = -1;
			for (int i = 0; i < ((Texture)source).height; i++)
			{
				int num5 = i * ((Texture)source).width;
				for (int j = 0; j < ((Texture)source).width; j++)
				{
					if (pixels[num5 + j].a > 8)
					{
						num = Math.Min(num, j);
						num2 = Math.Min(num2, i);
						num3 = Math.Max(num3, j);
						num4 = Math.Max(num4, i);
					}
				}
			}
			if (num3 < num || num4 < num2 || (num == 0 && num2 == 0 && num3 == ((Texture)source).width - 1 && num4 == ((Texture)source).height - 1))
			{
				return source;
			}
			int num6 = num3 - num + 1;
			int num7 = num4 - num2 + 1;
			Color32[] array = (Color32[])(object)new Color32[num6 * num7];
			for (int k = 0; k < num7; k++)
			{
				Array.Copy(pixels, (num2 + k) * ((Texture)source).width + num, array, k * num6, num6);
			}
			Texture2D val = new Texture2D(num6, num7, (TextureFormat)4, false);
			val.SetPixels32(array);
			val.Apply(false, false);
			Object.Destroy((Object)(object)source);
			return val;
		}

		private static Texture2D BuildFallbackIcon(string key)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false);
			Color32[] array = (Color32[])(object)new Color32[16384];
			Color32 val2 = (Color32)(key switch
			{
				"headshot" => new Color32((byte)240, (byte)105, (byte)105, byte.MaxValue), 
				"knifekill" => new Color32((byte)150, (byte)220, byte.MaxValue, byte.MaxValue), 
				"grenadekill" => new Color32((byte)150, byte.MaxValue, (byte)170, byte.MaxValue), 
				"boostingmark" => new Color32(byte.MaxValue, (byte)210, (byte)70, byte.MaxValue), 
				_ => new Color32(byte.MaxValue, (byte)225, (byte)110, byte.MaxValue), 
			});
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					bool flag = j < 6 || i < 6 || j >= 122 || i >= 122;
					bool flag2 = Math.Abs(j - 64) < 6 || Math.Abs(i - 64) < 6;
					array[i * 128 + j] = (Color32)(flag ? new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue) : (flag2 ? val2 : new Color32((byte)45, (byte)50, (byte)65, (byte)240)));
				}
			}
			val.SetPixels32(array);
			val.Apply();
			return val;
		}

		private Rect GetEnergyRect()
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			float num = Math.Min(_config.EnergyBarWidth.Value, Math.Max(140f, (float)Screen.width - 24f));
			float value = _config.EnergyBarHeight.Value;
			float num2 = Mathf.Clamp((float)Screen.width - _config.EnergyBarRight.Value - num, 12f, Math.Max(12f, (float)Screen.width - num - 12f));
			float num3 = Mathf.Clamp((float)Screen.height - _config.EnergyBarBottom.Value - value, 12f, Math.Max(12f, (float)Screen.height - value - 12f));
			return new Rect(num2, num3, num, value);
		}

		private bool HasActiveLocalPlayer()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_localPlayer != (Object)null)
			{
				Scene scene = ((Component)_localPlayer).gameObject.scene;
				if (((Scene)(ref scene)).IsValid())
				{
					return ((Component)_localPlayer).gameObject.activeInHierarchy;
				}
			}
			return false;
		}

		private static void DrawSolid(Rect rect, Color color)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Rect)(ref rect)).width <= 0f) && !(((Rect)(ref rect)).height <= 0f))
			{
				Color color2 = GUI.color;
				GUI.color = color;
				GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture);
				GUI.color = color2;
			}
		}

		private static void DrawLine(Vector2 from, Vector2 to, float width, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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)
			Vector2 val = to - from;
			float magnitude = ((Vector2)(ref val)).magnitude;
			if (!(magnitude <= 0.01f) && !(width <= 0f))
			{
				Matrix4x4 matrix = GUI.matrix;
				GUIUtility.RotateAroundPivot(Mathf.Atan2(val.y, val.x) * 57.29578f, from);
				DrawSolid(new Rect(from.x, from.y - width * 0.5f, magnitude, width), color);
				GUI.matrix = matrix;
			}
		}

		private void DrawRounded(Rect rect, Color color)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Rect)(ref rect)).width <= 0f) && !(((Rect)(ref rect)).height <= 0f))
			{
				EnsureRoundedStyle();
				if (_roundedStyle == null)
				{
					DrawSolid(rect, color);
					return;
				}
				Color color2 = GUI.color;
				GUI.color = color;
				GUI.Box(rect, GUIContent.none, _roundedStyle);
				GUI.color = color2;
			}
		}

		private void DrawRoundedBorder(Rect rect, Color color)
		{
			//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_0037: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Rect)(ref rect)).width <= 0f) && !(((Rect)(ref rect)).height <= 0f))
			{
				EnsureRoundedStyle();
				if (_roundedBorderStyle != null)
				{
					Color color2 = GUI.color;
					GUI.color = color;
					GUI.Box(rect, GUIContent.none, _roundedBorderStyle);
					GUI.color = color2;
				}
			}
		}

		private void EnsureRoundedStyle()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0044: Expected O, but got Unknown
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Expected O, but got Unknown
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: 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_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Expected O, but got Unknown
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Expected O, but got Unknown
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			if (_roundedStyle != null && _roundedBorderStyle != null)
			{
				return;
			}
			float num = 12f;
			Texture2D val = new Texture2D(24, 24, (TextureFormat)4, false)
			{
				name = "CFChallenge.RoundedMask",
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)61
			};
			Color32[] array = (Color32[])(object)new Color32[576];
			Color32[] array2 = (Color32[])(object)new Color32[576];
			for (int i = 0; i < 24; i++)
			{
				for (int j = 0; j < 24; j++)
				{
					float val2 = Math.Abs((float)j + 0.5f - num) - (num - 6f);
					float val3 = Math.Abs((float)i + 0.5f - num) - (num - 6f);
					float num2 = Math.Max(val2, 0f);
					float num3 = Math.Max(val3, 0f);
					float num4 = MathF.Sqrt(num2 * num2 + num3 * num3) - 6f;
					float num5 = Mathf.Clamp01(0.5f - num4);
					byte b = (byte)Math.Round(num5 * 255f);
					array[i * 24 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
					float num6 = num - 2f;
					float num7 = 4f;
					float val4 = Math.Abs((float)j + 0.5f - num) - (num6 - num7);
					float val5 = Math.Abs((float)i + 0.5f - num) - (num6 - num7);
					float num8 = Math.Max(val4, 0f);
					float num9 = Math.Max(val5, 0f);
					float num10 = MathF.Sqrt(num8 * num8 + num9 * num9) - num7;
					float num11 = Mathf.Clamp01(0.5f - num10);
					byte b2 = (byte)Math.Round(num5 * (1f - num11) * 255f);
					array2[i * 24 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b2);
				}
			}
			val.SetPixels32(array);
			val.Apply(false, true);
			_roundedMask = val;
			_roundedStyle = new GUIStyle();
			_roundedStyle.normal.background = val;
			_roundedStyle.border = new RectOffset(7, 7, 7, 7);
			Texture2D val6 = new Texture2D(24, 24, (TextureFormat)4, false)
			{
				name = "CFChallenge.RoundedBorderMask",
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)61
			};
			val6.SetPixels32(array2);
			val6.Apply(false, true);
			_roundedBorderMask = val6;
			_roundedBorderStyle = new GUIStyle();
			_roundedBorderStyle.normal.background = val6;
			_roundedBorderStyle.border = new RectOffset(7, 7, 7, 7);
		}

		private bool IsBoostRequested()
		{
			//IL_000b: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or miss