Decompiled source of ContentCurator v1.2.0

ContentCurator.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using RoR2.Achievements;
using RoR2.ContentManagement;
using RoR2.Skills;
using RoR2.UI;
using RoR2.UI.LogBook;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace AchievementDisabler;

[BepInPlugin("binma.achievementdisabler", "Content Curator", "1.2.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	internal static ConfigEntry<bool> HideUnobtainable;

	internal static ConfigEntry<bool> BlockUnlock;

	internal static readonly Dictionary<string, ConfigEntry<bool>> PerAchievement = new Dictionary<string, ConfigEntry<bool>>();

	internal static HashSet<string> Hidden = new HashSet<string>();

	internal static bool Ready;

	internal static bool Dirty;

	private static ConfigFile cfg;

	internal static readonly HashSet<string> ContentUnlockables = new HashSet<string>();

	private void Awake()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Expected O, but got Unknown
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0311: Expected O, but got Unknown
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Expected O, but got Unknown
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Expected O, but got Unknown
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		cfg = ((BaseUnityPlugin)this).Config;
		HideUnobtainable = ((BaseUnityPlugin)this).Config.Bind<bool>("00-General", "Hide achievements for removed skins and skills", false, "Also hide achievements whose skin or skill reward no longer exists in the game (for example, removed with Content Disabler).");
		BlockUnlock = ((BaseUnityPlugin)this).Config.Bind<bool>("00-General", "Disabled achievements cannot be unlocked", true, "When true, a disabled achievement can't be earned. When false, it is only hidden from the lists.");
		Harmony val = new Harmony("binma.achievementdisabler");
		val.PatchAll(typeof(Plugin).Assembly);
		RecipeCleanup.Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("02-Recipes", "Remove recipes for disabled content", true, "Removes crafting recipes that make or use an item or equipment turned off in Content Disabler, so they no longer show in the logbook or at the Wandering CHEF.");
		EliteTuning.Health = ((BaseUnityPlugin)this).Config.Bind<float>("03-Elites", "Empyrean health multiplier", 1f, "Multiplies the health boost of Empyrean elites (enemies only). 1 = unchanged. Host only.");
		EliteTuning.Damage = ((BaseUnityPlugin)this).Config.Bind<float>("03-Elites", "Empyrean damage multiplier", 1f, "Multiplies the damage boost of Empyrean elites (enemies only). 1 = unchanged. Host only.");
		RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(EliteTuning.Apply));
		LunarLook.Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("04-Visuals", "His Resentment uses the lunar look", true, "Gives Enemies Returns' His Resentment the blue lunar glow, highlight and name color instead of orange. Visual only: it is not treated as a lunar equipment.");
		RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(LunarLook.Apply));
		ModelSizes.List = ((BaseUnityPlugin)this).Config.Bind<string>("06-Sizes", "Model size overrides", "", "Comma-separated BodyName=scale pairs (e.g. DemineurBody=3). Scales the enemy's model and hurtboxes directly, for enemies Size Scaler can't resize. Everyone should use the same values.");
		CharacterBody.onBodyStartGlobal += ModelSizes.OnBodyStart;
		Run.onRunStartGlobal += delegate
		{
			FamilyCompat.Apply();
		};
		DisabledEnemies.List = ((BaseUnityPlugin)this).Config.Bind<string>("05-Enemies", "Disabled enemies", "", "Comma-separated body names (e.g. AssassinBody). Listed enemies never spawn and have no logbook page. Host decides spawns; the logbook part is per player.");
		try
		{
			MethodInfo methodInfo = AccessTools.Method(typeof(DirectorCard), "IsAvailable", (Type[])null, (Type[])null);
			HarmonyMethod val2 = new HarmonyMethod(typeof(DisabledEnemies), "CardPostfix", (Type[])null);
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			methodInfo = AccessTools.Method(typeof(LogBookController), "BuildMonsterEntries", (Type[])null, (Type[])null);
			val2 = new HarmonyMethod(typeof(DisabledEnemies), "LogbookPostfix", (Type[])null);
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Disabled enemies hook failed: " + ex));
		}
		try
		{
			MethodInfo methodInfo = AccessTools.Method(typeof(PickupDisplay), "RebuildModel", (Type[])null, (Type[])null);
			HarmonyMethod val2 = new HarmonyMethod(typeof(LunarLook), "DisplayPostfix", (Type[])null);
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		catch (Exception ex2)
		{
			Log.LogError((object)("Lunar look hook failed: " + ex2));
		}
		try
		{
			val.Patch((MethodBase)AccessTools.Method(typeof(CraftableCatalog), "SetCraftableDefs", (Type[])null, (Type[])null), new HarmonyMethod(typeof(RecipeCleanup), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		catch (Exception ex3)
		{
			Log.LogError((object)("Recipe cleanup hook failed: " + ex3));
		}
		try
		{
			MethodInfo methodInfo = AccessTools.Method(typeof(RecipeIngredient), "Validate", new Type[1] { typeof(PickupIndex) }, (Type[])null);
			HarmonyMethod val2 = new HarmonyMethod(typeof(RecipeCleanup), "IngredientPostfix", (Type[])null);
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		catch (Exception ex4)
		{
			Log.LogError((object)("Ingredient cleanup hook failed: " + ex4));
		}
		RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Build));
	}

	private unsafe static void Build()
	{
		//IL_000b: 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_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			cfg.SaveOnConfigSet = false;
			GenericStaticEnumerable<AchievementDef, Enumerator> allAchievementDefs = AchievementManager.allAchievementDefs;
			Enumerator enumerator = allAchievementDefs.GetEnumerator();
			try
			{
				while (((Enumerator)(ref enumerator)).MoveNext())
				{
					AchievementDef current = ((Enumerator)(ref enumerator)).Current;
					if (current != null && !string.IsNullOrEmpty(current.identifier))
					{
						string s = Language.GetString(current.nameToken ?? "", "en");
						ConfigEntry<bool> val = cfg.Bind<bool>("01-Achievements", Key(current.identifier), false, "Disable achievement: " + Clean(s));
						PerAchievement[current.identifier] = val;
						val.SettingChanged += delegate
						{
							Recompute();
						};
					}
				}
			}
			finally
			{
				((IDisposable)(*(Enumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose();
			}
			cfg.Save();
			cfg.SaveOnConfigSet = true;
			HideUnobtainable.SettingChanged += delegate
			{
				Recompute();
			};
			Dirty = true;
		}
		catch (Exception ex)
		{
			Log.LogError((object)ex);
		}
	}

	internal unsafe static void Recompute()
	{
		//IL_0076: 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_007f: 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)
		HashSet<string> hashSet = new HashSet<string>();
		foreach (KeyValuePair<string, ConfigEntry<bool>> item in PerAchievement)
		{
			if (item.Value.Value)
			{
				hashSet.Add(item.Key);
			}
		}
		if (HideUnobtainable.Value)
		{
			NoteSkins();
			HashSet<string> hashSet2 = LiveUnlockables();
			GenericStaticEnumerable<AchievementDef, Enumerator> allAchievementDefs = AchievementManager.allAchievementDefs;
			Enumerator enumerator2 = allAchievementDefs.GetEnumerator();
			try
			{
				while (((Enumerator)(ref enumerator2)).MoveNext())
				{
					AchievementDef current2 = ((Enumerator)(ref enumerator2)).Current;
					string text = current2?.unlockableRewardIdentifier;
					if (!string.IsNullOrEmpty(text) && (text.StartsWith("Skins.") || text.StartsWith("Skills.") || ContentUnlockables.Contains(text)) && !hashSet2.Contains(text))
					{
						hashSet.Add(current2.identifier);
					}
				}
			}
			finally
			{
				((IDisposable)(*(Enumerator*)(&enumerator2))/*cast due to .constrained prefix*/).Dispose();
			}
		}
		Hidden = hashSet;
		Ready = true;
		Log.LogInfo((object)("Hiding " + hashSet.Count + " achievement(s)."));
	}

	internal static void NoteSkins()
	{
		SkinDef[] array = Resources.FindObjectsOfTypeAll<SkinDef>();
		foreach (SkinDef val in array)
		{
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.unlockableDef))
			{
				ContentUnlockables.Add(val.unlockableDef.cachedName);
			}
		}
	}

	private static HashSet<string> LiveUnlockables()
	{
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		HashSet<string> hashSet = new HashSet<string>();
		foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs)
		{
			ModelLocator val = ((!Object.op_Implicit((Object)(object)allBodyPrefab)) ? null : allBodyPrefab.GetComponent<ModelLocator>());
			ModelSkinController val2 = ((!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.modelTransform)) ? null : ((Component)val.modelTransform).GetComponent<ModelSkinController>());
			if (!Object.op_Implicit((Object)(object)val2) || val2.skins == null)
			{
				continue;
			}
			SkinDef[] skins = val2.skins;
			foreach (SkinDef val3 in skins)
			{
				if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val3.unlockableDef))
				{
					hashSet.Add(val3.unlockableDef.cachedName);
				}
			}
		}
		foreach (SkillFamily allSkillFamily in SkillCatalog.allSkillFamilies)
		{
			if (!Object.op_Implicit((Object)(object)allSkillFamily) || allSkillFamily.variants == null)
			{
				continue;
			}
			Variant[] variants = allSkillFamily.variants;
			for (int j = 0; j < variants.Length; j++)
			{
				Variant val4 = variants[j];
				if (Object.op_Implicit((Object)(object)val4.unlockableDef))
				{
					hashSet.Add(val4.unlockableDef.cachedName);
				}
			}
		}
		return hashSet;
	}

	internal static void EnsureReady()
	{
		if (Dirty)
		{
			Dirty = false;
			try
			{
				Recompute();
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}
	}

	internal static bool IsHidden(string id)
	{
		EnsureReady();
		return id != null && Hidden.Contains(id);
	}

	private static string Key(string s)
	{
		char[] bad = new char[8] { '=', '\n', '\t', '\\', '"', '\'', '[', ']' };
		return new string(s.Where((char c) => Array.IndexOf(bad, c) < 0).ToArray());
	}

	private static string Clean(string s)
	{
		return (s ?? "").Replace('\n', ' ').Replace('\r', ' ');
	}
}
[HarmonyPatch(typeof(SkillCatalog), "SetSkillFamilies")]
internal static class SkillSnapshotPatch
{
	private static void Postfix()
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			foreach (SkillFamily allSkillFamily in SkillCatalog.allSkillFamilies)
			{
				if (!Object.op_Implicit((Object)(object)allSkillFamily) || allSkillFamily.variants == null)
				{
					continue;
				}
				Variant[] variants = allSkillFamily.variants;
				for (int i = 0; i < variants.Length; i++)
				{
					Variant val = variants[i];
					if (Object.op_Implicit((Object)(object)val.unlockableDef))
					{
						Plugin.ContentUnlockables.Add(val.unlockableDef.cachedName);
					}
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}
}
[HarmonyPatch(typeof(AchievementListPanelController), "Rebuild")]
internal static class ListPatch
{
	private static readonly FieldRef<List<string>> Sorted = AccessTools.StaticFieldRefAccess<List<string>>(AccessTools.Field(typeof(AchievementListPanelController), "sortedAchievementIdentifiers"));

	private static readonly MethodInfo BuildOrder = AccessTools.Method(typeof(AchievementListPanelController), "BuildAchievementListOrder", (Type[])null, (Type[])null);

	private unsafe static void Prefix()
	{
		//IL_004d: Expected O, but got Ref
		try
		{
			Plugin.EnsureReady();
			if (Plugin.Ready)
			{
				BuildOrder.Invoke(null, null);
				((List<string>)Unsafe.AsPointer(ref Sorted.Invoke())).RemoveAll(Plugin.IsHidden);
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}
}
[HarmonyPatch(typeof(LogBookController), "CanSelectAchievementEntry")]
internal static class LogbookPatch
{
	private static void Postfix(AchievementDef __0, ref bool __result)
	{
		if (__result && __0 != null && Plugin.IsHidden(__0.identifier))
		{
			__result = false;
		}
	}
}
[HarmonyPatch(typeof(BaseAchievement), "Grant")]
internal static class GrantPatch
{
	private static bool Prefix(BaseAchievement __instance)
	{
		return !Plugin.BlockUnlock.Value || __instance.achievementDef == null || !Plugin.IsHidden(__instance.achievementDef.identifier);
	}
}
internal static class RecipeCleanup
{
	internal static ConfigEntry<bool> Enabled;

	private static HashSet<string> disabled;

	private static readonly Dictionary<int, bool> pickupCache = new Dictionary<int, bool>();

	private static HashSet<string> Disabled()
	{
		if (disabled != null)
		{
			return disabled;
		}
		disabled = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
		try
		{
			string path = Path.Combine(Paths.ConfigPath, "com.TPDespair.ContentDisabler.cfg");
			if (!File.Exists(path))
			{
				return disabled;
			}
			string text = "";
			string[] array = File.ReadAllLines(path);
			foreach (string text2 in array)
			{
				string text3 = text2.Trim();
				if (text3.Length == 0 || text3[0] == '#')
				{
					continue;
				}
				if (text3[0] == '[')
				{
					text = text3.Trim('[', ']');
				}
				else if (!(text != "Item") || !(text != "Equipment"))
				{
					int num = text3.LastIndexOf('=');
					if (num > 0 && text3.Substring(num + 1).Trim().Equals("true", StringComparison.OrdinalIgnoreCase))
					{
						disabled.Add(text3.Substring(0, num).Trim());
					}
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
		return disabled;
	}

	private static bool IsDisabled(Object pickup)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit(pickup))
		{
			return false;
		}
		HashSet<string> hashSet = Disabled();
		if (hashSet.Count == 0)
		{
			return false;
		}
		string text = null;
		if (pickup is ItemDef)
		{
			text = ((ItemDef)pickup).nameToken;
		}
		else
		{
			if (!(pickup is EquipmentDef))
			{
				return false;
			}
			text = ((EquipmentDef)pickup).nameToken;
		}
		return hashSet.Contains(pickup.name) || (!string.IsNullOrEmpty(text) && hashSet.Contains(text));
	}

	private static void IngredientPostfix(PickupIndex __0, ref bool __result)
	{
		//IL_0033: 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_0049: Invalid comparison between Unknown and I4
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Invalid comparison between Unknown and I4
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!__result || !Enabled.Value)
			{
				return;
			}
			if (!pickupCache.TryGetValue(__0.value, out var value))
			{
				PickupDef pickupDef = PickupCatalog.GetPickupDef(__0);
				Object pickup = null;
				if (pickupDef != null)
				{
					if ((int)pickupDef.itemIndex != -1)
					{
						pickup = (Object)(object)ItemCatalog.GetItemDef(pickupDef.itemIndex);
					}
					else if ((int)pickupDef.equipmentIndex != -1)
					{
						pickup = (Object)(object)EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
					}
				}
				value = IsDisabled(pickup);
				pickupCache[__0.value] = value;
			}
			if (value)
			{
				__result = false;
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}

	private static void Prefix(ref CraftableDef[] __0)
	{
		try
		{
			if (!Enabled.Value || __0 == null)
			{
				return;
			}
			List<CraftableDef> list = new List<CraftableDef>(__0.Length);
			int num = 0;
			CraftableDef[] array = __0;
			foreach (CraftableDef val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (IsDisabled(val.pickup))
				{
					num += ((val.recipes == null) ? 1 : val.recipes.Length);
					Plugin.Log.LogInfo((object)("Removed recipes for disabled " + val.pickup.name));
					continue;
				}
				if (val.recipes != null)
				{
					List<Recipe> list2 = new List<Recipe>(val.recipes.Length);
					Recipe[] recipes = val.recipes;
					foreach (Recipe val2 in recipes)
					{
						bool flag = false;
						if (val2 != null && val2.ingredients != null)
						{
							RecipeIngredient[] ingredients = val2.ingredients;
							foreach (RecipeIngredient val3 in ingredients)
							{
								if (val3 != null && IsDisabled(val3.pickup))
								{
									flag = true;
									break;
								}
							}
						}
						if (flag)
						{
							num++;
						}
						else
						{
							list2.Add(val2);
						}
					}
					if (list2.Count == 0)
					{
						continue;
					}
					val.recipes = list2.ToArray();
				}
				list.Add(val);
			}
			if (num > 0)
			{
				Plugin.Log.LogInfo((object)("Removed " + num + " recipe(s) for content disabled in Content Disabler."));
			}
			__0 = list.ToArray();
			FieldInfo fieldInfo = AccessTools.Field(typeof(ContentManager), "_craftableDefs");
			if (fieldInfo != null && num > 0)
			{
				fieldInfo.SetValue(null, __0);
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)("Recipe cleanup failed: " + ex));
		}
	}
}
internal static class EliteTuning
{
	internal static ConfigEntry<float> Health;

	internal static ConfigEntry<float> Damage;

	internal static void Apply()
	{
		try
		{
			float value = Health.Value;
			float value2 = Damage.Value;
			if (value == 1f && value2 == 1f)
			{
				return;
			}
			int num = 0;
			for (int i = 0; i < EliteCatalog.eliteCount; i++)
			{
				EliteDef eliteDef = EliteCatalog.GetEliteDef((EliteIndex)i);
				if (Object.op_Implicit((Object)(object)eliteDef) && Object.op_Implicit((Object)(object)eliteDef.eliteEquipmentDef) && !(((Object)eliteDef.eliteEquipmentDef).name != "AffixEmpyrean"))
				{
					eliteDef.healthBoostCoefficient *= value;
					eliteDef.damageBoostCoefficient *= value2;
					num++;
				}
			}
			Plugin.Log.LogInfo((object)("Tuned " + num + " Empyrean elite tier(s)."));
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}
}
internal static class LunarLook
{
	internal static ConfigEntry<bool> Enabled;

	internal static PickupIndex target = PickupIndex.none;

	internal const string Equip = "ER_MithrixHammer";

	internal static void Apply()
	{
		//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_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Invalid comparison between Unknown and I4
		//IL_002b: 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)
		//IL_0039: 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_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: 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_006e: Unknown result type (might be due to invalid IL or missing references)
		//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_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!Enabled.Value)
			{
				return;
			}
			EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex("ER_MithrixHammer");
			if ((int)val == -1)
			{
				return;
			}
			EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(val);
			equipmentDef.colorIndex = (ColorIndex)4;
			target = PickupCatalog.FindPickupIndex(val);
			PickupDef pickupDef = PickupCatalog.GetPickupDef(target);
			if (pickupDef != null)
			{
				pickupDef.baseColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)4));
				pickupDef.darkColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)21));
				PickupDef pickupDef2 = PickupCatalog.GetPickupDef(PickupCatalog.FindPickupIndex(Equipment.Meteor.equipmentIndex));
				if (pickupDef2 != null && Object.op_Implicit((Object)(object)pickupDef2.dropletDisplayPrefab))
				{
					pickupDef.dropletDisplayPrefab = pickupDef2.dropletDisplayPrefab;
				}
				Plugin.Log.LogInfo((object)"His Resentment now uses the lunar look.");
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}

	private static void DisplayPostfix(PickupDisplay __instance)
	{
		//IL_000f: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!Enabled.Value || target == PickupIndex.none || !Object.op_Implicit((Object)(object)__instance))
			{
				return;
			}
			PickupIndex value = Traverse.Create((object)__instance).Field("pickupState").Field("pickupIndex")
				.GetValue<PickupIndex>();
			if (!(value != target))
			{
				if (Object.op_Implicit((Object)(object)__instance.equipmentParticleEffect))
				{
					__instance.equipmentParticleEffect.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)__instance.lunarParticleEffect))
				{
					__instance.lunarParticleEffect.SetActive(true);
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}
}
internal static class DisabledEnemies
{
	internal static ConfigEntry<string> List;

	private static HashSet<string> names;

	private static HashSet<string> tokens;

	private static HashSet<string> Names()
	{
		if (names != null)
		{
			return names;
		}
		names = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
		string[] array = (List.Value ?? "").Split(',');
		foreach (string text in array)
		{
			string text2 = text.Trim();
			if (text2.Length > 0)
			{
				names.Add(text2);
			}
		}
		return names;
	}

	private static HashSet<string> Tokens()
	{
		if (tokens != null)
		{
			return tokens;
		}
		tokens = new HashSet<string>();
		foreach (string item in Names())
		{
			GameObject val = BodyCatalog.FindBodyPrefab(item);
			CharacterBody val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.GetComponent<CharacterBody>());
			if (Object.op_Implicit((Object)(object)val2) && !string.IsNullOrEmpty(val2.baseNameToken))
			{
				tokens.Add(val2.baseNameToken);
			}
		}
		return tokens;
	}

	private static void CardPostfix(DirectorCard __instance, ref bool __result)
	{
		try
		{
			if (!__result || Names().Count == 0)
			{
				return;
			}
			SpawnCard spawnCard = __instance.spawnCard;
			CharacterSpawnCard val = (CharacterSpawnCard)(object)((spawnCard is CharacterSpawnCard) ? spawnCard : null);
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((SpawnCard)val).prefab))
			{
				CharacterMaster component = ((SpawnCard)val).prefab.GetComponent<CharacterMaster>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.bodyPrefab) && Names().Contains(((Object)component.bodyPrefab).name))
				{
					__result = false;
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}

	private static void LogbookPostfix(ref Entry[] __result)
	{
		try
		{
			if (__result == null || Names().Count == 0)
			{
				return;
			}
			List<Entry> list = new List<Entry>(__result.Length);
			Entry[] array = __result;
			foreach (Entry val in array)
			{
				if (val != null)
				{
					object extraData = val.extraData;
					CharacterBody val2 = (CharacterBody)((extraData is CharacterBody) ? extraData : null);
					if (!((!Object.op_Implicit((Object)(object)val2)) ? Tokens().Contains(val.nameToken ?? "") : Names().Contains(((Object)val2).name)))
					{
						list.Add(val);
					}
				}
			}
			__result = list.ToArray();
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}
}
internal static class ModelSizes
{
	internal static ConfigEntry<string> List;

	private static Dictionary<string, float> sizes;

	private static Dictionary<string, float> Sizes()
	{
		if (sizes != null)
		{
			return sizes;
		}
		sizes = new Dictionary<string, float>(StringComparer.OrdinalIgnoreCase);
		string[] array = (List.Value ?? "").Split(',');
		foreach (string text in array)
		{
			string[] array2 = text.Split('=');
			if (array2.Length == 2 && float.TryParse(array2[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && result > 0f)
			{
				sizes[array2[0].Trim().Replace("(Clone)", "")] = result;
			}
		}
		return sizes;
	}

	internal static void OnBodyStart(CharacterBody body)
	{
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (Object.op_Implicit((Object)(object)body) && Sizes().Count != 0 && Sizes().TryGetValue(((Object)body).name.Replace("(Clone)", "").Trim(), out var value) && value != 1f)
			{
				Transform val = ((!Object.op_Implicit((Object)(object)body.modelLocator)) ? null : body.modelLocator.modelTransform);
				if (Object.op_Implicit((Object)(object)val))
				{
					val.localScale *= value;
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}
}
internal static class FamilyCompat
{
	private struct Entry
	{
		public string Family;

		public string Card;

		public string Fallback;

		public Entry(string f, string c, string fb)
		{
			Family = f;
			Card = c;
			Fallback = fb;
		}
	}

	private static readonly Entry[] entries = new Entry[1]
	{
		new Entry("RoR2/DLC1/Common/dccsConstructFamily.asset", "cscGammaConstruct", "Minibosses")
	};

	private static bool done;

	internal static void Apply()
	{
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Expected O, but got Unknown
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		if (done)
		{
			return;
		}
		done = true;
		try
		{
			CharacterSpawnCard[] array = Resources.FindObjectsOfTypeAll<CharacterSpawnCard>();
			DirectorCardCategorySelection[] array2 = Resources.FindObjectsOfTypeAll<DirectorCardCategorySelection>();
			Entry[] array3 = entries;
			for (int i = 0; i < array3.Length; i++)
			{
				Entry entry = array3[i];
				CharacterSpawnCard val = null;
				CharacterSpawnCard[] array4 = array;
				foreach (CharacterSpawnCard val2 in array4)
				{
					if (Object.op_Implicit((Object)(object)val2) && ((Object)val2).name == entry.Card)
					{
						val = val2;
						break;
					}
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				DirectorCardCategorySelection val3 = Addressables.LoadAssetAsync<DirectorCardCategorySelection>((object)entry.Family).WaitForCompletion();
				if (!Object.op_Implicit((Object)(object)val3) || val3.categories == null || Contains(val3, (SpawnCard)(object)val))
				{
					continue;
				}
				string text = entry.Fallback;
				DirectorCard val4 = null;
				DirectorCardCategorySelection[] array5 = array2;
				foreach (DirectorCardCategorySelection val5 in array5)
				{
					if (!Object.op_Implicit((Object)(object)val5) || val5.categories == null || (Object)(object)val5 == (Object)(object)val3)
					{
						continue;
					}
					Category[] categories = val5.categories;
					for (int l = 0; l < categories.Length; l++)
					{
						Category val6 = categories[l];
						if (val6.cards == null)
						{
							continue;
						}
						DirectorCard[] cards = val6.cards;
						foreach (DirectorCard val7 in cards)
						{
							if (val7 != null && (Object)(object)val7.GetSpawnCard() == (Object)(object)val)
							{
								val4 = val7;
								text = val6.name;
								break;
							}
						}
						if (val4 != null)
						{
							break;
						}
					}
					if (val4 != null)
					{
						break;
					}
				}
				int num = val3.FindCategoryIndexByName(text);
				if (num < 0)
				{
					num = val3.FindCategoryIndexByName(entry.Fallback);
				}
				if (num >= 0)
				{
					DirectorCard val8 = new DirectorCard();
					val8.spawnCard = (SpawnCard)(object)val;
					val8.selectionWeight = val4?.selectionWeight ?? 1;
					val8.spawnDistance = (MonsterSpawnDistance)((val4 != null) ? ((int)val4.spawnDistance) : 0);
					val8.preventOverhead = val4?.preventOverhead ?? false;
					val8.minimumStageCompletions = val4?.minimumStageCompletions ?? 0;
					DirectorCard val9 = val8;
					val3.AddCard(num, val9);
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}

	private static bool Contains(DirectorCardCategorySelection d, SpawnCard sc)
	{
		//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)
		Category[] categories = d.categories;
		for (int i = 0; i < categories.Length; i++)
		{
			Category val = categories[i];
			if (val.cards == null)
			{
				continue;
			}
			DirectorCard[] cards = val.cards;
			foreach (DirectorCard val2 in cards)
			{
				if (val2 != null && ((Object)(object)val2.GetSpawnCard() == (Object)(object)sc || (Object.op_Implicit((Object)(object)val2.GetSpawnCard()) && ((Object)val2.GetSpawnCard()).name == ((Object)sc).name)))
				{
					return true;
				}
			}
		}
		return false;
	}
}