Decompiled source of RiskUI v1.5.2

RiskUI.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using HarmonyLib;
using JetBrains.Annotations;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using SimpleJSON;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
using Zio;
using ZioConfigFile;
using ZioRiskOfOptions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace MaterialHud;

public class BepinScaleController : MonoBehaviour
{
	public string Category;

	public string Key;

	public string Description;

	private ZioConfigEntry<float> _configValue;

	private void Awake()
	{
		_configValue = ConfigHelper.Bind(Category, Key, 100f, Description, null, 300f);
		((ZioConfigEntryBase)_configValue).SettingChanged += SettingChanged;
	}

	private void OnEnable()
	{
		SettingChanged(null, null, arg3: false);
	}

	private void OnDestroy()
	{
		((ZioConfigEntryBase)_configValue).SettingChanged -= SettingChanged;
	}

	private void SettingChanged(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
	{
		//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_0034: Unknown result type (might be due to invalid IL or missing references)
		float num = _configValue.Value / 100f;
		Vector3 localScale = ((Component)this).transform.localScale;
		localScale.y = num;
		localScale.x = num;
		((Component)this).transform.localScale = localScale;
	}
}
public class BepinVerticalSpacing : MonoBehaviour
{
	private ZioConfigEntry<float> configEntry;

	public string desc;

	public string key;

	private GridLayoutGroup target;

	public float Value
	{
		get
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return target.spacing.y;
		}
		set
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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)
			Vector2 spacing = target.spacing;
			spacing.y = value;
			target.spacing = spacing;
		}
	}

	private void Awake()
	{
		target = ((Component)this).GetComponent<GridLayoutGroup>();
		configEntry = ConfigHelper.Bind("Repositioning", key, Value, desc, null, 200f);
		((ZioConfigEntryBase)configEntry).SettingChanged += SettingChanged;
	}

	private void OnEnable()
	{
		SettingChanged(null, null, arg3: false);
	}

	private void OnDestroy()
	{
		((ZioConfigEntryBase)configEntry).SettingChanged -= SettingChanged;
	}

	private void SettingChanged(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
	{
		Value = configEntry.Value;
	}
}
public class CloneFillValue : MonoBehaviour
{
	public Image from;

	private Image _to;

	private void Awake()
	{
		_to = ((Component)this).GetComponent<Image>();
	}

	private void Update()
	{
		_to.fillAmount = from.fillAmount;
	}
}
public class AddressablePrefabLoader : MonoBehaviour
{
	public string Address;

	public bool defaultActiveState = true;

	private void OnValidate()
	{
		Awake();
	}

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)Address).WaitForCompletion(), ((Component)this).transform).SetActive(defaultActiveState);
	}
}
public class CombatHealthBarLoader : MonoBehaviour
{
	public CombatHealthBarViewer viewer;

	private static GameObject HealthBar => Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/CombatHealthbar.prefab").WaitForCompletion();

	public void Start()
	{
		viewer.healthBarPrefab = HealthBar;
	}
}
public class FieldLoader : MonoBehaviour
{
	public string addressablePath;

	public string targetFieldName;

	public MonoBehaviour target;

	private static readonly MethodInfo LoadAsset = typeof(Addressables).GetMethod("LoadAssetAsync", new Type[1] { typeof(string) });

	public void Start()
	{
		FieldInfo field = ((object)target).GetType().GetField(targetFieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (!(field == null))
		{
			object obj = LoadAsset.MakeGenericMethod(field.FieldType).Invoke(null, new object[1] { addressablePath });
			object value = obj.GetType().GetMethod("WaitForCompletion", BindingFlags.Instance | BindingFlags.Public).Invoke(obj, null);
			field.SetValue(target, value);
		}
	}
}
public class NotificationAreaLoader : MonoBehaviour
{
	public NotificationUIController controller;

	private static GameObject genericNotificationPrefab => Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/NotificationPanel2.prefab").WaitForCompletion();

	private static GameObject genericTransformationNotificationPrefab => Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/GenericTransformationNotificationPanel.prefab").WaitForCompletion();

	private static GameObject contagiousVoidTransformationNotificationPrefab => Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/UI/VoidTransformationNotificationPanel.prefab").WaitForCompletion();

	private static GameObject cloverVoidTransformationNotificationPrefab => Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/CloverVoid/CloverVoidTransformationNotificationPanel.prefab").WaitForCompletion();

	private static GameObject regeneratingScrapRegenTransformationNotificationPrefab => Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/RegeneratingScrap/RegeneratingScrapRegenTransformationNotificationPanel.prefab").WaitForCompletion();

	private static GameObject lowerPricedChestsRegenTransformationNotificationPanel => Addressables.LoadAssetAsync<GameObject>((object)"Assets/RoR2/DLC2/Items/LowerPricedChests/LowerPricedChestsRegenTransformationNotificationPanel.prefab").WaitForCompletion();

	private static GameObject droneRepairNotificationPanel => Addressables.LoadAssetAsync<GameObject>((object)"Assets/RoR2/DLC3/UI/NotificationPanels/DroneRepairNotificationPanel.prefab").WaitForCompletion();

	public void Start()
	{
		NotificationUIController val = controller;
		if (val.genericNotificationPrefab == null)
		{
			val.genericNotificationPrefab = genericNotificationPrefab;
		}
		val = controller;
		if (val.genericTransformationNotificationPrefab == null)
		{
			val.genericTransformationNotificationPrefab = genericTransformationNotificationPrefab;
		}
		val = controller;
		if (val.contagiousVoidTransformationNotificationPrefab == null)
		{
			val.contagiousVoidTransformationNotificationPrefab = contagiousVoidTransformationNotificationPrefab;
		}
		val = controller;
		if (val.cloverVoidTransformationNotificationPrefab == null)
		{
			val.cloverVoidTransformationNotificationPrefab = cloverVoidTransformationNotificationPrefab;
		}
		val = controller;
		if (val.regeneratingScrapRegenTransformationNotificationPrefab == null)
		{
			val.regeneratingScrapRegenTransformationNotificationPrefab = regeneratingScrapRegenTransformationNotificationPrefab;
		}
		val = controller;
		if (val.LowerPricedChestsRegenTransformationNotificationPrefab == null)
		{
			val.LowerPricedChestsRegenTransformationNotificationPrefab = lowerPricedChestsRegenTransformationNotificationPanel;
		}
		val = controller;
		if (val.droneRepairNotificationPrefab == null)
		{
			val.droneRepairNotificationPrefab = droneRepairNotificationPanel;
		}
	}
}
public class HideIfFirst : MonoBehaviour
{
	public GameObject target;

	public int position;

	private void Awake()
	{
		target.SetActive(((Component)this).transform.GetSiblingIndex() != position);
	}
}
public class BepinConfigParentManager : MonoBehaviour, IConfigHandler
{
	public Transform[] choices;

	public string category;

	public string key;

	public string description;

	private ZioConfigEntry<int> _configEntry;

	public void Awake()
	{
		Startup();
		((ZioConfigEntryBase)_configEntry).SettingChanged += ConfigUpdated;
	}

	private void OnEnable()
	{
		ConfigUpdated(null, null, arg3: false);
	}

	public void OnDestroy()
	{
		((ZioConfigEntryBase)_configEntry).SettingChanged -= ConfigUpdated;
	}

	private void ConfigUpdated(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
	{
		int num = Math.Min(choices.Length - 1, _configEntry.Value);
		((Component)this).transform.SetParent(choices[num], false);
	}

	public void Startup()
	{
		_configEntry = ConfigHelper.Bind(category, key, 0, description, null, choices.Length - 1);
	}
}
public class DifficultyTextController : MonoBehaviour, IConfigHandler
{
	public TextMeshProUGUI text;

	public string[] segmentTokens;

	public Image ringImage;

	public Image ringBehind;

	public RedToColorRemapperIndividual textRecolorer;

	public RedToColorRemapperIndividual ringRecolorer;

	public RedToColorRemapperIndividual ringBehindRecolorer;

	public RedToColorRemapperIndividual timerTextRecolorer;

	public RedToColorRemapperIndividual timerCentiTextRecolorer;

	public TextMeshProUGUI monsterLevel;

	public float levelsPerSegment = 3f;

	private int _previousSegment = -1;

	private ZioConfigEntry<bool> _textRecolor;

	private ZioConfigEntry<bool> _ringLowerRecolor;

	private ZioConfigEntry<bool> _ringRecolor;

	private ZioConfigEntry<bool> _timerRecolor;

	private ZioConfigEntry<bool> _timerCentiRecolor;

	private ZioConfigEntry<bool> _monsterLevelEnabled;

	public static readonly Color[] DifficultyColors = (Color[])(object)new Color[9]
	{
		new Color(0.28627452f, 0.9490196f, 0.8509804f),
		new Color(0.2627451f, 83f / 85f, 38f / 85f),
		new Color(1f, 0.8862745f, 0.4f),
		new Color(1f, 0.6627451f, 0.2627451f),
		new Color(1f, 0.4862745f, 12f / 85f),
		new Color(1f, 0.4f, 0.2627451f),
		new Color(1f, 0.2627451f, 12f / 85f),
		new Color(1f, 0.101960786f, 0.101960786f),
		new Color(0.827451f, 0f, 0f)
	};

	private void Awake()
	{
		Startup();
		((ZioConfigEntryBase)_textRecolor).SettingChanged += TextColorerChanged;
		((ZioConfigEntryBase)_ringLowerRecolor).SettingChanged += RingLowerColorerChanged;
		((ZioConfigEntryBase)_ringRecolor).SettingChanged += RingColorerChanged;
		((ZioConfigEntryBase)_timerRecolor).SettingChanged += TimerColorerChanged;
		((ZioConfigEntryBase)_timerCentiRecolor).SettingChanged += CentiColorerChanged;
		((ZioConfigEntryBase)_monsterLevelEnabled).SettingChanged += MonsterLevelChanged;
		TextColorerChanged(null, null, arg3: false);
		RingLowerColorerChanged(null, null, arg3: false);
		RingColorerChanged(null, null, arg3: false);
		TimerColorerChanged(null, null, arg3: false);
		CentiColorerChanged(null, null, arg3: false);
		MonsterLevelChanged(null, null, arg3: false);
	}

	private void MonsterLevelChanged(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
	{
		((Component)monsterLevel).gameObject.SetActive(_monsterLevelEnabled.Value);
	}

	private void OnDestroy()
	{
		((ZioConfigEntryBase)_textRecolor).SettingChanged -= TextColorerChanged;
		((ZioConfigEntryBase)_ringLowerRecolor).SettingChanged -= RingLowerColorerChanged;
		((ZioConfigEntryBase)_ringRecolor).SettingChanged -= RingColorerChanged;
		((ZioConfigEntryBase)_timerRecolor).SettingChanged -= TimerColorerChanged;
		((ZioConfigEntryBase)_timerCentiRecolor).SettingChanged -= CentiColorerChanged;
	}

	private void RingColorerChanged(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
	{
		((Behaviour)ringRecolorer).enabled = !_ringRecolor.Value;
		UpdateColors();
	}

	private void RingLowerColorerChanged(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
	{
		((Behaviour)ringBehindRecolorer).enabled = !_ringLowerRecolor.Value;
		UpdateColors();
	}

	private void TextColorerChanged(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
	{
		((Behaviour)textRecolorer).enabled = !_textRecolor.Value;
		UpdateColors();
	}

	private void CentiColorerChanged(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
	{
		((Behaviour)timerCentiTextRecolorer).enabled = !_timerCentiRecolor.Value;
		UpdateColors();
	}

	private void TimerColorerChanged(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
	{
		((Behaviour)timerTextRecolorer).enabled = !_timerRecolor.Value;
		UpdateColors();
	}

	public void Update()
	{
		if (Object.op_Implicit((Object)(object)Run.instance))
		{
			float num = Run.instance.ambientLevel - 1f;
			float num2 = num / levelsPerSegment;
			int num3 = Mathf.FloorToInt(num2);
			float fillAmount = num2 - (float)num3;
			if (num3 >= segmentTokens.Length)
			{
				fillAmount = 1f;
			}
			if (_monsterLevelEnabled.Value)
			{
				((TMP_Text)monsterLevel).text = Language.GetStringFormatted("AMBIENT_LEVEL_DISPLAY_FORMAT", new object[1] { num + 1f });
			}
			int num4 = Math.Min(segmentTokens.Length - 1, num3);
			if (num4 != _previousSegment)
			{
				((TMP_Text)text).text = Language.GetString(segmentTokens[num4]).ToUpper();
				_previousSegment = num4;
				UpdateColors();
			}
			ringImage.fillAmount = fillAmount;
		}
	}

	private void UpdateColors()
	{
		//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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)Run.instance))
		{
			int num = Math.Max(0, _previousSegment);
			Color color = DifficultyColors[num];
			if (_ringRecolor.Value)
			{
				((Graphic)(Image)ringRecolorer.target).color = color;
			}
			if (_ringLowerRecolor.Value)
			{
				((Graphic)(Image)ringBehindRecolorer.target).color = color;
			}
			if (_textRecolor.Value)
			{
				((Graphic)(TextMeshProUGUI)textRecolorer.target).color = color;
			}
			if (_timerRecolor.Value)
			{
				((Graphic)(TextMeshProUGUI)timerTextRecolorer.target).color = color;
			}
			if (_timerCentiRecolor.Value)
			{
				((Graphic)(TextMeshProUGUI)timerCentiTextRecolorer.target).color = color;
			}
		}
	}

	public void Startup()
	{
		_textRecolor = ConfigHelper.Bind("General", "Difficulty Text Colored Per Difficulty", defaultValue: false, "Should the difficulty text be recolored based on current difficulty.");
		_ringLowerRecolor = ConfigHelper.Bind("General", "Difficulty Lower Ring Colored Per Difficulty", defaultValue: false, "Should the difficulty lower ring be recolored based on current difficulty.");
		_ringRecolor = ConfigHelper.Bind("General", "Difficulty Upper Ring Colored Per Difficulty", defaultValue: false, "Should the difficulty upper ring be recolored based on current difficulty.");
		_timerRecolor = ConfigHelper.Bind("General", "Timer Text Colored Per Difficulty", defaultValue: false, "Should the timer text be recolored based on current difficulty.");
		_timerCentiRecolor = ConfigHelper.Bind("General", "Centisecond Timer Text Colored Per Difficulty", defaultValue: false, "Should the timer centisecond text be recolored based on current difficulty.");
		_monsterLevelEnabled = ConfigHelper.Bind("General", "Monster Level Text Enable", defaultValue: false, "Should the monster level text be displayed.");
	}
}
public class HealthbarRecolor : MonoBehaviour, IConfigHandler
{
	public class HealthBarConfig
	{
		private static readonly Type StyleType = typeof(HealthBarStyle);

		public HealthBarStyle style;

		private readonly FieldInfo _fieldInfo;

		private ZioConfigEntry<Color> _configValue;

		private bool rainbow;

		public Color Color
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				return ((BarStyle)_fieldInfo.GetValue(style)).baseColor;
			}
			set
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: 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_002b: Unknown result type (might be due to invalid IL or missing references)
				BarStyle val = (BarStyle)_fieldInfo.GetValue(style);
				val.baseColor = value;
				_fieldInfo.SetValue(style, val);
			}
		}

		public HealthBarConfig(string category, string key, string desc, string field, HealthBarStyle styleIn, bool b)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			style = styleIn;
			_fieldInfo = StyleType.GetField(field, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			_configValue = ConfigHelper.Bind<Color>(category, key, Color, desc);
			if (b)
			{
				((ZioConfigEntryBase)_configValue).SettingChanged += ConfigChanged;
			}
		}

		public void Destroy()
		{
			((ZioConfigEntryBase)_configValue).SettingChanged -= ConfigChanged;
		}

		public void ConfigChanged(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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)
			rainbow = _configValue.Value == Color.clear;
			Color = _configValue.Value;
		}

		public void Update(Color color)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (rainbow)
			{
				Color = color;
			}
		}
	}

	public string whichBar = "Player HealthBar";

	public HealthBar healthBar;

	private readonly Dictionary<string, HealthBarConfig> entries = new Dictionary<string, HealthBarConfig>();

	public void Awake()
	{
		Startup(b: true);
		OnEnable();
	}

	private void OnEnable()
	{
		foreach (KeyValuePair<string, HealthBarConfig> entry in entries)
		{
			entry.Value.ConfigChanged(null, null, arg3: false);
		}
	}

	private void SetupConfig(string key, string desc, HealthBarStyle style, string field, bool b)
	{
		string key2 = "Recoloring " + whichBar + key;
		HealthBarConfig value = new HealthBarConfig("Recoloring " + whichBar, key, desc, field, style, b);
		entries[key2] = value;
	}

	private void OnDestroy()
	{
		foreach (KeyValuePair<string, HealthBarConfig> entry in entries)
		{
			entry.Value.Destroy();
		}
	}

	private void Update()
	{
		//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_0043: Unknown result type (might be due to invalid IL or missing references)
		Color color = Color.HSVToRGB(Mathf.Sin(Time.time) * 0.5f + 0.5f, 1f, 1f);
		foreach (KeyValuePair<string, HealthBarConfig> entry in entries)
		{
			entry.Value.Update(color);
		}
	}

	public void Startup(bool b)
	{
		HealthBarStyle style = healthBar.style;
		SetupConfig("Trailing Under", "When hurt the bit that is slow to catch up.", style, "trailingUnderHealthBarStyle", b);
		SetupConfig("Instant Health", "From medkits, etc.", style, "instantHealthBarStyle", b);
		SetupConfig("Trailing Over", "The general color of the healthbar.", style, "trailingOverHealthBarStyle", b);
		SetupConfig("Shield", "Shield", style, "shieldBarStyle", b);
		SetupConfig("Curse", "Curse refers to having Shaped glass / anything that temporarily lowers max HP & normally leaves you w/ the white outlined section.", style, "curseBarStyle", b);
		SetupConfig("Barrier", "Barrier", style, "barrierBarStyle", b);
		SetupConfig("Flash", "?", style, "flashBarStyle", b);
		SetupConfig("Cull", "Cull refers to things like guillotine / freeze, and is only seen when an allied minion (turret / zoea / drone, etc..) is hit by a Glacial Elite's death effect radius. Cull can't be applied to players however.", style, "cullBarStyle", b);
		SetupConfig("Low Health Over", "Color for delicate watches and things like that.", style, "lowHealthOverStyle", b);
		SetupConfig("Low Health Under", "?", style, "lowHealthUnderStyle", b);
		SetupConfig("Magnetic", "A unused??? healthbar style.", style, "magneticStyle", b);
		SetupConfig("OSP", "One shot protection color.", style, "ospStyle", b);
	}

	public void Startup()
	{
		Startup(b: false);
	}
}
public class HideFromBepinConfig : MonoBehaviour, IConfigHandler
{
	public GameObject target;

	public string configName;

	public string configDesc;

	public string configCategory;

	public bool defaultValue;

	private ZioConfigEntry<bool> _configEntry;

	public void Awake()
	{
		Startup();
		((ZioConfigEntryBase)_configEntry).SettingChanged += SettingChanged;
		SettingChanged();
	}

	public void OnDestroy()
	{
		((ZioConfigEntryBase)_configEntry).SettingChanged -= SettingChanged;
	}

	private void SettingChanged(ZioConfigEntryBase config, object oldValue, bool ignoreSave)
	{
		SettingChanged();
	}

	private void SettingChanged()
	{
		target.SetActive(_configEntry.Value);
	}

	public void Startup()
	{
		_configEntry = ConfigHelper.Bind(configCategory, configName, defaultValue, configDesc);
	}
}
public interface IConfigHandler
{
	void Startup();
}
public class RedToColorRemapperIndividual : MonoBehaviour, IConfigHandler
{
	public string configKey;

	public string configDesc;

	private Color defaultColor;

	private ZioConfigEntry<Color> _configEntry;

	public MonoBehaviour target;

	private bool _rainbow;

	public void Startup()
	{
		//IL_0002: 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_0019: Unknown result type (might be due to invalid IL or missing references)
		defaultColor = GetColor();
		_configEntry = ConfigHelper.Bind<Color>("Recoloring", configKey, defaultColor, configDesc);
	}

	public void Awake()
	{
		Startup();
		((ZioConfigEntryBase)_configEntry).SettingChanged += UpdateColor;
	}

	private void OnEnable()
	{
		UpdateColor();
	}

	private void OnDestroy()
	{
		((ZioConfigEntryBase)_configEntry).SettingChanged -= UpdateColor;
	}

	private void UpdateColor(ZioConfigEntryBase config, object oldValue, bool ignoreSave)
	{
		UpdateColor();
	}

	private void SetColor(Color color)
	{
		//IL_0027: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		MonoBehaviour val = target;
		TextMeshProUGUI val2 = (TextMeshProUGUI)(object)((val is TextMeshProUGUI) ? val : null);
		if (val2 == null)
		{
			Image val3 = (Image)(object)((val is Image) ? val : null);
			if (val3 == null)
			{
				HealthBar val4 = (HealthBar)(object)((val is HealthBar) ? val : null);
				if (val4 != null)
				{
					val4.style.trailingOverHealthBarStyle.baseColor = color;
				}
			}
			else
			{
				((Graphic)val3).color = color;
			}
		}
		else
		{
			((Graphic)val2).color = color;
		}
	}

	private Color GetColor()
	{
		//IL_0028: 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_0040: 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)
		MonoBehaviour val = target;
		TextMeshProUGUI val2 = (TextMeshProUGUI)(object)((val is TextMeshProUGUI) ? val : null);
		if (val2 == null)
		{
			Image val3 = (Image)(object)((val is Image) ? val : null);
			if (val3 == null)
			{
				return ((HealthBar)(((val is HealthBar) ? val : null)?)).style.trailingOverHealthBarStyle.baseColor ?? Color.black;
			}
			return ((Graphic)val3).color;
		}
		return ((Graphic)val2).color;
	}

	private void UpdateColor()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		if (_configEntry.Value == Color.clear)
		{
			_rainbow = true;
		}
		else
		{
			SetColor(_configEntry.Value);
		}
	}

	private void Update()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		if (_rainbow)
		{
			SetColor(Color.HSVToRGB(Mathf.Sin(Time.time) * 0.5f + 0.5f, 1f, 1f));
		}
	}
}
public class TextSizeBepin : MonoBehaviour, IConfigHandler
{
	public string Key;

	public string Description;

	public TextMeshProUGUI Target;

	private ZioConfigEntry<float> _configEntry;

	public void Awake()
	{
		Startup();
		((ZioConfigEntryBase)_configEntry).SettingChanged += SettingChanged;
	}

	private void OnEnable()
	{
		SettingChanged(null, null, arg3: false);
	}

	private void OnDestroy()
	{
		((ZioConfigEntryBase)_configEntry).SettingChanged -= SettingChanged;
	}

	private void SettingChanged(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
	{
		((TMP_Text)Target).fontSize = _configEntry.Value;
	}

	public void Startup()
	{
		_configEntry = ConfigHelper.Bind("Rescaling", Key, ((TMP_Text)Target).fontSize, Description, null, 100f);
	}
}
public class MaterialEquipmentIcon : MonoBehaviour
{
	public EquipmentIcon icon;

	public Image onCooldown;

	public Image mask;

	public TextMeshProUGUI stockText;

	public GameObject keyText;

	public void Update()
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		if (!icon.hasEquipment)
		{
			((Component)((TMP_Text)stockText).transform.parent).gameObject.SetActive(false);
			mask.fillAmount = 0f;
			((Behaviour)onCooldown).enabled = false;
			return;
		}
		EquipmentState val = (icon.displayAlternateEquipment ? icon.targetInventory.alternateEquipmentState : icon.targetInventory.currentEquipmentState);
		FixedTimeStamp now = FixedTimeStamp.now;
		FixedTimeStamp chargeFinishTime = val.chargeFinishTime;
		((Behaviour)onCooldown).enabled = ((DisplayData)(ref icon.currentDisplayData)).showCooldown;
		float num = Mathf.Max(0f, chargeFinishTime - now);
		if (float.IsPositiveInfinity(num))
		{
			num = 0f;
		}
		float cooldown = val.equipmentDef.cooldown;
		cooldown *= icon.targetInventory.CalculateEquipmentCooldownScale();
		mask.fillAmount = num / cooldown;
		((Component)((TMP_Text)stockText).transform.parent).gameObject.SetActive(icon.currentDisplayData.maxStock > 1);
	}
}
[RequireComponent(typeof(RectTransform))]
public class MaterialItemIcon : MonoBehaviour
{
	public InspectPanelLocator inspectPanelLocator;

	public UserProfile userProfile;

	public RawImage glowImage;

	public RawImage image;

	public TextMeshProUGUI stackText;

	public TooltipProvider tooltipProvider;

	public ItemIndex itemIndex;

	public int itemCount;

	public Action OnItemClicked;

	public RectTransform rectTransform { get; set; }

	public InspectPanelController inspectPanel
	{
		get
		{
			if (Object.op_Implicit((Object)(object)inspectPanelLocator))
			{
				return inspectPanelLocator.InspectPanel;
			}
			return null;
		}
	}

	public void Awake()
	{
		CacheRectTransform();
		inspectPanelLocator = ((Component)this).GetComponent<InspectPanelLocator>();
		userProfile = ((Component)this).GetComponentInParent<HUD>().localUserViewer.userProfile;
	}

	public void CacheRectTransform()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		if (rectTransform == null)
		{
			rectTransform = (RectTransform)((Component)this).transform;
		}
	}

	public void SetItemIndex(ItemIndex newItemIndex, int newItemCount)
	{
		//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_0014: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: 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_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		if (itemIndex == newItemIndex && itemCount == newItemCount)
		{
			return;
		}
		itemIndex = newItemIndex;
		itemCount = newItemCount;
		string titleToken = "";
		string bodyToken = "";
		Color val = Color.white;
		Color bodyColor = default(Color);
		((Color)(ref bodyColor))..ctor(0.6f, 0.6f, 0.6f, 1f);
		ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
		if ((Object)(object)itemDef != (Object)null)
		{
			image.texture = itemDef.pickupIconTexture;
			if (itemCount > 1)
			{
				((TMP_Text)stackText).text = "x" + itemCount;
				((Behaviour)stackText).enabled = true;
			}
			else
			{
				((TMP_Text)stackText).text = "";
				((Behaviour)stackText).enabled = false;
			}
			titleToken = itemDef.nameToken;
			bodyToken = itemDef.pickupToken;
			val = Color32.op_Implicit(ColorCatalog.GetColor(Object.op_Implicit((Object)(object)itemDef._itemTierDef) ? itemDef._itemTierDef.darkColorIndex : itemDef.darkColorIndex));
		}
		if (Object.op_Implicit((Object)(object)glowImage))
		{
			((Graphic)glowImage).color = new Color(val.r, val.g, val.b, 0.75f);
		}
		if (Object.op_Implicit((Object)(object)tooltipProvider))
		{
			tooltipProvider.titleToken = titleToken;
			tooltipProvider.bodyToken = bodyToken;
			tooltipProvider.titleColor = val;
			tooltipProvider.bodyColor = bodyColor;
		}
	}

	public void ItemClicked()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		if (!userProfile.useInspectFeature)
		{
			return;
		}
		ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
		if ((Object)(object)itemDef != (Object)null)
		{
			if (Object.op_Implicit((Object)(object)inspectPanel))
			{
				inspectPanel.Show(InspectInfo.op_Implicit(itemDef), false, (UserProfile)null);
			}
			OnItemClicked?.Invoke();
		}
	}
}
public class MaterialSkillIcon : MonoBehaviour
{
	public Image onCooldown;

	public SkillIcon icon;

	public Image mask;

	public TextMeshProUGUI stockText;

	private void Update()
	{
		if (Object.op_Implicit((Object)(object)icon.targetSkill))
		{
			float cooldownRemaining = icon.targetSkill.cooldownRemaining;
			float num = icon.targetSkill.CalculateFinalRechargeInterval();
			bool flag = num >= float.Epsilon;
			mask.fillAmount = (flag ? (cooldownRemaining / num) : 0f);
			((Behaviour)onCooldown).enabled = flag && icon.targetSkill.stock <= 0 && mask.fillAmount > float.Epsilon;
			if (icon.targetSkill.maxStock > 1)
			{
				((Component)((TMP_Text)stockText).transform.parent).gameObject.SetActive(true);
			}
			else
			{
				((Component)((TMP_Text)stockText).transform.parent).gameObject.SetActive(false);
			}
		}
	}
}
public static class ConfigHelper
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static Action<ZioConfigEntryBase, object, bool> <>9__8_0;

		public static UnityAction <>9__10_0;

		public static UnityAction <>9__10_1;

		internal void <get_SelectedProfile>b__8_0(ZioConfigEntryBase _, object profile, bool _)
		{
			SelectedProfile = (int)profile;
		}

		internal void <MakeSelectedProfileOptions>b__10_0()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			configFiles.Add(new ZioConfigFile(whichFile.FileSystem, UPath.op_Implicit($"{UPathExtensions.GetDirectory(whichFile.FilePath)}/RiskUI/{default(Guid)}"), true, whichFile.OwnerMetadata));
			option.max = configFiles.Count - 1;
		}

		internal void <MakeSelectedProfileOptions>b__10_1()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			whichFile.FileSystem.DeleteFile(configFiles[SelectedProfile].FilePath);
			configFiles.RemoveAt(SelectedProfile);
			option.max = configFiles.Count - 1;
		}
	}

	public static Dictionary<string, ZioConfigEntryBase> Entries = new Dictionary<string, ZioConfigEntryBase>();

	private static ZioConfigEntry<int> _selectedProfile;

	private static IntSliderConfig option;

	public static ZioConfigFile whichFile => RiskUIPlugin.ConfigFile;

	public static List<ZioConfigFile> configFiles => RiskUIPlugin.ConfigFiles;

	public static int SelectedProfile
	{
		get
		{
			if (_selectedProfile != null)
			{
				return _selectedProfile.Value;
			}
			_selectedProfile = whichFile.Bind<int>("Profiles", "Selected Profile", 0, "Currently selected profile.");
			((ZioConfigEntryBase)_selectedProfile).SettingChanged += delegate(ZioConfigEntryBase _, object profile, bool _)
			{
				SelectedProfile = (int)profile;
			};
			if (RiskUIPlugin.RiskOfOptionsEnabled)
			{
				MakeSelectedProfileOptions();
			}
			return _selectedProfile.Value;
		}
		set
		{
			_selectedProfile.Value = value;
			foreach (KeyValuePair<ConfigDefinition, ZioConfigEntryBase> item in whichFile)
			{
				if (!(item.Key == ((ZioConfigEntryBase)_selectedProfile).Definition))
				{
					ApplyConfigProfile(item.Value);
				}
			}
		}
	}

	private static void MakeSelectedProfileOptions()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		option = new IntSliderConfig
		{
			max = configFiles.Count - 1
		};
		ModSettingsManager.AddOption((BaseOption)new ZioIntSliderOption(_selectedProfile, option));
		object obj = <>c.<>9__10_0;
		if (obj == null)
		{
			UnityAction val = delegate
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Expected O, but got Unknown
				configFiles.Add(new ZioConfigFile(whichFile.FileSystem, UPath.op_Implicit($"{UPathExtensions.GetDirectory(whichFile.FilePath)}/RiskUI/{default(Guid)}"), true, whichFile.OwnerMetadata));
				option.max = configFiles.Count - 1;
			};
			<>c.<>9__10_0 = val;
			obj = (object)val;
		}
		ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Add Profile", "Profiles", (UnityAction)obj));
		object obj2 = <>c.<>9__10_1;
		if (obj2 == null)
		{
			UnityAction val2 = delegate
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				whichFile.FileSystem.DeleteFile(configFiles[SelectedProfile].FilePath);
				configFiles.RemoveAt(SelectedProfile);
				option.max = configFiles.Count - 1;
			};
			<>c.<>9__10_1 = val2;
			obj2 = (object)val2;
		}
		ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Delete Profile", "Profiles", (UnityAction)obj2));
	}

	public static ZioConfigEntry<T> Bind<T>(string category, string key, T defaultValue, string desc, [CanBeNull] Action<ZioConfigEntry<T>> firstSetupCallback = null, object riskOfOptionsExtra = null)
	{
		string key2 = category + key;
		if (!Entries.ContainsKey(key2))
		{
			ZioConfigEntry<T> val = RiskUIPlugin.ConfigFile.Bind<T>(category, key, defaultValue, desc);
			((ZioConfigEntryBase)val).SettingChanged += UpdateSelectedProfile;
			foreach (ZioConfigFile configFile in RiskUIPlugin.ConfigFiles)
			{
				configFile.Bind<T>(category, key, defaultValue, desc);
			}
			ApplyConfigProfile((ZioConfigEntryBase)(object)val);
			if (RiskUIPlugin.RiskOfOptionsEnabled)
			{
				FillRiskOfOptions<T>(val, riskOfOptionsExtra);
			}
			Entries.Add(key2, (ZioConfigEntryBase)(object)val);
			firstSetupCallback?.Invoke(val);
		}
		return (ZioConfigEntry<T>)(object)Entries[key2];
	}

	private static void UpdateSelectedProfile(ZioConfigEntryBase arg1, object arg2, bool arg3)
	{
		configFiles[SelectedProfile][arg1.Definition].BoxedValue = arg1.BoxedValue;
	}

	private static void ApplyConfigProfile(ZioConfigEntryBase configEntry)
	{
		if (RiskUIPlugin.NeverBeforeInitialized)
		{
			UpdateSelectedProfile(configEntry, null, arg3: false);
		}
		else
		{
			configEntry.BoxedValue = configFiles[SelectedProfile][configEntry.Definition].BoxedValue;
		}
	}

	private static void FillRiskOfOptions<T>(ZioConfigEntry<T> configEntry, object riskOfOptionsExtra = null)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Expected O, but got Unknown
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Expected O, but got Unknown
		if (!(configEntry is ZioConfigEntry<string> val))
		{
			if (!(configEntry is ZioConfigEntry<bool> val2))
			{
				if (!(configEntry is ZioConfigEntry<int> val3))
				{
					if (!(configEntry is ZioConfigEntry<float> val4))
					{
						if (configEntry is ZioConfigEntry<Color> val5)
						{
							ModSettingsManager.AddOption((BaseOption)new ZioColorOption(val5));
						}
					}
					else
					{
						ModSettingsManager.AddOption((BaseOption)new ZioSliderOption(val4, new SliderConfig
						{
							max = (float)riskOfOptionsExtra
						}));
					}
				}
				else
				{
					ModSettingsManager.AddOption((BaseOption)new ZioIntSliderOption(val3, new IntSliderConfig
					{
						max = (int)riskOfOptionsExtra
					}));
				}
			}
			else
			{
				ModSettingsManager.AddOption((BaseOption)new ZioCheckBoxOption(val2));
			}
		}
		else
		{
			ModSettingsManager.AddOption((BaseOption)new ZioStringInputFieldOption(val));
		}
	}
}
internal static class Log
{
	private static ManualLogSource _logSource;

	internal static void Init(ManualLogSource logSource)
	{
		_logSource = logSource;
	}

	internal static void Debug(object data)
	{
		_logSource.LogDebug(data);
	}

	internal static void Error(object data)
	{
		_logSource.LogError(data);
	}

	internal static void Fatal(object data)
	{
		_logSource.LogFatal(data);
	}

	internal static void Info(object data)
	{
		_logSource.LogInfo(data);
	}

	internal static void Message(object data)
	{
		_logSource.LogMessage(data);
	}

	internal static void Warning(object data)
	{
		_logSource.LogWarning(data);
	}
}
[HarmonyPatch]
public static class NewHarmonyPatches
{
	[HarmonyILManipulator]
	[HarmonyPatch(typeof(CameraRigController), "UpdateHUD")]
	public static void ReplaceHUD(ILContext il)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		int num = default(int);
		MethodReference val2 = default(MethodReference);
		if (val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[3]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val2),
			(Instruction x) => ILPatternMatchingExt.MatchStsfld(x, typeof(CameraRigController), "HudPrefab")
		}))
		{
			val.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(RiskUIPlugin), "CreateHud", (Type[])null, (Type[])null));
			val.RemoveRange(2);
			if (val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(CameraRigController), "HudPrefab")
			}))
			{
				val.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(RiskUIPlugin), "CreateHud", (Type[])null, (Type[])null));
				val.Remove();
			}
			else
			{
				Log.Error("CameraRigController.UpdateHUD # 2");
			}
		}
		else
		{
			Log.Error("CameraRigController.UpdateHUD # 1");
		}
	}

	[HarmonyILManipulator]
	[HarmonyPatch(typeof(HealthBar), "UpdateBarInfos")]
	public static void FixInfusionColor(ILContext il)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(HealthBar), "voidPanelColor")
		}))
		{
			val.Remove();
			val.EmitDelegate<Func<Color>>((Func<Color>)delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
				Color value3 = RiskUIPlugin.VoidColor.Value;
				return (value3 == Color.clear) ? Color.HSVToRGB(Mathf.Sin(Time.time) * 0.5f + 0.5f, 1f, 1f) : value3;
			});
		}
		else
		{
			Log.Error("HealthBar.UpdateBarInfos # 1");
		}
		if (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(HealthBar), "infusionPanelColor")
		}))
		{
			val.Remove();
			val.EmitDelegate<Func<Color>>((Func<Color>)delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
				Color value2 = RiskUIPlugin.InfusionColor.Value;
				return (value2 == Color.clear) ? Color.HSVToRGB(Mathf.Sin(Time.time) * 0.5f + 0.5f, 1f, 1f) : value2;
			});
		}
		else
		{
			Log.Error("HealthBar.UpdateBarInfos # 2");
		}
		if (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(HealthBar), "voidShieldsColor")
		}))
		{
			val.Remove();
			val.EmitDelegate<Func<Color>>((Func<Color>)delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
				Color value = RiskUIPlugin.VoidShieldColor.Value;
				return (value == Color.clear) ? Color.HSVToRGB(Mathf.Sin(Time.time) * 0.5f + 0.5f, 1f, 1f) : value;
			});
		}
		else
		{
			Log.Error("HealthBar.UpdateBarInfos # 3");
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(Run), "InstantiateUi")]
	public static bool OverwriteTracker(Run __instance, Transform uiRoot, ref GameObject __result)
	{
		if (!Object.op_Implicit((Object)(object)uiRoot))
		{
			return true;
		}
		string nameToken = __instance.nameToken;
		if (nameToken == "ECLIPSE_GAMEMODE_NAME" || nameToken == "GAMEMODE_CLASSIC_RUN_NAME")
		{
			__result = Object.Instantiate<GameObject>(RiskUIPlugin.CreateClassicRunHud(), uiRoot);
			__instance.uiInstances.Add(__result);
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(DifficultyDef), "GetIconSprite")]
	public static bool SwapIcon(DifficultyDef __instance, ref Sprite __result)
	{
		if (__instance.nameToken == null || !RiskUIPlugin.DifficultyIconMap.ContainsKey(__instance.nameToken))
		{
			return true;
		}
		__result = RiskUIPlugin.DifficultyIconMap[__instance.nameToken];
		return false;
	}

	[HarmonyILManipulator]
	[HarmonyPatch(typeof(AllyCardManager), "Awake")]
	public static void ReplaceAllyCards(ILContext il)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "Prefabs/UI/AllyCard")
		}))
		{
			val.RemoveRange(2);
			val.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(RiskUIPlugin), "CreateAllyCard", (Type[])null, (Type[])null));
		}
		else
		{
			Log.Error("AllyCardManager.Awake");
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(EnemyInfoPanel), "Init")]
	public static void ChangeMonsterInventory()
	{
		EnemyInfoPanel.panelPrefab = RiskUIPlugin.EnemyInfoPanel;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(HUD), "DeactivateScoreboard")]
	public static void Unselect(HUD __instance)
	{
		ScoreboardController val = default(ScoreboardController);
		if (Object.op_Implicit((Object)(object)__instance.scoreboardPanel) && __instance.scoreboardPanel.TryGetComponent<ScoreboardController>(ref val) && Object.op_Implicit((Object)(object)val.eventSystem))
		{
			((EventSystem)val.eventSystem).SetSelectedGameObject((GameObject)null);
			val.eventSystem.currentSelectedButton = null;
		}
	}
}
internal static class Utils
{
	public static T TryAddComponent<T>(this GameObject go) where T : Component
	{
		T result = default(T);
		if (go.TryGetComponent<T>(ref result))
		{
			return result;
		}
		return go.AddComponent<T>();
	}

	public static void RemoveComponent<T>(this GameObject go) where T : Component
	{
		T val = default(T);
		if (go.TryGetComponent<T>(ref val))
		{
			Object.Destroy((Object)(object)val);
		}
	}

	public static void RemoveComponents<T>(this GameObject go) where T : Component
	{
		T[] components = go.GetComponents<T>();
		for (int i = 0; i < components.Length; i++)
		{
			Object.Destroy((Object)(object)components[i]);
		}
	}

	public static T GetCopyOf<T>(this Component comp, T other) where T : Component
	{
		Type type = ((object)comp).GetType();
		if (type != ((object)other).GetType())
		{
			return default(T);
		}
		BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
		PropertyInfo[] properties = type.GetProperties(bindingAttr);
		foreach (PropertyInfo propertyInfo in properties)
		{
			if (propertyInfo.CanWrite)
			{
				try
				{
					propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null);
				}
				catch
				{
				}
			}
		}
		FieldInfo[] fields = type.GetFields(bindingAttr);
		foreach (FieldInfo fieldInfo in fields)
		{
			fieldInfo.SetValue(comp, fieldInfo.GetValue(other));
		}
		return (T)(object)((comp is T) ? comp : null);
	}

	public static T GetCopyOf<T>(this ScriptableObject comp, T other) where T : ScriptableObject
	{
		Type type = ((object)comp).GetType();
		if (type != ((object)other).GetType())
		{
			return default(T);
		}
		BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
		PropertyInfo[] properties = type.GetProperties(bindingAttr);
		foreach (PropertyInfo propertyInfo in properties)
		{
			if (propertyInfo.CanWrite)
			{
				try
				{
					propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null);
				}
				catch
				{
				}
			}
		}
		FieldInfo[] fields = type.GetFields(bindingAttr);
		foreach (FieldInfo fieldInfo in fields)
		{
			fieldInfo.SetValue(comp, fieldInfo.GetValue(other));
		}
		return (T)(object)((comp is T) ? comp : null);
	}

	public static T AddComponentCopy<T>(this GameObject go, T toAdd) where T : Component
	{
		return ((Component)(object)go.AddComponent<T>()).GetCopyOf(toAdd);
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("bubbet.riskui", "Risk UI", "1.5.2")]
public class RiskUIPlugin : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static UnityAction <>9__26_0;

		public static UnityAction <>9__26_1;

		internal void <MakeRiskofOptions>b__26_0()
		{
			Application.OpenURL("https://github.com/Bubbet/Risk-Of-Rain-Mods/issues/new");
		}

		internal void <MakeRiskofOptions>b__26_1()
		{
			Application.OpenURL("https://ko-fi.com/bubbet");
		}
	}

	public static GameObject _newHud;

	public static GameObject _newClassicRunHud;

	public static GameObject _newSimulacrumHud;

	public static GameObject _allyCard;

	public static GameObject BaseWaveUI;

	public static GameObject EnemyInfoPanel;

	public static readonly Dictionary<string, Sprite> DifficultyIconMap = new Dictionary<string, Sprite>();

	public static ZioConfigEntry<Color> VoidColor;

	public static ZioConfigEntry<Color> InfusionColor;

	public static ZioConfigEntry<Color> VoidShieldColor;

	public static ZioConfigFile ConfigFile;

	private string description;

	private Sprite icon;

	public static ZioConfigEntry<bool> Enabled;

	private Harmony harm;

	private PatchClassProcessor patcher;

	public static readonly List<ZioConfigFile> ConfigFiles = new List<ZioConfigFile>();

	public static bool NeverBeforeInitialized;

	public static bool RiskOfOptionsEnabled => Chainloader.PluginInfos.ContainsKey("bubbet.zioriskofoptions");

	public void Awake()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		Log.Init(((BaseUnityPlugin)this).Logger);
		LoadAssets();
		harm = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
		patcher = new PatchClassProcessor(harm, typeof(NewHarmonyPatches));
		RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
	}

	private void LoadAssets()
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		try
		{
			JSONNode val = JSON.Parse(File.OpenText(Path.Combine(directoryName, "manifest.json")).ReadToEnd());
			description = ((object)val["description"]).ToString();
			byte[] array = File.ReadAllBytes(Path.Combine(directoryName, "icon.png"));
			Texture2D val2 = new Texture2D(256, 256);
			ImageConversion.LoadImage(val2, array);
			icon = Sprite.Create(val2, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f));
		}
		catch
		{
		}
		AssetBundle val3 = AssetBundle.LoadFromFile(Path.Combine(directoryName, "riskui"));
		_newHud = val3.LoadAsset<GameObject>("RiskUI");
		_newClassicRunHud = val3.LoadAsset<GameObject>("MaterialClassicRunInfoHudPanel");
		_newSimulacrumHud = val3.LoadAsset<GameObject>("MaterialSimulacrum");
		_allyCard = val3.LoadAsset<GameObject>("MaterialAllyCard");
		BaseWaveUI = val3.LoadAsset<GameObject>("MaterialDefaultWaveUI");
		EnemyInfoPanel = val3.LoadAsset<GameObject>("MaterialMonsterItemInventory");
		CreateIconMap(val3);
	}

	private void CreateIconMap(AssetBundle assetBundle)
	{
		DifficultyIconMap["SUNNY_NAME"] = assetBundle.LoadAsset<Sprite>("Sunny (More Difficulties)");
		DifficultyIconMap["RAINSOON_NAME"] = assetBundle.LoadAsset<Sprite>("ThunderStorm (More Difficulties)");
		DifficultyIconMap["HIFU_DIFFICULTY_NAME"] = assetBundle.LoadAsset<Sprite>("Inferno (Inferno)");
		DifficultyIconMap["DIFFICULTY_CONFIGURABLEDIFFICULTYMOD_NAME"] = assetBundle.LoadAsset<Sprite>("Pluviculture (ConfigurableDifficulty)");
		DifficultyIconMap["Mico27_DIFFICULTY_TROPICALSTORM_NAME"] = assetBundle.LoadAsset<Sprite>("Tropical Storm (Tropical Storm)");
		DifficultyIconMap["GROOVYDIFFICULTY_4_NAME"] = assetBundle.LoadAsset<Sprite>("Deluge (UntitledDifficultyMod)");
		DifficultyIconMap["CALYPSO_NAME"] = assetBundle.LoadAsset<Sprite>("Calypso (More Difficulties)");
		DifficultyIconMap["GROOVYDIFFICULTY_5_NAME"] = assetBundle.LoadAsset<Sprite>("Charybdis (UntitledDifficultyMod)");
		DifficultyIconMap["TEMPEST_NAME"] = assetBundle.LoadAsset<Sprite>("Tempest (More Difficulties)");
		DifficultyIconMap["SCYLLA_NAME"] = assetBundle.LoadAsset<Sprite>("Armageddon (More Difficulties)");
		DifficultyIconMap["DIFFICULTY_EASY_NAME"] = assetBundle.LoadAsset<Sprite>("Drizzle");
		DifficultyIconMap["DIFFICULTY_NORMAL_NAME"] = assetBundle.LoadAsset<Sprite>("Rainstorm");
		DifficultyIconMap["DIFFICULTY_HARD_NAME"] = assetBundle.LoadAsset<Sprite>("Monsoon");
	}

	private void OnLoad()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: 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_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Expected O, but got Unknown
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		ConfigFile = new ZioConfigFile(RoR2Application.cloudStorage, UPath.op_Implicit("/RiskUI.cfg"), true, (BaseUnityPlugin)(object)this);
		foreach (UPath item in FileSystemExtensions.EnumeratePaths((IFileSystem)(object)RoR2Application.cloudStorage, new UPath("/RiskUI/")))
		{
			ConfigFiles.Add(new ZioConfigFile(RoR2Application.cloudStorage, item, true, (BaseUnityPlugin)(object)this));
		}
		if (ConfigFiles.Count < 1)
		{
			NeverBeforeInitialized = true;
			ConfigFiles.Add(new ZioConfigFile(RoR2Application.cloudStorage, UPath.op_Implicit($"/RiskUI/{default(Guid)}"), true, (BaseUnityPlugin)(object)this));
		}
		Enabled = ConfigHelper.Bind("General", "Enabled", defaultValue: true, "Should the hud be replaced. Only updates on hud awake, so stage change and starting new runs.");
		((ZioConfigEntryBase)Enabled).SettingChanged += EnabledChanged;
		EnabledChanged();
		VoidColor = ConfigHelper.Bind<Color>("Recoloring Player HealthBar", "Void Color", Color32.op_Implicit(new Color32((byte)181, (byte)100, (byte)189, byte.MaxValue)), "Color of void, Void Fiends health bar.");
		InfusionColor = ConfigHelper.Bind<Color>("Recoloring Player HealthBar", "Infusion Color", Color32.op_Implicit(new Color32((byte)221, (byte)44, (byte)38, byte.MaxValue)), "Color of infusion.");
		VoidShieldColor = ConfigHelper.Bind<Color>("Recoloring Player HealthBar", "Void Shield Color", Color32.op_Implicit(new Color32((byte)229, (byte)127, (byte)240, byte.MaxValue)), "Color of void shield.");
		if (RiskOfOptionsEnabled)
		{
			MakeRiskofOptions();
		}
		IConfigHandler[] componentsInChildren = _newHud.GetComponentsInChildren<IConfigHandler>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			componentsInChildren[i].Startup();
		}
	}

	private void EnabledChanged()
	{
		if (Enabled.Value)
		{
			patcher.Patch();
		}
		else
		{
			harm.UnpatchSelf();
		}
	}

	private void EnabledChanged(ZioConfigEntryBase arg1, object arg2, bool arg3)
	{
		EnabledChanged();
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	private void MakeRiskofOptions()
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Expected O, but got Unknown
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Expected O, but got Unknown
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Expected O, but got Unknown
		if (Object.op_Implicit((Object)(object)icon))
		{
			ModSettingsManager.SetModIcon(icon);
		}
		if (description != null)
		{
			ModSettingsManager.SetModDescription(description);
		}
		object obj = <>c.<>9__26_0;
		if (obj == null)
		{
			UnityAction val = delegate
			{
				Application.OpenURL("https://github.com/Bubbet/Risk-Of-Rain-Mods/issues/new");
			};
			<>c.<>9__26_0 = val;
			obj = (object)val;
		}
		ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Report An Issue", "General", "If you find a bug in the mod, reporting an issue is the best way to ensure it gets fixed.", "Open Link", (UnityAction)obj));
		object obj2 = <>c.<>9__26_1;
		if (obj2 == null)
		{
			UnityAction val2 = delegate
			{
				Application.OpenURL("https://ko-fi.com/bubbet");
			};
			<>c.<>9__26_1 = val2;
			obj2 = (object)val2;
		}
		ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Donate to Bubbet", "General", "Donate to the programmer of RiskUI.", "Open Link", (UnityAction)obj2));
	}

	public static GameObject CreateHud()
	{
		return _newHud;
	}

	public static GameObject CreateClassicRunHud()
	{
		return _newClassicRunHud;
	}

	public static GameObject CreateSimulcrum()
	{
		return _newSimulacrumHud;
	}

	public static GameObject CreateAllyCard()
	{
		return _allyCard;
	}
}