Decompiled source of UITweaks v1.1.0

Mycopunk.UITweaks.dll

Decompiled a day ago
using System;
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.IgnoreSymbolStoreSequencePoints)]
[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("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("Mycopunk.UITweaks")]
[assembly: AssemblyTitle("Mycopunk.UITweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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.1.0";
	}
	[MycoMod(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Mycopunk.UITweaks", "Mycopunk.UITweaks", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony m_Harmony;

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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 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_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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__Prefix2(Player __instance)
		{
			if (((NetworkBehaviour)__instance).IsLocalPlayer)
			{
				player = __instance;
				Debug.Log((object)((Object)player).name);
			}
		}

		[HarmonyPatch("SelectCharacter")]
		[HarmonyPatch(typeof(CharacterSelectWindow), new Type[] { typeof(Character) })]
		[HarmonyPostfix]
		internal static void CreateObject__Postfix2(Highlighter __instance)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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__Postfix2(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 Health_MB : MonoBehaviour
	{
		public static TextMeshProUGUI text;

		public float health;

		public float healthPercent;

		public Color healthColor = Color.white;

		public static Vector3 position = new Vector3(21.2162f, -45.0458f, -5.5684f);

		public static Vector3 position2 = new Vector3(187.9581f, -44.3458f, -5.5684f);

		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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			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})";
		}

		public void Update()
		{
			//IL_005b: 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)
			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)
		{
		}
	}
}