Decompiled source of MyLittleRebalance v0.1.1

plugins/MyLittleRebalance.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using ShinyShoe;
using ShinyShoe.Audio;
using TMPro;
using TrainworksReloaded.Base.Localization;
using TrainworksReloaded.Core;
using TrainworksReloaded.Core.Extensions;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MyLittleRebalance")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+4a52f8c1110c7e37fef3970b66378b19f476722a")]
[assembly: AssemblyProduct("MyLittleRebalance")]
[assembly: AssemblyTitle("MyLittleRebalance")]
[assembly: AssemblyVersion("0.1.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MyLittleRebalance
{
	[HarmonyPatch(typeof(CardManager), "OnCardPlayedVfx")]
	internal static class TrainWhistleFirstPatch
	{
		internal static string? blownCue;

		internal static CoreSoundEffectData? blown;

		private static void Prefix(CardState playCard, SoundManager ___soundManager)
		{
			CoreSoundEffectData coreSoundEffectData = playCard.GetCoreSoundEffectData();
			if (!(playCard.GetAssetName() != "RailforgedChampionConductorStewardAbility") && !((Object)(object)coreSoundEffectData == (Object)null))
			{
				string text = (coreSoundEffectData.HasCue("Play") ? "Play" : (coreSoundEffectData.HasCue("UnitAbility") ? "UnitAbility" : null));
				if (text != null)
				{
					blown = null;
					___soundManager.PlaySfx(text, coreSoundEffectData, 0f);
					blownCue = text;
					blown = coreSoundEffectData;
				}
			}
		}
	}
	[HarmonyPatch(typeof(SoundManager), "PlaySfx", new Type[]
	{
		typeof(string),
		typeof(CoreSoundEffectData),
		typeof(float)
	})]
	internal static class TrainWhistleOncePatch
	{
		private static bool Prefix(string cueName, CoreSoundEffectData soundData)
		{
			if ((Object)(object)soundData == (Object)null || (Object)(object)soundData != (Object)(object)TrainWhistleFirstPatch.blown || cueName != TrainWhistleFirstPatch.blownCue)
			{
				return true;
			}
			TrainWhistleFirstPatch.blown = null;
			return false;
		}
	}
	[HarmonyPatch(typeof(RoomStateModifierBase), "OnRoomModifierAttachedToOwner")]
	internal static class RememberStatusBonusOwnerPatch
	{
		internal static readonly ConditionalWeakTable<RoomStateAddStatusEffectOnStatusApplied, CharacterState> Owners = new ConditionalWeakTable<RoomStateAddStatusEffectOnStatusApplied, CharacterState>();

		private static void Postfix(RoomStateModifierBase __instance, CharacterState ownerCharacterState)
		{
			RoomStateAddStatusEffectOnStatusApplied val = (RoomStateAddStatusEffectOnStatusApplied)(object)((__instance is RoomStateAddStatusEffectOnStatusApplied) ? __instance : null);
			if (val != null)
			{
				Owners.Remove(val);
				Owners.Add(val, ownerCharacterState);
			}
		}
	}
	[HarmonyPatch(typeof(RoomStateAddStatusEffectOnStatusApplied), "ApplyCharacterTriggerModification")]
	internal static class StatusBonusDualismPatch
	{
		private static bool Prefix(RoomStateAddStatusEffectOnStatusApplied __instance, ref IEnumerator __result, int ___thisInstTrackingId, AddStatusEffectParams ___addStatusEffectParams, Trigger trigger, CharacterState affectedCharacter, FireTriggersData? fireTriggersData)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!RememberStatusBonusOwnerPatch.Owners.TryGetValue(__instance, out CharacterState value))
			{
				return true;
			}
			__result = Apply(value, ___thisInstTrackingId, ___addStatusEffectParams, trigger, affectedCharacter, fireTriggersData);
			return false;
		}

		private static IEnumerator Apply(CharacterState owner, int trackingId, AddStatusEffectParams addStatusEffectParams, Trigger trigger, CharacterState affectedCharacter, FireTriggersData? fireTriggersData)
		{
			//IL_001c: 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)
			if ((int)trigger == 57 && fireTriggersData != null && fireTriggersData.paramInt2 == trackingId)
			{
				addStatusEffectParams.fromRoomModifier = true;
				affectedCharacter.AddStatusEffect(fireTriggersData.paramString, fireTriggersData.paramInt, addStatusEffectParams, owner, true, false, true, false, false);
			}
			yield break;
		}
	}
	[HarmonyPatch(typeof(StatusEffectManager), "Start")]
	internal static class UnhideFixedAttackPatch
	{
		private static void Postfix(StatusEffectManager __instance, StatusEffectsDisplayData ___displayData)
		{
			StatusEffectData statusEffectDataById = __instance.GetStatusEffectDataById("fixedattack", true);
			AccessTools.Field(typeof(StatusEffectData), "hidden").SetValue(statusEffectDataById, false);
			AccessTools.Field(typeof(StatusEffectData), "showStackCount").SetValue(statusEffectDataById, true);
			AccessTools.Field(typeof(StatusEffectData), "icon").SetValue(statusEffectDataById, AccessTools.Field(typeof(StatusEffectsDisplayData), "defaultRoomModifierIcon").GetValue(___displayData));
		}
	}
	[HarmonyPatch(typeof(CardData), "GetOverrideDescriptionKey")]
	internal static class IrontongueDescriptionPatch
	{
		private static void Postfix(CardData __instance, ref string __result)
		{
			if (((Object)__instance).name == "Irontongue")
			{
				__result = string.Empty;
			}
		}
	}
	internal static class JudgesScalesHandSelection
	{
		internal static bool Active;

		internal static readonly List<CardState> Selected = new List<CardState>();

		internal static GameUISelectableButton? ConfirmButton;

		internal static HandUI? Hand;

		private static readonly FieldInfo FocusedCardUI = AccessTools.Field(typeof(HandUI), "focusedCardUI");

		private static readonly FieldInfo CardFrontTinter = AccessTools.Field(typeof(CardUI), "cardFrontTinter");

		private static readonly FieldInfo GraphicsToTint = AccessTools.Field(typeof(ContentTinter), "graphicsToTint");

		private static readonly FieldInfo TintColor = AccessTools.Field(typeof(ContentTinter), "tintColor");

		private static readonly FieldInfo OverlaysToShow = AccessTools.Field(typeof(ContentTinter), "overlaysToShow");

		private static readonly FieldInfo OverlayColor = AccessTools.Field(typeof(ContentTinter), "overlayColor");

		private static readonly FieldInfo ControlChildTinters = AccessTools.Field(typeof(ContentTinter), "controlChildContentTinters");

		private static readonly FieldInfo DontTintColored = AccessTools.Field(typeof(ContentTinter), "dontTintColoredGraphics");

		private static Color? configuredTint;

		private static Color? appliedTint;

		internal static bool CannotDiscard(CardState card)
		{
			if (!card.HasTrait<CardTraitInfusion>())
			{
				return card.HasTrait<CardTraitPersistent>();
			}
			return true;
		}

		internal static bool IsSelected(CardUI cardUI)
		{
			if ((Object)(object)cardUI != (Object)null)
			{
				return Selected.Contains(cardUI.GetCardState());
			}
			return false;
		}

		private static IEnumerable<CardUI> CardUIs()
		{
			if ((Object)(object)Hand == (Object)null)
			{
				yield break;
			}
			foreach (CardUI cardUI in Hand.GetCardUIList())
			{
				yield return cardUI;
			}
			object? value = FocusedCardUI.GetValue(Hand);
			CardUI val = (CardUI)((value is CardUI) ? value : null);
			if (val != null)
			{
				yield return val;
			}
		}

		internal static void Reset()
		{
			foreach (CardUI item in CardUIs())
			{
				if (IsSelected(item))
				{
					Tint(item, on: false);
				}
			}
			Active = false;
			Selected.Clear();
			ConfirmButton = null;
			Hand = null;
		}

		internal static void RefreshLook(CardUI cardUI)
		{
			CardState cardState = cardUI.GetCardState();
			if (cardState != null && !CannotDiscard(cardState))
			{
				bool flag = Selected.Contains(cardState);
				Tint(cardUI, flag);
				if (flag)
				{
					cardUI.SetEdgeFxActive((EdgeHighlight)0, true);
				}
			}
		}

		internal static void RefreshAllLooks()
		{
			foreach (CardUI item in CardUIs())
			{
				RefreshLook(item);
			}
		}

		internal static void RefreshButtons(GameUISelectableButton confirm, TMP_Text confirmLabel, GameUISelectableButton cancel)
		{
			int count = Selected.Count;
			((Component)confirm).gameObject.SetActive(count > 0);
			((Component)cancel).gameObject.SetActive(count == 0);
			confirmLabel.text = LocalizationExtensions.Localize("ScreenDeck_Discard_Action", (ILocalizationParameterContext)null) + ((count > 1) ? $" ({count})" : string.Empty);
		}

		internal static void Retint()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			string text = Plugin.SelectedCardTint?.Value?.Trim().TrimStart('#') ?? string.Empty;
			Color? val = null;
			if (text.Length > 0)
			{
				Color value = default(Color);
				if (ColorUtility.TryParseHtmlString("#" + text, ref value))
				{
					val = value;
				}
				else
				{
					Plugin.Logger.LogWarning((object)("[Judge's Scales] SelectedCardTint '" + text + "' is not a hex colour; using the game's grey."));
				}
			}
			configuredTint = val;
			if (!Active)
			{
				return;
			}
			foreach (CardUI item in CardUIs())
			{
				if (IsSelected(item))
				{
					Tint(item, on: false);
				}
			}
			appliedTint = configuredTint;
			RefreshAllLooks();
		}

		internal static void Tint(CardUI card, bool on)
		{
			//IL_003c: 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_005b: 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)
			if ((Object)(object)card == (Object)null)
			{
				return;
			}
			object? value = CardFrontTinter.GetValue(card);
			ContentTinter val = (ContentTinter)((value is ContentTinter) ? value : null);
			if (val != null)
			{
				if (on)
				{
					appliedTint = configuredTint;
				}
				Color? val2 = appliedTint;
				if (val2.HasValue)
				{
					Color valueOrDefault = val2.GetValueOrDefault();
					Apply(val, on ? new Color?(valueOrDefault) : ((Color?)null), valueOrDefault);
				}
				else
				{
					val.Toggle(on);
				}
			}
		}

		private static void Apply(ContentTinter tinter, Color? colour, Color previous)
		{
			//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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_005e: 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)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			Color val = (Color)TintColor.GetValue(tinter);
			bool flag = (bool)DontTintColored.GetValue(tinter);
			foreach (Graphic item in (List<Graphic>)GraphicsToTint.GetValue(tinter))
			{
				if (!((Object)(object)item == (Object)null))
				{
					Color color = item.color;
					if (!flag || color == Color.white || color == previous || color == val)
					{
						Color val2 = (Color)(((??)colour) ?? Color.white);
						item.color = new Color(val2.r, val2.g, val2.b, color.a);
					}
				}
			}
			Color val3 = (Color)OverlayColor.GetValue(tinter);
			foreach (Graphic item2 in (List<Graphic>)OverlaysToShow.GetValue(tinter))
			{
				if ((Object)(object)item2 != (Object)null)
				{
					item2.color = (colour.HasValue ? val3 : Color.clear);
				}
			}
			if (!(bool)ControlChildTinters.GetValue(tinter))
			{
				return;
			}
			ContentTinter[] componentsInChildren = ((Component)tinter).GetComponentsInChildren<ContentTinter>();
			foreach (ContentTinter val4 in componentsInChildren)
			{
				if ((Object)(object)val4 != (Object)(object)tinter)
				{
					Apply(val4, colour, previous);
				}
			}
		}

		internal static void KeepDiscardButtonSelected()
		{
			if (Active && Selected.Count != 0 && !((Object)(object)ConfirmButton == (Object)null) && ((Component)ConfirmButton).gameObject.activeInHierarchy)
			{
				InputManager inst = InputManager.Inst;
				if (!((Object)(object)inst == (Object)null) && ((CoreInput)inst).currentInputModeUsesNavigation && !((Object)(object)EventSystem.current == (Object)null) && !((Object)(object)EventSystem.current.currentSelectedGameObject != (Object)null))
				{
					inst.SelectGameUIComponent((IGameUIComponent)(object)ConfirmButton, true, false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(RelicEffectChooseDiscardsDrawReplacementsOnPostOpeningDraw), "ApplyEffectOnPostOpeningDraw")]
	internal static class JudgesScalesDiscardAtOncePatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__Reset;

			public static CardStateChosenDelegate <1>__DiscardSelected;

			public static CancelledDelegate <2>__KeepHand;

			public static FilterCardStateDelegate <3>__CannotDiscard;
		}

		private static readonly bool BetterUILoaded = Chainloader.PluginInfos.ContainsKey("SpecialCircumstances.BetterUI");

		private static bool Prefix(ICoreGameManagers coreGameManagers, ref IEnumerator __result)
		{
			if (BetterUILoaded)
			{
				return true;
			}
			__result = Run(coreGameManagers);
			return false;
		}

		private static IEnumerator Run(ICoreGameManagers coreGameManagers)
		{
			CardManager cardManager = coreGameManagers.GetCardManager();
			AnimationTimingData animationTimingData = coreGameManagers.GetAllGameData().GetBalanceData().GetAnimationTimingData();
			JudgesScalesHandSelection.Reset();
			JudgesScalesHandSelection.Active = true;
			cardManager.AddSelectCardFromHandOnCompletedCallback((Action)JudgesScalesHandSelection.Reset);
			Params val = new Params
			{
				descriptionKey = "ScreenDeck_Select_CardEffectChooseDiscard",
				overrideActionKey = "ScreenDeck_Discard_Action",
				overrideCancelKey = "ScreenDeck_DiscardComplete_Action"
			};
			object obj = <>O.<1>__DiscardSelected;
			if (obj == null)
			{
				CardStateChosenDelegate val2 = DiscardSelected;
				<>O.<1>__DiscardSelected = val2;
				obj = (object)val2;
			}
			val.cardChosenCallback = (CardStateChosenDelegate)obj;
			object obj2 = <>O.<2>__KeepHand;
			if (obj2 == null)
			{
				CancelledDelegate val3 = KeepHand;
				<>O.<2>__KeepHand = val3;
				obj2 = (object)val3;
			}
			val.cancelledCallback = (CancelledDelegate)obj2;
			object obj3 = <>O.<3>__CannotDiscard;
			if (obj3 == null)
			{
				FilterCardStateDelegate val4 = JudgesScalesHandSelection.CannotDiscard;
				<>O.<3>__CannotDiscard = val4;
				obj3 = (object)val4;
			}
			val.filterCallback = (FilterCardStateDelegate)obj3;
			val.instantApplyDelay = animationTimingData.cardDrawAnimationDuration;
			val.disableIneligibleCards = true;
			val.allowShowCancel = true;
			val.selectionHandState = (CardUIState)9;
			yield return cardManager.SelectCardFromHand(val, false);
		}

		private static IEnumerator DiscardSelected(CardState chosenCard, CardManager cardManager)
		{
			List<CardState> cards = JudgesScalesHandSelection.Selected.ToList();
			JudgesScalesHandSelection.Reset();
			foreach (CardState item in cards)
			{
				yield return cardManager.DiscardCard(new DiscardCardParams
				{
					discardCard = item,
					triggeredByCard = true,
					wasPlayed = false
				}, false);
			}
			if (cards.Count != 0)
			{
				cardManager.RefreshHandCards(true, false);
				cardManager.DrawCards(cards.Count, (CardState)null, (CardType)4, -1);
			}
		}

		private static IEnumerator KeepHand(CardManager cardManager)
		{
			JudgesScalesHandSelection.Reset();
			yield break;
		}
	}
	[HarmonyPatch(typeof(HandSelectionUI), "SelectCard")]
	internal static class JudgesScalesToggleCardPatch
	{
		private static bool Prefix(CardUI cardUI, ref bool __result, HandUI ___handUI, GameUISelectableButton ___confirmButton, TMP_Text ___confirmButtonLabel, GameUISelectableButton ___cancelButton)
		{
			if (!JudgesScalesHandSelection.Active)
			{
				return true;
			}
			JudgesScalesHandSelection.ConfirmButton = ___confirmButton;
			JudgesScalesHandSelection.Hand = ___handUI;
			CardState cardState = cardUI.GetCardState();
			List<CardState> selected = JudgesScalesHandSelection.Selected;
			if (!selected.Remove(cardState))
			{
				selected.Add(cardState);
				if (((CoreInput)InputManager.Inst).currentInputModeUsesNavigation)
				{
					InputManager.Inst.SelectGameUIComponent((IGameUIComponent)(object)___confirmButton, true, false);
				}
			}
			JudgesScalesHandSelection.RefreshAllLooks();
			JudgesScalesHandSelection.RefreshButtons(___confirmButton, ___confirmButtonLabel, ___cancelButton);
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(HandSelectionUI), "UnSelectCard")]
	internal static class JudgesScalesUnselectAllPatch
	{
		private static void Prefix(GameUISelectableButton ___confirmButton, TMP_Text ___confirmButtonLabel, GameUISelectableButton ___cancelButton)
		{
			if (JudgesScalesHandSelection.Active && JudgesScalesHandSelection.Selected.Count != 0)
			{
				JudgesScalesHandSelection.Selected.Clear();
				JudgesScalesHandSelection.RefreshAllLooks();
				JudgesScalesHandSelection.RefreshButtons(___confirmButton, ___confirmButtonLabel, ___cancelButton);
			}
		}
	}
	[HarmonyPatch(typeof(HandSelectionUI), "Finish")]
	internal static class JudgesScalesFinishPatch
	{
		private static void Prefix(ref CardUI ___currentlySelectedCardUI, HandUI ___handUI)
		{
			if (JudgesScalesHandSelection.Active && JudgesScalesHandSelection.Selected.Count != 0)
			{
				___currentlySelectedCardUI = ((IEnumerable<CardUI>)___handUI.GetCardUIList()).FirstOrDefault((Func<CardUI, bool>)JudgesScalesHandSelection.IsSelected);
			}
		}
	}
	[HarmonyPatch(typeof(HandUI), "UpdateCardUIAtEndOfFrame")]
	internal static class JudgesScalesCardLookPatch
	{
		private static void Postfix(CardUI cardUI)
		{
			if (JudgesScalesHandSelection.Active)
			{
				JudgesScalesHandSelection.RefreshLook(cardUI);
			}
		}
	}
	[HarmonyPatch(typeof(HeroManager), "RemoveCharacter")]
	internal static class ReturnEquipmentOnEnemyDeathPatch
	{
		private static readonly MethodInfo CheckStandByConditions = AccessTools.Method(typeof(CardManager), "CheckStandByConditions", (Type[])null, (Type[])null);

		private static void Postfix(ref IEnumerator __result, CharacterState removeCharacter, CardManager ___cardManager, SaveManager ___saveManager)
		{
			if (!___saveManager.PreviewMode)
			{
				__result = Run(__result, removeCharacter, ___cardManager);
			}
		}

		private static IEnumerator Run(IEnumerator original, CharacterState character, CardManager cardManager)
		{
			yield return original;
			List<CardState> list = (from card in character.GetEquipment()
				where card.HasTrait<CardTraitReturnToHandEquipment>()
				select card).ToList();
			if (list.Count == 0)
			{
				yield break;
			}
			character.SetAllowDestroyedAccess(true);
			foreach (CardState item in list)
			{
				yield return (IEnumerator)CheckStandByConditions.Invoke(cardManager, new object[2] { null, item });
			}
			character.SetAllowDestroyedAccess(false);
		}
	}
	[HarmonyPatch(typeof(CustomLocalizationTermRegistry), "LoadData")]
	internal static class PierceCardTooltipPatch
	{
		private static void Prefix(CustomLocalizationTermRegistry __instance)
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			__instance.Register("StatusEffect_conductor_pierce_CardTooltipText", new LocalizationTerm
			{
				Key = "StatusEffect_conductor_pierce_CardTooltipText",
				English = "Attacks also hit one unit behind the attacked unit per stack."
			});
		}
	}
	[BepInPlugin("MyLittleRebalance", "MyLittleRebalance", "0.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger = new ManualLogSource("MyLittleRebalance");

		internal static ConfigEntry<string> SelectedCardTint = null;

		private FileSystemWatcher? configWatcher;

		private volatile bool configFileChanged;

		public void Awake()
		{
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			SelectedCardTint = ((BaseUnityPlugin)this).Config.Bind<string>("JudgesScales", "SelectedCardTint", "", "Colour of the cards picked for discard, as hex RRGGBB or RRGGBBAA (808080 is a mid grey). Empty: the grey the game uses for ineligible cards. A change applies at once, even while picking.");
			((BaseUnityPlugin)this).Config.SettingChanged += delegate
			{
				JudgesScalesHandSelection.Retint();
			};
			((BaseUnityPlugin)this).Config.ConfigReloaded += delegate
			{
				JudgesScalesHandSelection.Retint();
			};
			JudgesScalesHandSelection.Retint();
			configWatcher = new FileSystemWatcher(Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath), Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath))
			{
				NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite)
			};
			configWatcher.Changed += delegate
			{
				configFileChanged = true;
			};
			configWatcher.Created += delegate
			{
				configFileChanged = true;
			};
			configWatcher.Renamed += delegate
			{
				configFileChanged = true;
			};
			configWatcher.EnableRaisingEvents = true;
			string dir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			List<string> files = (from f in Directory.GetFiles(Path.Combine(dir, "json"), "*.json", SearchOption.AllDirectories)
				select Path.GetRelativePath(dir, f)).OrderBy<string, string>((string f) => f, StringComparer.Ordinal).ToList();
			Railhead.GetBuilder().Configure("MyLittleRebalance", (Action<IConfigurationBuilder>)delegate(IConfigurationBuilder c)
			{
				ConfigurationExtensions.AddMergedJsonFile(c, files);
			});
			new Harmony("MyLittleRebalance").PatchAll();
			Logger.LogInfo((object)"Plugin MyLittleRebalance is loaded!");
		}

		public void Update()
		{
			if (configFileChanged)
			{
				configFileChanged = false;
				try
				{
					((BaseUnityPlugin)this).Config.Reload();
				}
				catch (IOException)
				{
					configFileChanged = true;
				}
			}
			JudgesScalesHandSelection.KeepDiscardButtonSelected();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MyLittleRebalance";

		public const string PLUGIN_NAME = "MyLittleRebalance";

		public const string PLUGIN_VERSION = "0.1.1";
	}
}