Decompiled source of UITweaks v1.2.1

Mycopunk.UITweaks.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mycopunk.UITweaks.MonoBehaviours;
using Mycopunk.UITweaks.Patches;
using Pigeon.Movement;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Mycopunk.UITweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]
[assembly: AssemblyProduct("Mycopunk.UITweaks")]
[assembly: AssemblyTitle("Mycopunk.UITweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Mycopunk.UITweaks
{
	internal static class MyPluginInfo
	{
		internal const string PLUGIN_GUID = "Mycopunk.UITweaks";

		internal const string PLUGIN_NAME = "Mycopunk.UITweaks";

		internal const string PLUGIN_VERSION = "1.2.1";
	}
	[MycoMod(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Mycopunk.UITweaks", "Mycopunk.UITweaks", "1.2.1")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony m_Harmony;

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Mycopunk.UITweaks is loaded!");
			m_Harmony = new Harmony("Mycopunk.UITweaks");
			m_Harmony.PatchAll();
		}
	}
}
namespace Mycopunk.UITweaks.Patches
{
	[HarmonyPatch]
	internal class Cooldown_Patches
	{
		public static GameObject coolDownGO;

		public static TextMeshProUGUI coolDownText;

		public static Vector3 coolDownPosition = new Vector3(99.1806f, 64.116f, 0f);

		public static Dictionary<AbilityRechargeUI, TextMeshProUGUI> coolDownDict = new Dictionary<AbilityRechargeUI, TextMeshProUGUI>();

		public static Cooldown_CR cooldown_CR;

		[HarmonyPatch("SelectCharacter")]
		[HarmonyPatch(typeof(CharacterSelectWindow), new Type[] { typeof(Character) })]
		[HarmonyPostfix]
		internal static void CreateObject__Postfix(CharacterSelectWindow __instance)
		{
			if (Object.op_Implicit((Object)(object)coolDownGO))
			{
				foreach (TextMeshProUGUI value in coolDownDict.Values)
				{
					Object.DestroyImmediate((Object)(object)((Component)value).gameObject);
				}
				coolDownDict.Clear();
			}
			if (Object.op_Implicit((Object)(object)cooldown_CR))
			{
				Object.DestroyImmediate((Object)(object)cooldown_CR);
			}
			if (!Object.op_Implicit((Object)(object)cooldown_CR))
			{
				cooldown_CR = ((Component)Player.LocalPlayer.healthbar).gameObject.AddComponent<Cooldown_CR>();
			}
			cooldown_CR.MakeCooldowns();
		}

		[HarmonyPatch(typeof(JoinFriendsWindow), "QuitToMenu")]
		[HarmonyPostfix]
		internal static void DestroyGM__Postfix(JoinFriendsWindow __instance)
		{
			if (Object.op_Implicit((Object)(object)coolDownGO))
			{
				foreach (TextMeshProUGUI value in coolDownDict.Values)
				{
					Object.Destroy((Object)(object)((Component)value).gameObject);
				}
				coolDownDict.Clear();
			}
			Object.Destroy((Object)(object)cooldown_CR);
		}

		[HarmonyPatch(typeof(MatchmakingWindow), "JoinLobby")]
		[HarmonyPostfix]
		internal static void DestroyJoin__Postfix(MatchmakingWindow __instance)
		{
			if (Object.op_Implicit((Object)(object)coolDownGO))
			{
				foreach (TextMeshProUGUI value in coolDownDict.Values)
				{
					Object.Destroy((Object)(object)((Component)value).gameObject);
				}
				coolDownDict.Clear();
			}
			Object.Destroy((Object)(object)cooldown_CR);
		}

		[HarmonyPatch(typeof(AbilityRechargeUI), "OnCooldownChanged")]
		[HarmonyPostfix]
		internal static void GetCD__Postfix(AbilityRechargeUI __instance)
		{
			foreach (AbilityRechargeUI key in coolDownDict.Keys)
			{
				if (((TMP_Text)key.keybindText).text == ((TMP_Text)__instance.keybindText).text)
				{
					TextMeshProUGUI val = coolDownDict[key];
					((TMP_Text)val).text = $"{__instance.prevCharge * 100f:F2}%";
					break;
				}
			}
		}
	}
	[HarmonyPatch]
	internal class EndScreen_Patches
	{
		public static string playerName;

		[HarmonyPatch(typeof(MissionStat), "Setup")]
		[HarmonyPrefix]
		internal static void StatSetup__Prefix(MissionStat __instance, Player player, ref MissionPlayerData data)
		{
			playerName = ((Object)player).name;
		}

		[HarmonyPatch(typeof(MissionPlayerData), "GetStatText")]
		[HarmonyPostfix]
		internal static void GetEndStats__Postfix(MissionPlayerData __instance, out string title, out string description)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			float damageDealt = __instance.damageDealt;
			int enemiesKilled = __instance.enemiesKilled;
			float appliedStatusEffect = __instance.appliedStatusEffect;
			float damageTaken = __instance.damageTaken;
			float num = __instance.deaths;
			float friendlyFireDamageDealt = __instance.friendlyFireDamageDealt;
			float healingDealt = __instance.healingDealt;
			int playersRepaired = __instance.playersRepaired;
			float num2 = __instance.targetsKilled;
			float timeInAir = __instance.timeInAir;
			float num3 = __instance.timesCorroded;
			float num4 = __instance.timesIgnited;
			float timeSliding = __instance.timeSliding;
			title = string.Empty;
			description = $"Damage Dealt: {damageDealt}\n" + $"Enemies Killed: {enemiesKilled}\n" + $"Elemental Stacks: {appliedStatusEffect}";
			Debug.Log((object)("\n________________________________________________________________Player: " + playerName + "\n" + $"Damage Dealt: {damageDealt}\n" + $"Enemies Killed: {enemiesKilled}\n" + $"Elemental Stacks: {appliedStatusEffect}\n" + $"Damage Taken: {damageTaken}\n" + $"Deaths: {num}\n" + $"Friendly Fire Dealt: {friendlyFireDamageDealt}\n" + $"Healing Dealt: {healingDealt}\n" + $"Players Repaired: {playersRepaired}\n" + $"Targets Killed: {num2}\n" + $"Time In Air: {timeInAir}\n" + $"Times Corroded: {num3}\n" + $"Times Ignited: {num4}\n" + $"Time Sliding: {timeSliding}"));
		}
	}
	[HarmonyPatch]
	internal class HealthBar_Patches
	{
		public static Health_MB health_MB;

		public static TextMeshProUGUI healthText;

		public static GameObject healthTextGO;

		public static Player player;

		[HarmonyPatch(typeof(Player), "Start")]
		[HarmonyPrefix]
		internal static void GetPlayer__Prefix(Player __instance)
		{
			if (((NetworkBehaviour)__instance).IsLocalPlayer)
			{
				player = __instance;
			}
		}

		[HarmonyPatch("SelectCharacter")]
		[HarmonyPatch(typeof(CharacterSelectWindow), new Type[] { typeof(Character) })]
		[HarmonyPostfix]
		internal static void CreateObject__Postfix(CharacterSelectWindow __instance)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)player).IsLocalPlayer && !Object.op_Implicit((Object)(object)healthTextGO))
			{
				Debug.Log((object)"Creating Health Text Object ------------------------------------------------------");
				healthTextGO = new GameObject("HealthText");
				health_MB = healthTextGO.AddComponent<Health_MB>();
				healthTextGO.TryGetComponent<TextMeshProUGUI>(ref healthText);
				healthTextGO.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
				healthTextGO.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
				healthTextGO.layer = 5;
				health_MB.health = player.health;
				healthTextGO.SetActive(true);
			}
		}

		[HarmonyPatch(typeof(Player), "OnSyncedHealthChanged")]
		[HarmonyPostfix]
		internal static void OwnerHealthChange__Postfix(Player __instance)
		{
			if (((NetworkBehaviour)__instance).IsLocalPlayer && (Object)(object)healthText != (Object)null)
			{
				health_MB.health = __instance.health;
				health_MB.healthPercent = health_MB.health / __instance.maxHealth;
				health_MB.isDamaged = true;
			}
		}
	}
	[HarmonyPatch]
	internal class XP_Patches
	{
		[HarmonyPatch(typeof(GearData), "GetLevelString")]
		[HarmonyPostfix]
		internal static void NumericalXP__Postfix(GearData __instance, ref string __result)
		{
			if (__instance.level >= __instance.MaxLevel)
			{
				__result = "∞";
			}
			int num = __instance.NextLevelXPCost - __instance.levelXP;
			__result = $"{TextBlocks.GetNumberString(__instance.level)} (NEXT LEVEL: {num})";
		}
	}
}
namespace Mycopunk.UITweaks.MonoBehaviours
{
	internal class Cooldown_CR : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <CooldownCoroutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Cooldown_CR <>4__this;

			private AbilityRechargeUI[] <cdUIs>5__1;

			private AbilityRechargeUI[] <>s__2;

			private int <>s__3;

			private AbilityRechargeUI <cdUI>5__4;

			private Dictionary<AbilityRechargeUI, TextMeshProUGUI>.Enumerator <>s__5;

			private KeyValuePair<AbilityRechargeUI, TextMeshProUGUI> <cooldown>5__6;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <CooldownCoroutine>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<cdUIs>5__1 = null;
				<>s__2 = null;
				<cdUI>5__4 = null;
				<>s__5 = default(Dictionary<AbilityRechargeUI, TextMeshProUGUI>.Enumerator);
				<cooldown>5__6 = default(KeyValuePair<AbilityRechargeUI, TextMeshProUGUI>);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Expected O, but got Unknown
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Expected O, but got Unknown
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (((NetworkBehaviour)Player.LocalPlayer).IsLocalPlayer)
					{
						Debug.Log((object)"local player found");
						<>2__current = (object)new WaitForSeconds(2f);
						<>1__state = 1;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					<cdUIs>5__1 = Object.FindObjectsByType<AbilityRechargeUI>((FindObjectsSortMode)0);
					<>s__2 = <cdUIs>5__1;
					for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++)
					{
						<cdUI>5__4 = <>s__2[<>s__3];
						Debug.Log((object)"Creating Cooldown Objects --------------------------------------------");
						Cooldown_Patches.coolDownGO = new GameObject("CoolDownText");
						Cooldown_Patches.coolDownText = Cooldown_Patches.coolDownGO.AddComponent<TextMeshProUGUI>();
						((TMP_Text)Cooldown_Patches.coolDownText).fontSize = 16f;
						((TMP_Text)Cooldown_Patches.coolDownText).text = "100.00%";
						Cooldown_Patches.coolDownGO.transform.SetParent(((Component)<cdUI>5__4).transform);
						Cooldown_Patches.coolDownGO.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
						Cooldown_Patches.coolDownGO.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
						Cooldown_Patches.coolDownGO.transform.localPosition = Cooldown_Patches.coolDownPosition;
						Cooldown_Patches.coolDownGO.transform.localScale = Vector3.one;
						Cooldown_Patches.coolDownGO.layer = 5;
						Cooldown_Patches.coolDownGO.SetActive(true);
						Cooldown_Patches.coolDownDict.Add(<cdUI>5__4, Cooldown_Patches.coolDownText);
						<cdUI>5__4 = null;
					}
					<>s__2 = null;
					<>s__5 = Cooldown_Patches.coolDownDict.GetEnumerator();
					try
					{
						while (<>s__5.MoveNext())
						{
							<cooldown>5__6 = <>s__5.Current;
							<cooldown>5__6 = default(KeyValuePair<AbilityRechargeUI, TextMeshProUGUI>);
						}
					}
					finally
					{
						((IDisposable)<>s__5).Dispose();
					}
					<>s__5 = default(Dictionary<AbilityRechargeUI, TextMeshProUGUI>.Enumerator);
					<cdUIs>5__1 = null;
					break;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public void MakeCooldowns()
		{
			Debug.Log((object)"coroutine starting");
			((MonoBehaviour)this).StartCoroutine(CooldownCoroutine());
		}

		[IteratorStateMachine(typeof(<CooldownCoroutine>d__1))]
		public IEnumerator CooldownCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CooldownCoroutine>d__1(0)
			{
				<>4__this = this
			};
		}
	}
	internal class Health_MB : MonoBehaviour
	{
		public static TextMeshProUGUI text;

		public float health = 0f;

		public float healthPercent = 0f;

		public Color healthColor = Color.white;

		public static Vector3 position = new Vector3(8.0934f, -41.4283f, 0f);

		public static Vector3 position2 = new Vector3(128.0934f, -41.4283f, 0f);

		public static Quaternion rotation = Quaternion.Euler(0f, 0f, 0f);

		public static Vector3 scale = new Vector3(1f, 1f, 1f);

		public bool isDamaged;

		public void Awake()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Healthbar");
			text = ((Component)this).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)text).fontSize = 24f;
			((Graphic)text).color = Color.white;
			((TMP_Text)text).rectTransform.sizeDelta = new Vector2(250f, 50f);
			((Component)this).gameObject.transform.SetParent(val.transform);
			((Component)this).gameObject.transform.rotation = rotation;
			if (((NetworkBehaviour)HealthBar_Patches.player).IsLocalPlayer)
			{
				((Component)this).gameObject.transform.localPosition = position;
			}
			else
			{
				((Component)this).gameObject.transform.localPosition = position2;
			}
			((Component)this).gameObject.transform.localScale = scale;
			((Component)text).gameObject.layer = 5;
			((TMP_Text)text).text = $"100% ({Math.Round(health, 2):F2})";
			((MaskableGraphic)text).maskable = false;
		}

		public void Update()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (isDamaged)
			{
				((TMP_Text)text).text = $"{healthPercent * 100f:F2}% ({Math.Round(health, 2):F2})";
				float num = Player.CalculateWeightedHealth(healthPercent);
				((Graphic)text).color = Global.Instance.HealthGradient.Evaluate(num);
				isDamaged = false;
			}
			if (((Component)Player.LocalPlayer.overhealthbar).gameObject.activeSelf)
			{
				((Graphic)text).color = Player.LocalPlayer.overhealthbar.color;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}