Decompiled source of EnemyKillBonus v4.0.0

EnemyKillBonus.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("REPOJP")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("zabuMod")]
[assembly: AssemblyTitle("zabuMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 REPOJP.EnemyKillBonusMod
{
	[BepInPlugin("REPOJP.EnemyKillBonus", "EnemyKillBonus", "4.0.0")]
	public sealed class EnemyKillBonusPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "REPOJP.EnemyKillBonus";

		public const string PluginName = "EnemyKillBonus";

		public const string PluginVersion = "4.0.0";

		internal static EnemyKillBonusPlugin Instance;

		internal static ManualLogSource ModLogger;

		internal static EnemyKillBonusComboHud ComboHud;

		internal static ConfigEntry<bool> EnableMod;

		internal static ConfigEntry<bool> ApplyInArena;

		internal static ConfigEntry<int> Tier1MinK;

		internal static ConfigEntry<int> Tier1MaxK;

		internal static ConfigEntry<int> Tier2MinK;

		internal static ConfigEntry<int> Tier2MaxK;

		internal static ConfigEntry<int> Tier3MinK;

		internal static ConfigEntry<int> Tier3MaxK;

		internal static ConfigEntry<bool> EnableComboBonus;

		internal static ConfigEntry<float> ComboWindowSeconds;

		internal static ConfigEntry<bool> UseComboCountMinusOneBonus;

		internal static ConfigEntry<int> FixedComboBonusK;

		internal static ConfigEntry<bool> ShowComboHud;

		internal static ConfigEntry<bool> SendTruckScreenMessage;

		internal static ConfigEntry<bool> ShowDebugLog;

		private Harmony harmony;

		private void Awake()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			Instance = this;
			ModLogger = ((BaseUnityPlugin)this).Logger;
			((Component)this).transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)0;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			BindConfig();
			ValidateConfig();
			EnemyKillBonusRuntime.Initialize();
			CreateComboHud();
			harmony = new Harmony("REPOJP.EnemyKillBonus");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"EnemyKillBonus loaded v4.0.0");
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
				harmony = null;
			}
			if ((Object)(object)ComboHud != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)ComboHud).gameObject);
				ComboHud = null;
			}
		}

		private void BindConfig()
		{
			EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "Enable this mod.このMODを有効化");
			ApplyInArena = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ApplyInArena", false, "Apply rewards in arena levels.アリーナでも報酬を適用");
			ShowDebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowDebugLog", false, "Enable debug logs.デバッグログ有効化");
			Tier1MinK = ((BaseUnityPlugin)this).Config.Bind<int>("Reward", "Tier1MinK", 0, "Minimum reward for Difficulty1 enemies in k$.Difficulty1敵の最小報酬k$");
			Tier1MaxK = ((BaseUnityPlugin)this).Config.Bind<int>("Reward", "Tier1MaxK", 2, "Maximum reward for Difficulty1 enemies in k$.Difficulty1敵の最大報酬k$");
			Tier2MinK = ((BaseUnityPlugin)this).Config.Bind<int>("Reward", "Tier2MinK", 2, "Minimum reward for Difficulty2 enemies in k$.Difficulty2敵の最小報酬k$");
			Tier2MaxK = ((BaseUnityPlugin)this).Config.Bind<int>("Reward", "Tier2MaxK", 5, "Maximum reward for Difficulty2 enemies in k$.Difficulty2敵の最大報酬k$");
			Tier3MinK = ((BaseUnityPlugin)this).Config.Bind<int>("Reward", "Tier3MinK", 5, "Minimum reward for Difficulty3 enemies in k$.Difficulty3敵の最小報酬k$");
			Tier3MaxK = ((BaseUnityPlugin)this).Config.Bind<int>("Reward", "Tier3MaxK", 10, "Maximum reward for Difficulty3 enemies in k$.Difficulty3敵の最大報酬k$");
			EnableComboBonus = ((BaseUnityPlugin)this).Config.Bind<bool>("Combo", "EnableComboBonus", true, "Add combo bonus from the second kill.2キル目以降の連続キルボーナスを加算");
			ComboWindowSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Combo", "ComboWindowSeconds", 10f, "Seconds allowed from the previous kill to continue the combo.連続キル継続秒数");
			UseComboCountMinusOneBonus = ((BaseUnityPlugin)this).Config.Bind<bool>("Combo", "UseComboCountMinusOneBonus", true, "Use combo count minus one as the bonus k$.連続キル数-1をボーナスk$として使用");
			FixedComboBonusK = ((BaseUnityPlugin)this).Config.Bind<int>("Combo", "FixedComboBonusK", 1, "Fixed combo bonus in k$ when UseComboCountMinusOneBonus is false.UseComboCountMinusOneBonusがfalseの時の固定ボーナスk$");
			ShowComboHud = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowComboHud", true, "Show local bottom-center combo text and progress bar on the mod-installed client.導入者画面の中央下に連続キルHUDを表示");
			SendTruckScreenMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "SendTruckScreenMessage", true, "Send vanilla TruckScreenText reward messages to all players.全プレイヤーへバニラTruckScreenText通知を送信");
		}

		private void ValidateConfig()
		{
			ClampRange(Tier1MinK, Tier1MaxK, "Tier1");
			ClampRange(Tier2MinK, Tier2MaxK, "Tier2");
			ClampRange(Tier3MinK, Tier3MaxK, "Tier3");
			if (ComboWindowSeconds.Value < 0.1f)
			{
				ComboWindowSeconds.Value = 0.1f;
			}
			if (ComboWindowSeconds.Value > 300f)
			{
				ComboWindowSeconds.Value = 300f;
			}
			if (FixedComboBonusK.Value < 0)
			{
				FixedComboBonusK.Value = 0;
			}
			if (FixedComboBonusK.Value > 9999)
			{
				FixedComboBonusK.Value = 9999;
			}
		}

		private void ClampRange(ConfigEntry<int> minEntry, ConfigEntry<int> maxEntry, string label)
		{
			int num = minEntry.Value;
			int num2 = maxEntry.Value;
			if (num < 0)
			{
				num = 0;
			}
			if (num2 < 0)
			{
				num2 = 0;
			}
			if (num2 < num)
			{
				num2 = num;
			}
			if (num > 9999)
			{
				num = 9999;
			}
			if (num2 > 9999)
			{
				num2 = 9999;
			}
			if (num != minEntry.Value || num2 != maxEntry.Value)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)$"{label} reward range corrected: Min={num} Max={num2}");
			}
			minEntry.Value = num;
			maxEntry.Value = num2;
		}

		private void CreateComboHud()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			GameObject val = new GameObject("REPOJP EnemyKillBonus Combo HUD");
			val.transform.parent = null;
			((Object)val).hideFlags = (HideFlags)0;
			Object.DontDestroyOnLoad((Object)(object)val);
			ComboHud = val.AddComponent<EnemyKillBonusComboHud>();
			ComboHud.Initialize();
		}
	}
	internal static class EnemyKillBonusRuntime
	{
		private static readonly HashSet<int> RewardedEnemyViewIds = new HashSet<int>();

		private static int comboCount;

		private static float lastKillTime = -9999f;

		internal static void Initialize()
		{
			ResetAllState();
		}

		internal static void ResetAllState()
		{
			RewardedEnemyViewIds.Clear();
			comboCount = 0;
			lastKillTime = -9999f;
			if ((Object)(object)EnemyKillBonusPlugin.ComboHud != (Object)null)
			{
				EnemyKillBonusPlugin.ComboHud.HideNow();
			}
		}

		internal static void UnmarkRewarded(EnemyHealth enemyHealth)
		{
			if (!((Object)(object)enemyHealth == (Object)null))
			{
				PhotonView component = ((Component)enemyHealth).GetComponent<PhotonView>();
				if (!((Object)(object)component == (Object)null))
				{
					int enemyRewardKey = GetEnemyRewardKey(enemyHealth, component);
					RewardedEnemyViewIds.Remove(enemyRewardKey);
					WriteDebug("Removed rewarded flag for enemy Key=" + enemyRewardKey);
				}
			}
		}

		internal static void TryHandleEnemyDeath(EnemyHealth enemyHealth)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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)
			if ((Object)(object)enemyHealth == (Object)null || !EnemyKillBonusPlugin.EnableMod.Value || !SemiFunc.IsMasterClientOrSingleplayer() || !IsValidRunContext())
			{
				return;
			}
			PhotonView component = ((Component)enemyHealth).GetComponent<PhotonView>();
			if ((Object)(object)component == (Object)null)
			{
				WriteDebug("Enemy death skipped because PhotonView was not found");
				return;
			}
			int enemyRewardKey = GetEnemyRewardKey(enemyHealth, component);
			if (RewardedEnemyViewIds.Contains(enemyRewardKey))
			{
				WriteDebug("Enemy reward skipped because already rewarded. Key=" + enemyRewardKey);
				return;
			}
			Enemy component2 = ((Component)enemyHealth).GetComponent<Enemy>();
			if ((Object)(object)component2 == (Object)null)
			{
				WriteDebug("Enemy death skipped because Enemy component was not found");
				return;
			}
			EnemyParent componentInParent = ((Component)component2).GetComponentInParent<EnemyParent>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				WriteDebug("Enemy death skipped because EnemyParent was not found");
				return;
			}
			int rewardByDifficulty = GetRewardByDifficulty(componentInParent.difficulty);
			int num = UpdateComboAndGetBonus();
			int num2 = Mathf.Max(0, rewardByDifficulty + num);
			RewardedEnemyViewIds.Add(enemyRewardKey);
			int num3 = SemiFunc.StatGetRunCurrency();
			int num4 = AddCurrencySafe(num3, num2);
			SemiFunc.StatSetRunCurrency(num4);
			Vector3 enemyDeathPosition = GetEnemyDeathPosition(component2);
			PlayerAvatar nearestAlivePlayer = GetNearestAlivePlayer(enemyDeathPosition);
			SendRewardMessage(nearestAlivePlayer, rewardByDifficulty, num, num2);
			ShowComboHud(rewardByDifficulty, num, num2);
			WriteDebug($"Reward applied: Enemy={componentInParent.enemyName}, Difficulty={componentInParent.difficulty}, Base={rewardByDifficulty}k, Combo={num}k, Total={num2}k, ComboCount={comboCount}, Currency {num3}->{num4}");
		}

		private static int GetEnemyRewardKey(EnemyHealth enemyHealth, PhotonView photonView)
		{
			if ((Object)(object)photonView != (Object)null && photonView.ViewID != 0)
			{
				return photonView.ViewID;
			}
			if ((Object)(object)enemyHealth != (Object)null)
			{
				return ((Object)enemyHealth).GetInstanceID();
			}
			return 0;
		}

		private static bool IsValidRunContext()
		{
			if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)StatsManager.instance == (Object)null || (Object)(object)PunManager.instance == (Object)null)
			{
				return false;
			}
			bool flag = false;
			bool flag2 = false;
			try
			{
				flag = SemiFunc.RunIsLevel();
				flag2 = SemiFunc.RunIsArena();
			}
			catch
			{
				return false;
			}
			if (flag)
			{
				return true;
			}
			if (EnemyKillBonusPlugin.ApplyInArena.Value && flag2)
			{
				return true;
			}
			return false;
		}

		private static int UpdateComboAndGetBonus()
		{
			float time = Time.time;
			float value = EnemyKillBonusPlugin.ComboWindowSeconds.Value;
			if (comboCount > 0 && time - lastKillTime <= value)
			{
				comboCount++;
			}
			else
			{
				comboCount = 1;
			}
			lastKillTime = time;
			if (comboCount < 2)
			{
				return 0;
			}
			if (!EnemyKillBonusPlugin.EnableComboBonus.Value)
			{
				return 0;
			}
			if (EnemyKillBonusPlugin.UseComboCountMinusOneBonus.Value)
			{
				return Mathf.Max(0, comboCount - 1);
			}
			return Mathf.Max(0, EnemyKillBonusPlugin.FixedComboBonusK.Value);
		}

		private static int AddCurrencySafe(int beforeCurrency, int addK)
		{
			if (addK <= 0)
			{
				return beforeCurrency;
			}
			long num = (long)beforeCurrency + (long)addK;
			if (num > int.MaxValue)
			{
				return int.MaxValue;
			}
			if (num < 0)
			{
				return 0;
			}
			return (int)num;
		}

		private static Vector3 GetEnemyDeathPosition(Enemy enemy)
		{
			//IL_0038: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)enemy != (Object)null && (Object)(object)enemy.CenterTransform != (Object)null)
			{
				return enemy.CenterTransform.position;
			}
			if ((Object)(object)enemy != (Object)null)
			{
				return ((Component)enemy).transform.position;
			}
			return Vector3.zero;
		}

		private static PlayerAvatar GetNearestAlivePlayer(Vector3 position)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerAvatar> list = null;
			try
			{
				list = SemiFunc.PlayerGetAll();
			}
			catch
			{
				return null;
			}
			if (list == null || list.Count == 0)
			{
				return null;
			}
			PlayerAvatar result = null;
			float num = float.MaxValue;
			foreach (PlayerAvatar item in list)
			{
				if (IsAlivePlayer(item))
				{
					Vector3 playerDistancePosition = GetPlayerDistancePosition(item);
					float num2 = Vector3.Distance(position, playerDistancePosition);
					if (num2 < num)
					{
						num = num2;
						result = item;
					}
				}
			}
			return result;
		}

		private static bool IsAlivePlayer(PlayerAvatar player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			if (!((Component)player).gameObject.activeInHierarchy)
			{
				return false;
			}
			if ((Object)(object)player.playerHealth == (Object)null)
			{
				return false;
			}
			if (player.playerHealth.health <= 0)
			{
				return false;
			}
			return true;
		}

		private static Vector3 GetPlayerDistancePosition(PlayerAvatar player)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player != (Object)null && (Object)(object)player.PlayerVisionTarget != (Object)null && (Object)(object)player.PlayerVisionTarget.VisionTransform != (Object)null)
			{
				return player.PlayerVisionTarget.VisionTransform.position;
			}
			if ((Object)(object)player != (Object)null)
			{
				return ((Component)player).transform.position;
			}
			return Vector3.zero;
		}

		private static int GetRewardByDifficulty(Difficulty difficulty)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected I4, but got Unknown
			int num;
			int num2;
			switch ((int)difficulty)
			{
			case 0:
				num = EnemyKillBonusPlugin.Tier1MinK.Value;
				num2 = EnemyKillBonusPlugin.Tier1MaxK.Value;
				break;
			case 1:
				num = EnemyKillBonusPlugin.Tier2MinK.Value;
				num2 = EnemyKillBonusPlugin.Tier2MaxK.Value;
				break;
			case 2:
				num = EnemyKillBonusPlugin.Tier3MinK.Value;
				num2 = EnemyKillBonusPlugin.Tier3MaxK.Value;
				break;
			default:
				num = EnemyKillBonusPlugin.Tier1MinK.Value;
				num2 = EnemyKillBonusPlugin.Tier1MaxK.Value;
				break;
			}
			if (num < 0)
			{
				num = 0;
			}
			if (num2 < num)
			{
				num2 = num;
			}
			return Random.Range(num, num2 + 1);
		}

		private static void SendRewardMessage(PlayerAvatar nearestAlivePlayer, int baseRewardK, int comboBonusK, int totalRewardK)
		{
			if (!EnemyKillBonusPlugin.SendTruckScreenMessage.Value || (Object)(object)TruckScreenText.instance == (Object)null)
			{
				return;
			}
			string text = string.Empty;
			if ((Object)(object)nearestAlivePlayer != (Object)null)
			{
				try
				{
					text = SemiFunc.PlayerGetName(nearestAlivePlayer);
				}
				catch
				{
					text = string.Empty;
				}
			}
			string text2 = "+" + totalRewardK + "k$";
			if (comboCount >= 2)
			{
				text2 = $"{comboCount} KILL COMBO  +{totalRewardK}k$";
				if (comboBonusK > 0)
				{
					text2 = text2 + "  Combo +" + comboBonusK + "k$";
				}
			}
			else if (baseRewardK != totalRewardK)
			{
				text2 = text2 + "  Base +" + baseRewardK + "k$";
			}
			TruckScreenText.instance.MessageSendCustom(text, text2, 0);
		}

		private static void ShowComboHud(int baseRewardK, int comboBonusK, int totalRewardK)
		{
			if (EnemyKillBonusPlugin.ShowComboHud.Value && comboCount >= 2 && !((Object)(object)EnemyKillBonusPlugin.ComboHud == (Object)null))
			{
				EnemyKillBonusPlugin.ComboHud.Show(comboCount, baseRewardK, comboBonusK, totalRewardK, EnemyKillBonusPlugin.ComboWindowSeconds.Value);
			}
		}

		private static void WriteDebug(string message)
		{
			if (EnemyKillBonusPlugin.ShowDebugLog.Value && EnemyKillBonusPlugin.ModLogger != null)
			{
				EnemyKillBonusPlugin.ModLogger.LogInfo((object)message);
			}
		}
	}
	[HarmonyPatch]
	internal static class EnemyKillBonusPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyHealth), "DeathImpulseRPC")]
		private static void EnemyHealth_DeathImpulseRPC_Postfix(EnemyHealth __instance, PhotonMessageInfo _info)
		{
			try
			{
				EnemyKillBonusRuntime.TryHandleEnemyDeath(__instance);
			}
			catch (Exception ex)
			{
				LogError("Failure: EnemyHealth.DeathImpulseRPC Postfix\n" + ex);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyHealth), "OnSpawn")]
		private static void EnemyHealth_OnSpawn_Postfix(EnemyHealth __instance)
		{
			try
			{
				EnemyKillBonusRuntime.UnmarkRewarded(__instance);
			}
			catch (Exception ex)
			{
				LogError("Failure: EnemyHealth.OnSpawn Postfix\n" + ex);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(LevelGenerator), "GenerateDone")]
		private static void LevelGenerator_GenerateDone_Postfix()
		{
			try
			{
				EnemyKillBonusRuntime.ResetAllState();
			}
			catch (Exception ex)
			{
				LogError("Failure: LevelGenerator.GenerateDone Postfix\n" + ex);
			}
		}

		private static void LogError(string message)
		{
			if (EnemyKillBonusPlugin.ModLogger != null)
			{
				EnemyKillBonusPlugin.ModLogger.LogError((object)message);
			}
		}
	}
	internal sealed class EnemyKillBonusComboHud : MonoBehaviour
	{
		private Canvas canvas;

		private RectTransform rootRect;

		private TextMeshProUGUI comboText;

		private Image barBackground;

		private Image barFill;

		private float displayEndTime;

		private float displayDuration;

		private bool initialized;

		internal void Initialize()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00c8: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized)
			{
				initialized = true;
				canvas = ((Component)this).gameObject.AddComponent<Canvas>();
				canvas.renderMode = (RenderMode)0;
				canvas.sortingOrder = 32760;
				((Behaviour)canvas).enabled = false;
				CanvasScaler val = ((Component)this).gameObject.AddComponent<CanvasScaler>();
				val.uiScaleMode = (ScaleMode)1;
				val.referenceResolution = new Vector2(1920f, 1080f);
				val.screenMatchMode = (ScreenMatchMode)0;
				val.matchWidthOrHeight = 0.5f;
				((Component)this).gameObject.AddComponent<GraphicRaycaster>();
				GameObject val2 = new GameObject("Combo Root");
				val2.transform.SetParent(((Component)this).transform, false);
				rootRect = val2.AddComponent<RectTransform>();
				rootRect.anchorMin = new Vector2(0.5f, 0f);
				rootRect.anchorMax = new Vector2(0.5f, 0f);
				rootRect.pivot = new Vector2(0.5f, 0f);
				rootRect.anchoredPosition = new Vector2(0f, 135f);
				rootRect.sizeDelta = new Vector2(560f, 90f);
				GameObject val3 = new GameObject("Combo Text");
				val3.transform.SetParent(val2.transform, false);
				RectTransform val4 = val3.AddComponent<RectTransform>();
				val4.anchorMin = new Vector2(0f, 0.35f);
				val4.anchorMax = new Vector2(1f, 1f);
				val4.offsetMin = Vector2.zero;
				val4.offsetMax = Vector2.zero;
				comboText = val3.AddComponent<TextMeshProUGUI>();
				((TMP_Text)comboText).alignment = (TextAlignmentOptions)514;
				((TMP_Text)comboText).fontSize = 34f;
				((TMP_Text)comboText).fontStyle = (FontStyles)1;
				((TMP_Text)comboText).enableWordWrapping = false;
				((Graphic)comboText).raycastTarget = false;
				((TMP_Text)comboText).text = string.Empty;
				((Graphic)comboText).color = Color.white;
				GameObject val5 = new GameObject("Combo Bar Background");
				val5.transform.SetParent(val2.transform, false);
				RectTransform val6 = val5.AddComponent<RectTransform>();
				val6.anchorMin = new Vector2(0.18f, 0.08f);
				val6.anchorMax = new Vector2(0.82f, 0.22f);
				val6.offsetMin = Vector2.zero;
				val6.offsetMax = Vector2.zero;
				barBackground = val5.AddComponent<Image>();
				((Graphic)barBackground).color = new Color(0f, 0f, 0f, 0.55f);
				((Graphic)barBackground).raycastTarget = false;
				GameObject val7 = new GameObject("Combo Bar Fill");
				val7.transform.SetParent(val5.transform, false);
				RectTransform val8 = val7.AddComponent<RectTransform>();
				val8.anchorMin = new Vector2(0f, 0f);
				val8.anchorMax = new Vector2(1f, 1f);
				val8.offsetMin = Vector2.zero;
				val8.offsetMax = Vector2.zero;
				barFill = val7.AddComponent<Image>();
				((Graphic)barFill).color = new Color(1f, 0.82f, 0.15f, 0.95f);
				((Graphic)barFill).raycastTarget = false;
			}
		}

		internal void Show(int comboCount, int baseRewardK, int comboBonusK, int totalRewardK, float duration)
		{
			if (!initialized)
			{
				Initialize();
			}
			displayDuration = Mathf.Max(0.1f, duration);
			displayEndTime = Time.time + displayDuration;
			if (comboBonusK > 0)
			{
				((TMP_Text)comboText).text = $"{comboCount} KILL COMBO  +{totalRewardK}k$  BONUS +{comboBonusK}k$";
			}
			else
			{
				((TMP_Text)comboText).text = $"{comboCount} KILL COMBO  +{totalRewardK}k$";
			}
			((Behaviour)canvas).enabled = true;
			UpdateProgressBar(1f);
		}

		internal void HideNow()
		{
			if ((Object)(object)canvas != (Object)null)
			{
				((Behaviour)canvas).enabled = false;
			}
			displayEndTime = 0f;
			displayDuration = 0f;
		}

		private void Update()
		{
			if (initialized && !((Object)(object)canvas == (Object)null) && ((Behaviour)canvas).enabled)
			{
				float num = displayEndTime - Time.time;
				if (num <= 0f)
				{
					HideNow();
					return;
				}
				float progress = Mathf.Clamp01(num / Mathf.Max(0.1f, displayDuration));
				UpdateProgressBar(progress);
			}
		}

		private void UpdateProgressBar(float progress)
		{
			//IL_0026: 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_0042: 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)
			if (!((Object)(object)barFill == (Object)null))
			{
				RectTransform rectTransform = ((Graphic)barFill).rectTransform;
				rectTransform.anchorMin = new Vector2(0f, 0f);
				rectTransform.anchorMax = new Vector2(progress, 1f);
				rectTransform.offsetMin = Vector2.zero;
				rectTransform.offsetMax = Vector2.zero;
			}
		}
	}
}