Decompiled source of DamagePopups v1.0.2

BepInEx/plugins/DamagePopups/cyclozarin.contentwarning.DamagePopups.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DamagePopups.Behaviours;
using DamagePopups.Patches;
using Microsoft.CodeAnalysis;
using On;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Ashley.MeshSplitter")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("com.rlabrecque.steamworks.net")]
[assembly: IgnoresAccessChecksTo("Discord")]
[assembly: IgnoresAccessChecksTo("HBAO.Demo.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("HBAO.Runtime")]
[assembly: IgnoresAccessChecksTo("HBAO.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("MeshSplit")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("pworld")]
[assembly: IgnoresAccessChecksTo("sc.posteffects.runtime")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Tayx.Graphy")]
[assembly: IgnoresAccessChecksTo("Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")]
[assembly: IgnoresAccessChecksTo("Unity.Localization")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.PlayableGraphVisualizer")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipeline.Universal.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Shaders")]
[assembly: IgnoresAccessChecksTo("Unity.ResourceManager")]
[assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")]
[assembly: IgnoresAccessChecksTo("Unity.Splines")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("Zorro.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Zorro.PhotonUtility")]
[assembly: IgnoresAccessChecksTo("Zorro.Recorder")]
[assembly: IgnoresAccessChecksTo("Zorro.Settings.Runtime")]
[assembly: IgnoresAccessChecksTo("Zorro.UI.Runtime")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("cyclozarin.contentwarning.DamagePopups")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+e3dae7da6dc030ab594daaaeeb0ab76134f44610")]
[assembly: AssemblyProduct("DamagePopups")]
[assembly: AssemblyTitle("cyclozarin.contentwarning.DamagePopups")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 DamagePopups
{
	[ContentWarningPlugin("cyclozarin.contentwarning.DamagePopups", "1.0.2", true)]
	[BepInPlugin("cyclozarin.contentwarning.DamagePopups", "DamagePopups", "1.0.2")]
	public class DamagePopups : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Start <>9__12_0;

			internal void <Awake>b__12_0(orig_Start orig, MainMenuHandler self)
			{
				orig.Invoke(self);
				PopupFont = ((TMP_Text)GameObject.Find("Canvas/MainPage/HIGH SERVER LOAD").GetComponent<TextMeshProUGUI>()).font;
			}
		}

		public static DamagePopups Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static TMP_FontAsset PopupFont { get; private set; }

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			HookAll();
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, MainMenuHandler self)
				{
					orig.Invoke(self);
					PopupFont = ((TMP_Text)GameObject.Find("Canvas/MainPage/HIGH SERVER LOAD").GetComponent<TextMeshProUGUI>()).font;
				};
				<>c.<>9__12_0 = val;
				obj = (object)val;
			}
			MainMenuHandler.Start += (hook_Start)obj;
			Logger.LogInfo((object)("DamagePopups v1.0.2 by " + "cyclozarin.contentwarning.DamagePopups".Split(".")[0] + " has loaded!"));
		}

		internal static void HookAll()
		{
			Logger.LogDebug((object)"Hooking...");
			PlayerHook.Init();
			Logger.LogDebug((object)"Finished hooking!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "cyclozarin.contentwarning.DamagePopups";

		public const string PLUGIN_NAME = "DamagePopups";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace DamagePopups.Patches
{
	public class PlayerHook
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_TakeDamage <0>__MMHook_Postfix_ShowDamagePopup;

			public static hook_RPCA_Heal <1>__MMHook_Postfix_ShowHealPopup;

			public static hook_RPCA_PlayerDie <2>__MMHook_Postfix_ShowInstakillPopup;

			public static hook_CallRevive <3>__MMHook_Postfix_ShowRevivePopup;
		}

		internal static void Init()
		{
			//IL_0010: 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_001b: Expected O, but got Unknown
			//IL_0030: 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_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			object obj = <>O.<0>__MMHook_Postfix_ShowDamagePopup;
			if (obj == null)
			{
				hook_TakeDamage val = MMHook_Postfix_ShowDamagePopup;
				<>O.<0>__MMHook_Postfix_ShowDamagePopup = val;
				obj = (object)val;
			}
			Player.TakeDamage += (hook_TakeDamage)obj;
			object obj2 = <>O.<1>__MMHook_Postfix_ShowHealPopup;
			if (obj2 == null)
			{
				hook_RPCA_Heal val2 = MMHook_Postfix_ShowHealPopup;
				<>O.<1>__MMHook_Postfix_ShowHealPopup = val2;
				obj2 = (object)val2;
			}
			Player.RPCA_Heal += (hook_RPCA_Heal)obj2;
			object obj3 = <>O.<2>__MMHook_Postfix_ShowInstakillPopup;
			if (obj3 == null)
			{
				hook_RPCA_PlayerDie val3 = MMHook_Postfix_ShowInstakillPopup;
				<>O.<2>__MMHook_Postfix_ShowInstakillPopup = val3;
				obj3 = (object)val3;
			}
			Player.RPCA_PlayerDie += (hook_RPCA_PlayerDie)obj3;
			object obj4 = <>O.<3>__MMHook_Postfix_ShowRevivePopup;
			if (obj4 == null)
			{
				hook_CallRevive val4 = MMHook_Postfix_ShowRevivePopup;
				<>O.<3>__MMHook_Postfix_ShowRevivePopup = val4;
				obj4 = (object)val4;
			}
			Player.CallRevive += (hook_CallRevive)obj4;
		}

		private static void MMHook_Postfix_ShowHealPopup(orig_RPCA_Heal orig, Player self, float healAmount)
		{
			//IL_0036: 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)
			orig.Invoke(self, healAmount);
			if (((MonoBehaviourPun)self).photonView.IsMine)
			{
				InstantiateLocalPopup(Color.green, $"+{Mathf.RoundToInt(healAmount)}");
			}
			else
			{
				InstantiatePopupAtPlayer(self, Color.green, $"+{Mathf.RoundToInt(healAmount)}");
			}
		}

		private static void MMHook_Postfix_ShowDamagePopup(orig_TakeDamage orig, Player self, float damage)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, damage);
			if (!self.ai && !self.data.dead && !(self.Center().y < -100f) && !(self.Center().y > 100f))
			{
				string text = ((self.data.recentDamage.Sum((UniqueDamage x) => x.damage) >= PlayerData.maxHealth) ? "INSTAKILL!" : $"-{Mathf.RoundToInt(damage)}") ?? "";
				if (((MonoBehaviourPun)self).photonView.IsMine)
				{
					InstantiateLocalPopup(Color.red, text);
				}
				else
				{
					InstantiatePopupAtPlayer(self, Color.red, text);
				}
			}
		}

		private static void MMHook_Postfix_ShowInstakillPopup(orig_RPCA_PlayerDie orig, Player self)
		{
			//IL_002c: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!self.data.recentDamage.Any() && self.data.remainingOxygen >= 0f && !(self.Center().y < -100f) && !(self.Center().y > 100f))
			{
				InstantiatePopupAtPlayer(self, (Color.red + Color.black) / 2f, "INSTAKILL!");
			}
		}

		private static void MMHook_Postfix_ShowRevivePopup(orig_CallRevive orig, Player self)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			InstantiatePopupAtPlayer(self, Color.blue, "REVIVE!");
		}

		private static void InstantiatePopupAtPlayer(Player player, Color color, string text)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_002e: 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)
			Vector3 position = player.HeadPosition() + Vector3.up * 0.5f;
			GameObject val = new GameObject("DMG Popup");
			Transform transform = val.transform;
			transform.position = position;
			TextMeshPro val2 = val.AddComponent<TextMeshPro>();
			((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
			((Graphic)val2).color = color;
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).fontSize = 5f;
			((TMP_Text)val2).font = DamagePopups.PopupFont;
			val.AddComponent<PopupFadeOuter>();
			Object.Destroy((Object)(object)GameObject.Find("New Game Object"));
		}

		private static void InstantiateLocalPopup(Color color, string text)
		{
			//IL_0073: 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_0092: 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)
			GameObject val = GameObject.Find("GAME/HelmetUI/Pivot/Others/NextStep");
			GameObject val2 = Object.Instantiate<GameObject>(val, GameObject.Find("GAME/HelmetUI/Pivot/Others").transform);
			((Object)val2).name = "Local DMG popup";
			Object.Destroy((Object)(object)val2.GetComponent<NextStepUI>());
			Object.Destroy((Object)(object)((Component)val2.transform.Find("List")).gameObject);
			GameObject gameObject = ((Component)val2.transform.Find("Item Name")).gameObject;
			Transform transform = gameObject.transform;
			Vector3 localPosition = val.transform.localPosition;
			localPosition.x = 460f;
			localPosition.y = -650f;
			transform.localPosition = localPosition;
			TextMeshProUGUI component = gameObject.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).alignment = (TextAlignmentOptions)514;
			((Graphic)component).color = color;
			((TMP_Text)component).text = text;
			((TMP_Text)component).fontSize = 60f;
			((TMP_Text)component).font = DamagePopups.PopupFont;
			gameObject.AddComponent<UiPopupFadeOuter>();
			Object.Destroy((Object)(object)GameObject.Find("New Game Object"));
		}
	}
}
namespace DamagePopups.Behaviours
{
	internal class PopupFadeOuter : MonoBehaviour
	{
		private Vector3 _randomDesiredFadeOutPosition;

		private float _fadeOutTime = 3f;

		private TextMeshPro _textMesh;

		private void Start()
		{
			//IL_0018: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			_textMesh = ((Component)this).GetComponent<TextMeshPro>();
			_randomDesiredFadeOutPosition = ((Component)this).gameObject.transform.position + Random.insideUnitSphere;
			((MonoBehaviour)this).StartCoroutine(MoveAndFadeOut());
		}

		private IEnumerator MoveAndFadeOut()
		{
			float _counter = 0f;
			while (_counter < _fadeOutTime)
			{
				_counter += Time.deltaTime;
				float num = _counter / _fadeOutTime;
				((Component)this).gameObject.transform.LookAt(((Component)MainCamera.instance).transform.position);
				((Component)this).gameObject.transform.Rotate(new Vector3(0f, 180f, 0f));
				((Component)this).gameObject.transform.position = Vector3.Lerp(((Component)this).gameObject.transform.position, _randomDesiredFadeOutPosition, _fadeOutTime);
				((Graphic)_textMesh).color = Color.Lerp(((Graphic)_textMesh).color, Color.black, num);
				((TMP_Text)_textMesh).alpha = Mathf.Lerp(((TMP_Text)_textMesh).alpha, 0f, num);
				yield return null;
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	internal class UiPopupFadeOuter : MonoBehaviour
	{
		private float _fadeOutTime = 3f;

		private TextMeshProUGUI _textMesh;

		private void Start()
		{
			_textMesh = ((Component)this).GetComponent<TextMeshProUGUI>();
			((MonoBehaviour)this).StartCoroutine(MoveAndFadeOut());
		}

		private IEnumerator MoveAndFadeOut()
		{
			float _counter = 0f;
			while (_counter < _fadeOutTime)
			{
				_counter += Time.deltaTime;
				float num = _counter / _fadeOutTime;
				((Component)this).gameObject.transform.localPosition = Vector3.Lerp(((Component)this).gameObject.transform.localPosition, ((Component)this).gameObject.transform.localPosition + ((Component)this).gameObject.transform.right, _fadeOutTime);
				((Graphic)_textMesh).color = Color.Lerp(((Graphic)_textMesh).color, Color.black, num);
				((TMP_Text)_textMesh).alpha = Mathf.Lerp(((TMP_Text)_textMesh).alpha, 0f, num);
				yield return null;
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}