Decompiled source of DPSMeter v1.0.1

DPSMeter.dll

Decompiled an hour ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DPSMeter.Properties;
using HarmonyLib;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DPSMeter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DPSMeter")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c9836844-3885-4cd3-b034-12e8a2a55709")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public static class RiskOfOptionsCompatibility
{
	public static bool isLoaded => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void OnAwake()
	{
		//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_0011: 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)
		//IL_0028: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Expected O, but got Unknown
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Expected O, but got Unknown
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Expected O, but got Unknown
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Expected O, but got Unknown
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Expected O, but got Unknown
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Expected O, but got Unknown
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Expected O, but got Unknown
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Expected O, but got Unknown
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Expected O, but got Unknown
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Expected O, but got Unknown
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Expected O, but got Unknown
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Expected O, but got Unknown
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Expected O, but got Unknown
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Expected O, but got Unknown
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Expected O, but got Unknown
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Expected O, but got Unknown
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Expected O, but got Unknown
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Expected O, but got Unknown
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Expected O, but got Unknown
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Expected O, but got Unknown
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Expected O, but got Unknown
		//IL_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		StepSliderConfig val = new StepSliderConfig
		{
			min = 0f,
			max = 1f,
			increment = 0.1f
		};
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Plugin.instance.timeSpan));
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Plugin.instance.hideWhenChatBoxActive));
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Plugin.instance.hideBackground));
		ModSettingsManager.AddOption((BaseOption)new ColorOption(Plugin.instance.backgroundColor));
		ModSettingsManager.AddOption((BaseOption)new StepSliderOption(Plugin.instance.pivotX, val));
		ModSettingsManager.AddOption((BaseOption)new StepSliderOption(Plugin.instance.pivotY, val));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Plugin.instance.anchorPositionX));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Plugin.instance.anchorPositionY));
		ModSettingsManager.AddOption((BaseOption)new StepSliderOption(Plugin.instance.anchorMinX, val));
		ModSettingsManager.AddOption((BaseOption)new StepSliderOption(Plugin.instance.anchorMinY, val));
		ModSettingsManager.AddOption((BaseOption)new StepSliderOption(Plugin.instance.anchorMaxX, val));
		ModSettingsManager.AddOption((BaseOption)new StepSliderOption(Plugin.instance.anchorMaxY, val));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Plugin.instance.sizeX));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Plugin.instance.sizeY));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Plugin.instance.anglesX));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Plugin.instance.anglesY));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Plugin.instance.anglesZ));
		ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(Plugin.instance.textFormat));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Plugin.instance.textSpacingX));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Plugin.instance.textSpacingY));
		ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(Plugin.instance.textAlignment));
		ModSettingsManager.AddOption((BaseOption)new ColorOption(Plugin.instance.textColor));
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Plugin.instance.useCommas));
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Plugin.instance.useWholeNumbers));
		Bitmap icon = Resources.icon;
		using MemoryStream memoryStream = new MemoryStream();
		((Image)icon).Save((Stream)memoryStream, ImageFormat.Png);
		Texture2D val2 = new Texture2D(((Image)icon).Width, ((Image)icon).Height, (TextureFormat)5, false, false);
		ImageConversion.LoadImage(val2, memoryStream.ToArray());
		((Texture)val2).filterMode = (FilterMode)0;
		ModSettingsManager.SetModIcon(Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f)));
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("bulletbot.dpsmeter", "DPSMeter", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
	private struct DamageLog
	{
		public float damage;

		public float time;

		public DamageLog(float damage)
		{
			this.damage = damage;
			time = Time.time;
		}
	}

	private const string modGUID = "bulletbot.dpsmeter";

	private const string modName = "DPSMeter";

	private const string modVer = "1.0.1";

	public const string riskOfOptionsModGUID = "com.rune580.riskofoptions";

	public static Plugin instance;

	public ManualLogSource logger;

	private readonly Harmony harmony = new Harmony("bulletbot.dpsmeter");

	public ConfigEntry<float> timeSpan;

	public ConfigEntry<bool> hideWhenChatBoxActive;

	public ConfigEntry<bool> hideBackground;

	public ConfigEntry<Color> backgroundColor;

	public ConfigEntry<float> pivotX;

	public ConfigEntry<float> pivotY;

	public ConfigEntry<float> anchorPositionX;

	public ConfigEntry<float> anchorPositionY;

	public ConfigEntry<float> anchorMinX;

	public ConfigEntry<float> anchorMinY;

	public ConfigEntry<float> anchorMaxX;

	public ConfigEntry<float> anchorMaxY;

	public ConfigEntry<float> sizeX;

	public ConfigEntry<float> sizeY;

	public ConfigEntry<float> anglesX;

	public ConfigEntry<float> anglesY;

	public ConfigEntry<float> anglesZ;

	public ConfigEntry<string> textFormat;

	public ConfigEntry<float> textSpacingX;

	public ConfigEntry<float> textSpacingY;

	public ConfigEntry<string> textAlignment;

	public ConfigEntry<Color> textColor;

	public ConfigEntry<bool> useCommas;

	public ConfigEntry<bool> useWholeNumbers;

	private RectTransform dpsMeterTransform;

	private HGTextMeshProUGUI dpsMeterText;

	private bool previousChatBoxActive;

	public bool chatBoxActive;

	private readonly Queue<DamageLog> characterDamageLogs = new Queue<DamageLog>();

	private float characterDamageSum = 0f;

	private readonly Queue<DamageLog> minionDamageLogs = new Queue<DamageLog>();

	private float minionDamageSum = 0f;

	private readonly Queue<DamageLog> playerDamageLogs = new Queue<DamageLog>();

	private float playerDamageSum = 0f;

	private readonly Queue<DamageLog> teamDamageLogs = new Queue<DamageLog>();

	private float teamDamageSum = 0f;

	private void Awake()
	{
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04af: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0500: Unknown result type (might be due to invalid IL or missing references)
		//IL_0543: Unknown result type (might be due to invalid IL or missing references)
		//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e6: Expected O, but got Unknown
		instance = this;
		logger = Logger.CreateLogSource("DPSMeter");
		timeSpan = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Timespan", 5f, "Measures how much damage is dealt over a specific duration.");
		hideWhenChatBoxActive = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide When Chatbox Active", true, "Determines whether to hide the UI when the chatbox is active.");
		hideBackground = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide Background", false, "Determines whether the background of the UI is visible.");
		hideBackground.SettingChanged += OnSettingChanged;
		backgroundColor = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "Background Color", Color.gray, "The background color of the UI.");
		backgroundColor.SettingChanged += OnSettingChanged;
		pivotX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Pivot X", 0f, "X pivot point of the UI.");
		pivotX.SettingChanged += OnSettingChanged;
		pivotY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Pivot Y", 1f, "Y pivot point of the UI.");
		pivotY.SettingChanged += OnSettingChanged;
		anchorPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Anchor Position X", 5f, "X anchor position of the UI.");
		anchorPositionX.SettingChanged += OnSettingChanged;
		anchorPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Anchor Position Y", 180f, "Y nchor position of the UI.");
		anchorPositionY.SettingChanged += OnSettingChanged;
		anchorMinX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Anchor Min X", 0f, "Minimum X anchor of the UI.");
		anchorMinX.SettingChanged += OnSettingChanged;
		anchorMinY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Anchor Min Y", 0f, "Minimum Y anchor of the UI.");
		anchorMinY.SettingChanged += OnSettingChanged;
		anchorMaxX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Anchor Max X", 0f, "Maximum X anchor of the UI.");
		anchorMaxX.SettingChanged += OnSettingChanged;
		anchorMaxY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Anchor Max Y", 0f, "Maximum Y anchor of the UI.");
		anchorMaxY.SettingChanged += OnSettingChanged;
		sizeX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Size X", 420f, "Width of the UI.");
		sizeX.SettingChanged += OnSettingChanged;
		sizeY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Size Y", 45f, "Height of the UI.");
		sizeY.SettingChanged += OnSettingChanged;
		anglesX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Rotation Angle X", 0f, "X rotation angle of the UI.");
		anglesX.SettingChanged += OnSettingChanged;
		anglesY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Rotation Angle Y", -6f, "Y rotation angle of the UI.");
		anglesY.SettingChanged += OnSettingChanged;
		anglesZ = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Rotation Angle Z", 0f, "Z rotation angle of the UI.");
		anglesZ.SettingChanged += OnSettingChanged;
		textFormat = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Text Format", "DPS: {character+minion}", "Determines the format for displaying text.\nExample: \"Total DPS: {character+minion+player+team}\"\n\nTypes:\ncharacter (You)\nminion (Summoned by you)\nplayer (Other players)\nteam (Same team as you)\n\nSupports rich text.");
		textSpacingX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Text Spacing X", -12f, "Determines the horizontal space adjustment for the DPS text.");
		textSpacingX.SettingChanged += OnSettingChanged;
		textSpacingY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Text Spacing Y", -12f, "Determines the vertical space adjustment for the DPS text.");
		textSpacingY.SettingChanged += OnSettingChanged;
		string text = "The alignment of the DPS text.\n\nOptions:\n";
		foreach (TextAlignmentOptions value in Enum.GetValues(typeof(TextAlignmentOptions)))
		{
			TextAlignmentOptions val = value;
			text = text + ((object)(TextAlignmentOptions)(ref val)).ToString() + "\n";
		}
		ConfigFile config = ((BaseUnityPlugin)this).Config;
		TextAlignmentOptions val2 = (TextAlignmentOptions)4097;
		textAlignment = config.Bind<string>("General", "Text Alignment", ((object)(TextAlignmentOptions)(ref val2)).ToString(), text);
		textAlignment.SettingChanged += OnSettingChanged;
		textColor = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "Text Color", Color.white, "The color of the DPS text.");
		textColor.SettingChanged += OnSettingChanged;
		useCommas = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Commas", true, "Determines whether numbers are displayed with commas for thousands.");
		useWholeNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Whole Numbers", true, "Display DPS as whole numbers.");
		GlobalEventManager.onClientDamageNotified += delegate(DamageDealtMessage message)
		{
			//IL_011b: 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)
			CharacterMaster cachedMaster = LocalUserManager.GetFirstLocalUser().cachedMaster;
			if ((Object)(object)message.attacker == (Object)(object)cachedMaster.GetBodyObject())
			{
				characterDamageSum += message.damage;
				characterDamageLogs.Enqueue(new DamageLog(message.damage));
			}
			else
			{
				CharacterBody component2 = message.attacker.GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					if (component2.isPlayerControlled)
					{
						playerDamageSum += message.damage;
						playerDamageLogs.Enqueue(new DamageLog(message.damage));
					}
					else
					{
						CharacterMaster master = component2.master;
						if (Object.op_Implicit((Object)(object)master))
						{
							if (Object.op_Implicit((Object)(object)master.minionOwnership) && (Object)(object)master.minionOwnership.ownerMaster == (Object)(object)cachedMaster)
							{
								minionDamageSum += message.damage;
								minionDamageLogs.Enqueue(new DamageLog(message.damage));
							}
							else if (master.teamIndex == cachedMaster.teamIndex)
							{
								teamDamageSum += message.damage;
								teamDamageLogs.Enqueue(new DamageLog(message.damage));
							}
						}
					}
				}
			}
		};
		Stage.onStageStartGlobal += delegate
		{
			characterDamageLogs.Clear();
			characterDamageSum = 0f;
			minionDamageLogs.Clear();
			minionDamageSum = 0f;
			playerDamageLogs.Clear();
			playerDamageSum = 0f;
			teamDamageLogs.Clear();
			teamDamageSum = 0f;
		};
		HUD.shouldHudDisplay += (ShouldHudDisplayDelegate)delegate(HUD hud, ref bool _)
		{
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Expected O, but got Unknown
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			while (characterDamageLogs.Count > 0 && characterDamageLogs.Peek().time < Time.time - timeSpan.Value)
			{
				characterDamageSum -= characterDamageLogs.Dequeue().damage;
			}
			while (minionDamageLogs.Count > 0 && minionDamageLogs.Peek().time < Time.time - timeSpan.Value)
			{
				minionDamageSum -= minionDamageLogs.Dequeue().damage;
			}
			while (playerDamageLogs.Count > 0 && playerDamageLogs.Peek().time < Time.time - timeSpan.Value)
			{
				playerDamageSum -= playerDamageLogs.Dequeue().damage;
			}
			while (teamDamageLogs.Count > 0 && teamDamageLogs.Peek().time < Time.time - timeSpan.Value)
			{
				teamDamageSum -= teamDamageLogs.Dequeue().damage;
			}
			if ((Object)(object)dpsMeterTransform != (Object)null && (Object)(object)dpsMeterText != (Object)null)
			{
				if (chatBoxActive != previousChatBoxActive && hideWhenChatBoxActive.Value)
				{
					previousChatBoxActive = chatBoxActive;
					((Component)((TMP_Text)dpsMeterText).transform.parent).gameObject.SetActive(!previousChatBoxActive);
				}
				((TMP_Text)dpsMeterText).text = EvaluateExpressions(textFormat.Value);
			}
			else if ((Object)(object)hud.mainContainer != (Object)null && (Object)(object)hud.mainUIPanel != (Object)null)
			{
				GameObject val3 = new GameObject("DPSMeter");
				dpsMeterTransform = val3.AddComponent<RectTransform>();
				GameObject val4 = new GameObject("Text");
				RectTransform val5 = val4.AddComponent<RectTransform>();
				dpsMeterText = val4.AddComponent<HGTextMeshProUGUI>();
				((TMP_Text)dpsMeterText).enableAutoSizing = true;
				((TMP_Text)dpsMeterText).fontSizeMax = 256f;
				((TMP_Text)dpsMeterText).alignment = (TextAlignmentOptions)4097;
				val4.transform.SetParent(val3.transform);
				((Transform)val5).localPosition = Vector3.zero;
				((Transform)val5).localScale = Vector3.one;
				val5.anchorMin = Vector2.zero;
				val5.anchorMax = Vector2.one;
				val5.anchoredPosition = Vector2.zero;
				val3.transform.SetParent(hud.mainUIPanel.transform);
				((Transform)dpsMeterTransform).localPosition = Vector3.zero;
				((Transform)dpsMeterTransform).localScale = Vector3.one;
				Image component = ((Component)hud.itemInventoryDisplay).gameObject.GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					Image val6 = val3.AddComponent<Image>();
					val6.sprite = component.sprite;
					val6.type = (Type)1;
				}
				UpdateSettings();
				logger.LogMessage((object)"Created UI.");
			}
		};
		if (RiskOfOptionsCompatibility.isLoaded)
		{
			RiskOfOptionsCompatibility.OnAwake();
		}
		harmony.PatchAll();
	}

	public string EvaluateExpressions(string input)
	{
		int num = input.IndexOf('{');
		while (num != -1)
		{
			int num2 = input.IndexOf('}', num);
			if (num2 == -1)
			{
				break;
			}
			string input2 = input.Substring(num, num2 - num + 1);
			string text = Evaluate(input2);
			input = input.Substring(0, num) + text + input.Substring(num2 + 1);
			num = input.IndexOf('{', num + text.Length);
		}
		return input;
	}

	private string Evaluate(string input)
	{
		if (input.Contains("-") || input.Contains("*") || input.Contains("/") || input.Contains("%") || input.Contains("^"))
		{
			return input;
		}
		string result = input;
		try
		{
			input = input.Replace("character", GetCharacterDPS().ToString());
			input = input.Replace("minion", GetMinionDPS().ToString());
			input = input.Replace("player", GetPlayerDPS().ToString());
			input = input.Replace("team", GetTeamDPS().ToString());
			if (decimal.TryParse(new DataTable().Compute(input.Substring(1, input.Length - 2).Trim().Replace(" ", ""), "").ToString(), out var result2))
			{
				return result2.ToString((useCommas.Value ? "N" : "F") + (useWholeNumbers.Value ? "0" : "2"));
			}
			return result;
		}
		catch (Exception)
		{
			return result;
		}
	}

	private float Clamp(float value)
	{
		return Math.Min(Math.Max(1f, value), timeSpan.Value);
	}

	private float GetCharacterDPS()
	{
		if (characterDamageLogs.Count > 0)
		{
			return characterDamageSum / Clamp(Time.time - characterDamageLogs.Peek().time);
		}
		return 0f;
	}

	private float GetMinionDPS()
	{
		if (minionDamageLogs.Count > 0)
		{
			return minionDamageSum / Clamp(Time.time - minionDamageLogs.Peek().time);
		}
		return 0f;
	}

	private float GetPlayerDPS()
	{
		if (playerDamageLogs.Count > 0)
		{
			return playerDamageSum / Clamp(Time.time - playerDamageLogs.Peek().time);
		}
		return 0f;
	}

	private float GetTeamDPS()
	{
		if (teamDamageLogs.Count > 0)
		{
			return teamDamageSum / Clamp(Time.time - teamDamageLogs.Peek().time);
		}
		return 0f;
	}

	private void OnSettingChanged(object sender, EventArgs e)
	{
		UpdateSettings();
	}

	private void UpdateSettings()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_00c5: 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_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: 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)
		Image component = ((Component)dpsMeterTransform).GetComponent<Image>();
		((Behaviour)component).enabled = !hideBackground.Value;
		((Graphic)component).color = backgroundColor.Value;
		dpsMeterTransform.pivot = new Vector2(pivotX.Value, pivotY.Value);
		dpsMeterTransform.anchoredPosition = new Vector2(anchorPositionX.Value, anchorPositionY.Value);
		dpsMeterTransform.anchorMin = new Vector2(anchorMinX.Value, anchorMinY.Value);
		dpsMeterTransform.anchorMax = new Vector2(anchorMaxX.Value, anchorMaxY.Value);
		dpsMeterTransform.sizeDelta = new Vector2(sizeX.Value, sizeY.Value);
		((Transform)dpsMeterTransform).eulerAngles = new Vector3(anglesX.Value, anglesY.Value, anglesZ.Value);
		((Component)dpsMeterText).GetComponent<RectTransform>().sizeDelta = new Vector2(textSpacingX.Value, textSpacingY.Value);
		if (!Enum.TryParse<TextAlignmentOptions>(textAlignment.Value, ignoreCase: false, out TextAlignmentOptions result))
		{
			result = (TextAlignmentOptions)Enum.Parse(typeof(TextAlignmentOptions), (string)((ConfigEntryBase)textAlignment).DefaultValue, ignoreCase: false);
		}
		((TMP_Text)dpsMeterText).alignment = result;
		((TMP_Text)dpsMeterText).faceColor = Color32.op_Implicit(textColor.Value);
	}
}
namespace DPSMeter.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("DPSMeter.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static Bitmap icon
		{
			get
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected O, but got Unknown
				object @object = ResourceManager.GetObject("icon", resourceCulture);
				return (Bitmap)@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace BetterItemCounter.Patches
{
	[HarmonyPatch(typeof(ChatBox))]
	internal class ChatBoxPatch
	{
		[HarmonyPatch("FocusInputField")]
		[HarmonyPrefix]
		private static void FocusInputField()
		{
			Plugin.instance.chatBoxActive = true;
		}

		[HarmonyPatch("UnfocusInputField")]
		[HarmonyPrefix]
		private static void UnfocusInputField()
		{
			Plugin.instance.chatBoxActive = false;
		}
	}
}