Decompiled source of DPSMeter v1.0.9

plugins/DPSMeter/DPSMeter.dll

Decompiled 2 weeks 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.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DPSMeter.Properties;
using HarmonyLib;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ConVar;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
using WolfoQualityOfLife;

[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")]
namespace DPSMeter
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("bulletbot.dpsmeter", "DPSMeter", "1.0.9")]
	public class Plugin : BaseUnityPlugin
	{
		private class ColorJsonConverter : JsonConverter
		{
			public override bool CanConvert(Type objectType)
			{
				return objectType == typeof(Color);
			}

			public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
			{
				return null;
			}

			public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				writer.WriteValue("#" + ColorUtility.ToHtmlStringRGBA((Color)value));
			}
		}

		private static class RiskOfOptions
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static UnityAction <>9__1_0;

				internal void <OnAwake>b__1_0()
				{
					//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_0152: Unknown result type (might be due to invalid IL or missing references)
					//IL_0157: Unknown result type (might be due to invalid IL or missing references)
					//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
					//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
					//IL_032b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0332: Expected O, but got Unknown
					if (!Directory.Exists(instance.presetsPath))
					{
						Directory.CreateDirectory(instance.presetsPath);
					}
					int num = 0;
					Regex regex = new Regex("Preset(\\d+)\\.json");
					string[] files = Directory.GetFiles(instance.presetsPath, "Preset*.json");
					foreach (string path in files)
					{
						if (File.Exists(path))
						{
							Match match = regex.Match(Path.GetFileName(path));
							if (match.Success && int.TryParse(match.Groups[1].Value, out var result) && result > num)
							{
								num = result;
							}
						}
					}
					string text = $"Preset{num + 1}";
					Preset preset = new Preset(text)
					{
						timeSpan = instance.timeSpan.Value,
						toggleVisibility = instance.toggleVisibility.Value,
						isVisible = instance.isVisible.Value,
						hideWhenChatboxActive = instance.hideWhenChatboxActive.Value,
						hideBackground = instance.hideBackground.Value,
						backgroundColor = instance.backgroundColor.Value,
						hudScaling = instance.hudScaling.Value,
						parent = instance.parent.Value,
						sizeX = instance.sizeX.Value,
						sizeY = instance.sizeY.Value,
						anglesX = instance.anglesX.Value,
						anglesY = instance.anglesY.Value,
						anglesZ = instance.anglesZ.Value,
						pivotX = instance.pivotX.Value,
						pivotY = instance.pivotY.Value,
						anchorPositionX = instance.anchorPositionX.Value,
						anchorPositionY = instance.anchorPositionY.Value,
						anchorMinX = instance.anchorMinX.Value,
						anchorMinY = instance.anchorMinY.Value,
						anchorMaxX = instance.anchorMaxX.Value,
						anchorMaxY = instance.anchorMaxY.Value,
						textFormat = instance.textFormat.Value,
						textSpacingX = instance.textSpacingX.Value,
						textSpacingY = instance.textSpacingY.Value,
						textAlignment = instance.textAlignment.Value,
						textColor = instance.textColor.Value,
						useCommas = instance.useCommas.Value,
						useWholeNumbers = instance.useWholeNumbers.Value
					};
					JsonSerializerSettings val = new JsonSerializerSettings();
					val.Converters.Add((JsonConverter)(object)new ColorJsonConverter());
					File.WriteAllText(Path.Combine(instance.presetsPath, text + ".json"), JsonConvert.SerializeObject((object)preset, (Formatting)1, val));
					instance.logger.LogMessage((object)("Preset successfully exported: \"" + text + "\""));
				}
			}

			public static bool IsLoaded()
			{
				return Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
			}

			public static void OnAwake()
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Expected O, but got Unknown
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Expected O, but got Unknown
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Expected O, but got Unknown
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Expected O, but got Unknown
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Expected O, but got Unknown
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Expected O, but got Unknown
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Expected O, but got Unknown
				//IL_0138: Unknown result type (might be due to invalid IL or missing references)
				//IL_0142: Expected O, but got Unknown
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Expected O, but got Unknown
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_016d: Expected O, but got Unknown
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Expected O, but got Unknown
				//IL_018d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0197: Expected O, but got Unknown
				//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Expected O, but got Unknown
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c1: Expected O, but got Unknown
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d6: Expected O, but got Unknown
				//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ec: Expected O, but got Unknown
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Expected O, but got Unknown
				//IL_020d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0217: Expected O, but got Unknown
				//IL_0222: Unknown result type (might be due to invalid IL or missing references)
				//IL_022c: Expected O, but got Unknown
				//IL_0238: Unknown result type (might be due to invalid IL or missing references)
				//IL_0242: Expected O, but got Unknown
				//IL_024e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0258: Expected O, but got Unknown
				//IL_0264: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: Expected O, but got Unknown
				//IL_027a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0284: Expected O, but got Unknown
				//IL_0290: Unknown result type (might be due to invalid IL or missing references)
				//IL_029a: Expected O, but got Unknown
				//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_02af: Expected O, but got Unknown
				//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c4: Expected O, but got Unknown
				//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d9: Expected O, but got Unknown
				//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ee: Expected O, but got Unknown
				//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0303: Expected O, but got Unknown
				//IL_030e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0318: Expected O, but got Unknown
				//IL_034c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0356: Expected O, but got Unknown
				//IL_0341: Unknown result type (might be due to invalid IL or missing references)
				//IL_0346: Unknown result type (might be due to invalid IL or missing references)
				//IL_034c: Expected O, but got Unknown
				//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ad: Expected O, but got Unknown
				//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b2: Expected O, but got Unknown
				Bitmap icon = Resources.icon;
				using (MemoryStream memoryStream = new MemoryStream())
				{
					((Image)icon).Save((Stream)memoryStream, ImageFormat.Png);
					Texture2D val = new Texture2D(((Image)icon).Width, ((Image)icon).Height, (TextureFormat)5, false, false);
					ImageConversion.LoadImage(val, memoryStream.ToArray());
					((Texture)val).filterMode = (FilterMode)0;
					ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)));
				}
				StepSliderConfig val2 = new StepSliderConfig
				{
					min = 0f,
					max = 1f,
					increment = 0.01f
				};
				InputFieldConfig val3 = new InputFieldConfig
				{
					richText = false
				};
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(instance.timeSpan));
				ModSettingsManager.AddOption((BaseOption)new KeyBindOption(instance.toggleVisibility));
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(instance.isVisible));
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(instance.hideWhenChatboxActive));
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(instance.hideBackground));
				ModSettingsManager.AddOption((BaseOption)new ColorOption(instance.backgroundColor));
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(instance.hudScaling));
				ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(instance.parent, val3));
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(instance.sizeX));
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(instance.sizeY));
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(instance.anglesX));
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(instance.anglesY));
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(instance.anglesZ));
				ModSettingsManager.AddOption((BaseOption)new StepSliderOption(instance.pivotX, val2));
				ModSettingsManager.AddOption((BaseOption)new StepSliderOption(instance.pivotY, val2));
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(instance.anchorPositionX));
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(instance.anchorPositionY));
				ModSettingsManager.AddOption((BaseOption)new StepSliderOption(instance.anchorMinX, val2));
				ModSettingsManager.AddOption((BaseOption)new StepSliderOption(instance.anchorMinY, val2));
				ModSettingsManager.AddOption((BaseOption)new StepSliderOption(instance.anchorMaxX, val2));
				ModSettingsManager.AddOption((BaseOption)new StepSliderOption(instance.anchorMaxY, val2));
				ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(instance.textFormat, val3));
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(instance.textSpacingX));
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(instance.textSpacingY));
				ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(instance.textAlignment));
				ModSettingsManager.AddOption((BaseOption)new ColorOption(instance.textColor));
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(instance.useCommas));
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(instance.useWholeNumbers));
				object obj = <>c.<>9__1_0;
				if (obj == null)
				{
					UnityAction val4 = delegate
					{
						//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_0152: Unknown result type (might be due to invalid IL or missing references)
						//IL_0157: Unknown result type (might be due to invalid IL or missing references)
						//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
						//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
						//IL_032b: Unknown result type (might be due to invalid IL or missing references)
						//IL_0332: Expected O, but got Unknown
						if (!Directory.Exists(instance.presetsPath))
						{
							Directory.CreateDirectory(instance.presetsPath);
						}
						int num = 0;
						Regex regex = new Regex("Preset(\\d+)\\.json");
						string[] files = Directory.GetFiles(instance.presetsPath, "Preset*.json");
						foreach (string path in files)
						{
							if (File.Exists(path))
							{
								Match match = regex.Match(Path.GetFileName(path));
								if (match.Success && int.TryParse(match.Groups[1].Value, out var result) && result > num)
								{
									num = result;
								}
							}
						}
						string text = $"Preset{num + 1}";
						Preset preset = new Preset(text)
						{
							timeSpan = instance.timeSpan.Value,
							toggleVisibility = instance.toggleVisibility.Value,
							isVisible = instance.isVisible.Value,
							hideWhenChatboxActive = instance.hideWhenChatboxActive.Value,
							hideBackground = instance.hideBackground.Value,
							backgroundColor = instance.backgroundColor.Value,
							hudScaling = instance.hudScaling.Value,
							parent = instance.parent.Value,
							sizeX = instance.sizeX.Value,
							sizeY = instance.sizeY.Value,
							anglesX = instance.anglesX.Value,
							anglesY = instance.anglesY.Value,
							anglesZ = instance.anglesZ.Value,
							pivotX = instance.pivotX.Value,
							pivotY = instance.pivotY.Value,
							anchorPositionX = instance.anchorPositionX.Value,
							anchorPositionY = instance.anchorPositionY.Value,
							anchorMinX = instance.anchorMinX.Value,
							anchorMinY = instance.anchorMinY.Value,
							anchorMaxX = instance.anchorMaxX.Value,
							anchorMaxY = instance.anchorMaxY.Value,
							textFormat = instance.textFormat.Value,
							textSpacingX = instance.textSpacingX.Value,
							textSpacingY = instance.textSpacingY.Value,
							textAlignment = instance.textAlignment.Value,
							textColor = instance.textColor.Value,
							useCommas = instance.useCommas.Value,
							useWholeNumbers = instance.useWholeNumbers.Value
						};
						JsonSerializerSettings val5 = new JsonSerializerSettings();
						val5.Converters.Add((JsonConverter)(object)new ColorJsonConverter());
						File.WriteAllText(Path.Combine(instance.presetsPath, text + ".json"), JsonConvert.SerializeObject((object)preset, (Formatting)1, val5));
						instance.logger.LogMessage((object)("Preset successfully exported: \"" + text + "\""));
					};
					<>c.<>9__1_0 = val4;
					obj = (object)val4;
				}
				ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("New Preset", "Presets", "Exports the current settings to the \"Presets\" folder.\n\nNote: Restarting the game will only reload all presets since Risk of Options does not have implementation for removing UI elements.", "Export", (UnityAction)obj));
				foreach (Preset preset2 in instance.presets)
				{
					ModSettingsManager.AddOption((BaseOption)new GenericButtonOption(preset2.name, "Presets", "Applies the settings from the preset called \"" + preset2.name + "\".", "Apply", new UnityAction(preset2.Apply)));
				}
			}
		}

		private class Preset
		{
			[JsonIgnore]
			public string name;

			public float timeSpan = 5f;

			public KeyboardShortcut toggleVisibility = new KeyboardShortcut((KeyCode)120, Array.Empty<KeyCode>());

			public bool isVisible = true;

			public bool hideWhenChatboxActive = true;

			public bool hideBackground = false;

			public Color backgroundColor = new Color(0.6668f, 0.7341f, 0.7642f, 0.1961f);

			public bool hudScaling = true;

			public string parent = instance.parents[1];

			public float sizeX = 0f;

			public float sizeY = 45f;

			public float anglesX = 0f;

			public float anglesY = -6f;

			public float anglesZ = 0f;

			public float pivotX = 0f;

			public float pivotY = 0f;

			public float anchorPositionX = 0f;

			public float anchorPositionY = 135f;

			public float anchorMinX = 0f;

			public float anchorMinY = 0f;

			public float anchorMaxX = 1f;

			public float anchorMaxY = 0f;

			public string textFormat = "DPS: {character+minion}";

			public float textSpacingX = -12f;

			public float textSpacingY = -12f;

			public string textAlignment;

			public Color textColor;

			public bool useCommas;

			public bool useWholeNumbers;

			public Preset(string name)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: 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_0124: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				TextAlignmentOptions val = (TextAlignmentOptions)4097;
				textAlignment = ((object)(TextAlignmentOptions)(ref val)).ToString();
				textColor = Color.white;
				useCommas = true;
				useWholeNumbers = true;
				base..ctor();
				this.name = name;
			}

			public void Apply()
			{
				//IL_0022: 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_0232: Unknown result type (might be due to invalid IL or missing references)
				instance.timeSpan.Value = timeSpan;
				instance.toggleVisibility.Value = toggleVisibility;
				instance.isVisible.Value = isVisible;
				instance.hideWhenChatboxActive.Value = hideWhenChatboxActive;
				instance.hideBackground.Value = hideBackground;
				instance.backgroundColor.Value = backgroundColor;
				instance.hudScaling.Value = hudScaling;
				instance.parent.Value = parent;
				instance.sizeX.Value = sizeX;
				instance.sizeY.Value = sizeY;
				instance.anglesX.Value = anglesX;
				instance.anglesY.Value = anglesY;
				instance.anglesZ.Value = anglesZ;
				instance.pivotX.Value = pivotX;
				instance.pivotY.Value = pivotY;
				instance.anchorPositionX.Value = anchorPositionX;
				instance.anchorPositionY.Value = anchorPositionY;
				instance.anchorMinX.Value = anchorMinX;
				instance.anchorMinY.Value = anchorMinY;
				instance.anchorMaxX.Value = anchorMaxX;
				instance.anchorMaxY.Value = anchorMaxY;
				instance.textFormat.Value = textFormat;
				instance.textSpacingX.Value = textSpacingX;
				instance.textSpacingY.Value = textSpacingY;
				instance.textAlignment.Value = textAlignment;
				instance.textColor.Value = textColor;
				instance.useCommas.Value = useCommas;
				instance.useWholeNumbers.Value = useWholeNumbers;
				instance.UpdateSettings();
			}
		}

		private class DPSCalculator
		{
			public string name;

			public string example;

			private Dictionary<float, float> damageEntries = new Dictionary<float, float>();

			private float sum = 0f;

			public DPSCalculator(string name, string example)
			{
				this.name = name;
				this.example = example;
			}

			public void Clear()
			{
				damageEntries.Clear();
				sum = 0f;
			}

			public void Add(float damage)
			{
				damageEntries.Add(Time.time, damage);
				sum += damage;
			}

			public void RemoveOldEntries()
			{
				float num = instance.currentTime - instance.timeSpan.Value;
				List<KeyValuePair<float, float>> list = new List<KeyValuePair<float, float>>();
				foreach (KeyValuePair<float, float> damageEntry in damageEntries)
				{
					if (damageEntry.Key < num)
					{
						list.Add(damageEntry);
						continue;
					}
					break;
				}
				foreach (KeyValuePair<float, float> item in list)
				{
					sum -= item.Value;
					damageEntries.Remove(item.Key);
				}
			}

			public void Replace(ref string expression)
			{
				expression = expression.Replace(name, ((damageEntries.Count != 0) ? (sum / Mathf.Min(Mathf.Max(1f, instance.currentTime - damageEntries.First().Key), instance.timeSpan.Value)) : 0f).ToString());
			}
		}

		private const string modGUID = "bulletbot.dpsmeter";

		private const string modName = "DPSMeter";

		private const string modVer = "1.0.9";

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

		private const string wolfoQOLModGUID = "Wolfo.WolfoQualityOfLife";

		public static Plugin instance;

		public ManualLogSource logger;

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

		private ConfigEntry<float> timeSpan;

		private ConfigEntry<KeyboardShortcut> toggleVisibility;

		private ConfigEntry<bool> isVisible;

		private ConfigEntry<bool> hideWhenChatboxActive;

		private ConfigEntry<bool> hideBackground;

		private ConfigEntry<Color> backgroundColor;

		private ConfigEntry<bool> hudScaling;

		private ConfigEntry<string> parent;

		private ConfigEntry<float> sizeX;

		private ConfigEntry<float> sizeY;

		private ConfigEntry<float> anglesX;

		private ConfigEntry<float> anglesY;

		private ConfigEntry<float> anglesZ;

		private ConfigEntry<float> pivotX;

		private ConfigEntry<float> pivotY;

		private ConfigEntry<float> anchorPositionX;

		private ConfigEntry<float> anchorPositionY;

		private ConfigEntry<float> anchorMinX;

		private ConfigEntry<float> anchorMinY;

		private ConfigEntry<float> anchorMaxX;

		private ConfigEntry<float> anchorMaxY;

		private ConfigEntry<string> textFormat;

		private ConfigEntry<float> textSpacingX;

		private ConfigEntry<float> textSpacingY;

		private ConfigEntry<string> textAlignment;

		private ConfigEntry<Color> textColor;

		private ConfigEntry<bool> useCommas;

		private ConfigEntry<bool> useWholeNumbers;

		private string presetsPath;

		private readonly List<Preset> presets = new List<Preset>();

		private readonly List<string> parents = new List<string> { "None", "BottomLeftCluster", "UpperRightCluster", "BottomRightCluster", "UpperLeftCluster", "BottomCenterCluster", "TopCenterCluster", "LeftCluster", "RightCluster" };

		private RectTransform dpsMeterTransform;

		private HGTextMeshProUGUI dpsMeterText;

		private bool previousVisible;

		private bool previousChatBoxActive;

		private bool chatBoxActive;

		private Vector3 currentScale;

		private float currentHUDScale;

		public ChatBox currentChatBox;

		private HUD currentHUD;

		public float currentTime;

		private List<DPSCalculator> dpsCalculators = new List<DPSCalculator>();

		private bool IsWolfoQOLModLoaded()
		{
			return Chainloader.PluginInfos.ContainsKey("Wolfo.WolfoQualityOfLife");
		}

		private void Awake()
		{
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_073b: Unknown result type (might be due to invalid IL or missing references)
			//IL_07be: Unknown result type (might be due to invalid IL or missing references)
			//IL_086a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0874: Expected O, but got Unknown
			instance = this;
			logger = Logger.CreateLogSource("DPSMeter");
			presetsPath = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)instance).Info.Location), "Presets");
			Preset preset = new Preset("Default");
			presets.Add(preset);
			if (Directory.Exists(presetsPath))
			{
				string[] files = Directory.GetFiles(presetsPath, "*.json");
				foreach (string path in files)
				{
					if (File.Exists(path))
					{
						string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
						Preset preset2 = new Preset(fileNameWithoutExtension);
						if (IsValidJson(File.ReadAllText(path), preset2))
						{
							presets.Add(preset2);
							logger.LogMessage((object)("Preset successfully loaded: \"" + fileNameWithoutExtension + "\""));
						}
					}
				}
			}
			dpsCalculators.Add(new DPSCalculator("character", "You"));
			dpsCalculators.Add(new DPSCalculator("minion", "Summoned by your character"));
			dpsCalculators.Add(new DPSCalculator("player", "Other players"));
			dpsCalculators.Add(new DPSCalculator("team", "Same team as your character"));
			string text = "General";
			timeSpan = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Timespan", preset.timeSpan, "Measures how much damage is dealt over a specific duration.");
			toggleVisibility = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Toggle Visibility", preset.toggleVisibility, "The keybind to toggle the visibility of the UI.");
			toggleVisibility.SettingChanged += OnSettingChanged;
			isVisible = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Is Visible", true, "Determines whether the UI is currently visible.");
			hideWhenChatboxActive = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Hide When Chatbox Active", preset.hideWhenChatboxActive, "Determines whether to hide the UI when the chatbox is active.");
			hideWhenChatboxActive.SettingChanged += OnSettingChanged;
			hideBackground = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Hide Background", preset.hideBackground, "Determines whether to hide the background of the UI.");
			hideBackground.SettingChanged += OnSettingChanged;
			backgroundColor = ((BaseUnityPlugin)this).Config.Bind<Color>(text, "Background Color", preset.backgroundColor, "The background color of the UI.");
			backgroundColor.SettingChanged += OnSettingChanged;
			hudScaling = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "HUD Scaling", preset.hudScaling, "Determines if the UI scales according to the setting (Settings -> Video -> HUD Scale).");
			hudScaling.SettingChanged += OnSettingChanged;
			string text2 = "The parent object name of the UI.\n\nOptions:";
			foreach (string parent in parents)
			{
				text2 = text2 + "\n" + parent;
			}
			this.parent = ((BaseUnityPlugin)this).Config.Bind<string>(text, "Parent", preset.parent, text2);
			this.parent.SettingChanged += OnSettingChanged;
			sizeX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Size X", preset.sizeX, "The width of the UI.");
			sizeX.SettingChanged += OnSettingChanged;
			sizeY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Size Y", preset.sizeY, "The height of the UI.");
			sizeY.SettingChanged += OnSettingChanged;
			anglesX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Rotation Angle X", preset.anglesX, "The X rotation angle of the UI.");
			anglesX.SettingChanged += OnSettingChanged;
			anglesY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Rotation Angle Y", preset.anglesY, "The Y rotation angle of the UI.");
			anglesY.SettingChanged += OnSettingChanged;
			anglesZ = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Rotation Angle Z", preset.anglesZ, "The Z rotation angle of the UI.");
			anglesZ.SettingChanged += OnSettingChanged;
			pivotX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Pivot X", preset.pivotX, "The X pivot point of the UI.");
			pivotX.SettingChanged += OnSettingChanged;
			pivotY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Pivot Y", preset.pivotY, "The Y pivot point of the UI.");
			pivotY.SettingChanged += OnSettingChanged;
			anchorPositionX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Anchor Position X", preset.anchorPositionX, "The X anchor position of the UI.");
			anchorPositionX.SettingChanged += OnSettingChanged;
			anchorPositionY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Anchor Position Y", preset.anchorPositionY, "The Y anchor position of the UI.");
			anchorPositionY.SettingChanged += OnSettingChanged;
			anchorMinX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Anchor Min X", preset.anchorMinX, "The minimum X anchor of the UI.");
			anchorMinX.SettingChanged += OnSettingChanged;
			anchorMinY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Anchor Min Y", preset.anchorMinY, "The minimum Y anchor of the UI.");
			anchorMinY.SettingChanged += OnSettingChanged;
			anchorMaxX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Anchor Max X", preset.anchorMaxX, "The maximum X anchor of the UI.");
			anchorMaxX.SettingChanged += OnSettingChanged;
			anchorMaxY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Anchor Max Y", preset.anchorMaxY, "The maximum Y anchor of the UI.");
			anchorMaxY.SettingChanged += OnSettingChanged;
			string textFormatDescription = "The format for displaying text. Supports rich text.\n\nExamples:\n\"Total DPS: {character+minion+player+team}\"\n\"Minion DPS: {minion}\"\n\nOptions:";
			dpsCalculators.ForEach(delegate(DPSCalculator x)
			{
				textFormatDescription = textFormatDescription + "\n" + x.name + " (" + x.example + ")";
			});
			textFormat = ((BaseUnityPlugin)this).Config.Bind<string>(text, "Text Format", preset.textFormat, textFormatDescription);
			textSpacingX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Text Spacing X", preset.textSpacingX, "The horizontal text spacing of the UI text.");
			textSpacingX.SettingChanged += OnSettingChanged;
			textSpacingY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Text Spacing Y", preset.textSpacingY, "The vertical text spacing of the UI text.");
			textSpacingY.SettingChanged += OnSettingChanged;
			string text3 = "The alignment of the UI text.\n\nOptions:";
			foreach (TextAlignmentOptions value2 in Enum.GetValues(typeof(TextAlignmentOptions)))
			{
				TextAlignmentOptions val = value2;
				text3 = text3 + "\n" + ((object)(TextAlignmentOptions)(ref val)).ToString();
			}
			textAlignment = ((BaseUnityPlugin)this).Config.Bind<string>(text, "Text Alignment", preset.textAlignment, text3);
			textAlignment.SettingChanged += OnSettingChanged;
			textColor = ((BaseUnityPlugin)this).Config.Bind<Color>(text, "Text Color", preset.textColor, "The color of the UI text.");
			textColor.SettingChanged += OnSettingChanged;
			useCommas = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Use Commas", preset.useCommas, "Determines whether the numbers are with commas for thousands.");
			useWholeNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Use Whole Numbers", preset.useWholeNumbers, "Determines whether the numbers should display as whole numbers.");
			if (RiskOfOptions.IsLoaded())
			{
				RiskOfOptions.OnAwake();
			}
			GlobalEventManager.onClientDamageNotified += delegate(DamageDealtMessage message)
			{
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: 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())
				{
					dpsCalculators.First((DPSCalculator x) => x.name == "character").Add(message.damage);
				}
				else
				{
					CharacterBody component2 = message.attacker.GetComponent<CharacterBody>();
					if ((Object)(object)component2 != (Object)null)
					{
						if (component2.isPlayerControlled)
						{
							dpsCalculators.First((DPSCalculator x) => x.name == "player").Add(message.damage);
						}
						else
						{
							CharacterMaster master = component2.master;
							if ((Object)(object)master != (Object)null)
							{
								if (Object.op_Implicit((Object)(object)master.minionOwnership) && (Object)(object)master.minionOwnership.ownerMaster == (Object)(object)cachedMaster)
								{
									dpsCalculators.First((DPSCalculator x) => x.name == "minion").Add(message.damage);
								}
								else if (master.teamIndex == cachedMaster.teamIndex)
								{
									dpsCalculators.First((DPSCalculator x) => x.name == "team").Add(message.damage);
								}
							}
						}
					}
				}
			};
			Stage.onStageStartGlobal += delegate
			{
				previousVisible = !isVisible.Value;
				previousChatBoxActive = false;
				chatBoxActive = false;
				dpsCalculators.ForEach(delegate(DPSCalculator x)
				{
					x.Clear();
				});
			};
			HUD.shouldHudDisplay += (ShouldHudDisplayDelegate)delegate(HUD hud, ref bool _)
			{
				//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c4: Expected O, but got Unknown
				//IL_03db: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e2: Expected O, but got Unknown
				//IL_043a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0447: Unknown result type (might be due to invalid IL or missing references)
				//IL_0454: Unknown result type (might be due to invalid IL or missing references)
				//IL_0461: Unknown result type (might be due to invalid IL or missing references)
				//IL_046e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: 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)
				if ((Object)(object)currentHUD == (Object)null)
				{
					currentHUD = hud;
				}
				else
				{
					currentTime = Time.time;
					dpsCalculators.ForEach(delegate(DPSCalculator x)
					{
						x.RemoveOldEntries();
					});
					if ((Object)(object)dpsMeterTransform != (Object)null && (Object)(object)dpsMeterText != (Object)null)
					{
						if ((Object)(object)currentChatBox != (Object)null)
						{
							chatBoxActive = ((UIBehaviour)currentChatBox.inputField).IsActive();
						}
						if (!PauseManager.isPaused && !chatBoxActive)
						{
							KeyboardShortcut value = toggleVisibility.Value;
							if (((KeyboardShortcut)(ref value)).IsDown())
							{
								isVisible.Value = !isVisible.Value;
							}
						}
						if (previousVisible != isVisible.Value)
						{
							previousVisible = isVisible.Value;
							((Component)dpsMeterTransform).gameObject.SetActive(isVisible.Value);
							UpdateChatBox(currentChatBox);
						}
						else if (hideWhenChatboxActive.Value && previousChatBoxActive != chatBoxActive)
						{
							previousChatBoxActive = chatBoxActive;
							if (isVisible.Value)
							{
								((Component)dpsMeterTransform).gameObject.SetActive(!previousChatBoxActive);
							}
						}
						BaseConVar val2 = Console.instance.FindConVar("hud_scale");
						float num = default(float);
						if ((val2 != null && TextSerialization.TryParseInvariant(val2.GetString(), ref num) && currentHUDScale != num) || currentScale != ((Transform)dpsMeterTransform).localScale)
						{
							UpdateSettings();
						}
						if (isVisible.Value || !chatBoxActive)
						{
							string text4 = textFormat.Value;
							int num2 = text4.IndexOf('{');
							while (num2 != -1)
							{
								int num3 = text4.IndexOf('}', num2);
								if (num3 == -1)
								{
									break;
								}
								string text5 = Evaluate(text4.Substring(num2, num3 - num2 + 1));
								text4 = text4.Substring(0, num2) + text5 + text4.Substring(num3 + 1);
								num2 = text4.IndexOf('{', num2 + text5.Length);
							}
							((TMP_Text)dpsMeterText).text = text4;
						}
					}
					else if ((Object)(object)currentHUD.mainContainer != (Object)null && (Object)(object)currentHUD.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;
						((Transform)val5).SetParent((Transform)(object)dpsMeterTransform);
						((Transform)val5).localPosition = Vector3.zero;
						((Transform)val5).localScale = Vector3.one;
						val5.anchorMin = Vector2.zero;
						val5.anchorMax = Vector2.one;
						val5.anchoredPosition = Vector2.zero;
						Image component = ((Component)currentHUD.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.");
					}
				}
			};
			PatchAll("Patches");
			if (IsWolfoQOLModLoaded())
			{
				PatchAll("WolfoPatches");
			}
		}

		private void PatchAll(string name)
		{
			(from x in Assembly.GetExecutingAssembly().GetTypes()
				where x.Namespace == typeof(Plugin).Namespace + "." + name
				select x).ToList().ForEach(delegate(Type x)
			{
				harmony.CreateClassProcessor(x).Patch();
			});
		}

		private bool IsValidJson(string data, Preset preset)
		{
			Preset obj = presets[0];
			Dictionary<string, object> dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(data);
			FieldInfo[] fields = typeof(Preset).GetFields(BindingFlags.Instance | BindingFlags.Public);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (fieldInfo.GetCustomAttribute(typeof(JsonIgnoreAttribute)) != null)
				{
					continue;
				}
				if (!dictionary.ContainsKey(fieldInfo.Name))
				{
					fieldInfo.SetValue(preset, fieldInfo.GetValue(obj));
					continue;
				}
				object validValue = GetValidValue(dictionary[fieldInfo.Name], fieldInfo.FieldType);
				if (validValue == null)
				{
					logger.LogMessage((object)("Failed to load preset: \"" + preset.name + "\" - Error: Invalid type at field called \"" + fieldInfo.Name + "\""));
					return false;
				}
				fieldInfo.SetValue(preset, validValue);
			}
			return true;
		}

		private object GetValidValue(object value, Type type)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if (type == typeof(float) && value is double num)
			{
				return (float)num;
			}
			Color val = default(Color);
			if (type == typeof(Color) && value is string text && ColorUtility.TryParseHtmlString(text, ref val))
			{
				return val;
			}
			if (type == typeof(KeyboardShortcut))
			{
				try
				{
					JObject val2 = JObject.Parse(value.ToString());
					JToken val3 = default(JToken);
					JToken val4 = default(JToken);
					if (val2 != null && val2.ContainsKey("MainKey") && val2.TryGetValue("MainKey", ref val3) && val2.ContainsKey("Modifiers") && val2.TryGetValue("Modifiers", ref val4))
					{
						return (object)new KeyboardShortcut((KeyCode)Extensions.Value<long>((IEnumerable<JToken>)val3), (from x in val4.Values<long>()
							select (KeyCode)x).ToArray());
					}
				}
				catch (Exception)
				{
				}
			}
			if (value != null && value.GetType() == type)
			{
				return value;
			}
			return null;
		}

		private string Evaluate(string expression)
		{
			if (expression.Contains("-") || expression.Contains("*") || expression.Contains("/") || expression.Contains("%") || expression.Contains("^"))
			{
				return expression;
			}
			string result = expression;
			try
			{
				dpsCalculators.ForEach(delegate(DPSCalculator x)
				{
					x.Replace(ref expression);
				});
				if (float.TryParse(new DataTable().Compute(expression.Substring(1, expression.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 void OnSettingChanged(object sender, EventArgs e)
		{
			UpdateSettings();
		}

		public void UpdateSettings()
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: 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_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)dpsMeterTransform == (Object)null) && !((Object)(object)dpsMeterText == (Object)null))
			{
				bool flag = parents[0] == parent.Value || !parents.Contains(parent.Value);
				if ((Object)(object)((Transform)dpsMeterTransform).parent == (Object)null || parent.Value != ((Object)((Transform)dpsMeterTransform).parent).name)
				{
					Transform val = currentHUD.mainUIPanel.transform.Find("SpringCanvas");
					((Transform)dpsMeterTransform).SetParent(flag ? val : val.Find(parent.Value));
				}
				Vector3 one = Vector3.one;
				float num = 100f;
				BaseConVar val2 = Console.instance.FindConVar("hud_scale");
				if (val2 != null)
				{
					TextSerialization.TryParseInvariant(val2.GetString(), ref num);
				}
				if (!hudScaling.Value && !flag)
				{
					Vector3 localScale = ((Transform)dpsMeterTransform).parent.localScale;
					((Vector3)(ref one))..ctor(1f / localScale.x, 1f / localScale.y, 1f / localScale.z);
				}
				else if (hudScaling.Value && flag)
				{
					((Vector3)(ref one))..ctor(num / 100f, num / 100f, num / 100f);
				}
				((Transform)dpsMeterTransform).localScale = one;
				currentScale = one;
				currentHUDScale = num;
				((Transform)dpsMeterTransform).localPosition = Vector3.zero;
				Image component = ((Component)dpsMeterTransform).GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					((Behaviour)component).enabled = !hideBackground.Value;
					((Graphic)component).color = backgroundColor.Value;
				}
				dpsMeterTransform.sizeDelta = new Vector2(sizeX.Value, sizeY.Value);
				((Transform)dpsMeterTransform).eulerAngles = new Vector3(anglesX.Value, anglesY.Value, anglesZ.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);
				((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);
				UpdateChatBox(currentChatBox);
			}
		}

		public void UpdateChatBox(ChatBox chatBox)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)chatBox != (Object)null && IsWolfoQOLModLoaded() && (Object)(object)Run.instance != (Object)null)
			{
				RectTransform component = ((Component)((Transform)((Component)chatBox).gameObject.GetComponent<RectTransform>()).GetChild(2)).GetComponent<RectTransform>();
				if (hideWhenChatboxActive.Value && isVisible.Value)
				{
					component.offsetMin = new Vector2(-10f, 49f);
					component.offsetMax = new Vector2(120f, 0f);
				}
				else
				{
					component.offsetMin = new Vector2(-10f, 0f);
					component.offsetMax = new Vector2(120f, -6f);
				}
				typeof(ChatBox).GetMethod("RebuildChatRects", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(chatBox, null);
			}
		}
	}
}
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 DPSMeter.Patches
{
	[HarmonyPatch(typeof(ChatBox))]
	internal class ChatBoxPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start(ChatBox __instance)
		{
			Plugin.instance.currentChatBox = __instance;
		}
	}
}
namespace DPSMeter.WolfoPatches
{
	[HarmonyPatch(typeof(RandomMiscWithConfig))]
	internal class RandomMiscWithConfigPatch
	{
		[HarmonyPatch("AllowMoreChatMessages")]
		[HarmonyPostfix]
		private static void AllowMoreChatMessages(object[] __args)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Plugin.instance.UpdateChatBox((ChatBox)__args[1]);
		}
	}
}