Decompiled source of ThunderRain v1.0.2

plugins/ThunderRain/ThunderRain.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.Json;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Costura;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ThunderRain")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ThunderRain")]
[assembly: AssemblyTitle("ThunderRain")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
		AssemblyLoader.Attach();
	}
}
namespace ThunderRain
{
	internal static class ConfigManager
	{
		internal static ConfigEntry<int> TimeSpanSeconds;

		internal static ConfigEntry<DeviceManager.ShockerSelection> ShockerSelection;

		internal static ConfigFile OptionsConfig { get; set; }

		internal static ConfigEntry<string> PiShockUsername { get; set; }

		internal static ConfigEntry<string> PiShockApiKey { get; set; }

		internal static ConfigEntry<string> PiShockShareCodes { get; set; }

		internal static ConfigEntry<bool> VibrationsFromDealingDamage { get; set; }

		internal static ConfigEntry<bool> VibrationsFromReceivingDamage { get; set; }

		internal static ConfigEntry<bool> ShocksFromDealingDamage { get; set; }

		internal static ConfigEntry<bool> ShocksFromReceivingDamage { get; set; }

		internal static ConfigEntry<bool> VibrationsFromMinionsDealingDamage { get; set; }

		internal static ConfigEntry<bool> VibrationsFromMinionsReceivingDamage { get; set; }

		internal static ConfigEntry<bool> ShocksFromMinionsDealingDamage { get; set; }

		internal static ConfigEntry<bool> ShocksFromMinionsReceivingDamage { get; set; }

		internal static ConfigEntry<int> BaseVibrationDurationSeconds { get; set; }

		internal static ConfigEntry<int> BaseShockDurationSeconds { get; set; }

		internal static ConfigEntry<int> DealingDamageBaseVibrationIntensity { get; set; }

		internal static ConfigEntry<int> DealingDamageBaseShockIntensity { get; set; }

		internal static ConfigEntry<int> ReceivingDamageBaseVibrationIntensity { get; set; }

		internal static ConfigEntry<int> ReceivingDamageBaseShockIntensity { get; set; }

		internal static ConfigEntry<int> MaximumVibrationIntensity { get; set; }

		internal static ConfigEntry<int> MaximumShockIntensity { get; set; }

		internal static ConfigEntry<int> MaximumVibrationDuration { get; set; }

		internal static ConfigEntry<int> MaximumShockDuration { get; set; }

		internal static ConfigEntry<bool> AllowExcessDamage { get; set; }

		static ConfigManager()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Expected O, but got Unknown
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Expected O, but got Unknown
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Expected O, but got Unknown
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Expected O, but got Unknown
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Expected O, but got Unknown
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: 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_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Expected O, but got Unknown
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Expected O, but got Unknown
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Expected O, but got Unknown
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Expected O, but got Unknown
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Expected O, but got Unknown
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Expected O, but got Unknown
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Expected O, but got Unknown
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Expected O, but got Unknown
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Expected O, but got Unknown
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Expected O, but got Unknown
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Expected O, but got Unknown
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Expected O, but got Unknown
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Expected O, but got Unknown
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Expected O, but got Unknown
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Expected O, but got Unknown
			OptionsConfig = new ConfigFile(Paths.ConfigPath + "\\ThunderRain.cfg", true);
			ModSettingsManager.SetModDescription("Shocks PiShocks in response to in-game damage events.");
			PiShockUsername = OptionsConfig.Bind<string>("PiShock Info", "PiShock Username", "", "Your PiShock username.");
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(PiShockUsername));
			PiShockApiKey = OptionsConfig.Bind<string>("PiShock Info", "PiShock API Key", "", "Generated at https://pishock.com/#/account.");
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(PiShockApiKey));
			PiShockShareCodes = OptionsConfig.Bind<string>("PiShock Info", "PiShock Share Code", "", "Share code generated on PiShock control panel. Separate each code with a comma.");
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(PiShockShareCodes));
			VibrationsFromDealingDamage = OptionsConfig.Bind<bool>("Activated By", "Vibrations from Dealing Damage", false, "Generate vibrations when dealing damage.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(VibrationsFromDealingDamage));
			VibrationsFromReceivingDamage = OptionsConfig.Bind<bool>("Activated By", "Vibrations from Receiving Damage", true, "Generate vibrations when receiving damage.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(VibrationsFromReceivingDamage));
			ShocksFromDealingDamage = OptionsConfig.Bind<bool>("Activated By", "Shocks from Dealing Damage", false, "Generate shocks when dealing damage.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShocksFromDealingDamage));
			ShocksFromReceivingDamage = OptionsConfig.Bind<bool>("Activated By", "Shocks from Receiving Damage", false, "Generate shocks when receiving damage.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShocksFromReceivingDamage));
			VibrationsFromMinionsDealingDamage = OptionsConfig.Bind<bool>("Activated By", "Vibrations from Minions Dealing Damage", false, "Generate vibrations when your minions (drones, turrets, etc.) deal damage.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(VibrationsFromMinionsDealingDamage));
			VibrationsFromMinionsReceivingDamage = OptionsConfig.Bind<bool>("Activated By", "Vibrations from Minions Receiving Damage", false, "Generate vibrations when your minions (drones, turrets, etc.) receive damage.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(VibrationsFromMinionsReceivingDamage));
			ShocksFromMinionsDealingDamage = OptionsConfig.Bind<bool>("Activated By", "Shocks from Minions Dealing Damage", false, "Generate shocks when your minions (drones, turrets, etc.) deal damage.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShocksFromMinionsDealingDamage));
			ShocksFromMinionsReceivingDamage = OptionsConfig.Bind<bool>("Activated By", "Shocks from Minions Receiving Damage", false, "Generate shocks when your minions (drones, turrets, etc.) receive damage.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShocksFromMinionsReceivingDamage));
			BaseVibrationDurationSeconds = OptionsConfig.Bind<int>("Operation Values", "Base Vibration Duration in Seconds", 1, new ConfigDescription("The base vibration duration in seconds to add when damage is dealt or received. Multiplied by (damageDealt / maxHealthOfDamagedEntity).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 15), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(BaseVibrationDurationSeconds));
			BaseShockDurationSeconds = OptionsConfig.Bind<int>("Operation Values", "Base Shock Duration in Seconds", 1, new ConfigDescription("The base shock duration in seconds to add when damage is dealt or received. Multiplied by (damageDealt / maxHealthOfDamagedEntity).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 15), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(BaseShockDurationSeconds));
			DealingDamageBaseVibrationIntensity = OptionsConfig.Bind<int>("Operation Values", "Base Vibration Intensity on Damage Dealt", 1, new ConfigDescription("The base vibration intensity for vibrations generated by dealing damage. Multiplied by (damageDealt / maxHealthOfDamagedEntity).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(DealingDamageBaseVibrationIntensity));
			DealingDamageBaseShockIntensity = OptionsConfig.Bind<int>("Operation Values", "Base Shock Intensity on Damage Dealt", 1, new ConfigDescription("The base shock intensity for shocks generated by dealing damage. Multiplied by (damageDealt / maxHealthOfDamagedEntity).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(DealingDamageBaseShockIntensity));
			ReceivingDamageBaseVibrationIntensity = OptionsConfig.Bind<int>("Operation Values", "Base Vibration Intensity on Damage Received", 1, new ConfigDescription("The base vibration intensity for vibrations generated by receiving damage. Multiplied by (damageDealt / maxHealthOfDamagedEntity).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(ReceivingDamageBaseVibrationIntensity));
			ReceivingDamageBaseShockIntensity = OptionsConfig.Bind<int>("Operation Values", "Base Shock Intensity on Damage Received", 1, new ConfigDescription("The base shock intensity for shocks generated by receiving damage. Multiplied by (damageDealt / maxHealthOfDamagedEntity).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(ReceivingDamageBaseShockIntensity));
			MaximumVibrationIntensity = OptionsConfig.Bind<int>("Operation Values", "Maximum Vibration Intensity", 100, new ConfigDescription("The maximum vibration intensity for a single operation.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(MaximumVibrationIntensity));
			MaximumShockIntensity = OptionsConfig.Bind<int>("Operation Values", "Maximum Shock Intensity", 100, new ConfigDescription("The maximum shock intensity for a single operation.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(MaximumShockIntensity));
			MaximumVibrationDuration = OptionsConfig.Bind<int>("Operation Values", "Maximum Vibration Duration Seconds", 15, new ConfigDescription("The maximum shock duration for a single operation in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 15), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(MaximumVibrationDuration));
			MaximumShockDuration = OptionsConfig.Bind<int>("Operation Values", "Maximum Shock Duration Seconds", 15, new ConfigDescription("The maximum shock duration for a single operation in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 15), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(MaximumShockDuration));
			TimeSpanSeconds = OptionsConfig.Bind<int>("Operation Behavior", "Time Span", 3, new ConfigDescription("Sums up values over this many seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(TimeSpanSeconds));
			ShockerSelection = OptionsConfig.Bind<DeviceManager.ShockerSelection>("Operation Behavior", "Shocker Selection", DeviceManager.ShockerSelection.Random, "Controls which shockers are selected when commands are sent.");
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)ShockerSelection));
			AllowExcessDamage = OptionsConfig.Bind<bool>("Operation Behavior", "Allow For Excess Damage", false, "Allow for excess damage dealt over an entity's max combined health to affect operation intensity.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(AllowExcessDamage));
		}
	}
	internal class DeviceManager
	{
		internal enum ShockerSelection
		{
			All,
			Random
		}

		private const string PiShockApiUri = "https://do.pishock.com/api/apioperate/";

		private static readonly HttpClient HttpClient = new HttpClient
		{
			BaseAddress = new Uri("https://do.pishock.com/api/apioperate/")
		};

		internal string DisplayName { get; private set; }

		private PiShockShocker[] Shockers { get; set; }

		public DeviceManager(string displayName)
		{
			DisplayName = displayName;
			UpdateShockerList(null, null);
			ConfigManager.PiShockShareCodes.SettingChanged += UpdateShockerList;
		}

		private void UpdateShockerList(object _, EventArgs __)
		{
			Log.Info(ConfigManager.PiShockShareCodes.Value);
			Shockers = (from code in ConfigManager.PiShockShareCodes.Value.Split(new char[1] { ',' })
				select new PiShockShocker(code.Trim())).ToArray();
			Log.Info($"Amount of shockers: {Shockers.Length}");
			PiShockShocker[] shockers = Shockers;
			foreach (PiShockShocker piShockShocker in shockers)
			{
				Log.Info("Shocker share code: " + piShockShocker.ShareCode);
			}
		}

		private PiShockShocker GetRandomShocker()
		{
			return Shockers[new Random().Next(0, Shockers.Length)];
		}

		internal void ProcessValuePool(ValuePool pool)
		{
			if (!pool.VibrationValues.IsNill())
			{
				Operate(PiShockOperation.Vibrate, pool.VibrationValues);
			}
			if (!pool.ShockValues.IsNill())
			{
				Operate(PiShockOperation.Shock, pool.ShockValues);
			}
		}

		private void Operate(PiShockOperation operation, PiShockValues values)
		{
			switch (ConfigManager.ShockerSelection.Value)
			{
			case ShockerSelection.All:
			{
				PiShockShocker[] shockers = Shockers;
				foreach (PiShockShocker shocker in shockers)
				{
					SendOperation(operation, values, shocker);
				}
				break;
			}
			case ShockerSelection.Random:
				SendOperation(operation, values, GetRandomShocker());
				break;
			}
		}

		private async void SendOperation(PiShockOperation operation, PiShockValues values, PiShockShocker shocker)
		{
			Log.Info($"Sending {operation} with {values} to {shocker.ShareCode}");
			HttpContent content = new StringContent(JsonSerializer.Serialize(new
			{
				Username = ConfigManager.PiShockUsername.Value,
				Apikey = ConfigManager.PiShockApiKey.Value,
				Code = shocker.ShareCode,
				Name = DisplayName,
				Op = (int)operation,
				Duration = (int)values.Duration.TotalSeconds,
				Intensity = (int)values.Intensity
			}), Encoding.UTF8, "application/json");
			string text = await (await HttpClient.PostAsync("", content)).Content.ReadAsStringAsync();
			if (!(text == "Operation Succeeded.") && !(text == "Operation Attempted."))
			{
				Log.Error("Request failed for reason: " + text);
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource Logger { get; set; }

		internal static void Init(ManualLogSource logger)
		{
			Logger = logger;
		}

		[Conditional("DEBUG")]
		internal static void Debug(object data)
		{
			Logger.LogDebug(data);
		}

		internal static void Info(object data)
		{
			Logger.LogInfo(data);
		}

		internal static void Message(object data)
		{
			Logger.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			Logger.LogWarning(data);
		}

		internal static void Error(object data)
		{
			Logger.LogError(data);
		}

		internal static void Fatal(object data)
		{
			Logger.LogFatal(data);
		}
	}
	internal enum PiShockOperation
	{
		Shock,
		Vibrate,
		Beep
	}
	internal class PiShockRequest
	{
		internal string Username { get; set; }

		internal string Apikey { get; set; }

		internal string Code { get; set; }

		internal string Name { get; set; }

		internal int Op { get; set; }

		internal int Duration { get; set; }

		internal int Intensity { get; set; }
	}
	internal class PiShockShocker
	{
		internal string ShareCode { get; set; }

		internal PiShockShocker(string shareCode)
		{
			ShareCode = shareCode;
		}
	}
	internal class PiShockValues
	{
		internal const int MaxApiDurationSeconds = 15;

		internal const int MaxApiIntensity = 100;

		private TimeSpan _duration = TimeSpan.Zero;

		private float _intensity;

		private int MaxIntensity { get; set; }

		private TimeSpan MaxDuration { get; set; }

		internal TimeSpan Duration
		{
			get
			{
				return _duration;
			}
			set
			{
				float num = Mathf.Clamp((float)value.TotalSeconds, 0f, (float)MaxDuration.TotalSeconds);
				_duration = TimeSpan.FromSeconds(num);
			}
		}

		internal float Intensity
		{
			get
			{
				return _intensity;
			}
			set
			{
				_intensity = Mathf.Clamp(value, 0f, (float)MaxIntensity);
			}
		}

		internal PiShockValues(int maxIntensity, int maxDurationSeconds)
		{
			MaxIntensity = maxIntensity;
			MaxDuration = TimeSpan.FromSeconds(maxDurationSeconds);
		}

		internal PiShockValues()
			: this(100, 15)
		{
		}

		internal bool IsNill()
		{
			bool num = Duration.TotalSeconds < 1.0;
			bool flag = Intensity < 1f;
			return num || flag;
		}

		public override string ToString()
		{
			return $"PiShockValues(Intensity={Intensity}, Duration={Duration.TotalSeconds}s)";
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("quasikyo.ThunderRain", "ThunderRain", "1.0.2")]
	public class ThunderRain : BaseUnityPlugin
	{
		public const string PluginGUID = "quasikyo.ThunderRain";

		public const string PluginAuthor = "quasikyo";

		public const string PluginName = "ThunderRain";

		public const string PluginVersion = "1.0.2";

		private static ValuePool Buffer { get; set; }

		private static DeviceManager DeviceManager { get; set; }

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			Log.Info("Performing setup for ThunderRain");
			Buffer = new ValuePool();
			DeviceManager = new DeviceManager("ThunderRain");
			GlobalEventManager.onClientDamageNotified += OperateDevicesOnDamage;
		}

		private IEnumerator ReadBuffer()
		{
			Buffer.SetActive();
			yield return (object)new WaitForSeconds((float)ConfigManager.TimeSpanSeconds.Value);
			DeviceManager.ProcessValuePool(Buffer);
			Buffer.Reset();
		}

		private void OperateDevicesOnDamage(DamageDealtMessage damageMessage)
		{
			CharacterMaster cachedMaster = LocalUserManager.GetFirstLocalUser().cachedMaster;
			CharacterBody body = cachedMaster.GetBody();
			GameObject victim = damageMessage.victim;
			CharacterBody val = ((victim != null) ? victim.GetComponent<CharacterBody>() : null);
			GameObject attacker = damageMessage.attacker;
			CharacterBody val2 = ((attacker != null) ? attacker.GetComponent<CharacterBody>() : null);
			if (!((Object)(object)val == (Object)null))
			{
				if (Buffer.Status == ValuePool.PoolStatus.Empty)
				{
					((MonoBehaviour)this).StartCoroutine(ReadBuffer());
				}
				float fullCombinedHealth = val.healthComponent.fullCombinedHealth;
				float num = damageMessage.damage / fullCombinedHealth;
				if (!ConfigManager.AllowExcessDamage.Value)
				{
					num = Math.Min(num, 1f);
				}
				bool flag = (Object)(object)body == (Object)(object)val2;
				bool num2 = (Object)(object)body == (Object)(object)val;
				object obj;
				if (val2 == null)
				{
					obj = null;
				}
				else
				{
					CharacterMaster master = val2.master;
					obj = ((master != null) ? master.minionOwnership.ownerMaster : null);
				}
				bool flag2 = (Object)obj == (Object)(object)cachedMaster;
				CharacterMaster master2 = val.master;
				bool flag3 = (Object)(object)((master2 != null) ? master2.minionOwnership.ownerMaster : null) == (Object)(object)cachedMaster;
				if ((flag && ConfigManager.VibrationsFromDealingDamage.Value) || (flag2 && ConfigManager.VibrationsFromMinionsDealingDamage.Value))
				{
					Buffer.VibrationValues.Duration += TimeSpan.FromSeconds((float)ConfigManager.BaseVibrationDurationSeconds.Value * num);
					Buffer.VibrationValues.Intensity += (float)ConfigManager.DealingDamageBaseVibrationIntensity.Value * num;
				}
				if ((flag && ConfigManager.ShocksFromDealingDamage.Value) || (flag2 && ConfigManager.ShocksFromMinionsDealingDamage.Value))
				{
					Buffer.ShockValues.Duration += TimeSpan.FromSeconds((float)ConfigManager.BaseShockDurationSeconds.Value * num);
					Buffer.ShockValues.Intensity += (float)ConfigManager.DealingDamageBaseShockIntensity.Value * num;
				}
				if ((num2 && ConfigManager.VibrationsFromReceivingDamage.Value) || (flag3 && ConfigManager.VibrationsFromMinionsReceivingDamage.Value))
				{
					Buffer.VibrationValues.Duration += TimeSpan.FromSeconds((float)ConfigManager.BaseVibrationDurationSeconds.Value * num);
					Buffer.VibrationValues.Intensity += (float)ConfigManager.ReceivingDamageBaseVibrationIntensity.Value * num;
				}
				if ((num2 && ConfigManager.ShocksFromReceivingDamage.Value) || (flag3 && ConfigManager.ShocksFromMinionsReceivingDamage.Value))
				{
					Buffer.ShockValues.Duration += TimeSpan.FromSeconds((float)ConfigManager.BaseShockDurationSeconds.Value * num);
					Buffer.ShockValues.Intensity += (float)ConfigManager.ReceivingDamageBaseShockIntensity.Value * num;
				}
			}
		}
	}
	internal class ValuePool
	{
		internal enum PoolStatus
		{
			Empty,
			Active
		}

		internal PoolStatus Status { get; private set; }

		internal PiShockValues VibrationValues { get; set; }

		internal PiShockValues ShockValues { get; set; }

		internal ValuePool()
		{
			Reset();
			ConfigManager.MaximumShockDuration.SettingChanged += ResetOnSettingChange;
			ConfigManager.MaximumShockIntensity.SettingChanged += ResetOnSettingChange;
			ConfigManager.MaximumVibrationDuration.SettingChanged += ResetOnSettingChange;
			ConfigManager.MaximumVibrationIntensity.SettingChanged += ResetOnSettingChange;
		}

		internal void SetActive()
		{
			Status = PoolStatus.Active;
		}

		private void ResetOnSettingChange(object sender, EventArgs e)
		{
			Reset();
		}

		internal void Reset()
		{
			Status = PoolStatus.Empty;
			VibrationValues = new PiShockValues(ConfigManager.MaximumVibrationIntensity.Value, ConfigManager.MaximumVibrationDuration.Value);
			ShockValues = new PiShockValues(ConfigManager.MaximumShockIntensity.Value, ConfigManager.MaximumShockDuration.Value);
		}
	}
}
namespace Costura
{
	[CompilerGenerated]
	internal static class AssemblyLoader
	{
		private static object nullCacheLock = new object();

		private static Dictionary<string, bool> nullCache = new Dictionary<string, bool>();

		private static Dictionary<string, string> assemblyNames = new Dictionary<string, string>();

		private static Dictionary<string, string> symbolNames = new Dictionary<string, string>();

		private static int isAttached;

		private static string CultureToString(CultureInfo culture)
		{
			if (culture == null)
			{
				return "";
			}
			return culture.Name;
		}

		private static Assembly ReadExistingAssembly(AssemblyName name)
		{
			AppDomain currentDomain = AppDomain.CurrentDomain;
			Assembly[] assemblies = currentDomain.GetAssemblies();
			Assembly[] array = assemblies;
			foreach (Assembly assembly in array)
			{
				AssemblyName name2 = assembly.GetName();
				if (string.Equals(name2.Name, name.Name, StringComparison.InvariantCultureIgnoreCase) && string.Equals(CultureToString(name2.CultureInfo), CultureToString(name.CultureInfo), StringComparison.InvariantCultureIgnoreCase))
				{
					return assembly;
				}
			}
			return null;
		}

		private static void CopyTo(Stream source, Stream destination)
		{
			byte[] array = new byte[81920];
			int count;
			while ((count = source.Read(array, 0, array.Length)) != 0)
			{
				destination.Write(array, 0, count);
			}
		}

		private static Stream LoadStream(string fullName)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			if (fullName.EndsWith(".compressed"))
			{
				using (Stream stream = executingAssembly.GetManifestResourceStream(fullName))
				{
					using DeflateStream source = new DeflateStream(stream, CompressionMode.Decompress);
					MemoryStream memoryStream = new MemoryStream();
					CopyTo(source, memoryStream);
					memoryStream.Position = 0L;
					return memoryStream;
				}
			}
			return executingAssembly.GetManifestResourceStream(fullName);
		}

		private static Stream LoadStream(Dictionary<string, string> resourceNames, string name)
		{
			if (resourceNames.TryGetValue(name, out var value))
			{
				return LoadStream(value);
			}
			return null;
		}

		private static byte[] ReadStream(Stream stream)
		{
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			return array;
		}

		private static Assembly ReadFromEmbeddedResources(Dictionary<string, string> assemblyNames, Dictionary<string, string> symbolNames, AssemblyName requestedAssemblyName)
		{
			string text = requestedAssemblyName.Name.ToLowerInvariant();
			if (requestedAssemblyName.CultureInfo != null && !string.IsNullOrEmpty(requestedAssemblyName.CultureInfo.Name))
			{
				text = requestedAssemblyName.CultureInfo.Name + "." + text;
			}
			byte[] rawAssembly;
			using (Stream stream = LoadStream(assemblyNames, text))
			{
				if (stream == null)
				{
					return null;
				}
				rawAssembly = ReadStream(stream);
			}
			using (Stream stream2 = LoadStream(symbolNames, text))
			{
				if (stream2 != null)
				{
					byte[] rawSymbolStore = ReadStream(stream2);
					return Assembly.Load(rawAssembly, rawSymbolStore);
				}
			}
			return Assembly.Load(rawAssembly);
		}

		public static Assembly ResolveAssembly(object sender, ResolveEventArgs e)
		{
			lock (nullCacheLock)
			{
				if (nullCache.ContainsKey(e.Name))
				{
					return null;
				}
			}
			AssemblyName assemblyName = new AssemblyName(e.Name);
			Assembly assembly = ReadExistingAssembly(assemblyName);
			if ((object)assembly != null)
			{
				return assembly;
			}
			assembly = ReadFromEmbeddedResources(assemblyNames, symbolNames, assemblyName);
			if ((object)assembly == null)
			{
				lock (nullCacheLock)
				{
					nullCache[e.Name] = true;
				}
				if ((assemblyName.Flags & AssemblyNameFlags.Retargetable) != 0)
				{
					assembly = Assembly.Load(assemblyName);
				}
			}
			return assembly;
		}

		static AssemblyLoader()
		{
			assemblyNames.Add("microsoft.bcl.asyncinterfaces", "costura.microsoft.bcl.asyncinterfaces.dll.compressed");
			assemblyNames.Add("system.appcontext", "costura.system.appcontext.dll.compressed");
			assemblyNames.Add("system.buffers", "costura.system.buffers.dll.compressed");
			assemblyNames.Add("system.collections.concurrent", "costura.system.collections.concurrent.dll.compressed");
			assemblyNames.Add("system.collections", "costura.system.collections.dll.compressed");
			assemblyNames.Add("system.collections.nongeneric", "costura.system.collections.nongeneric.dll.compressed");
			assemblyNames.Add("system.collections.specialized", "costura.system.collections.specialized.dll.compressed");
			assemblyNames.Add("system.componentmodel.composition", "costura.system.componentmodel.composition.dll.compressed");
			assemblyNames.Add("system.componentmodel", "costura.system.componentmodel.dll.compressed");
			assemblyNames.Add("system.componentmodel.eventbasedasync", "costura.system.componentmodel.eventbasedasync.dll.compressed");
			assemblyNames.Add("system.componentmodel.primitives", "costura.system.componentmodel.primitives.dll.compressed");
			assemblyNames.Add("system.componentmodel.typeconverter", "costura.system.componentmodel.typeconverter.dll.compressed");
			assemblyNames.Add("system.console", "costura.system.console.dll.compressed");
			assemblyNames.Add("system.core", "costura.system.core.dll.compressed");
			assemblyNames.Add("system.data.common", "costura.system.data.common.dll.compressed");
			assemblyNames.Add("system.data", "costura.system.data.dll.compressed");
			assemblyNames.Add("system.diagnostics.contracts", "costura.system.diagnostics.contracts.dll.compressed");
			assemblyNames.Add("system.diagnostics.debug", "costura.system.diagnostics.debug.dll.compressed");
			assemblyNames.Add("system.diagnostics.fileversioninfo", "costura.system.diagnostics.fileversioninfo.dll.compressed");
			assemblyNames.Add("system.diagnostics.process", "costura.system.diagnostics.process.dll.compressed");
			assemblyNames.Add("system.diagnostics.stacktrace", "costura.system.diagnostics.stacktrace.dll.compressed");
			assemblyNames.Add("system.diagnostics.textwritertracelistener", "costura.system.diagnostics.textwritertracelistener.dll.compressed");
			assemblyNames.Add("system.diagnostics.tools", "costura.system.diagnostics.tools.dll.compressed");
			assemblyNames.Add("system.diagnostics.tracesource", "costura.system.diagnostics.tracesource.dll.compressed");
			assemblyNames.Add("system.diagnostics.tracing", "costura.system.diagnostics.tracing.dll.compressed");
			assemblyNames.Add("system.drawing", "costura.system.drawing.dll.compressed");
			assemblyNames.Add("system.drawing.primitives", "costura.system.drawing.primitives.dll.compressed");
			assemblyNames.Add("system.dynamic.runtime", "costura.system.dynamic.runtime.dll.compressed");
			assemblyNames.Add("system.globalization.calendars", "costura.system.globalization.calendars.dll.compressed");
			assemblyNames.Add("system.globalization", "costura.system.globalization.dll.compressed");
			assemblyNames.Add("system.globalization.extensions", "costura.system.globalization.extensions.dll.compressed");
			assemblyNames.Add("system.io.compression", "costura.system.io.compression.dll.compressed");
			assemblyNames.Add("system.io.compression.filesystem", "costura.system.io.compression.filesystem.dll.compressed");
			assemblyNames.Add("system.io.compression.zipfile", "costura.system.io.compression.zipfile.dll.compressed");
			assemblyNames.Add("system.io", "costura.system.io.dll.compressed");
			assemblyNames.Add("system.io.filesystem", "costura.system.io.filesystem.dll.compressed");
			assemblyNames.Add("system.io.filesystem.driveinfo", "costura.system.io.filesystem.driveinfo.dll.compressed");
			assemblyNames.Add("system.io.filesystem.primitives", "costura.system.io.filesystem.primitives.dll.compressed");
			assemblyNames.Add("system.io.filesystem.watcher", "costura.system.io.filesystem.watcher.dll.compressed");
			assemblyNames.Add("system.io.isolatedstorage", "costura.system.io.isolatedstorage.dll.compressed");
			assemblyNames.Add("system.io.memorymappedfiles", "costura.system.io.memorymappedfiles.dll.compressed");
			assemblyNames.Add("system.io.pipes", "costura.system.io.pipes.dll.compressed");
			assemblyNames.Add("system.io.unmanagedmemorystream", "costura.system.io.unmanagedmemorystream.dll.compressed");
			assemblyNames.Add("system.linq", "costura.system.linq.dll.compressed");
			assemblyNames.Add("system.linq.expressions", "costura.system.linq.expressions.dll.compressed");
			assemblyNames.Add("system.linq.parallel", "costura.system.linq.parallel.dll.compressed");
			assemblyNames.Add("system.linq.queryable", "costura.system.linq.queryable.dll.compressed");
			assemblyNames.Add("system.memory", "costura.system.memory.dll.compressed");
			assemblyNames.Add("system.net", "costura.system.net.dll.compressed");
			assemblyNames.Add("system.net.http", "costura.system.net.http.dll.compressed");
			assemblyNames.Add("system.net.nameresolution", "costura.system.net.nameresolution.dll.compressed");
			assemblyNames.Add("system.net.networkinformation", "costura.system.net.networkinformation.dll.compressed");
			assemblyNames.Add("system.net.ping", "costura.system.net.ping.dll.compressed");
			assemblyNames.Add("system.net.primitives", "costura.system.net.primitives.dll.compressed");
			assemblyNames.Add("system.net.requests", "costura.system.net.requests.dll.compressed");
			assemblyNames.Add("system.net.security", "costura.system.net.security.dll.compressed");
			assemblyNames.Add("system.net.sockets", "costura.system.net.sockets.dll.compressed");
			assemblyNames.Add("system.net.webheadercollection", "costura.system.net.webheadercollection.dll.compressed");
			assemblyNames.Add("system.net.websockets.client", "costura.system.net.websockets.client.dll.compressed");
			assemblyNames.Add("system.net.websockets", "costura.system.net.websockets.dll.compressed");
			assemblyNames.Add("system.numerics", "costura.system.numerics.dll.compressed");
			assemblyNames.Add("system.numerics.vectors", "costura.system.numerics.vectors.dll.compressed");
			assemblyNames.Add("system.objectmodel", "costura.system.objectmodel.dll.compressed");
			assemblyNames.Add("system.reflection", "costura.system.reflection.dll.compressed");
			assemblyNames.Add("system.reflection.emit", "costura.system.reflection.emit.dll.compressed");
			assemblyNames.Add("system.reflection.emit.ilgeneration", "costura.system.reflection.emit.ilgeneration.dll.compressed");
			assemblyNames.Add("system.reflection.emit.lightweight", "costura.system.reflection.emit.lightweight.dll.compressed");
			assemblyNames.Add("system.reflection.extensions", "costura.system.reflection.extensions.dll.compressed");
			assemblyNames.Add("system.reflection.primitives", "costura.system.reflection.primitives.dll.compressed");
			assemblyNames.Add("system.reflection.typeextensions", "costura.system.reflection.typeextensions.dll.compressed");
			assemblyNames.Add("system.resources.reader", "costura.system.resources.reader.dll.compressed");
			assemblyNames.Add("system.resources.resourcemanager", "costura.system.resources.resourcemanager.dll.compressed");
			assemblyNames.Add("system.resources.writer", "costura.system.resources.writer.dll.compressed");
			assemblyNames.Add("system.runtime.compilerservices.unsafe", "costura.system.runtime.compilerservices.unsafe.dll.compressed");
			assemblyNames.Add("system.runtime.compilerservices.visualc", "costura.system.runtime.compilerservices.visualc.dll.compressed");
			assemblyNames.Add("system.runtime", "costura.system.runtime.dll.compressed");
			assemblyNames.Add("system.runtime.extensions", "costura.system.runtime.extensions.dll.compressed");
			assemblyNames.Add("system.runtime.handles", "costura.system.runtime.handles.dll.compressed");
			assemblyNames.Add("system.runtime.interopservices", "costura.system.runtime.interopservices.dll.compressed");
			assemblyNames.Add("system.runtime.interopservices.runtimeinformation", "costura.system.runtime.interopservices.runtimeinformation.dll.compressed");
			assemblyNames.Add("system.runtime.numerics", "costura.system.runtime.numerics.dll.compressed");
			assemblyNames.Add("system.runtime.serialization", "costura.system.runtime.serialization.dll.compressed");
			assemblyNames.Add("system.runtime.serialization.formatters", "costura.system.runtime.serialization.formatters.dll.compressed");
			assemblyNames.Add("system.runtime.serialization.json", "costura.system.runtime.serialization.json.dll.compressed");
			assemblyNames.Add("system.runtime.serialization.primitives", "costura.system.runtime.serialization.primitives.dll.compressed");
			assemblyNames.Add("system.runtime.serialization.xml", "costura.system.runtime.serialization.xml.dll.compressed");
			assemblyNames.Add("system.security.claims", "costura.system.security.claims.dll.compressed");
			assemblyNames.Add("system.security.cryptography.algorithms", "costura.system.security.cryptography.algorithms.dll.compressed");
			assemblyNames.Add("system.security.cryptography.csp", "costura.system.security.cryptography.csp.dll.compressed");
			assemblyNames.Add("system.security.cryptography.encoding", "costura.system.security.cryptography.encoding.dll.compressed");
			assemblyNames.Add("system.security.cryptography.primitives", "costura.system.security.cryptography.primitives.dll.compressed");
			assemblyNames.Add("system.security.cryptography.x509certificates", "costura.system.security.cryptography.x509certificates.dll.compressed");
			assemblyNames.Add("system.security.principal", "costura.system.security.principal.dll.compressed");
			assemblyNames.Add("system.security.securestring", "costura.system.security.securestring.dll.compressed");
			assemblyNames.Add("system.servicemodel.web", "costura.system.servicemodel.web.dll.compressed");
			assemblyNames.Add("system.text.encoding", "costura.system.text.encoding.dll.compressed");
			assemblyNames.Add("system.text.encoding.extensions", "costura.system.text.encoding.extensions.dll.compressed");
			assemblyNames.Add("system.text.encodings.web", "costura.system.text.encodings.web.dll.compressed");
			assemblyNames.Add("system.text.json", "costura.system.text.json.dll.compressed");
			assemblyNames.Add("system.text.regularexpressions", "costura.system.text.regularexpressions.dll.compressed");
			assemblyNames.Add("system.threading", "costura.system.threading.dll.compressed");
			assemblyNames.Add("system.threading.overlapped", "costura.system.threading.overlapped.dll.compressed");
			assemblyNames.Add("system.threading.tasks", "costura.system.threading.tasks.dll.compressed");
			assemblyNames.Add("system.threading.tasks.extensions", "costura.system.threading.tasks.extensions.dll.compressed");
			assemblyNames.Add("system.threading.tasks.parallel", "costura.system.threading.tasks.parallel.dll.compressed");
			assemblyNames.Add("system.threading.thread", "costura.system.threading.thread.dll.compressed");
			assemblyNames.Add("system.threading.threadpool", "costura.system.threading.threadpool.dll.compressed");
			assemblyNames.Add("system.threading.timer", "costura.system.threading.timer.dll.compressed");
			assemblyNames.Add("system.transactions", "costura.system.transactions.dll.compressed");
			assemblyNames.Add("system.valuetuple", "costura.system.valuetuple.dll.compressed");
			assemblyNames.Add("system.web", "costura.system.web.dll.compressed");
			assemblyNames.Add("system.windows", "costura.system.windows.dll.compressed");
			assemblyNames.Add("system.xml", "costura.system.xml.dll.compressed");
			assemblyNames.Add("system.xml.linq", "costura.system.xml.linq.dll.compressed");
			assemblyNames.Add("system.xml.readerwriter", "costura.system.xml.readerwriter.dll.compressed");
			assemblyNames.Add("system.xml.serialization", "costura.system.xml.serialization.dll.compressed");
			assemblyNames.Add("system.xml.xdocument", "costura.system.xml.xdocument.dll.compressed");
			assemblyNames.Add("system.xml.xmldocument", "costura.system.xml.xmldocument.dll.compressed");
			assemblyNames.Add("system.xml.xmlserializer", "costura.system.xml.xmlserializer.dll.compressed");
			assemblyNames.Add("system.xml.xpath", "costura.system.xml.xpath.dll.compressed");
			assemblyNames.Add("system.xml.xpath.xdocument", "costura.system.xml.xpath.xdocument.dll.compressed");
		}

		public static void Attach()
		{
			if (Interlocked.Exchange(ref isAttached, 1) == 1)
			{
				return;
			}
			AppDomain currentDomain = AppDomain.CurrentDomain;
			currentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs e)
			{
				lock (nullCacheLock)
				{
					if (nullCache.ContainsKey(e.Name))
					{
						return null;
					}
				}
				AssemblyName assemblyName = new AssemblyName(e.Name);
				Assembly assembly = ReadExistingAssembly(assemblyName);
				if ((object)assembly != null)
				{
					return assembly;
				}
				assembly = ReadFromEmbeddedResources(assemblyNames, symbolNames, assemblyName);
				if ((object)assembly == null)
				{
					lock (nullCacheLock)
					{
						nullCache[e.Name] = true;
					}
					if ((assemblyName.Flags & AssemblyNameFlags.Retargetable) != 0)
					{
						assembly = Assembly.Load(assemblyName);
					}
				}
				return assembly;
			};
		}
	}
}
internal class ThunderRain_ProcessedByFody
{
	internal const string FodyVersion = "6.8.0.0";

	internal const string Costura = "5.7.0";
}