Decompiled source of FancyHitmarkers v1.1.2

FancyHitmarkers.dll

Decompiled 4 months 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 Microsoft.CodeAnalysis;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FancyHitmarkers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8ebcb852c9f1bad534e4cee67f099d475f414f40")]
[assembly: AssemblyProduct("FancyHitmarkers")]
[assembly: AssemblyTitle("FancyHitmarkers")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace rubiefawn
{
	[BepInPlugin("rubiefawn.FancyHitmarkers", "FancyHitmarkers", "1.1.2")]
	public class FancyHitmarkers : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_HandleHitMarker <0>__ApplyHitmarkerColor;
		}

		public const string PluginGUID = "rubiefawn.FancyHitmarkers";

		public const string PluginAuthor = "rubiefawn";

		public const string PluginName = "FancyHitmarkers";

		public const string PluginVersion = "1.1.2";

		private static readonly Color critcolor = new Color(1f, 0.75f, 0f);

		private static readonly Color killcolor = new Color(1f, 0f, 0f);

		private const float phi = 1.618f;

		private const float basetime = 0.15f;

		private const float crittime = 0.39268863f;

		private const float killtime = 0.6353702f;

		private static void ApplyHitmarkerColor(orig_HandleHitMarker orig, DamageDealtMessage dmg)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			GameObject victim = dmg.victim;
			bool num = victim == null || !victim.GetComponent<HealthComponent>().alive;
			bool crit = dmg.crit;
			var (color, hitmarkerTimer) = (num ? (killcolor, 0.6353702f) : ((!crit) ? (Color.white, 0.15f) : (critcolor, 0.39268863f)));
			orig.Invoke(dmg);
			foreach (CrosshairManager instances in CrosshairManager.instancesList)
			{
				GameObject attacker = dmg.attacker;
				CameraRigController cameraRigController = instances.cameraRigController;
				if ((Object)(object)attacker == (Object)(object)((cameraRigController != null) ? cameraRigController.target : null))
				{
					((Graphic)instances.hitmarker).color = color;
					instances.hitmarkerTimer = hitmarkerTimer;
					((Component)instances.hitmarker).gameObject.SetActive(false);
					((Component)instances.hitmarker).gameObject.SetActive(true);
				}
			}
		}

		private void OnEnable()
		{
			//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
			object obj = <>O.<0>__ApplyHitmarkerColor;
			if (obj == null)
			{
				hook_HandleHitMarker val = ApplyHitmarkerColor;
				<>O.<0>__ApplyHitmarkerColor = val;
				obj = (object)val;
			}
			CrosshairManager.HandleHitMarker += (hook_HandleHitMarker)obj;
		}

		private void OnDisable()
		{
			//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
			object obj = <>O.<0>__ApplyHitmarkerColor;
			if (obj == null)
			{
				hook_HandleHitMarker val = ApplyHitmarkerColor;
				<>O.<0>__ApplyHitmarkerColor = val;
				obj = (object)val;
			}
			CrosshairManager.HandleHitMarker -= (hook_HandleHitMarker)obj;
		}
	}
}