Decompiled source of FlappyBirdWalls v1.0.2

Mods/FlappyBirdWalls.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using FlappyBirdWalls;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.MoveSystem;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Pools;
using Il2CppRUMBLE.Poses;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RumbleModUI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Main), "FlappyBirdWalls", "1.0.2", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 6, true)]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FlappyBirdWalls")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+997adbb5f79932372d4ea437114d48c88653a6dc")]
[assembly: AssemblyProduct("FlappyBirdWalls")]
[assembly: AssemblyTitle("FlappyBirdWalls")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace FlappyBirdWalls
{
	[RegisterTypeInIl2Cpp]
	public class FlappyBird : MonoBehaviour
	{
		private class Bird
		{
			public bool isAlive = false;

			public int gameScore = 0;

			public float height = 0f;

			public float speedY = 0f;

			public Bird()
			{
				isAlive = true;
				gameScore = 0;
				height = 0f;
				speedY = 0f;
			}
		}

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

			private object <>2__current;

			public FlappyBird <>4__this;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<>4__this.bird.isAlive && <>4__this.gameStarted)
				{
					<>4__this.CheckPipes();
					<>4__this.MovePipes();
					<>4__this.MoveBird();
					<>4__this.UpdatePositions();
					<>2__current = (object)new WaitForFixedUpdate();
					<>1__state = 1;
					return true;
				}
				<>4__this.gameStarted = false;
				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();
			}
		}

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

			private object <>2__current;

			public GameObject structure;

			public FlappyBird <>4__this;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (structure.active)
				{
					<>2__current = (object)new WaitForFixedUpdate();
					<>1__state = 1;
					return true;
				}
				<>4__this.canvas.SetActive(false);
				<>4__this.bird.isAlive = false;
				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();
			}
		}

		private Bird bird = new Bird();

		private List<Vector2> pipes = new List<Vector2>
		{
			Vector2.zero,
			Vector2.zero
		};

		private Random random = new Random();

		private const int maxPipeHeight = 200;

		private const float halfScreenHeight = 400f;

		private const float halfScreenWidth = 250f;

		public bool gameStarted = false;

		private GameObject canvas;

		private GameObject birdMain;

		private GameObject birdUp;

		private GameObject birdFlat;

		private GameObject birdDown;

		private GameObject pipe1;

		private GameObject pipe2;

		private GameObject score1;

		private GameObject score2;

		private void Start()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			Object.Destroy((Object)(object)val.GetComponent<MeshRenderer>());
			((Object)val).name = "FlappyBirdTrigger";
			val.transform.parent = ((Component)this).gameObject.transform;
			val.transform.localPosition = new Vector3(0f, 0f, -0.22f);
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = new Vector3(1.1f, 1.9f, 0.01f);
			val.layer = 22;
			((Collider)val.GetComponent<BoxCollider>()).isTrigger = true;
			val.AddComponent<FlappyBirdStart>();
			canvas = Object.Instantiate<GameObject>(Main.ddolCanvas);
			score1 = ((Component)canvas.transform.GetChild(0).GetChild(0)).gameObject;
			score2 = ((Component)canvas.transform.GetChild(0).GetChild(1)).gameObject;
			pipe1 = ((Component)canvas.transform.GetChild(1).GetChild(0)).gameObject;
			pipe2 = ((Component)canvas.transform.GetChild(1).GetChild(1)).gameObject;
			birdMain = ((Component)canvas.transform.GetChild(2)).gameObject;
			birdUp = ((Component)canvas.transform.GetChild(2).GetChild(0)).gameObject;
			birdFlat = ((Component)canvas.transform.GetChild(2).GetChild(1)).gameObject;
			birdDown = ((Component)canvas.transform.GetChild(2).GetChild(2)).gameObject;
			canvas.transform.parent = ((Component)this).gameObject.transform;
			canvas.transform.localPosition = new Vector3(0f, 0f, -0.225f);
			canvas.transform.localRotation = Quaternion.identity;
			canvas.transform.localScale = new Vector3(0.0023f, 0.0023f, 0.0023f);
		}

		public void StartGame()
		{
			//IL_0035: 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)
			gameStarted = true;
			bird = new Bird();
			pipes = new List<Vector2>
			{
				new Vector2(275f, (float)random.Next(-200, 200)),
				new Vector2(575f, (float)random.Next(-200, 200))
			};
			canvas.SetActive(true);
			TextMeshProUGUI component = score1.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = "1";
			((TMP_Text)component).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component).fontSize = 64f;
			TextMeshProUGUI component2 = score2.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component2).text = "2";
			((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component2).fontSize = 64f;
			MelonCoroutines.Start(StopGameIfStructureDestroyed(((Component)((Component)this).gameObject.transform.parent).gameObject));
			MelonCoroutines.Start(GameLoop());
		}

		[IteratorStateMachine(typeof(<StopGameIfStructureDestroyed>d__19))]
		private IEnumerator StopGameIfStructureDestroyed(GameObject structure)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <StopGameIfStructureDestroyed>d__19(0)
			{
				<>4__this = this,
				structure = structure
			};
		}

		public void Jump()
		{
			if (bird.speedY < 5f)
			{
				bird.speedY = 0f;
			}
			bird.speedY += 5f;
		}

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

		private void UpdatePositions()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			birdMain.transform.localPosition = new Vector3(-125f, bird.height, 0f);
			pipe1.transform.localPosition = new Vector3(pipes[0].x, pipes[0].y, 0f);
			pipe2.transform.localPosition = new Vector3(pipes[1].x, pipes[1].y, 0f);
			score1.transform.parent = pipe1.transform;
			score1.transform.localPosition = Vector3.zero;
			score2.transform.parent = pipe2.transform;
			score2.transform.localPosition = Vector3.zero;
		}

		private void MoveBird()
		{
			bird.speedY -= 0.1f;
			bird.height += bird.speedY;
			if (Math.Abs(bird.speedY) < 1f)
			{
				if (!birdFlat.active)
				{
					birdFlat.SetActive(true);
					birdUp.SetActive(false);
					birdDown.SetActive(false);
				}
			}
			else if (0f < bird.speedY)
			{
				if (!birdUp.active)
				{
					birdUp.SetActive(true);
					birdFlat.SetActive(false);
					birdDown.SetActive(false);
				}
			}
			else if (bird.speedY < 0f && !birdDown.active)
			{
				birdDown.SetActive(true);
				birdUp.SetActive(false);
				birdFlat.SetActive(false);
			}
			if (bird.height < -400f)
			{
				bird.isAlive = false;
			}
			if (bird.height > 400f)
			{
				bird.isAlive = false;
			}
		}

		private void CheckPipes()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < pipes.Count; i++)
			{
				if (pipes[i].x < -300f)
				{
					pipes[i] = new Vector2(300f, (float)random.Next(-200, 200));
					TextMeshProUGUI component = ((Component)((i == 0) ? pipe1 : pipe2).transform.GetChild(0)).gameObject.GetComponent<TextMeshProUGUI>();
					((TMP_Text)component).text = (int.Parse(((TMP_Text)component).text) + 2).ToString();
				}
			}
		}

		private void MovePipes()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < pipes.Count; i++)
			{
				pipes[i] = new Vector2(pipes[i].x - 1f, pipes[i].y);
				if (Math.Abs(-125f - pipes[i].x) < 75f && 80f < Math.Abs(bird.height - pipes[i].y))
				{
					bird.isAlive = false;
				}
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class FlappyBirdStart : MonoBehaviour
	{
		private FlappyBird gameToStart;

		public FlappyBirdStart()
		{
			gameToStart = ((Component)((Component)this).gameObject.transform.parent).GetComponent<FlappyBird>();
		}

		private void OnTriggerEnter(Collider other)
		{
			if (Main.touchPlay && (!(((Object)((Component)other).gameObject).name != "Bone_HandAlpha_L") || !(((Object)((Component)other).gameObject).name != "Bone_HandAlpha_R")))
			{
				if (!gameToStart.gameStarted)
				{
					gameToStart.StartGame();
				}
				else
				{
					gameToStart.Jump();
				}
			}
		}
	}
	internal class BuildInfo
	{
		public const string ModName = "FlappyBirdWalls";

		public const string Author = "UlvakSkillz";

		public const string ModVersion = "1.0.2";
	}
	public class Main : MelonMod
	{
		[HarmonyPatch(typeof(Structure), "Start")]
		public static class StructureSpawn
		{
			private static void Postfix(ref Structure __instance)
			{
				try
				{
					if (((Object)((Component)__instance.processableComponent).gameObject).name != "Wall")
					{
						return;
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Msg((object)ex);
					return;
				}
				((Component)((Component)__instance.processableComponent).gameObject.transform.GetChild(0)).gameObject.AddComponent<FlappyBird>();
			}
		}

		[HarmonyPatch(typeof(PlayerPoseSystem), "OnPoseSetCompleted", new Type[] { typeof(PoseSet) })]
		private static class PosePatch
		{
			private static void Postfix(PoseSet set)
			{
				if (!kickPlay || !(((Object)set).name == "PoseSetKick"))
				{
					return;
				}
				GameObject val = SelectStructure(((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform.GetChild(1).GetChild(0).GetChild(0));
				if (!((Object)(object)val == (Object)null) && !(((Object)val).name != "Wall"))
				{
					FlappyBird component = ((Component)val.transform.GetChild(0)).GetComponent<FlappyBird>();
					if (!component.gameStarted)
					{
						component.StartGame();
					}
					else
					{
						component.Jump();
					}
				}
			}
		}

		public static GameObject ddolCanvas;

		private Mod FlappyBirdWalls = new Mod();

		public static bool touchPlay = true;

		public static bool kickPlay = true;

		private static List<PooledMonoBehaviour> pooledStructuresWall;

		private static List<PooledMonoBehaviour> pooledStructuresCube;

		private static List<PooledMonoBehaviour> pooledStructuresPillar;

		private static List<PooledMonoBehaviour> pooledStructuresBall;

		private static List<PooledMonoBehaviour> pooledStructuresDisc;

		private static List<PooledMonoBehaviour> pooledStructuresBoulder;

		private static List<PooledMonoBehaviour> pooledStructuresSmallRock;

		private static List<PooledMonoBehaviour> pooledStructuresTetherBall;

		public static GameObject SelectStructure(Transform playerPos)
		{
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_0583: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			List<GameObject> list = new List<GameObject>();
			List<GameObject> list2 = new List<GameObject>();
			List<float> list3 = new List<float>();
			List<PooledMonoBehaviour> val = new List<PooledMonoBehaviour>();
			for (int i = 0; i < pooledStructuresWall.Count; i++)
			{
				if (((Component)((Component)pooledStructuresWall[i]).transform).gameObject.active)
				{
					val.Add(pooledStructuresWall[i]);
				}
			}
			for (int j = 0; j < pooledStructuresCube.Count; j++)
			{
				if (((Component)((Component)pooledStructuresCube[j]).transform).gameObject.active)
				{
					val.Add(pooledStructuresCube[j]);
				}
			}
			for (int k = 0; k < pooledStructuresPillar.Count; k++)
			{
				if (((Component)((Component)pooledStructuresPillar[k]).transform).gameObject.active)
				{
					val.Add(pooledStructuresPillar[k]);
				}
			}
			for (int l = 0; l < pooledStructuresBall.Count; l++)
			{
				if (((Component)((Component)pooledStructuresBall[l]).transform).gameObject.active)
				{
					val.Add(pooledStructuresBall[l]);
				}
			}
			for (int m = 0; m < pooledStructuresDisc.Count; m++)
			{
				if (((Component)((Component)pooledStructuresDisc[m]).transform).gameObject.active)
				{
					val.Add(pooledStructuresDisc[m]);
				}
			}
			for (int n = 0; n < pooledStructuresBoulder.Count; n++)
			{
				if (((Component)((Component)pooledStructuresBoulder[n]).transform).gameObject.active)
				{
					val.Add(pooledStructuresBoulder[n]);
				}
			}
			for (int num = 0; num < pooledStructuresSmallRock.Count; num++)
			{
				if (((Component)((Component)pooledStructuresSmallRock[num]).transform).gameObject.active)
				{
					val.Add(pooledStructuresSmallRock[num]);
				}
			}
			for (int num2 = 0; num2 < pooledStructuresTetherBall.Count; num2++)
			{
				if (((Component)((Component)pooledStructuresTetherBall[num2]).transform).gameObject.active)
				{
					val.Add(pooledStructuresTetherBall[num2]);
				}
			}
			Vector2 val3 = default(Vector2);
			Vector2 val4 = default(Vector2);
			for (int num3 = 0; num3 < val.Count; num3++)
			{
				GameObject gameObject = ((Component)((Component)val[num3]).transform).gameObject;
				float item = Vector2.Distance(Vector2.op_Implicit(gameObject.transform.position), Vector2.op_Implicit(playerPos.position));
				float num4 = Vector2.Distance(new Vector2(0f, gameObject.transform.position.y), new Vector2(0f, playerPos.position.y));
				if (!(Vector2.Distance(new Vector2(gameObject.transform.position.x, gameObject.transform.position.z), new Vector2(((Component)playerPos).transform.position.x, ((Component)playerPos).transform.position.z)) < 2.5f) || !(num4 < 2.5f))
				{
					continue;
				}
				Vector3 val2 = playerPos.forward;
				float x = ((Vector3)(ref val2)).normalized.x;
				val2 = playerPos.forward;
				((Vector2)(ref val3))..ctor(x, ((Vector3)(ref val2)).normalized.z);
				val2 = gameObject.transform.position - playerPos.position;
				float x2 = ((Vector3)(ref val2)).normalized.x;
				val2 = gameObject.transform.position - playerPos.position;
				((Vector2)(ref val4))..ctor(x2, ((Vector3)(ref val2)).normalized.z);
				float num5 = Vector2.Dot(val3, val4);
				float num6 = Mathf.Acos(num5) * 57.29578f;
				if (num6 <= 90f)
				{
					list.Add(gameObject);
					if (num6 <= 30f)
					{
						list2.Add(gameObject);
						list3.Add(item);
					}
				}
			}
			if (list.Count > 0)
			{
				if (list2.Count > 0)
				{
					int index = -1;
					float num7 = 2.6f;
					for (int num8 = 0; num8 < list2.Count; num8++)
					{
						if (list3[num8] < num7)
						{
							index = num8;
							num7 = list3[num8];
						}
					}
					return list2[index];
				}
				int index2 = -1;
				float num9 = 2.6f;
				for (int num10 = 0; num10 < list.Count; num10++)
				{
					float num11 = Vector2.Distance(new Vector2(list[num10].transform.position.x, list[num10].transform.position.z), new Vector2(((Component)playerPos).transform.position.x, ((Component)playerPos).transform.position.z));
					if (num11 < num9)
					{
						index2 = num10;
						num9 = num11;
					}
				}
				return list[index2];
			}
			return null;
		}

		public override void OnLateInitializeMelon()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			ddolCanvas = LoadAssetBundle("FlappyBirdWalls.flappybird", "Canvas");
			((Object)ddolCanvas).name = "Flappy Bird Canvas";
			ddolCanvas.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)ddolCanvas);
			FlappyBirdWalls.ModName = "FlappyBirdWalls";
			FlappyBirdWalls.ModVersion = "1.0.2";
			FlappyBirdWalls.SetFolder("FlappyBirdWalls");
			FlappyBirdWalls.AddToList("Touch Play", true, 0, "Toggles Touching the Wall to Play", new Tags());
			FlappyBirdWalls.AddToList("Kick Play", true, 0, "Toggles Kicking the Wall to Play", new Tags());
			FlappyBirdWalls.GetFromFile();
			UI.instance.UI_Initialized += UIInit;
			FlappyBirdWalls.ModSaved += Save;
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Loader")
			{
				pooledStructuresWall = ((Il2CppArrayBase<Pool<PooledMonoBehaviour>>)(object)Singleton<PoolManager>.instance.availablePools)[Singleton<PoolManager>.instance.GetPoolIndex("Wall")].PooledObjects;
				pooledStructuresCube = ((Il2CppArrayBase<Pool<PooledMonoBehaviour>>)(object)Singleton<PoolManager>.instance.availablePools)[Singleton<PoolManager>.instance.GetPoolIndex("RockCube")].PooledObjects;
				pooledStructuresPillar = ((Il2CppArrayBase<Pool<PooledMonoBehaviour>>)(object)Singleton<PoolManager>.instance.availablePools)[Singleton<PoolManager>.instance.GetPoolIndex("Pillar")].PooledObjects;
				pooledStructuresBall = ((Il2CppArrayBase<Pool<PooledMonoBehaviour>>)(object)Singleton<PoolManager>.instance.availablePools)[Singleton<PoolManager>.instance.GetPoolIndex("Ball")].PooledObjects;
				pooledStructuresDisc = ((Il2CppArrayBase<Pool<PooledMonoBehaviour>>)(object)Singleton<PoolManager>.instance.availablePools)[Singleton<PoolManager>.instance.GetPoolIndex("Disc")].PooledObjects;
				pooledStructuresBoulder = ((Il2CppArrayBase<Pool<PooledMonoBehaviour>>)(object)Singleton<PoolManager>.instance.availablePools)[Singleton<PoolManager>.instance.GetPoolIndex("LargeRock")].PooledObjects;
				pooledStructuresSmallRock = ((Il2CppArrayBase<Pool<PooledMonoBehaviour>>)(object)Singleton<PoolManager>.instance.availablePools)[Singleton<PoolManager>.instance.GetPoolIndex("SmallRock")].PooledObjects;
				pooledStructuresTetherBall = ((Il2CppArrayBase<Pool<PooledMonoBehaviour>>)(object)Singleton<PoolManager>.instance.availablePools)[Singleton<PoolManager>.instance.GetPoolIndex("BoulderBall")].PooledObjects;
			}
		}

		private void UIInit()
		{
			UI.instance.AddMod(FlappyBirdWalls);
		}

		private void Save()
		{
			touchPlay = (bool)FlappyBirdWalls.Settings[0].SavedValue;
			kickPlay = (bool)FlappyBirdWalls.Settings[1].SavedValue;
		}

		public GameObject LoadAssetBundle(string bundleName, string objectName)
		{
			using Stream stream = ((MelonBase)this).MelonAssembly.Assembly.GetManifestResourceStream(bundleName);
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Il2CppAssetBundle val = Il2CppAssetBundleManager.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(array));
			return Object.Instantiate<GameObject>(val.LoadAsset<GameObject>(objectName));
		}
	}
}