Decompiled source of CRuSUI v1.0.0

CRuSUI.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using ABLoader;
using BepInEx;
using Configgy;
using TMPro;
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: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("CRuSUI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Replaces the ULTRAKILL HUD with a recreation of the Cruelty Squad one.")]
[assembly: AssemblyTitle("CRuSUI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public class HealthPulsator : MonoBehaviour
{
	public float freq_timer = 0.03f;

	public Texture[] tex;

	private int cur_tex = 0;

	private float cur_timer = 0f;

	private void Update()
	{
		cur_timer += Time.deltaTime;
		if (cur_timer > freq_timer)
		{
			cur_timer = 0f;
			cur_tex++;
			if (cur_tex > tex.Length - 1)
			{
				cur_tex = 0;
			}
		}
		((Component)this).GetComponent<RawImage>().texture = tex[cur_tex];
	}
}
public class SquadUIReferences : MonoBehaviour
{
	public RawImage border;

	public RawImage health;

	public RawImage ammo_ind;

	public TextMeshProUGUI health_text;

	public Texture border1;

	public Texture border2;

	public Texture border3;

	public Texture border4;
}
namespace CRuSUI
{
	[BepInPlugin("com.ssar.crusui", "Cruelty Squad UI", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[Configgable("", "Is on Death mode", 0, null)]
		public static ConfigToggle death = new ConfigToggle(true);

		private GameObject crus_ui;

		private SquadUIReferences shared_ui_ref;

		private HealthPulsator shared_hp;

		private float rot_spd = 0f;

		private void Awake()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			ConfigBuilder val = new ConfigBuilder("com.ssar.crusui", "Cruelty Squad UI");
			val.BuildAll();
		}

		private void SetLife(bool on)
		{
			Texture[] array = null;
			if (on)
			{
				AssetBundle val = Loader.LoadBundle("crus-death-tex");
				array = val.LoadAllAssets<Texture>();
			}
			else
			{
				AssetBundle val2 = Loader.LoadBundle("crus-life-tex");
				array = val2.LoadAllAssets<Texture>();
			}
			shared_hp.tex = array;
		}

		private void Start()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			AssetBundle val = Loader.LoadBundle("crus");
			Texture[] array = null;
			if (((ConfigValueElement<bool>)(object)death).Value)
			{
				AssetBundle val2 = Loader.LoadBundle("crus-death-tex");
				array = val2.LoadAllAssets<Texture>();
			}
			else
			{
				AssetBundle val3 = Loader.LoadBundle("crus-life-tex");
				array = val3.LoadAllAssets<Texture>();
			}
			GameObject val4 = (GameObject)val.LoadAsset("CRUSUI.prefab");
			GameObject val5 = Object.Instantiate<GameObject>(val4);
			SquadUIReferences squadUIReferences = ((Component)val5.transform.Find("Canvas")).gameObject.AddComponent<SquadUIReferences>();
			squadUIReferences.border = ((Component)((Component)squadUIReferences).transform.Find("Border")).GetComponent<RawImage>();
			squadUIReferences.health = ((Component)((Component)squadUIReferences).transform.Find("h")).GetComponent<RawImage>();
			squadUIReferences.ammo_ind = ((Component)((Component)squadUIReferences).transform.Find("ammo")).GetComponent<RawImage>();
			squadUIReferences.health_text = ((Component)((Component)squadUIReferences).transform.Find("h_text")).GetComponent<TextMeshProUGUI>();
			squadUIReferences.border1 = (Texture)val.LoadAsset("border.png");
			squadUIReferences.border2 = (Texture)val.LoadAsset("border2.png");
			squadUIReferences.border3 = (Texture)val.LoadAsset("border3.png");
			squadUIReferences.border4 = (Texture)val.LoadAsset("border4.png");
			shared_ui_ref = squadUIReferences;
			(shared_hp = ((Component)squadUIReferences.health).gameObject.AddComponent<HealthPulsator>()).tex = array;
			crus_ui = val5;
			Object.DontDestroyOnLoad((Object)(object)val5);
			ConfigToggle obj = death;
			((ConfigValueElement<bool>)(object)obj).OnValueChanged = (Action<bool>)Delegate.Combine(((ConfigValueElement<bool>)(object)obj).OnValueChanged, new Action<bool>(SetLife));
		}

		private void Update()
		{
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)crus_ui))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)MonoSingleton<NewMovement>.Instance) && SceneHelper.CurrentScene != "Main Menu")
			{
				crus_ui.SetActive(true);
				MonoSingleton<NewMovement>.Instance.screenHud.GetComponent<HudController>().gunCanvas.SetActive(false);
				((Component)MonoSingleton<NewMovement>.Instance.screenHud.transform.Find("StyleCanvas")).gameObject.SetActive(false);
				int num = MonoSingleton<NewMovement>.Instance.hp;
				if (((ConfigValueElement<bool>)(object)death).Value)
				{
					num += 250;
				}
				((TMP_Text)shared_ui_ref.health_text).text = Convert.ToString(MonoSingleton<NewMovement>.Instance.hp);
				((Graphic)shared_ui_ref.health).color = Color.HSVToRGB((float)num * 0.01f * 0.25f, 1f, 1f);
				if (MonoSingleton<InputManager>.Instance.InputSource.Fire1.IsPressed || MonoSingleton<InputManager>.Instance.InputSource.Fire2.WasPerformedThisFrame || MonoSingleton<InputManager>.Instance.InputSource.Punch.WasPerformedThisFrame)
				{
					rot_spd -= 2f;
				}
				((Component)shared_ui_ref.ammo_ind).transform.Rotate(0f, 0f, rot_spd * 57.29578f);
				int @int = MonoSingleton<PrefsManager>.Instance.GetInt("difficulty", 0);
				if (@int == 3)
				{
					shared_ui_ref.border.texture = shared_ui_ref.border2;
				}
				else if (@int > 3)
				{
					shared_ui_ref.border.texture = shared_ui_ref.border4;
				}
				else if (@int >= 1)
				{
					shared_ui_ref.border.texture = shared_ui_ref.border1;
				}
				else
				{
					shared_ui_ref.border.texture = shared_ui_ref.border3;
				}
				shared_hp.freq_timer = 1f / (float)Mathf.Clamp(100 - MonoSingleton<NewMovement>.Instance.hp, 24, 100);
				rot_spd = Mathf.Lerp(rot_spd, 0f, 0.1f);
			}
			else
			{
				crus_ui.SetActive(false);
			}
		}
	}
	public class PluginData
	{
		public const string GUID = "com.ssar.crusui";

		public const string Name = "Cruelty Squad UI";

		public const string Version = "1.0.0";
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CRuSUI";

		public const string PLUGIN_NAME = "Replaces the ULTRAKILL HUD with a recreation of the Cruelty Squad one.";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ABLoader
{
	public static class Loader
	{
		public static AssetBundle LoadBundle(string name)
		{
			string location = Assembly.GetExecutingAssembly().Location;
			return AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(location), name));
		}
	}
}