Decompiled source of DreamStartOfTurn v0.0.1

DreamStartOfTurnMod_Windows.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AddWatermark;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using LBoL.Core;
using LBoL.Core.Battle;
using LBoL.Core.Battle.BattleActions;
using LBoL.Core.Battle.Interactions;
using LBoL.Core.Cards;
using LbolDreamStartOfTurnMod.BattleActions;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("DreamStartOfTurnMod_Windows")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DreamStartOfTurnMod_Windows")]
[assembly: AssemblyTitle("DreamStartOfTurnMod_Windows")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace LbolDreamStartOfTurnMod
{
	[BepInPlugin("rokk.lbol.gameplay.DreamStartOfTurn", "DreamStartOfTurn", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("LBoL.exe")]
	public class BepinexPlugin : BaseUnityPlugin
	{
		public static string modUniqueID = "DreamStartOfTurnMod";

		private static readonly Harmony harmony = PInfo.harmony;

		internal static ManualLogSource log;

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			log.LogInfo((object)"Patching harmony for LbolDreamStartOfTurnMod");
			harmony.PatchAll();
			log.LogInfo((object)"Harmony patched for LbolDreamStartOfTurnMod");
			if (Chainloader.PluginInfos.ContainsKey("neo.lbol.tools.watermark"))
			{
				WatermarkWrapper.ActivateWatermark();
			}
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public static class PInfo
	{
		public const string GUID = "rokk.lbol.gameplay.DreamStartOfTurn";

		public const string Name = "DreamStartOfTurn";

		public const string version = "0.0.1";

		public static readonly Harmony harmony = new Harmony("rokk.lbol.gameplay.DreamStartOfTurn");
	}
	internal class WatermarkWrapper
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void ActivateWatermark()
		{
			API.ActivateWatermark();
		}
	}
}
namespace LbolDreamStartOfTurnMod.Patches
{
	[HarmonyPatch(typeof(BattleController), "StartPlayerTurn")]
	internal class BattleControllerPatches
	{
		private static void Postfix(BattleController __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			__instance.React(new Reactor((BattleAction)(object)new DreamToHandStartOfTurnAction()), (GameEntity)null, (ActionCause)12);
		}
	}
}
namespace LbolDreamStartOfTurnMod.BattleActions
{
	public sealed class DreamToHandStartOfTurnAction : SimpleAction
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass0_0
		{
			public SelectCardInteraction interaction;

			public IReadOnlyList<Card> selected;

			public DreamToHandStartOfTurnAction <>4__this;

			internal void <GetPhases>b__1()
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Expected O, but got Unknown
				((BattleAction)<>4__this).React(Reactor.op_Implicit((BattleAction)new InteractionAction((Interaction)(object)interaction, false)), (GameEntity)null, (ActionCause?)null);
			}

			internal void <GetPhases>b__2()
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				foreach (Card item in selected)
				{
					((BattleAction)<>4__this).React(Reactor.op_Implicit((BattleAction)new MoveCardAction(item, (CardZone)2)), (GameEntity)null, (ActionCause?)null);
				}
			}
		}

		[CompilerGenerated]
		private sealed class <GetPhases>d__0 : IEnumerable<Phase>, IEnumerable, IEnumerator<Phase>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private Phase <>2__current;

			private int <>l__initialThreadId;

			public DreamToHandStartOfTurnAction <>4__this;

			private List<Card> <list>5__1;

			private <>c__DisplayClass0_0 <>8__2;

			Phase IEnumerator<Phase>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GetPhases>d__0(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<list>5__1 = null;
				<>8__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					BepinexPlugin.log.LogInfo((object)"GetPhases called");
					<list>5__1 = (from card in ((BattleAction)<>4__this).Battle.DrawZone.Union(((BattleAction)<>4__this).Battle.DiscardZone)
						where card.IsDreamCard
						select card).ToList();
					BepinexPlugin.log.LogInfo((object)("GetPhases dream card count: " + <list>5__1.Count));
					if (<list>5__1.Count > 0)
					{
						<>8__2 = new <>c__DisplayClass0_0();
						<>8__2.<>4__this = <>4__this;
						<>8__2.interaction = new SelectCardInteraction(0, 1, (IEnumerable<Card>)<list>5__1, (SelectedCardHandling)0)
						{
							Description = LocalizationExtensions.Localize("SelectCard.DreamCardsToHand", true)
						};
						<>2__current = ((BattleAction)<>4__this).CreatePhase("Select", (Action)delegate
						{
							//IL_000e: Unknown result type (might be due to invalid IL or missing references)
							//IL_0018: Expected O, but got Unknown
							((BattleAction)<>8__2.<>4__this).React(Reactor.op_Implicit((BattleAction)new InteractionAction((Interaction)(object)<>8__2.interaction, false)), (GameEntity)null, (ActionCause?)null);
						}, false);
						<>1__state = 1;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					<>8__2.selected = <>8__2.interaction.SelectedCards;
					if (<>8__2.selected.Count > 0)
					{
						<>2__current = ((BattleAction)<>4__this).CreatePhase("MoveToHand", (Action)delegate
						{
							//IL_0020: Unknown result type (might be due to invalid IL or missing references)
							//IL_002a: Expected O, but got Unknown
							foreach (Card item in <>8__2.selected)
							{
								((BattleAction)<>8__2.<>4__this).React(Reactor.op_Implicit((BattleAction)new MoveCardAction(item, (CardZone)2)), (GameEntity)null, (ActionCause?)null);
							}
						}, false);
						<>1__state = 2;
						return true;
					}
					goto IL_01be;
				case 2:
					{
						<>1__state = -1;
						goto IL_01be;
					}
					IL_01be:
					<>8__2 = null;
					break;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<Phase> IEnumerable<Phase>.GetEnumerator()
			{
				<GetPhases>d__0 result;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					result = this;
				}
				else
				{
					result = new <GetPhases>d__0(0)
					{
						<>4__this = <>4__this
					};
				}
				return result;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<Phase>)this).GetEnumerator();
			}
		}

		[IteratorStateMachine(typeof(<GetPhases>d__0))]
		public override IEnumerable<Phase> GetPhases()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetPhases>d__0(-2)
			{
				<>4__this = this
			};
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}