Decompiled source of SequencedDropGameMode v1.1.0

BepInEx/plugins/lammas123.SequencedDropGameMode.dll

Decompiled 6 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.IL2CPP;
using BepInEx.IL2CPP.Utils;
using BepInEx.Logging;
using CrabDevKit.Utilities;
using CustomGameModes;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 SequencedDropGameMode
{
	public sealed class CustomGameModeSequencedDrop : CustomGameMode
	{
		internal enum DropPosition
		{
			Pos0 = 1,
			Pos1 = 11,
			Pos2 = 0,
			Pos3 = 10,
			Pos4 = 18,
			Pos5 = 7,
			Pos6 = 19,
			Pos7 = 8,
			Pos8 = 16,
			Pos9 = 5,
			Pos10 = 15,
			Pos11 = 4,
			Pos12 = 14,
			Pos13 = 3,
			Pos14 = 13,
			Pos15 = 2
		}

		internal struct InstructionDataDrop : IInstructionData
		{
			public DropPosition dropPosition;

			public float dropTime;

			public InstructionDataDrop(DropPosition dropPosition, float dropTime)
			{
				this.dropPosition = dropPosition;
				this.dropTime = dropTime;
			}
		}

		internal struct InstructionDataMultiDrop : IInstructionData
		{
			public DropPosition[] dropPositions;

			public float dropTime;

			public int dropCount;

			public float waitTime;

			public InstructionDataMultiDrop(DropPosition[] dropPositions, float dropTime, int dropCount, float waitTime)
			{
				this.dropPositions = dropPositions;
				this.dropTime = dropTime;
				this.dropCount = dropCount;
				this.waitTime = waitTime;
			}
		}

		internal struct InstructionDataWait : IInstructionData
		{
			public float waitTime;

			public InstructionDataWait(float waitTime)
			{
				this.waitTime = waitTime;
			}
		}

		internal interface IInstructionData
		{
		}

		internal enum InstructionType
		{
			Drop,
			MultiDrop,
			Wait
		}

		internal struct Instruction
		{
			public InstructionType instructionType;

			public IInstructionData instructionData;

			public Instruction(InstructionType instructionType, IInstructionData instructionData)
			{
				this.instructionType = instructionType;
				this.instructionData = instructionData;
			}
		}

		internal struct Sequence
		{
			public string name;

			public int height;

			public int minPlayers;

			public int maxPlayers;

			public Instruction[] instructions;

			public Sequence(string name, int height, int minPlayers, int maxPlayers, Instruction[] instructions)
			{
				this.name = name;
				this.height = height;
				this.minPlayers = minPlayers;
				this.maxPlayers = maxPlayers;
				this.instructions = instructions;
			}
		}

		[CompilerGenerated]
		private sealed class <ProcessSequences>d__33 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CustomGameModeSequencedDrop <>4__this;

			private Random <random>5__2;

			private int <currentHeight>5__3;

			private Sequence <currentSequence>5__4;

			private bool <flippedX>5__5;

			private bool <flippedY>5__6;

			private bool <rotated>5__7;

			private Instruction[] <>7__wrap7;

			private int <>7__wrap8;

			private InstructionDataMultiDrop <multiDrop>5__10;

			private int <dropped>5__11;

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

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

			[DebuggerHidden]
			public <ProcessSequences>d__33(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<random>5__2 = null;
				<currentSequence>5__4 = default(Sequence);
				<>7__wrap7 = null;
				<multiDrop>5__10 = default(InstructionDataMultiDrop);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Expected O, but got Unknown
				//IL_08af: Unknown result type (might be due to invalid IL or missing references)
				//IL_08b9: Expected I4, but got Unknown
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Expected O, but got Unknown
				//IL_085e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0868: Expected O, but got Unknown
				//IL_07e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_07f1: Expected O, but got Unknown
				//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0703: Expected O, but got Unknown
				int num = <>1__state;
				CustomGameModeSequencedDrop customGameModeSequencedDrop = <>4__this;
				float speedMultiplier;
				DropPosition[] dropPositions;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<random>5__2 = new Random();
					<currentHeight>5__3 = 0;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					customGameModeSequencedDrop.startTime = ((GameMode)BlockDrop).GetFreezeTime();
					goto IL_0884;
				case 2:
					<>1__state = -1;
					goto IL_0097;
				case 3:
					<>1__state = -1;
					goto IL_0713;
				case 4:
					<>1__state = -1;
					goto IL_0801;
				case 5:
					{
						<>1__state = -1;
						<currentSequence>5__4 = default(Sequence);
						goto IL_0884;
					}
					IL_0884:
					if (<currentHeight>5__3 > MaxHeight)
					{
						break;
					}
					goto IL_0097;
					IL_0097:
					if (customGameModeSequencedDrop.testing && customGameModeSequencedDrop.testingSequence == -1)
					{
						<>2__current = (object)new WaitForEndOfFrame();
						<>1__state = 2;
						return true;
					}
					<flippedX>5__5 = false;
					<flippedY>5__6 = false;
					<rotated>5__7 = false;
					if (customGameModeSequencedDrop.testing)
					{
						if (customGameModeSequencedDrop.testingSequence == -2)
						{
							<currentSequence>5__4 = new Sequence("Test", 1, -1, -1, new Instruction[31]
							{
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos0, 0.125f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(0.5f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos1, 0.25f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(1f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos2, 0.375f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(1.5f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos3, 0.5f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(2f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos4, 0.625f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(2.5f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos5, 0.75f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(3f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos6, 0.875f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(3.5f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos7, 1f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(4f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos8, 1.125f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(4.5f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos9, 1.25f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(5f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos10, 1.375f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(5.5f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos11, 1.5f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(6f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos12, 1.625f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(6.5f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos13, 1.75f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(7f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos14, 1.875f)),
								new Instruction(InstructionType.Wait, new InstructionDataWait(7.5f)),
								new Instruction(InstructionType.Drop, new InstructionDataDrop(DropPosition.Pos15, 2f))
							});
						}
						else
						{
							<currentSequence>5__4 = customGameModeSequencedDrop.sequences[customGameModeSequencedDrop.testingSequence];
						}
						customGameModeSequencedDrop.testingSequence = -1;
					}
					else
					{
						int playersAlive = MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.GetPlayersAlive();
						List<Sequence> list = new List<Sequence>();
						foreach (Sequence sequence in customGameModeSequencedDrop.sequences)
						{
							if ((sequence.minPlayers == -1 || sequence.minPlayers <= playersAlive) && (sequence.maxPlayers == -1 || sequence.maxPlayers >= playersAlive) && <currentHeight>5__3 + sequence.height <= MaxHeight)
							{
								list.Add(sequence);
							}
						}
						if (list.Count == 0)
						{
							foreach (Sequence sequence2 in customGameModeSequencedDrop.sequences)
							{
								if (<currentHeight>5__3 + sequence2.height <= 26)
								{
									list.Add(sequence2);
								}
							}
						}
						if (list.Count == 0)
						{
							break;
						}
						<currentSequence>5__4 = list[<random>5__2.Next(list.Count)];
						<flippedX>5__5 = <random>5__2.Next(2) == 1;
						<flippedY>5__6 = <random>5__2.Next(2) == 1;
						<rotated>5__7 = <random>5__2.Next(2) == 1;
					}
					MonoBehaviourPublicInInUnique.SendChatMessage(1uL, "Current Sequence: " + <currentSequence>5__4.name);
					<>7__wrap7 = <currentSequence>5__4.instructions;
					<>7__wrap8 = 0;
					goto IL_080f;
					IL_0801:
					<>7__wrap8++;
					goto IL_080f;
					IL_078c:
					if (<dropped>5__11 < <multiDrop>5__10.dropCount)
					{
						if (<dropped>5__11 != 0 && <multiDrop>5__10.waitTime > 0f)
						{
							<>2__current = (object)new WaitForSeconds(<multiDrop>5__10.waitTime * customGameModeSequencedDrop.GetSpeedMultiplier(((GameMode)BlockDrop).GetFreezeTime()));
							<>1__state = 3;
							return true;
						}
						goto IL_0713;
					}
					goto IL_0801;
					IL_0713:
					speedMultiplier = customGameModeSequencedDrop.GetSpeedMultiplier(((GameMode)BlockDrop).GetFreezeTime());
					dropPositions = <multiDrop>5__10.dropPositions;
					foreach (DropPosition dropPosition in dropPositions)
					{
						customGameModeSequencedDrop.Drop(customGameModeSequencedDrop.GetModifiedDropPosition(dropPosition, <flippedX>5__5, <flippedY>5__6, <rotated>5__7), <multiDrop>5__10.dropTime * speedMultiplier);
					}
					<dropped>5__11++;
					goto IL_078c;
					IL_080f:
					if (<>7__wrap8 < <>7__wrap7.Length)
					{
						Instruction instruction = <>7__wrap7[<>7__wrap8];
						switch (instruction.instructionType)
						{
						case InstructionType.Drop:
						{
							InstructionDataDrop instructionDataDrop = (InstructionDataDrop)(object)instruction.instructionData;
							customGameModeSequencedDrop.Drop(customGameModeSequencedDrop.GetModifiedDropPosition(instructionDataDrop.dropPosition, <flippedX>5__5, <flippedY>5__6, <rotated>5__7), instructionDataDrop.dropTime * customGameModeSequencedDrop.GetSpeedMultiplier(((GameMode)BlockDrop).GetFreezeTime()));
							goto IL_0801;
						}
						case InstructionType.MultiDrop:
							break;
						case InstructionType.Wait:
						{
							InstructionDataWait instructionDataWait = (InstructionDataWait)(object)instruction.instructionData;
							if (instructionDataWait.waitTime > 0f)
							{
								<>2__current = (object)new WaitForSeconds(instructionDataWait.waitTime * customGameModeSequencedDrop.GetSpeedMultiplier(((GameMode)BlockDrop).GetFreezeTime() - instructionDataWait.waitTime / 2f));
								<>1__state = 4;
								return true;
							}
							goto IL_0801;
						}
						default:
							goto IL_0801;
						}
						<multiDrop>5__10 = (InstructionDataMultiDrop)(object)instruction.instructionData;
						<dropped>5__11 = 0;
						goto IL_078c;
					}
					<>7__wrap7 = null;
					<currentHeight>5__3 += <currentSequence>5__4.height;
					<>2__current = (object)new WaitForSeconds(4f * customGameModeSequencedDrop.GetSpeedMultiplier(((GameMode)BlockDrop).GetFreezeTime() - 2f));
					<>1__state = 5;
					return true;
				}
				if (((GameMode)BlockDrop).GetFreezeTime() > 3f)
				{
					MonoBehaviourPublicInInUnique.SendGameModeTimer(3f, (int)((GameMode)BlockDrop).modeState);
				}
				MonoBehaviourPublicInInUnique.SendChatMessage(1uL, "Congratulations on making it to the top!");
				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();
			}
		}

		internal static CustomGameModeSequencedDrop Instance;

		internal static GameModePublicObSiInSiSiUnique BlockDrop;

		internal static readonly string SequencesPath = "SequencedDropSequences\\";

		internal static readonly int MaxHeight = 26;

		internal static readonly float MinSpeed = 0.8f;

		internal static readonly float MaxSpeed = 1.3f;

		internal static readonly float GoalSpeed = 1.5f;

		internal List<Sequence> sequences = new List<Sequence>();

		internal float startTime;

		internal bool testing;

		internal int testingSequence = -1;

		internal Harmony patches;

		public CustomGameModeSequencedDrop()
			: base("Sequenced Drop", "• The blocks will drop in a sequence\n\n• You must survive for the entire sequence\n\n• Be respectful, no pushing >=(", (EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique)17, (EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique)17, (string)null, true, (EnumNPublicSealedvaNoInMeFuScWi7vUnique)1, true, 0, int.MaxValue, 100, 130, 160, (IEnumerable<string>)new <>z__ReadOnlyArray<string>(new string[3] { "Cheeky Chamber", "Lava Drop", "Peaceful Platform" }), 4, 5, 9, 100)
		{
			Instance = this;
		}

		public override void PreInit()
		{
			startTime = 0f;
			testing = false;
			testingSequence = -1;
			patches = Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
			LoadSequences();
		}

		public override void PostEnd()
		{
			startTime = 0f;
			testing = false;
			testingSequence = -1;
			Harmony obj = patches;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			sequences.Clear();
		}

		private IEnumerable<string> ScrapeSequences(string directory)
		{
			return from path in Directory.EnumerateDirectories(directory, "*", SearchOption.AllDirectories)
				where path.EndsWith("\\SequencedDropSequences")
				select path;
		}

		internal void LoadSequences()
		{
			sequences.Clear();
			foreach (string item in ScrapeSequences(Paths.PluginPath))
			{
				string[] files = Directory.GetFiles(item, "*.txt", SearchOption.AllDirectories);
				for (int i = 0; i < files.Length; i++)
				{
					string[] array = File.ReadAllLines(files[i]);
					int num = -1;
					for (int j = 0; j < array.Length; j++)
					{
						if (array[j].Trim().ToLower() == "sequence:")
						{
							num = j;
							break;
						}
					}
					if (num == -1)
					{
						continue;
					}
					string name = "Unnamed";
					int height = 1;
					int minPlayers = -1;
					int maxPlayers = -1;
					for (int k = 0; k < num; k++)
					{
						string text = array[k].Trim();
						if (text == "" || text.StartsWith('#'))
						{
							continue;
						}
						int num2 = text.IndexOf('=');
						if (num2 == -1)
						{
							continue;
						}
						string text2 = text.Substring(0, num2).ToLower();
						string text3 = text;
						int num3 = num2 + 1;
						string text4 = text3.Substring(num3, text3.Length - num3);
						switch (text2)
						{
						case "name":
							name = text4;
							break;
						case "height":
						{
							if (int.TryParse(text4, out var result2))
							{
								height = Math.Max(1, result2);
							}
							break;
						}
						case "minplayers":
						{
							if (int.TryParse(text4, out var result3))
							{
								minPlayers = Math.Max(-1, result3);
							}
							break;
						}
						case "maxplayers":
						{
							if (int.TryParse(text4, out var result))
							{
								maxPlayers = Math.Max(-1, result);
							}
							break;
						}
						}
					}
					List<Instruction> list = new List<Instruction>();
					for (int l = num + 1; l < array.Length; l++)
					{
						string text5 = array[l].Trim().ToLower();
						if (text5 == "" || text5.StartsWith('#'))
						{
							continue;
						}
						int num4 = text5.IndexOf('=');
						if (num4 == -1)
						{
							continue;
						}
						string text6 = text5.Substring(0, num4);
						string text3 = text5;
						int num3 = num4 + 1;
						string text7 = text3.Substring(num3, text3.Length - num3).Replace(" ", "");
						switch (text6)
						{
						case "drop":
						{
							string[] array2 = text7.Split(',', StringSplitOptions.RemoveEmptyEntries);
							if (array2.Length > 1 && int.TryParse(array2[0], out var result5) && float.TryParse(array2[1], out var result6))
							{
								list.Add(new Instruction(InstructionType.Drop, new InstructionDataDrop(IndexToDropPosition(Math.Clamp(result5, 0, 15)), Math.Max(float.Epsilon, result6))));
							}
							break;
						}
						case "multidrop":
						{
							if (!text7.StartsWith('['))
							{
								break;
							}
							int num5 = text7.IndexOf(']');
							if (num5 == -1)
							{
								break;
							}
							string[] array3 = text7.Substring(1, num5 - 1).Split(',', StringSplitOptions.RemoveEmptyEntries);
							List<DropPosition> list2 = new List<DropPosition>();
							bool flag = false;
							string[] array4 = array3;
							for (num3 = 0; num3 < array4.Length; num3++)
							{
								if (!int.TryParse(array4[num3], out var result7))
								{
									flag = true;
									break;
								}
								list2.Add(IndexToDropPosition(Math.Clamp(result7, 0, 15)));
							}
							if (flag)
							{
								break;
							}
							text3 = text7;
							num3 = num5 + 1;
							string[] array5 = text3.Substring(num3, text3.Length - num3).Split(',', StringSplitOptions.RemoveEmptyEntries);
							if (array5.Length == 0 || !float.TryParse(array5[0], out var result8))
							{
								break;
							}
							int result9 = 1;
							if (array5.Length < 2 || int.TryParse(array5[1], out result9))
							{
								float result10 = 1f;
								if (array5.Length < 3 || float.TryParse(array5[2], out result10))
								{
									list.Add(new Instruction(InstructionType.MultiDrop, new InstructionDataMultiDrop(list2.ToArray(), Math.Max(float.Epsilon, result8), Math.Max(1, result9), Math.Max(float.Epsilon, result10))));
								}
							}
							break;
						}
						case "wait":
						{
							if (float.TryParse(text7, out var result4))
							{
								list.Add(new Instruction(InstructionType.Wait, new InstructionDataWait(Math.Max(float.Epsilon, result4))));
							}
							break;
						}
						}
					}
					sequences.Add(new Sequence(name, height, minPlayers, maxPlayers, list.ToArray()));
				}
			}
		}

		internal float GetSpeedMultiplier(float timeRemaining)
		{
			if (!testing)
			{
				return Math.Min(timeRemaining / startTime * (GoalSpeed - MinSpeed) + MinSpeed, MaxSpeed);
			}
			return 1f;
		}

		internal DropPosition IndexToDropPosition(int index)
		{
			return index switch
			{
				0 => DropPosition.Pos0, 
				1 => DropPosition.Pos1, 
				2 => DropPosition.Pos2, 
				3 => DropPosition.Pos3, 
				4 => DropPosition.Pos4, 
				5 => DropPosition.Pos5, 
				6 => DropPosition.Pos6, 
				7 => DropPosition.Pos7, 
				8 => DropPosition.Pos8, 
				9 => DropPosition.Pos9, 
				10 => DropPosition.Pos10, 
				11 => DropPosition.Pos11, 
				12 => DropPosition.Pos12, 
				13 => DropPosition.Pos13, 
				14 => DropPosition.Pos14, 
				15 => DropPosition.Pos15, 
				_ => DropPosition.Pos0, 
			};
		}

		internal int DropPositionToIndex(DropPosition dropPosition)
		{
			return dropPosition switch
			{
				DropPosition.Pos0 => 0, 
				DropPosition.Pos1 => 1, 
				DropPosition.Pos2 => 2, 
				DropPosition.Pos3 => 3, 
				DropPosition.Pos4 => 4, 
				DropPosition.Pos5 => 5, 
				DropPosition.Pos6 => 6, 
				DropPosition.Pos7 => 7, 
				DropPosition.Pos8 => 8, 
				DropPosition.Pos9 => 9, 
				DropPosition.Pos10 => 10, 
				DropPosition.Pos11 => 11, 
				DropPosition.Pos12 => 12, 
				DropPosition.Pos13 => 13, 
				DropPosition.Pos14 => 14, 
				DropPosition.Pos15 => 15, 
				_ => 0, 
			};
		}

		internal DropPosition GetModifiedDropPosition(DropPosition dropPosition, bool flippedX, bool flippedY, bool rotated)
		{
			int num = DropPositionToIndex(dropPosition);
			int num2 = ((!rotated) ? (flippedX ? (3 - num % 4) : (num % 4)) : (flippedY ? (3 - num / 4) : (num / 4)));
			int num3 = ((!rotated) ? (flippedY ? (3 - num / 4) : (num / 4)) : (flippedX ? (num % 4) : (3 - num % 4)));
			return IndexToDropPosition(num2 + num3 * 4);
		}

		internal void Drop(DropPosition dropPosition, float dropTime)
		{
			Enumerator<ulong, int> enumerator = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID.Keys.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ulong current = enumerator.Current;
				MonoBehaviourPublicInInUnique.SendBlockCrush(1f / dropTime, (int)dropPosition, current);
			}
		}

		internal void EnableTesting()
		{
			testing = true;
			MonoBehaviourPublicInInUnique.SendChatMessage(1uL, "Testing enabled.");
		}

		internal void PlayTestSequence()
		{
			testingSequence = -2;
			MonoBehaviourPublicInInUnique.SendChatMessage(1uL, "Playing the debug test sequence.");
		}

		internal void TestSequence(string name)
		{
			foreach (Sequence sequence in sequences)
			{
				if (sequence.name.ToLower().StartsWith(name))
				{
					testingSequence = sequences.IndexOf(sequence);
					MonoBehaviourPublicInInUnique.SendChatMessage(1uL, "Debugging: " + sequence.name);
					return;
				}
			}
			MonoBehaviourPublicInInUnique.SendChatMessage(1uL, "No sequence matched: " + name);
		}

		[IteratorStateMachine(typeof(<ProcessSequences>d__33))]
		internal IEnumerator ProcessSequences()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ProcessSequences>d__33(0)
			{
				<>4__this = this
			};
		}

		[HarmonyPatch(typeof(GameModePublicObSiInSiSiUnique), "InitMode")]
		[HarmonyPostfix]
		internal static void PostInitMode(GameModePublicObSiInSiSiUnique __instance)
		{
			BlockDrop = __instance;
		}

		[HarmonyPatch(typeof(GameModePublicObSiInSiSiUnique), "OnFreezeOver")]
		[HarmonyPrefix]
		internal static bool PreOnFreezeOver()
		{
			if (!MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
			{
				return false;
			}
			MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)MonoBehaviourPublicInwiheInblSiflInblGaUnique.Instance, Instance.ProcessSequences());
			Enumerator<ulong, MonoBehaviourPublicCSstReshTrheObplBojuUnique> enumerator = MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.Keys.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ulong current = enumerator.Current;
				MonoBehaviourPublicInInUnique.DropItem(current, 2, MonoBehaviourPublicDi2InObInObInUnique.Instance.GetNextId(), int.MaxValue);
				GiveUtil.GiveItem(current, 2, int.MaxValue);
			}
			return false;
		}

		[HarmonyPatch(typeof(GameModePublicObSiInSiSiUnique), "Method_Private_Void_4")]
		[HarmonyPrefix]
		internal static bool PreTryEndEarly()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected I4, but got Unknown
			if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner() && (int)((GameMode)BlockDrop).modeState == 1 && MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.GetPlayersAlive() <= 1 && ((GameMode)BlockDrop).GetFreezeTime() > 10f)
			{
				MonoBehaviourPublicInInUnique.SendGameModeTimer(10f, (int)((GameMode)BlockDrop).modeState);
			}
			return false;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "UseItem")]
		[HarmonyPrefix]
		internal static bool PreServerSendUseItem(int param_1)
		{
			return param_1 != 2;
		}
	}
	[BepInPlugin("lammas123.SequencedDropGameMode", "SequencedDropGameMode", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class SequencedDropGameMode : BasePlugin
	{
		public override void Load()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
			CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
			CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
			CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
			Api.RegisterCustomGameMode((CustomGameMode)(object)new CustomGameModeSequencedDrop());
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Initialized [");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("SequencedDropGameMode");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]");
			}
			log.LogInfo(val);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "lammas123.SequencedDropGameMode";

		public const string PLUGIN_NAME = "SequencedDropGameMode";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}