Decompiled source of FlorpifySkulls v1.0.3

FlorpifySkulls.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("FlorpifySkulls")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FlorpifySkulls")]
[assembly: AssemblyTitle("FlorpifySkulls")]
[assembly: AssemblyVersion("1.0.0.0")]
[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;
		}
	}
}
[BepInPlugin("com.silentsmilee.florpifyskulls", "Florpify Skulls", "1.0.3")]
public sealed class FlorpifySkulls : BaseUnityPlugin
{
	private static Mesh a;

	private static Material[] b;

	private static Material[] c;

	private static Material[] d;

	private static bool e;

	private static readonly Vector3 f = new Vector3(-0.19f, 0.03f, -0.2f);

	private static readonly Vector3 g = new Vector3(-0.07f, 0.02f, -0.22f);

	private static readonly Vector3 h = new Vector3(1f, 16f, 87f);

	private static readonly float i = 2.8f;

	private static readonly Vector3 j = new Vector3(-0.23f, -0.05f, 0.03f);

	private static readonly Vector3 k = new Vector3(14f, 58f, 120f);

	private static readonly float l = 2.15f;

	private ConfigEntry<bool> enabledCfg;

	private ConfigEntry<bool> optimizeCfg;

	private Skull[] cache = (Skull[])(object)new Skull[0];

	private void Awake()
	{
		enabledCfg = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable Florpify Skulls");
		optimizeCfg = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Optimize", true, "For lower-end pc's");
	}

	private void Update()
	{
		if (!enabledCfg.Value)
		{
			return;
		}
		if (!e)
		{
			m();
		}
		if (!e)
		{
			return;
		}
		if (optimizeCfg.Value)
		{
			if ((Time.frameCount & 7) == 0 || cache.Length == 0)
			{
				cache = Object.FindObjectsOfType<Skull>();
			}
			for (int i = 0; i < cache.Length; i++)
			{
				if ((Object)(object)cache[i] != (Object)null)
				{
					n0(cache[i]);
				}
			}
		}
		else
		{
			Skull[] array = Object.FindObjectsOfType<Skull>();
			for (int j = 0; j < array.Length; j++)
			{
				n0(array[j]);
			}
		}
	}

	private static void m()
	{
		GameObject val = ((IEnumerable<GameObject>)Resources.FindObjectsOfTypeAll<GameObject>()).FirstOrDefault((Func<GameObject, bool>)((GameObject x) => ((Object)x).name == "Florp"));
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		MeshFilter componentInChildren = val.GetComponentInChildren<MeshFilter>(true);
		MeshRenderer componentInChildren2 = val.GetComponentInChildren<MeshRenderer>(true);
		if (Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)componentInChildren2))
		{
			a = componentInChildren.sharedMesh;
			b = ((Renderer)componentInChildren2).sharedMaterials.Select(r).ToArray();
			c = b.Select((Material x) => s0(x, new Color(1f, 0.55f, 0.55f))).ToArray();
			d = b.Select((Material x) => s0(x, new Color(0.55f, 0.75f, 1f))).ToArray();
			e = true;
		}
	}

	private static void n0(Skull s)
	{
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		Transform val = ((IEnumerable<Transform>)((Component)((Component)s).transform).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "NewSkull"));
		if (!Object.op_Implicit((Object)(object)val) || !e)
		{
			return;
		}
		MeshFilter component = ((Component)val).GetComponent<MeshFilter>();
		MeshRenderer component2 = ((Component)val).GetComponent<MeshRenderer>();
		if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2))
		{
			bool flag = ((Object)s).name.ToLower().Contains("red");
			if ((Object)(object)component.sharedMesh != (Object)(object)a)
			{
				component.sharedMesh = a;
				((Renderer)component2).materials = (flag ? c : d);
			}
			if ((Object)(object)((Component)s).transform.root != (Object)null && ((Object)((Component)s).transform.root).name == "Player")
			{
				val.localPosition = j;
				val.localRotation = Quaternion.Euler(k);
				val.localScale = Vector3.one * l;
			}
			else
			{
				val.localPosition = (flag ? f : g);
				val.localRotation = Quaternion.Euler(h);
				val.localScale = Vector3.one * i;
			}
		}
	}

	private static Material r(Material m)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		Material val = new Material(m);
		if (val.HasProperty("_EmissionColor"))
		{
			val.EnableKeyword("_EMISSION");
		}
		return val;
	}

	private static Material s0(Material src, Color tint)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0020: 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_002b: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		Material val = new Material(src);
		if (val.HasProperty("_BaseColor"))
		{
			val.SetColor("_BaseColor", Color.Lerp(val.GetColor("_BaseColor"), tint, 0.95f));
		}
		else if (val.HasProperty("_Color"))
		{
			val.SetColor("_Color", Color.Lerp(val.GetColor("_Color"), tint, 0.95f));
		}
		val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
		return val;
	}
}