Decompiled source of MyOrbs v0.1.0

plugins/MyOrbs/MyOrbs.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 System.Security;
using System.Security.Permissions;
using BepInEx;
using ExitGames.Client.Photon;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;

[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("")]
[assembly: AssemblyCompany("feedmore")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MyOrbs")]
[assembly: AssemblyTitle("MyOrbs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.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;
		}
	}
	[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;
		}
	}
}
[HarmonyPatch(typeof(ItemBattery), "ChargeBattery")]
public static class ChargingStationPatch
{
	public static void Prefix(ItemBattery __instance, ref float __1)
	{
		if ((Object)(object)((Component)__instance).GetComponent<PinkHandgun>() != (Object)null || (Object)(object)((Component)__instance).GetComponent<PinkFryingPan>() != (Object)null || (Object)(object)((Component)__instance).GetComponent<PinkCartCannon>() != (Object)null || (Object)(object)((Component)__instance).GetComponent<PinkCartLaser>() != (Object)null)
		{
			__1 *= 1.2f;
		}
		else if ((Object)(object)((Component)__instance).GetComponent<BlueHandgun>() != (Object)null || (Object)(object)((Component)__instance).GetComponent<BlueFryingPan>() != (Object)null || (Object)(object)((Component)__instance).GetComponent<BlueCartCannon>() != (Object)null || (Object)(object)((Component)__instance).GetComponent<BlueCartLaser>() != (Object)null)
		{
			__1 *= 1.1f;
		}
	}
}
public class EnemyDeathHandler : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <ReplaceOrbCoroutine>d__5 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public EnemyDeathHandler <>4__this;

		private GameObject <orbToDestroy>5__1;

		private float <closestDist>5__2;

		private string <visualBoneName>5__3;

		private Transform <visualRoot>5__4;

		private Vector3 <enemyPos>5__5;

		private string <orbToSpawn>5__6;

		private Vector3 <spawnPos>5__7;

		private GameObject <orb>5__8;

		private EnemyWatcher.EnemyType <>s__9;

		private GameObject[] <>s__10;

		private int <>s__11;

		private GameObject <obj>5__12;

		private float <dist>5__13;

		private EnemyWatcher.EnemyType <>s__14;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<orbToDestroy>5__1 = null;
			<visualBoneName>5__3 = null;
			<visualRoot>5__4 = null;
			<orbToSpawn>5__6 = null;
			<orb>5__8 = null;
			<>s__10 = null;
			<obj>5__12 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: 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_03be: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.2f);
				<>1__state = 1;
				return true;
			case 1:
			{
				<>1__state = -1;
				<orbToDestroy>5__1 = null;
				<closestDist>5__2 = float.MaxValue;
				<>s__9 = <>4__this.enemyType;
				if (1 == 0)
				{
				}
				string text = <>s__9 switch
				{
					EnemyWatcher.EnemyType.DuckBlue => "ANIM ROT BOT", 
					EnemyWatcher.EnemyType.DuckPink => "ANIM ROT BOT", 
					EnemyWatcher.EnemyType.BabyBlue => "ANIM BOT", 
					EnemyWatcher.EnemyType.BabyPink => "ANIM BOT", 
					EnemyWatcher.EnemyType.RobeBlue => "Main Animation", 
					EnemyWatcher.EnemyType.RobePink => "Main Animation", 
					_ => "ANIM ROT BOT", 
				};
				if (1 == 0)
				{
				}
				<visualBoneName>5__3 = text;
				<visualRoot>5__4 = ((Component)<>4__this).transform.FindDeepChild(<visualBoneName>5__3);
				<enemyPos>5__5 = (((Object)(object)<visualRoot>5__4 != (Object)null) ? <visualRoot>5__4.position : ((Component)<>4__this).transform.position);
				<>s__10 = Object.FindObjectsOfType<GameObject>();
				for (<>s__11 = 0; <>s__11 < <>s__10.Length; <>s__11++)
				{
					<obj>5__12 = <>s__10[<>s__11];
					if (((Object)<obj>5__12).name.StartsWith("Enemy Valuable") && (Object)(object)<obj>5__12.GetComponent<PhotonView>() != (Object)null)
					{
						<dist>5__13 = Vector3.Distance(<obj>5__12.transform.position, <enemyPos>5__5);
						if (<dist>5__13 < <closestDist>5__2)
						{
							<closestDist>5__2 = <dist>5__13;
							<orbToDestroy>5__1 = <obj>5__12;
						}
					}
					<obj>5__12 = null;
				}
				<>s__10 = null;
				if ((Object)(object)<orbToDestroy>5__1 != (Object)null)
				{
					Debug.Log((object)$">>> Destroying closest default orb at {<orbToDestroy>5__1.transform.position} (distance {<closestDist>5__2})");
					PhotonNetwork.Destroy(<orbToDestroy>5__1);
				}
				else
				{
					Debug.LogWarning((object)">>> No suitable orb found to destroy");
				}
				<>s__14 = <>4__this.enemyType;
				if (1 == 0)
				{
				}
				text = <>s__14 switch
				{
					EnemyWatcher.EnemyType.DuckBlue => "BlueOrbSmall", 
					EnemyWatcher.EnemyType.DuckPink => "PinkOrbSmall", 
					EnemyWatcher.EnemyType.BabyBlue => "BlueOrbMedium", 
					EnemyWatcher.EnemyType.BabyPink => "PinkOrbMedium", 
					EnemyWatcher.EnemyType.RobeBlue => "BlueOrbBig", 
					EnemyWatcher.EnemyType.RobePink => "PinkOrbBig", 
					_ => null, 
				};
				if (1 == 0)
				{
				}
				<orbToSpawn>5__6 = text;
				if (<orbToSpawn>5__6 == null)
				{
					Debug.LogWarning((object)(">>> No orb configured for duck type: " + <>4__this.enemyType));
					return false;
				}
				Transform obj = <visualRoot>5__4;
				<spawnPos>5__7 = ((obj != null) ? obj.position : ((Component)<>4__this).transform.position) + Vector3.up * 0.4f;
				Vector3 val = <spawnPos>5__7;
				Debug.Log((object)(">>> Using spawn position: " + ((object)(Vector3)(ref val)).ToString()));
				Debug.Log((object)(">>> Orb prefab to spawn: " + <orbToSpawn>5__6));
				<orb>5__8 = NetworkPrefabs.SpawnNetworkPrefab(<orbToSpawn>5__6, <spawnPos>5__7, Quaternion.identity, (byte)0, (object[])null);
				if ((Object)(object)<orb>5__8 != (Object)null)
				{
					Debug.Log((object)$">>> Spawned {<orbToSpawn>5__6} at {<spawnPos>5__7}");
				}
				else
				{
					Debug.LogError((object)(">>> Failed to spawn orb: " + <orbToSpawn>5__6));
				}
				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 <WaitForEnemyHealth>d__4 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public EnemyDeathHandler <>4__this;

		private float <timeout>5__1;

		private float <elapsed>5__2;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<timeout>5__1 = 5f;
				<elapsed>5__2 = 0f;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (<elapsed>5__2 < <timeout>5__1)
			{
				<>4__this.health = ((Component)<>4__this).GetComponentInChildren<EnemyHealth>();
				if ((Object)(object)<>4__this.health != (Object)null)
				{
					<>4__this.health.onDeath.AddListener(new UnityAction(<>4__this.OnEnemyDeath));
					Debug.Log((object)(">>> DeathHandler: Subscribed to onDeath for type: " + <>4__this.enemyType));
					return false;
				}
				<elapsed>5__2 += Time.deltaTime;
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			Debug.LogWarning((object)">>> DeathHandler: No EnemyHealth found after waiting.");
			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();
		}
	}

	public EnemyWatcher.EnemyType enemyType;

	private EnemyHealth? health;

	private void Start()
	{
		((MonoBehaviour)this).StartCoroutine(WaitForEnemyHealth());
	}

	private void OnEnemyDeath()
	{
		if (PhotonNetwork.IsMasterClient)
		{
			Debug.Log((object)">>> OnDeath triggered");
			Debug.Log((object)(">>> DeathHandler triggered for type: " + enemyType));
			health.spawnValuable = false;
			((MonoBehaviour)this).StartCoroutine(ReplaceOrbCoroutine());
		}
	}

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

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

	private void OnDestroy()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		if ((Object)(object)health != (Object)null)
		{
			health.onDeath.RemoveListener(new UnityAction(OnEnemyDeath));
		}
	}
}
[HarmonyPatch(typeof(EnemyDirector), "AmountSetup")]
public static class EnemySpawnPatch
{
	[HarmonyPrefix]
	public static bool Prefix(EnemyDirector __instance)
	{
		if (!PhotonNetwork.IsMasterClient)
		{
			return true;
		}
		int num = 7;
		int num2 = 7;
		int num3 = 7;
		int additionalEnemies = SavedUpgradesManager.state.additionalEnemies;
		for (int i = 0; i < additionalEnemies; i++)
		{
			float value = Random.value;
			if (value <= 0.35f)
			{
				num++;
			}
			else if (value <= 0.7f)
			{
				num2++;
			}
			else
			{
				num3++;
			}
		}
		List<EnemySetup> enemiesDifficulty = __instance.enemiesDifficulty1;
		List<EnemySetup> enemiesDifficulty2 = __instance.enemiesDifficulty2;
		List<EnemySetup> enemiesDifficulty3 = __instance.enemiesDifficulty3;
		FieldInfo field = typeof(EnemyDirector).GetField("enemyList", BindingFlags.Instance | BindingFlags.NonPublic);
		List<EnemySetup> list = (List<EnemySetup>)field.GetValue(__instance);
		list.Clear();
		for (int j = 0; j < num; j++)
		{
			list.Add(enemiesDifficulty[Random.Range(0, enemiesDifficulty.Count)]);
		}
		for (int k = 0; k < num2; k++)
		{
			list.Add(enemiesDifficulty2[Random.Range(0, enemiesDifficulty2.Count)]);
		}
		for (int l = 0; l < num3; l++)
		{
			float value2 = Random.value;
			EnemySetup item;
			if (value2 <= 0.15f)
			{
				List<EnemySetup> list2 = enemiesDifficulty3.Where((EnemySetup e) => ((Object)e).name.Contains("Group")).ToList();
				item = ((list2.Count > 0) ? list2[Random.Range(0, list2.Count)] : enemiesDifficulty3[Random.Range(0, enemiesDifficulty3.Count)]);
			}
			else
			{
				List<EnemySetup> list3 = enemiesDifficulty3.Where((EnemySetup e) => !((Object)e).name.Contains("Group")).ToList();
				item = ((list3.Count > 0) ? list3[Random.Range(0, list3.Count)] : enemiesDifficulty3[Random.Range(0, enemiesDifficulty3.Count)]);
			}
			list.Add(item);
		}
		__instance.totalAmount = num + num2 + num3;
		Debug.Log((object)$">>> EnemySpawnPatch: Final counts - T1: {num}, T2: {num2}, T3: {num3} (Total: {__instance.totalAmount})");
		return false;
	}
}
public class EnemyWatcher : MonoBehaviour
{
	public enum EnemyType
	{
		DuckBlue,
		DuckPink,
		BabyBlue,
		BabyPink,
		RobeBlue,
		RobePink
	}

	private readonly HashSet<GameObject> knownDucks = new HashSet<GameObject>();

	private readonly HashSet<GameObject> knownBabies = new HashSet<GameObject>();

	private readonly HashSet<GameObject> knownRobes = new HashSet<GameObject>();

	private Transform? EnemyParent;

	private const byte ShopPriceUpdateEventCode = 43;

	private const byte DuckUpgradeEventCode = 42;

	private const byte BabyUpgradeEventCode = 45;

	private const byte RobeUpgradeEventCode = 46;

	public const byte OrbValueUpdateEventCode = 44;

	private static readonly string[] meshDuckNamesToReplace = new string[10] { "mesh Wing R", "mesh Wing L", "mesh Head", "mesh Body", "mesh Mon Body", "mesh Mon Wing L", "mesh Mon Wing R", "mesh Mon Head", "mesh Mon Beak top", "mesh Mon Beak Bot" };

	private static readonly string[] meshBabyNamesToReplace = new string[13]
	{
		"mesh body", "mesh arm r straight", "mesh arm r bent", "mesh arm l straight", "mesh arm l bent", "mesh head", "mesh eye", "mesh_eyes_top", "mesh eyes_bot", "mesh leg r straight",
		"mesh leg r bent", "mesh leg l bent", "mesh leg l straight"
	};

	private void OnEnable()
	{
		PhotonNetwork.NetworkingClient.EventReceived += OnPhotonEvent;
	}

	private void OnDisable()
	{
		PhotonNetwork.NetworkingClient.EventReceived -= OnPhotonEvent;
	}

	private void Update()
	{
		if ((Object)(object)EnemyParent == (Object)null)
		{
			GameObject val = GameObject.Find("Level Generator");
			if ((Object)(object)val != (Object)null)
			{
				Transform val2 = val.transform.Find("Enemies");
				if ((Object)(object)val2 != (Object)null)
				{
					EnemyParent = val2;
					Debug.Log((object)">>> EnemyWatcher found Enemies under Level Generator");
				}
			}
			return;
		}
		for (int i = 0; i < EnemyParent.childCount; i++)
		{
			Transform child = EnemyParent.GetChild(i);
			string name = ((Object)child).name;
			if (name.StartsWith("Enemy - Duck") && !knownDucks.Contains(((Component)child).gameObject))
			{
				((Object)child).name = "Enemy - DuckVerified";
				knownDucks.Add(((Component)child).gameObject);
				Debug.Log((object)">>> A duck is on this level!");
				if (PhotonNetwork.IsMasterClient)
				{
					float num = Random.Range(0f, 1f);
					Debug.Log((object)(">>> Duck roll was " + num));
					if (num <= 0.2f)
					{
						RaiseDuckUpgradeEvent(i, EnemyType.DuckPink);
						Debug.Log((object)$">>> Sent PinkDuck upgrade for duck index {i}");
					}
					else if (num <= 0.5f)
					{
						RaiseDuckUpgradeEvent(i, EnemyType.DuckBlue);
						Debug.Log((object)$">>> Sent BlueDuck upgrade for duck index {i}");
					}
				}
			}
			else if (name.StartsWith("Enemy - Valuable Thrower") && !knownBabies.Contains(((Component)child).gameObject))
			{
				((Object)child).name = "Enemy - BabyVerified";
				knownBabies.Add(((Component)child).gameObject);
				Debug.Log((object)">>> A baby is on this level!");
				if (PhotonNetwork.IsMasterClient)
				{
					float num2 = Random.Range(0f, 1f);
					Debug.Log((object)(">>> Baby roll was " + num2));
					if (num2 <= 0.2f)
					{
						RaiseBabyUpgradeEvent(i, EnemyType.BabyPink);
						Debug.Log((object)$">>> Sent PinkBaby upgrade for duck index {i}");
					}
					else if (num2 <= 0.5f)
					{
						RaiseBabyUpgradeEvent(i, EnemyType.BabyBlue);
						Debug.Log((object)$">>> Sent BlueBaby upgrade for duck index {i}");
					}
				}
			}
			else
			{
				if (!name.StartsWith("Enemy - Robe") || knownRobes.Contains(((Component)child).gameObject))
				{
					continue;
				}
				((Object)child).name = "Enemy - RobeVerified";
				knownRobes.Add(((Component)child).gameObject);
				Debug.Log((object)">>> A robe enemy is on this level!");
				if (PhotonNetwork.IsMasterClient)
				{
					float num3 = Random.Range(0f, 1f);
					Debug.Log((object)(">>> Robe roll was " + num3));
					if (num3 <= 0.2f)
					{
						RaiseRobeUpgradeEvent(i, EnemyType.RobePink);
						Debug.Log((object)$">>> Sent PinkRobe upgrade for robe index {i}");
					}
					else if (num3 <= 0.5f)
					{
						RaiseRobeUpgradeEvent(i, EnemyType.RobeBlue);
						Debug.Log((object)$">>> Sent BlueRobe upgrade for robe index {i}");
					}
				}
			}
		}
	}

	private void RaiseDuckUpgradeEvent(int index, EnemyType type)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		object[] array = new object[2]
		{
			index,
			(int)type
		};
		PhotonNetwork.RaiseEvent((byte)42, (object)array, new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)1
		}, SendOptions.SendReliable);
	}

	private void RaiseBabyUpgradeEvent(int index, EnemyType type)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		object[] array = new object[2]
		{
			index,
			(int)type
		};
		PhotonNetwork.RaiseEvent((byte)45, (object)array, new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)1
		}, SendOptions.SendReliable);
	}

	private void RaiseRobeUpgradeEvent(int index, EnemyType type)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		object[] array = new object[2]
		{
			index,
			(int)type
		};
		PhotonNetwork.RaiseEvent((byte)46, (object)array, new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)1
		}, SendOptions.SendReliable);
	}

	private void OnPhotonEvent(EventData photonEvent)
	{
		if (photonEvent.Code == 42)
		{
			object[] array = (object[])photonEvent.CustomData;
			int index = (int)array[0];
			EnemyType type = (EnemyType)array[1];
			UpgradeDuckByIndex(index, type);
		}
		if (photonEvent.Code == 45)
		{
			object[] array2 = (object[])photonEvent.CustomData;
			int index2 = (int)array2[0];
			EnemyType type2 = (EnemyType)array2[1];
			UpgradeBabyByIndex(index2, type2);
		}
		if (photonEvent.Code == 46)
		{
			object[] array3 = (object[])photonEvent.CustomData;
			int index3 = (int)array3[0];
			EnemyType type3 = (EnemyType)array3[1];
			UpgradeRobeByIndex(index3, type3);
		}
		else if (photonEvent.Code == 43)
		{
			object[] array4 = (object[])photonEvent.CustomData;
			int num = (int)array4[0];
			int num2 = (int)array4[1];
			GameObject val = GameObject.Find("Level Generator");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform val2 = val.transform.Find("Items");
			if (!((Object)(object)val2 == (Object)null) && num < val2.childCount)
			{
				GameObject gameObject = ((Component)val2.GetChild(num)).gameObject;
				ItemAttributes component = gameObject.GetComponent<ItemAttributes>();
				if ((Object)(object)component != (Object)null)
				{
					component.value = num2;
					Debug.Log((object)$">>> Client applied synced price: '{((Object)gameObject).name}' = {num2}");
				}
			}
		}
		else
		{
			if (photonEvent.Code != 44)
			{
				return;
			}
			object[] array5 = (object[])photonEvent.CustomData;
			int num3 = (int)array5[0];
			float num4 = (float)array5[1];
			PhotonView val3 = PhotonView.Find(num3);
			if ((Object)(object)val3 != (Object)null)
			{
				ValuableObject component2 = ((Component)val3).GetComponent<ValuableObject>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.dollarValueOriginal = num4;
					component2.dollarValueCurrent = num4;
					Debug.Log((object)$">>> Synced orb value for '{((Object)((Component)val3).gameObject).name}': {num4}");
				}
			}
			else
			{
				Debug.LogWarning((object)(">>> OrbValue sync failed: PhotonView not found for ViewID " + num3));
			}
		}
	}

	private void UpgradeDuckByIndex(int index, EnemyType type)
	{
		if (!((Object)(object)EnemyParent == (Object)null) && index < EnemyParent.childCount)
		{
			Transform child = EnemyParent.GetChild(index);
			((Object)child).name = $"Enemy - {type}Duck(Clone)";
			ApplyDuckVisuals(((Component)child).gameObject, type);
			if ((Object)(object)((Component)child).GetComponent<EnemyDeathHandler>() == (Object)null)
			{
				EnemyDeathHandler enemyDeathHandler = ((Component)child).gameObject.AddComponent<EnemyDeathHandler>();
				enemyDeathHandler.enemyType = type;
			}
			Debug.Log((object)$">>> {type}Duck upgraded via RaiseEvent (by index)");
		}
	}

	private void UpgradeBabyByIndex(int index, EnemyType type)
	{
		if (!((Object)(object)EnemyParent == (Object)null) && index < EnemyParent.childCount)
		{
			Transform child = EnemyParent.GetChild(index);
			((Object)child).name = $"Enemy - {type}Baby(Clone)";
			ApplyBabyVisuals(((Component)child).gameObject, type);
			if ((Object)(object)((Component)child).GetComponent<EnemyDeathHandler>() == (Object)null)
			{
				EnemyDeathHandler enemyDeathHandler = ((Component)child).gameObject.AddComponent<EnemyDeathHandler>();
				enemyDeathHandler.enemyType = type;
			}
			Debug.Log((object)$">>> {type}Baby upgraded via RaiseEvent (by index)");
		}
	}

	private void UpgradeRobeByIndex(int index, EnemyType type)
	{
		if (!((Object)(object)EnemyParent == (Object)null) && index < EnemyParent.childCount)
		{
			Transform child = EnemyParent.GetChild(index);
			((Object)child).name = $"Enemy - {type}Robe(Clone)";
			ApplyRobeVisuals(((Component)child).gameObject, type);
			if ((Object)(object)((Component)child).GetComponent<EnemyDeathHandler>() == (Object)null)
			{
				EnemyDeathHandler enemyDeathHandler = ((Component)child).gameObject.AddComponent<EnemyDeathHandler>();
				enemyDeathHandler.enemyType = type;
			}
			Debug.Log((object)$">>> {type}Robe upgraded via RaiseEvent (by index)");
		}
	}

	private void ApplyDuckVisuals(GameObject duck, EnemyType type)
	{
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_035d: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		Material material = null;
		Material material2 = null;
		GameObject val = null;
		GameObject val2 = null;
		switch (type)
		{
		case EnemyType.DuckBlue:
			material = MyOrbs.Instance?.blueDuckMaterial;
			material2 = MyOrbs.Instance?.blueDuckFeathers;
			val = MyOrbs.Instance?.blueDuckAuraPrefab;
			break;
		case EnemyType.DuckPink:
			material = MyOrbs.Instance?.pinkDuckMaterial;
			material2 = MyOrbs.Instance?.pinkDuckFeathers;
			val = MyOrbs.Instance?.pinkDuckAuraPrefab;
			val2 = MyOrbs.Instance?.pinkDuckAuraPrefab2;
			break;
		}
		string[] array = meshDuckNamesToReplace;
		foreach (string text in array)
		{
			Transform val3 = duck.transform.Find("Visuals/" + text) ?? duck.transform.FindDeepChild(text);
			if ((Object)(object)val3 != (Object)null)
			{
				Renderer component = ((Component)val3).GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					component.material = material;
				}
			}
		}
		Transform val4 = duck.transform.Find("Particles/Feathers");
		if ((Object)(object)val4 != (Object)null)
		{
			ParticleSystemRenderer component2 = ((Component)val4).GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)component2 != (Object)null)
			{
				((Renderer)component2).material = material2;
			}
		}
		else
		{
			Debug.LogWarning((object)">>> Could not find Particles/Feathers for Duck");
		}
		Transform val5 = duck.transform.FindDeepChild("ANIM ROT BOT");
		Transform val6 = duck.transform.FindDeepChild("ANIM MON ROT BOT");
		Transform val7 = duck.transform.FindDeepChild("Controller");
		Transform val8 = duck.transform.Find("Enable/Visuals/Hurt Collider");
		EnemyHealth component3 = ((Component)val7).GetComponent<EnemyHealth>();
		HurtCollider component4 = ((Component)val8).GetComponent<HurtCollider>();
		if ((Object)(object)val5 != (Object)null && (Object)(object)val6 != (Object)null)
		{
			switch (type)
			{
			case EnemyType.DuckBlue:
				if ((Object)(object)val5.Find("BlueDuckAuraEffect") == (Object)null)
				{
					component4.enemyHitForce = 22.5f;
					component4.enemyHitTorque = 7.5f;
					component3.health = 225;
					GameObject val13 = Object.Instantiate<GameObject>(val, val5);
					GameObject val14 = Object.Instantiate<GameObject>(val, val6);
					val14.transform.localPosition = new Vector3(0f, -0.1417573f, 0f);
					val14.transform.localRotation = Quaternion.identity;
					val14.transform.localScale = new Vector3(0.4383981f, 0.3794659f, 0.3747339f);
				}
				break;
			case EnemyType.DuckPink:
				if ((Object)(object)val5.Find("PinkDuckAuraEffect") == (Object)null && (Object)(object)val5.Find("PinkDuckAuraEffect2") == (Object)null)
				{
					component4.enemyHitForce = 30f;
					component4.enemyHitTorque = 10f;
					component3.health = 300;
					GameObject val9 = Object.Instantiate<GameObject>(val, val5);
					GameObject val10 = Object.Instantiate<GameObject>(val2, val5);
					GameObject val11 = Object.Instantiate<GameObject>(val, val6);
					GameObject val12 = Object.Instantiate<GameObject>(val2, val6);
					val11.transform.localPosition = new Vector3(0f, -0.1417573f, 0f);
					val11.transform.localRotation = Quaternion.identity;
					val11.transform.localScale = new Vector3(0.4383981f, 0.3794659f, 0.3747339f);
					val12.transform.localPosition = new Vector3(0f, 0f, 0f);
					val12.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
					val12.transform.localScale = new Vector3(1f, 1f, 1f);
				}
				break;
			}
		}
		else
		{
			Debug.LogWarning((object)">>> Could not find ANIM ROT BOT or ANIM MON ROT BOT to parent aura");
		}
	}

	private void ApplyBabyVisuals(GameObject baby, EnemyType type)
	{
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Expected O, but got Unknown
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_031c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		Material material = null;
		Material material2 = null;
		GameObject val = null;
		GameObject val2 = null;
		switch (type)
		{
		case EnemyType.BabyBlue:
			material = MyOrbs.Instance?.blueBabyMaterial;
			material2 = MyOrbs.Instance?.blueBabyEyesMaterial;
			val = MyOrbs.Instance?.blueBabyAuraPrefab;
			break;
		case EnemyType.BabyPink:
			material = MyOrbs.Instance?.pinkBabyMaterial;
			material2 = MyOrbs.Instance?.pinkBabyEyesMaterial;
			val = MyOrbs.Instance?.pinkBabyAuraPrefab;
			val2 = MyOrbs.Instance?.pinkBabyAuraPrefab2;
			break;
		}
		string[] array = meshBabyNamesToReplace;
		foreach (string text in array)
		{
			Transform val3 = baby.transform.Find("Visuals/" + text) ?? baby.transform.FindDeepChild(text);
			if (!((Object)(object)val3 != (Object)null))
			{
				continue;
			}
			Renderer component = ((Component)val3).GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				if (((Object)val3).name == "mesh eye")
				{
					component.material = material2;
				}
				else
				{
					component.material = material;
				}
			}
		}
		Transform val4 = baby.transform.Find("Particles");
		if ((Object)(object)val4 != (Object)null)
		{
			Color white = default(Color);
			switch (type)
			{
			case EnemyType.BabyBlue:
				((Color)(ref white))..ctor(0f, 0.1f, 1f);
				break;
			case EnemyType.BabyPink:
				((Color)(ref white))..ctor(1f, 0f, 1f);
				break;
			default:
				white = Color.white;
				break;
			}
			Gradient val5 = new Gradient();
			val5.mode = (GradientMode)1;
			val5.SetKeys((GradientColorKey[])(object)new GradientColorKey[1]
			{
				new GradientColorKey(white, 0f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[1]
			{
				new GradientAlphaKey(1f, 0f)
			});
			string[] array2 = new string[2] { "Bits", "Directional Bits" };
			string[] array3 = array2;
			foreach (string text2 in array3)
			{
				Transform val6 = val4.Find(text2);
				if ((Object)(object)val6 != (Object)null)
				{
					ParticleSystem component2 = ((Component)val6).GetComponent<ParticleSystem>();
					if ((Object)(object)component2 != (Object)null)
					{
						MainModule main = component2.main;
						((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(white);
						TrailModule trails = component2.trails;
						((TrailModule)(ref trails)).enabled = true;
						ColorOverLifetimeModule colorOverLifetime = component2.colorOverLifetime;
						((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
						((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val5);
						((TrailModule)(ref trails)).enabled = true;
						((TrailModule)(ref trails)).colorOverTrail = new MinMaxGradient(val5);
					}
				}
			}
			Transform val7 = val4.Find("Impact");
			if ((Object)(object)val7 != (Object)null)
			{
				ParticleSystem component3 = ((Component)val7).GetComponent<ParticleSystem>();
				if ((Object)(object)component3 != (Object)null)
				{
					MainModule main2 = component3.main;
					((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(white);
				}
			}
		}
		else
		{
			Debug.LogWarning((object)">>> Could not find Particles/Bits for Baby");
		}
		Transform val8 = baby.transform.FindDeepChild("ANIM BOT");
		Transform val9 = baby.transform.FindDeepChild("Controller");
		Transform val10 = baby.transform.Find("Enable/Visuals/Hurt Collider");
		EnemyHealth component4 = ((Component)val9).GetComponent<EnemyHealth>();
		if ((Object)(object)val8 != (Object)null)
		{
			switch (type)
			{
			case EnemyType.BabyBlue:
				if ((Object)(object)val8.Find("BlueBabyAuraEffect") == (Object)null)
				{
					component4.health = 225;
					GameObject val13 = Object.Instantiate<GameObject>(val, val8);
				}
				break;
			case EnemyType.BabyPink:
				if ((Object)(object)val8.Find("PinkBabyAuraEffect") == (Object)null && (Object)(object)val8.Find("PinkBabyAuraEffect2") == (Object)null)
				{
					component4.health = 300;
					GameObject val11 = Object.Instantiate<GameObject>(val, val8);
					GameObject val12 = Object.Instantiate<GameObject>(val2, val8);
				}
				break;
			}
		}
		else
		{
			Debug.LogWarning((object)">>> Could not find ANIM ROT BOT or ANIM MON ROT BOT to parent aura");
		}
	}

	private void ApplyRobeVisuals(GameObject robe, EnemyType type)
	{
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Expected O, but got Unknown
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0392: Unknown result type (might be due to invalid IL or missing references)
		Material material = null;
		GameObject val = null;
		GameObject val2 = null;
		switch (type)
		{
		case EnemyType.RobeBlue:
			material = MyOrbs.Instance?.blueRobe;
			val = MyOrbs.Instance?.blueRobeAuraEffect;
			break;
		case EnemyType.RobePink:
			material = MyOrbs.Instance?.pinkRobe;
			val = MyOrbs.Instance?.pinkRobeAuraEffect;
			val2 = MyOrbs.Instance?.pinkRobeAuraEffect2;
			break;
		}
		string[] array = new string[7] { "Robe Hand Base", "Robe Hand Finger S", "Robe Hand Finger E", "Body Closed", "Body Open", "Body Attack", "Mesh" };
		string[] array2 = array;
		foreach (string name in array2)
		{
			foreach (Transform item in robe.transform.FindDeepChildren(name))
			{
				Renderer component = ((Component)item).GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					component.material = material;
				}
			}
		}
		if (1 == 0)
		{
		}
		Color val3 = (Color)(type switch
		{
			EnemyType.RobeBlue => new Color(0f, 0.1f, 1f), 
			EnemyType.RobePink => new Color(1f, 0f, 1f), 
			_ => Color.white, 
		});
		if (1 == 0)
		{
		}
		Color val4 = val3;
		Gradient val5 = new Gradient();
		val5.mode = (GradientMode)1;
		val5.SetKeys((GradientColorKey[])(object)new GradientColorKey[1]
		{
			new GradientColorKey(val4, 0f)
		}, (GradientAlphaKey[])(object)new GradientAlphaKey[1]
		{
			new GradientAlphaKey(1f, 0f)
		});
		string[] array3 = new string[2] { "Death Bits Far", "Death Bits Short" };
		string[] array4 = array3;
		foreach (string text in array4)
		{
			Transform val6 = robe.transform.Find("Particles/Death Particles/" + text);
			if ((Object)(object)val6 != (Object)null)
			{
				ParticleSystem component2 = ((Component)val6).GetComponent<ParticleSystem>();
				if ((Object)(object)component2 != (Object)null)
				{
					MainModule main = component2.main;
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(val4);
					TrailModule trails = component2.trails;
					ColorOverLifetimeModule colorOverLifetime = component2.colorOverLifetime;
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val5);
					((TrailModule)(ref trails)).colorOverTrail = new MinMaxGradient(val5);
				}
			}
		}
		Transform val7 = robe.transform.Find("Particles/Death Particles/Death Impact");
		if ((Object)(object)val7 != (Object)null)
		{
			ParticleSystem component3 = ((Component)val7).GetComponent<ParticleSystem>();
			if ((Object)(object)component3 != (Object)null)
			{
				MainModule main2 = component3.main;
				((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(val4);
			}
		}
		Transform val8 = robe.transform.Find("Particles/Death Particles/Death Smoke");
		if ((Object)(object)val8 != (Object)null)
		{
			ParticleSystem component4 = ((Component)val8).GetComponent<ParticleSystem>();
			if ((Object)(object)component4 != (Object)null)
			{
				MainModule main3 = component4.main;
				((MainModule)(ref main3)).startColor = MinMaxGradient.op_Implicit(val4);
				ColorOverLifetimeModule colorOverLifetime2 = component4.colorOverLifetime;
				((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = new MinMaxGradient(val5);
			}
		}
		Transform val9 = robe.transform.Find("Enable/Visual/Spot Light");
		if ((Object)(object)val9 != (Object)null)
		{
			Light component5 = ((Component)val9).GetComponent<Light>();
			if ((Object)(object)component5 != (Object)null)
			{
				component5.color = val4;
			}
		}
		Transform val10 = robe.transform.Find("Enable/Controller");
		if ((Object)(object)val10 != (Object)null)
		{
			EnemyHealth component6 = ((Component)val10).GetComponent<EnemyHealth>();
			if ((Object)(object)component6 != (Object)null)
			{
				switch (type)
				{
				case EnemyType.RobeBlue:
					component6.health = 375;
					break;
				case EnemyType.RobePink:
					component6.health = 500;
					break;
				}
			}
		}
		Transform val11 = robe.transform.Find("Enable/Visual/Main Animation");
		if ((Object)(object)val11 != (Object)null)
		{
			switch (type)
			{
			case EnemyType.RobeBlue:
				if ((Object)(object)val11.Find("BlueRobeAuraEffect") == (Object)null)
				{
					GameObject val14 = Object.Instantiate<GameObject>(val, val11);
				}
				break;
			case EnemyType.RobePink:
				if ((Object)(object)val11.Find("PinkRobeAuraEffect") == (Object)null && (Object)(object)val11.Find("PinkRobeAuraEffect2") == (Object)null)
				{
					GameObject val12 = Object.Instantiate<GameObject>(val, val11);
					GameObject val13 = Object.Instantiate<GameObject>(val2, val11);
				}
				break;
			}
		}
		else
		{
			Debug.LogWarning((object)">>> Could not find Main Animation to parent aura");
		}
	}
}
[HarmonyPatch(typeof(ItemGrenadeExplosive), "Explosion")]
public static class GrenadeExplosionPatch
{
	[HarmonyPostfix]
	public static void Postfix(ItemGrenadeExplosive __instance)
	{
		if ((Object)(object)((Component)__instance).GetComponent<PinkGrenade>() != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)__instance).GetComponent<PinkGrenade>());
			ParticlePrefabExplosion val = Object.FindObjectOfType<ParticlePrefabExplosion>();
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)">>> [PinkGrenadePatch] No explosion instance found.");
				return;
			}
			val.explosionDamageEnemy = 240;
			val.explosionSize = 1.44f;
			val.forceMultiplier = 4.8f;
			Debug.Log((object)">>> [PinkGrenadePatch] Explosion overridden for PinkGrenade");
		}
		else if ((Object)(object)((Component)__instance).GetComponent<BlueGrenade>() != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)__instance).GetComponent<BlueGrenade>());
			ParticlePrefabExplosion val2 = Object.FindObjectOfType<ParticlePrefabExplosion>();
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogWarning((object)">>> [BlueGrenadePatch] No explosion instance found.");
				return;
			}
			val2.explosionDamageEnemy = 200;
			val2.explosionSize = 1.32f;
			val2.forceMultiplier = 4.4f;
			Debug.Log((object)">>> [BlueGrenadePatch] Explosion overridden for BlueGrenade");
		}
	}
}
[HarmonyPatch(typeof(TruckScreenText), "GotoNextLevel")]
public static class TruckScreenText_GotoNextLevel_Patch
{
	[HarmonyPostfix]
	public static void Postfix()
	{
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		int num5 = 0;
		int num6 = 0;
		int num7 = 0;
		int num8 = 0;
		int num9 = 0;
		int num10 = 0;
		int num11 = 0;
		int num12 = 0;
		int num13 = 0;
		int num14 = 0;
		if (SemiFunc.RunIsLevel())
		{
			SavedUpgradesManager.state.additionalEnemies++;
		}
		GameObject obj = GameObject.Find("Level Generator");
		Transform val = ((obj != null) ? obj.transform.Find("Items") : null);
		if ((Object)(object)val != (Object)null)
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			for (int i = 0; i < val.childCount; i++)
			{
				GameObject gameObject = ((Component)val.GetChild(i)).gameObject;
				if ((Object)(object)gameObject.GetComponent<BlueGrenade>() != (Object)null)
				{
					num2++;
				}
				if ((Object)(object)gameObject.GetComponent<PinkGrenade>() != (Object)null)
				{
					num++;
				}
				if ((Object)(object)gameObject.GetComponent<BlueStunGrenade>() != (Object)null)
				{
					num4++;
				}
				if ((Object)(object)gameObject.GetComponent<PinkStunGrenade>() != (Object)null)
				{
					num3++;
				}
				if ((Object)(object)gameObject.GetComponent<BlueShockwaveGrenade>() != (Object)null)
				{
					num6++;
				}
				if ((Object)(object)gameObject.GetComponent<PinkShockwaveGrenade>() != (Object)null)
				{
					num5++;
				}
				if ((Object)(object)gameObject.GetComponent<BlueExplosiveMine>() != (Object)null)
				{
					num8++;
				}
				if ((Object)(object)gameObject.GetComponent<PinkExplosiveMine>() != (Object)null)
				{
					num7++;
				}
				if ((Object)(object)gameObject.GetComponent<BlueHealthPackLarge>() != (Object)null)
				{
					num9++;
				}
				if ((Object)(object)gameObject.GetComponent<BlueHealthPackMedium>() != (Object)null)
				{
					num10++;
				}
				if ((Object)(object)gameObject.GetComponent<BlueHealthPackSmall>() != (Object)null)
				{
					num11++;
				}
				if ((Object)(object)gameObject.GetComponent<PinkHealthPackLarge>() != (Object)null)
				{
					num12++;
				}
				if ((Object)(object)gameObject.GetComponent<PinkHealthPackMedium>() != (Object)null)
				{
					num13++;
				}
				if ((Object)(object)gameObject.GetComponent<PinkHealthPackSmall>() != (Object)null)
				{
					num14++;
				}
				if ((Object)(object)gameObject.GetComponent<BlueHandgun>() != (Object)null)
				{
					SavedUpgradesManager.state.handgunUpgrade = 1;
				}
				if ((Object)(object)gameObject.GetComponent<PinkHandgun>() != (Object)null)
				{
					SavedUpgradesManager.state.handgunUpgrade = 2;
				}
				if ((Object)(object)gameObject.GetComponent<BlueFryingPan>() != (Object)null)
				{
					SavedUpgradesManager.state.fryingPanUpgrade = 1;
				}
				if ((Object)(object)gameObject.GetComponent<PinkFryingPan>() != (Object)null)
				{
					SavedUpgradesManager.state.fryingPanUpgrade = 2;
				}
				if ((Object)(object)gameObject.GetComponent<BlueCartCannon>() != (Object)null)
				{
					SavedUpgradesManager.state.cartcannonUpgrade = 1;
				}
				if ((Object)(object)gameObject.GetComponent<PinkCartCannon>() != (Object)null)
				{
					SavedUpgradesManager.state.cartcannonUpgrade = 2;
				}
				if ((Object)(object)gameObject.GetComponent<BlueCartLaser>() != (Object)null)
				{
					SavedUpgradesManager.state.cartlaserUpgrade = 1;
				}
				if ((Object)(object)gameObject.GetComponent<PinkCartLaser>() != (Object)null)
				{
					SavedUpgradesManager.state.cartlaserUpgrade = 2;
				}
			}
			SavedUpgradesManager.state.blueGrenades = num2;
			SavedUpgradesManager.state.pinkGrenades = num;
			SavedUpgradesManager.state.blueStunGrenades = num4;
			SavedUpgradesManager.state.pinkStunGrenades = num3;
			SavedUpgradesManager.state.blueShockwaveGrenades = num6;
			SavedUpgradesManager.state.pinkShockwaveGrenades = num5;
			SavedUpgradesManager.state.bluemines = num8;
			SavedUpgradesManager.state.pinkmines = num7;
			SavedUpgradesManager.state.largeBlueHealthPacks = num9;
			SavedUpgradesManager.state.mediumBlueHealthPacks = num10;
			SavedUpgradesManager.state.smallBlueHealthPacks = num11;
			SavedUpgradesManager.state.largePinkHealthPacks = num12;
			SavedUpgradesManager.state.mediumPinkHealthPacks = num13;
			SavedUpgradesManager.state.smallPinkHealthPacks = num14;
			SavedUpgradesManager.Save();
		}
		else
		{
			Debug.LogWarning((object)">>> Could not find Level Generator/Items to save grenade upgrades.");
		}
	}
}
[HarmonyPatch(typeof(ItemMineExplosive), "OnTriggered")]
public static class MineExplosionPatch
{
	[HarmonyPostfix]
	public static void Postfix(ItemMineExplosive __instance)
	{
		if ((Object)(object)((Component)__instance).GetComponent<BlueExplosiveMine>() != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)__instance).GetComponent<BlueExplosiveMine>());
			ParticlePrefabExplosion val = Object.FindObjectOfType<ParticlePrefabExplosion>();
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)">>> [BlueMinePatch] No explosion instance found.");
				return;
			}
			val.explosionDamageEnemy = 250;
			val.explosionSize = 1.875f;
			val.forceMultiplier = 5f;
			Debug.Log((object)">>> [BlueMinePatch] Explosion overridden for BlueMine.");
		}
		if ((Object)(object)((Component)__instance).GetComponent<PinkExplosiveMine>() != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)__instance).GetComponent<PinkExplosiveMine>());
			ParticlePrefabExplosion val2 = Object.FindObjectOfType<ParticlePrefabExplosion>();
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogWarning((object)">>> [BlueMinePatch] No explosion instance found.");
				return;
			}
			val2.explosionDamageEnemy = 300;
			val2.explosionSize = 2.25f;
			val2.forceMultiplier = 6f;
			Debug.Log((object)">>> [PinkMinePatch] Explosion overridden for BlueMine.");
		}
	}
}
public class BlueGrenade : MonoBehaviour
{
}
public class PinkGrenade : MonoBehaviour
{
}
public class BlueStunGrenade : MonoBehaviour
{
}
public class PinkStunGrenade : MonoBehaviour
{
}
public class BlueShockwaveGrenade : MonoBehaviour
{
}
public class PinkShockwaveGrenade : MonoBehaviour
{
}
public class BlueHandgun : MonoBehaviour
{
}
public class PinkHandgun : MonoBehaviour
{
}
public class BlueFryingPan : MonoBehaviour
{
}
public class PinkFryingPan : MonoBehaviour
{
}
public class BlueExplosiveMine : MonoBehaviour
{
}
public class PinkExplosiveMine : MonoBehaviour
{
}
public class BlueHealthPackLarge : MonoBehaviour
{
}
public class BlueHealthPackMedium : MonoBehaviour
{
}
public class BlueHealthPackSmall : MonoBehaviour
{
}
public class PinkHealthPackLarge : MonoBehaviour
{
}
public class PinkHealthPackMedium : MonoBehaviour
{
}
public class PinkHealthPackSmall : MonoBehaviour
{
}
public class BlueCartCannon : MonoBehaviour
{
}
public class PinkCartCannon : MonoBehaviour
{
}
public class BlueCartLaser : MonoBehaviour
{
}
public class PinkCartLaser : MonoBehaviour
{
}
[BepInPlugin("com.feedmore.myorbs", "MyOrbs", "1.0.0")]
public class MyOrbs : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <WaitAndInit>d__99 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public MyOrbs <>4__this;

		private string <bundlePath>5__1;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(2f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<bundlePath>5__1 = Path.Combine(Paths.PluginPath, "feedmore-MyOrbs", "MyOrbs", "myorbsbundle");
				((BaseUnityPlugin)<>4__this).Logger.LogWarning((object)(">>> Trying to load AssetBundle from: " + <bundlePath>5__1));
				<>4__this.bundle = AssetBundle.LoadFromFile(<bundlePath>5__1);
				if ((Object)(object)<>4__this.bundle == (Object)null)
				{
					((BaseUnityPlugin)<>4__this).Logger.LogError((object)">>> Failed to load AssetBundle.");
					return false;
				}
				<>4__this.orbbig = <>4__this.bundle.LoadAsset<GameObject>("BlueOrbBig");
				<>4__this.orbMedium = <>4__this.bundle.LoadAsset<GameObject>("BlueOrbMedium");
				<>4__this.orbSmall = <>4__this.bundle.LoadAsset<GameObject>("BlueOrbSmall");
				<>4__this.pinkorbSmall = <>4__this.bundle.LoadAsset<GameObject>("PinkOrbSmall");
				<>4__this.pinkorbMedium = <>4__this.bundle.LoadAsset<GameObject>("PinkOrbMedium");
				<>4__this.pinkorbBig = <>4__this.bundle.LoadAsset<GameObject>("PinkOrbBig");
				<>4__this.blueDuckMaterial = <>4__this.bundle.LoadAsset<Material>("BlueDuck");
				<>4__this.blueDuckFeathers = <>4__this.bundle.LoadAsset<Material>("BlueDuckFeathers");
				<>4__this.blueDuckAuraPrefab = <>4__this.bundle.LoadAsset<GameObject>("BlueDuckAuraEffect");
				<>4__this.pinkgrenadeMat = <>4__this.bundle.LoadAsset<Material>("PinkGrenade");
				<>4__this.pinkgrenadeTrailMat = <>4__this.bundle.LoadAsset<Material>("PinkGrenadeTrail");
				<>4__this.pinkExplosionPreset = <>4__this.bundle.LoadAsset<ExplosionPreset>("PinkGrenadeParticles");
				<>4__this.bluegrenadeMat = <>4__this.bundle.LoadAsset<Material>("BlueGrenade");
				<>4__this.bluegrenadeTrailMat = <>4__this.bundle.LoadAsset<Material>("BlueGrenadeTrail");
				<>4__this.blueExplosionPreset = <>4__this.bundle.LoadAsset<ExplosionPreset>("BlueGrenadeParticles");
				<>4__this.blueStun = <>4__this.bundle.LoadAsset<Material>("BlueStun");
				<>4__this.blueStunTrail = <>4__this.bundle.LoadAsset<Material>("BlueStunTrail");
				<>4__this.blueStunParticles = <>4__this.bundle.LoadAsset<Material>("BlueStunParticles");
				<>4__this.pinkStun = <>4__this.bundle.LoadAsset<Material>("PinkStun");
				<>4__this.pinkStunTrail = <>4__this.bundle.LoadAsset<Material>("PinkStunTrail");
				<>4__this.pinkStunParticles = <>4__this.bundle.LoadAsset<Material>("PinkStunParticles");
				<>4__this.pinkDuckMaterial = <>4__this.bundle.LoadAsset<Material>("PinkDuck");
				<>4__this.pinkDuckFeathers = <>4__this.bundle.LoadAsset<Material>("PinkDuckFeathers");
				<>4__this.pinkDuckAuraPrefab = <>4__this.bundle.LoadAsset<GameObject>("PinkDuckAuraEffect");
				<>4__this.pinkDuckAuraPrefab2 = <>4__this.bundle.LoadAsset<GameObject>("PinkDuckAuraEffect2");
				<>4__this.blueHandgunMat = <>4__this.bundle.LoadAsset<Material>("BlueHandgun");
				<>4__this.blueHandgunSparks = <>4__this.bundle.LoadAsset<Material>("BlueHandgunSparks");
				<>4__this.blueHandgunBulletTrail = <>4__this.bundle.LoadAsset<Material>("BlueHandgunBulletTrail");
				<>4__this.pinkHandgunMat = <>4__this.bundle.LoadAsset<Material>("PinkHandgun");
				<>4__this.pinkHandgunSparks = <>4__this.bundle.LoadAsset<Material>("PinkHandgunSparks");
				<>4__this.pinkHandgunBulletTrail = <>4__this.bundle.LoadAsset<Material>("PinkHandgunBulletTrail");
				<>4__this.blueFryingPan = <>4__this.bundle.LoadAsset<Material>("BlueFryingPan");
				<>4__this.blueFryingPanParticles = <>4__this.bundle.LoadAsset<Material>("BlueFryingPanParticles");
				<>4__this.blueFryingPanTrail = <>4__this.bundle.LoadAsset<Material>("BlueFryingPanTrail");
				<>4__this.pinkFryingPan = <>4__this.bundle.LoadAsset<Material>("PinkFryingPan");
				<>4__this.pinkFryingPanParticles = <>4__this.bundle.LoadAsset<Material>("PinkFryingPanParticles");
				<>4__this.pinkFryingPanTrail = <>4__this.bundle.LoadAsset<Material>("PinkFryingPanTrail");
				<>4__this.blueExplosiveMine = <>4__this.bundle.LoadAsset<Material>("BlueExplosiveMine");
				<>4__this.blueExplosiveMineParticles = <>4__this.bundle.LoadAsset<Material>("BlueExplosiveMineParticles");
				<>4__this.blueExplosiveMineTrail = <>4__this.bundle.LoadAsset<Material>("BlueExplosiveMineTrail");
				<>4__this.blueMineExplosionPreset = <>4__this.bundle.LoadAsset<ExplosionPreset>("BlueExplosiveMinePrefab");
				<>4__this.pinkExplosiveMine = <>4__this.bundle.LoadAsset<Material>("PinkExplosiveMine");
				<>4__this.pinkExplosiveMineParticles = <>4__this.bundle.LoadAsset<Material>("PinkExplosiveMineParticles");
				<>4__this.pinkExplosiveMineTrail = <>4__this.bundle.LoadAsset<Material>("PinkExplosiveMineTrail");
				<>4__this.pinkMineExplosionPreset = <>4__this.bundle.LoadAsset<ExplosionPreset>("PinkExplosiveMinePrefab");
				<>4__this.blueHealthPack = <>4__this.bundle.LoadAsset<Material>("BlueHealthPack");
				<>4__this.blueHealthPackParticles = <>4__this.bundle.LoadAsset<Material>("BlueHealthPackParticles");
				<>4__this.blueHealthPackSmoke = <>4__this.bundle.LoadAsset<Material>("BlueHealthPackSmoke");
				<>4__this.pinkHealthPack = <>4__this.bundle.LoadAsset<Material>("PinkHealthPack");
				<>4__this.pinkHealthPackParticles = <>4__this.bundle.LoadAsset<Material>("PinkHealthPackParticles");
				<>4__this.pinkHealthPackSmoke = <>4__this.bundle.LoadAsset<Material>("PinkHealthPackSmoke");
				<>4__this.blueBabyMaterial = <>4__this.bundle.LoadAsset<Material>("BlueBaby");
				<>4__this.blueBabyEyesMaterial = <>4__this.bundle.LoadAsset<Material>("BlueBabyEyes");
				<>4__this.blueBabyAuraPrefab = <>4__this.bundle.LoadAsset<GameObject>("BlueBabyAuraEffect");
				<>4__this.pinkBabyMaterial = <>4__this.bundle.LoadAsset<Material>("PinkBaby");
				<>4__this.pinkBabyEyesMaterial = <>4__this.bundle.LoadAsset<Material>("PinkBabyEyes");
				<>4__this.pinkBabyAuraPrefab = <>4__this.bundle.LoadAsset<GameObject>("PinkBabyAuraEffect");
				<>4__this.pinkBabyAuraPrefab2 = <>4__this.bundle.LoadAsset<GameObject>("PinkBabyAuraEffect2");
				<>4__this.blueCannon = <>4__this.bundle.LoadAsset<Material>("BlueCannon");
				<>4__this.blueCannonStunParticles = <>4__this.bundle.LoadAsset<Material>("BlueCannonStunParticles");
				<>4__this.blueCannonShoot = <>4__this.bundle.LoadAsset<Material>("BlueCannonShoot");
				<>4__this.blueCannonArrow = <>4__this.bundle.LoadAsset<Material>("BlueCannonArrow");
				<>4__this.blueCannonSwitch = <>4__this.bundle.LoadAsset<Material>("BlueCannonSwitch");
				<>4__this.blueCannonLaserScreen = <>4__this.bundle.LoadAsset<Material>("BlueCannonLaserScreen");
				<>4__this.blueCannonTrail = <>4__this.bundle.LoadAsset<Material>("BlueCannonTrail");
				<>4__this.pinkCannon = <>4__this.bundle.LoadAsset<Material>("PinkCannon");
				<>4__this.pinkCannonStunParticles = <>4__this.bundle.LoadAsset<Material>("PinkCannonStunParticles");
				<>4__this.pinkCannonShoot = <>4__this.bundle.LoadAsset<Material>("PinkCannonShoot");
				<>4__this.pinkCannonArrow = <>4__this.bundle.LoadAsset<Material>("PinkCannonArrow");
				<>4__this.pinkCannonSwitch = <>4__this.bundle.LoadAsset<Material>("PinkCannonSwitch");
				<>4__this.pinkCannonLaserScreen = <>4__this.bundle.LoadAsset<Material>("PinkCannonLaserScreen");
				<>4__this.pinkCannonTrail = <>4__this.bundle.LoadAsset<Material>("PinkCannonTrail");
				<>4__this.blueLaser = <>4__this.bundle.LoadAsset<Material>("BlueLaser");
				<>4__this.blueLaserSpark = <>4__this.bundle.LoadAsset<Material>("BlueLaserSpark");
				<>4__this.blueLaserMeter = <>4__this.bundle.LoadAsset<Material>("BlueLaserMeter");
				<>4__this.blueLaserInside = <>4__this.bundle.LoadAsset<Material>("BlueLaserInside");
				<>4__this.blueLaserSmoke = <>4__this.bundle.LoadAsset<Material>("BlueLaserSmoke");
				<>4__this.pinkLaser = <>4__this.bundle.LoadAsset<Material>("PinkLaser");
				<>4__this.pinkLaserSpark = <>4__this.bundle.LoadAsset<Material>("PinkLaserSpark");
				<>4__this.pinkLaserMeter = <>4__this.bundle.LoadAsset<Material>("PinkLaserMeter");
				<>4__this.pinkLaserInside = <>4__this.bundle.LoadAsset<Material>("PinkLaserInside");
				<>4__this.pinkLaserSmoke = <>4__this.bundle.LoadAsset<Material>("PinkLaserSmoke");
				<>4__this.blueRobe = <>4__this.bundle.LoadAsset<Material>("BlueRobe");
				<>4__this.blueRobeAuraEffect = <>4__this.bundle.LoadAsset<GameObject>("BlueRobeAuraEffect");
				<>4__this.pinkRobe = <>4__this.bundle.LoadAsset<Material>("PinkRobe");
				<>4__this.pinkRobeAuraEffect = <>4__this.bundle.LoadAsset<GameObject>("PinkRobeAuraEffect");
				<>4__this.pinkRobeAuraEffect2 = <>4__this.bundle.LoadAsset<GameObject>("PinkRobeAuraEffect2");
				<>4__this.blueShockwaveGrenade = <>4__this.bundle.LoadAsset<Material>("BlueShockwave");
				<>4__this.blueShockwaveExplosion = <>4__this.bundle.LoadAsset<GameObject>("BlueShockwaveExplosion");
				<>4__this.blueShockwaveGrenadeTrail = <>4__this.bundle.LoadAsset<Material>("BlueShockwaveTrail");
				<>4__this.pinkShockwaveGrenade = <>4__this.bundle.LoadAsset<Material>("PinkShockwave");
				<>4__this.pinkShockwaveExplosion = <>4__this.bundle.LoadAsset<GameObject>("PinkShockwaveExplosion");
				<>4__this.pinkShockwaveGrenadeTrail = <>4__this.bundle.LoadAsset<Material>("PinkShockwaveTrail");
				NetworkPrefabs.RegisterNetworkPrefab("BlueOrbBig", <>4__this.orbbig);
				NetworkPrefabs.RegisterNetworkPrefab("BlueOrbMedium", <>4__this.orbMedium);
				NetworkPrefabs.RegisterNetworkPrefab("BlueOrbSmall", <>4__this.orbSmall);
				NetworkPrefabs.RegisterNetworkPrefab("PinkOrbSmall", <>4__this.pinkorbSmall);
				NetworkPrefabs.RegisterNetworkPrefab("PinkOrbMedium", <>4__this.pinkorbMedium);
				NetworkPrefabs.RegisterNetworkPrefab("PinkOrbBig", <>4__this.pinkorbBig);
				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 GameObject? orbbig;

	internal GameObject? orbSmall;

	internal GameObject? orbMedium;

	internal GameObject? pinkorbSmall;

	internal GameObject? pinkorbMedium;

	internal GameObject? pinkorbBig;

	internal Material? blueDuckMaterial;

	internal Material? blueDuckFeathers;

	internal GameObject? blueDuckAuraPrefab;

	internal Material? pinkgrenadeMat;

	internal Material? pinkgrenadeTrailMat;

	internal ExplosionPreset? pinkExplosionPreset;

	internal Material? bluegrenadeMat;

	internal Material? bluegrenadeTrailMat;

	internal ExplosionPreset? blueExplosionPreset;

	internal Material? blueShockwaveGrenade;

	internal GameObject? blueShockwaveExplosion;

	internal Material? blueShockwaveGrenadeTrail;

	internal Material? pinkShockwaveGrenade;

	internal GameObject? pinkShockwaveExplosion;

	internal Material? pinkShockwaveGrenadeTrail;

	internal Material? blueStun;

	internal Material? blueStunTrail;

	internal Material? blueStunParticles;

	internal Material? pinkStun;

	internal Material? pinkStunTrail;

	internal Material? pinkStunParticles;

	internal Material? pinkDuckMaterial;

	internal Material? pinkDuckFeathers;

	internal GameObject? pinkDuckAuraPrefab;

	internal GameObject? pinkDuckAuraPrefab2;

	internal Material? blueRobe;

	internal GameObject? blueRobeAuraEffect;

	internal Material? pinkRobe;

	internal GameObject? pinkRobeAuraEffect;

	internal GameObject? pinkRobeAuraEffect2;

	internal Material? blueHandgunMat;

	internal Material? blueHandgunSparks;

	internal Material? blueHandgunBulletTrail;

	internal Material? pinkHandgunMat;

	internal Material? pinkHandgunSparks;

	internal Material? pinkHandgunBulletTrail;

	internal Material? blueFryingPan;

	internal Material? blueFryingPanParticles;

	internal Material? blueFryingPanTrail;

	internal Material? pinkFryingPan;

	internal Material? pinkFryingPanParticles;

	internal Material? pinkFryingPanTrail;

	internal Material? blueExplosiveMine;

	internal Material? blueExplosiveMineParticles;

	internal Material? blueExplosiveMineTrail;

	internal ExplosionPreset? blueMineExplosionPreset;

	internal Material? pinkExplosiveMine;

	internal Material? pinkExplosiveMineParticles;

	internal Material? pinkExplosiveMineTrail;

	internal ExplosionPreset? pinkMineExplosionPreset;

	internal Material? blueHealthPack;

	internal Material? blueHealthPackParticles;

	internal Material? blueHealthPackSmoke;

	internal Material? pinkHealthPack;

	internal Material? pinkHealthPackParticles;

	internal Material? pinkHealthPackSmoke;

	internal Material? blueBabyMaterial;

	internal Material? blueBabyEyesMaterial;

	internal GameObject? blueBabyAuraPrefab;

	internal Material? pinkBabyMaterial;

	internal Material? pinkBabyEyesMaterial;

	internal GameObject? pinkBabyAuraPrefab;

	internal GameObject? pinkBabyAuraPrefab2;

	internal Material? blueCannon;

	internal Material? blueCannonStunParticles;

	internal Material? blueCannonShoot;

	internal Material? blueCannonSwitch;

	internal Material? blueCannonArrow;

	internal Material? blueCannonLaserScreen;

	internal Material? blueCannonTrail;

	internal Material? pinkCannon;

	internal Material? pinkCannonStunParticles;

	internal Material? pinkCannonShoot;

	internal Material? pinkCannonSwitch;

	internal Material? pinkCannonArrow;

	internal Material? pinkCannonLaserScreen;

	internal Material? pinkCannonTrail;

	internal Material? blueLaser;

	internal Material? blueLaserInside;

	internal Material? blueLaserMeter;

	internal Material? blueLaserSpark;

	internal Material? blueLaserSmoke;

	internal Material? pinkLaser;

	internal Material? pinkLaserInside;

	internal Material? pinkLaserMeter;

	internal Material? pinkLaserSpark;

	internal Material? pinkLaserSmoke;

	public AssetBundle bundle = null;

	public static MyOrbs? Instance { get; private set; }

	private void Awake()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Expected O, but got Unknown
		Instance = this;
		Harmony val = new Harmony("com.feedmore.myorbs");
		val.PatchAll();
		GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
		((Object)val2).name = "OrbInitRunner";
		((Object)val2).hideFlags = (HideFlags)61;
		Object.DontDestroyOnLoad((Object)(object)val2);
		Object.Destroy((Object)(object)val2.GetComponent<MeshRenderer>());
		Object.Destroy((Object)(object)val2.GetComponent<Collider>());
		val2.AddComponent<OrbCoroutineRunner>();
	}

	[IteratorStateMachine(typeof(<WaitAndInit>d__99))]
	public IEnumerator WaitAndInit()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WaitAndInit>d__99(0)
		{
			<>4__this = this
		};
	}
}
public class OrbCoroutineRunner : MonoBehaviour
{
	private void Start()
	{
		((MonoBehaviour)this).StartCoroutine(MyOrbs.Instance.WaitAndInit());
		SavedUpgradesManager.Load();
		((Component)this).gameObject.AddComponent<EnemyWatcher>();
		((Component)this).gameObject.AddComponent<OrbSpawnWatcher>();
		((Component)this).gameObject.AddComponent<ShopItemWatcher>();
		((Component)this).gameObject.AddComponent<UpgradeMenu>();
		((Component)this).gameObject.AddComponent<WeaponUpgradeWatcher>();
		((Component)this).gameObject.AddComponent<PlayerMoneyWatcher>();
		((Component)this).gameObject.AddComponent<UpgradePersistenceWatcher>();
	}
}
public class OrbSpawnWatcher : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <BoostOrbWhenReady>d__4 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public GameObject orb;

		public OrbSpawnWatcher <>4__this;

		private ValuableObject <valuable>5__1;

		private float <before>5__2;

		private PhotonView <view>5__3;

		private object[] <content>5__4;

		private RaiseEventOptions <options>5__5;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<valuable>5__1 = null;
			<view>5__3 = null;
			<content>5__4 = null;
			<options>5__5 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.5f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if ((Object)(object)orb == (Object)null || <>4__this.boostedOrbs.Contains(orb))
				{
					return false;
				}
				if (orb.TryGetComponent<ValuableObject>(ref <valuable>5__1) && <valuable>5__1.dollarValueSet)
				{
					<before>5__2 = <valuable>5__1.dollarValueCurrent;
					ValuableObject obj = <valuable>5__1;
					obj.dollarValueOriginal *= 3f;
					<valuable>5__1.dollarValueCurrent = <valuable>5__1.dollarValueOriginal;
					Debug.Log((object)$">>> OrbBoost: {((Object)orb).name} value {<before>5__2} → {<valuable>5__1.dollarValueCurrent}");
					<>4__this.boostedOrbs.Add(orb);
					<view>5__3 = orb.GetComponent<PhotonView>();
					if ((Object)(object)<view>5__3 != (Object)null)
					{
						<content>5__4 = new object[2] { <view>5__3.ViewID, <valuable>5__1.dollarValueOriginal };
						<options>5__5 = new RaiseEventOptions
						{
							Receivers = (ReceiverGroup)0
						};
						PhotonNetwork.RaiseEvent((byte)44, (object)<content>5__4, <options>5__5, SendOptions.SendReliable);
						<content>5__4 = null;
						<options>5__5 = null;
					}
					<view>5__3 = null;
				}
				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 readonly HashSet<GameObject> boostedOrbs = new HashSet<GameObject>();

	private float scanInterval = 0.5f;

	private float scanTimer = 0f;

	private void Update()
	{
		if (!PhotonNetwork.IsMasterClient)
		{
			return;
		}
		scanTimer -= Time.deltaTime;
		if (scanTimer > 0f)
		{
			return;
		}
		scanTimer = scanInterval;
		ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>();
		ValuableObject[] array2 = array;
		foreach (ValuableObject val in array2)
		{
			GameObject gameObject = ((Component)val).gameObject;
			if (!boostedOrbs.Contains(gameObject) && (((Object)gameObject).name.StartsWith("Enemy Valuable") || ((Object)gameObject).name.StartsWith("PinkOrb") || ((Object)gameObject).name.StartsWith("BlueOrb")) && (Object)(object)gameObject.GetComponent<PhotonView>() != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(BoostOrbWhenReady(gameObject));
			}
		}
	}

	[IteratorStateMachine(typeof(<BoostOrbWhenReady>d__4))]
	private IEnumerator BoostOrbWhenReady(GameObject orb)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <BoostOrbWhenReady>d__4(0)
		{
			<>4__this = this,
			orb = orb
		};
	}
}
public class PlayerMoneyWatcher : MonoBehaviour
{
	public static PlayerMoneyWatcher? Instance;

	private int cachedMoney = 0;

	private void Awake()
	{
		Instance = this;
		PhotonNetwork.NetworkingClient.EventReceived += OnPhotonEvent;
	}

	private void OnDestroy()
	{
		PhotonNetwork.NetworkingClient.EventReceived -= OnPhotonEvent;
	}

	public int GetMoney()
	{
		return SemiFunc.StatGetRunCurrency();
	}

	public bool TrySpend(int amount)
	{
		if (!PhotonNetwork.IsMasterClient)
		{
			return false;
		}
		int num = SemiFunc.StatGetRunCurrency();
		if (num < amount)
		{
			return false;
		}
		SemiFunc.StatSetRunCurrency(num - amount);
		BroadcastMoney();
		return true;
	}

	private void BroadcastMoney()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		if (PhotonNetwork.IsMasterClient)
		{
			int num = SemiFunc.StatGetRunCurrency();
			object[] array = new object[1] { num };
			PhotonNetwork.RaiseEvent((byte)22, (object)array, new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)1
			}, SendOptions.SendReliable);
		}
	}

	private void OnPhotonEvent(EventData photonEvent)
	{
		if (photonEvent.Code == 22)
		{
			object[] array = (object[])photonEvent.CustomData;
			cachedMoney = (int)array[0];
			if ((Object)(object)CurrencyUI.instance != (Object)null)
			{
				CurrencyUI.instance.FetchCurrency();
			}
		}
		if (photonEvent.Code == 23 && (Object)(object)CurrencyUI.instance != (Object)null)
		{
			((SemiUI)CurrencyUI.instance).Show();
			((SemiUI)CurrencyUI.instance).showTimer = 10f;
			CurrencyUI.instance.FetchCurrency();
		}
	}
}
public class SavedUpgrades
{
	public int blueGrenades = 0;

	public int pinkGrenades = 0;

	public int blueStunGrenades = 0;

	public int pinkStunGrenades = 0;

	public int blueShockwaveGrenades = 0;

	public int pinkShockwaveGrenades = 0;

	public int bluemines = 0;

	public int pinkmines = 0;

	public int handgunUpgrade = 0;

	public int cartcannonUpgrade = 0;

	public int cartlaserUpgrade = 0;

	public int additionalEnemies = 0;

	public int fryingPanUpgrade = 0;

	public int largeBlueHealthPacks = 0;

	public int mediumBlueHealthPacks = 0;

	public int smallBlueHealthPacks = 0;

	public int largePinkHealthPacks = 0;

	public int mediumPinkHealthPacks = 0;

	public int smallPinkHealthPacks = 0;
}
public static class SavedUpgradesManager
{
	public static SavedUpgrades state = new SavedUpgrades();

	private static bool upgradesAlreadyApplied = false;

	private static string SavePath => Path.Combine(Paths.ConfigPath, "MyOrbs", "saved_upgrades.json");

	public static void IncrementWeaponUpgrade(WeaponUpgradeWatcher.WeaponUpgradeType type)
	{
		switch (type)
		{
		case WeaponUpgradeWatcher.WeaponUpgradeType.GrenadeBlue:
			state.blueGrenades++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.GrenadePink:
			state.pinkGrenades++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.StunGrenadeBlue:
			state.blueStunGrenades++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.StunGrenadePink:
			state.pinkStunGrenades++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.ShockwaveGrenadeBlue:
			state.blueShockwaveGrenades++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.ShockwaveGrenadePink:
			state.pinkShockwaveGrenades++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.ExplosiveMineBlue:
			state.bluemines++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.ExplosiveMinePink:
			state.pinkmines++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.HealthPackLargeBlue:
			state.largeBlueHealthPacks++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.HealthPackMediumBlue:
			state.mediumBlueHealthPacks++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.HealthPackSmallBlue:
			state.smallBlueHealthPacks++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.HealthPackLargePink:
			state.largePinkHealthPacks++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.HealthPackMediumPink:
			state.mediumPinkHealthPacks++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.HealthPackSmallPink:
			state.smallPinkHealthPacks++;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.HandgunBlue:
			state.handgunUpgrade = 1;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.HandgunPink:
			state.handgunUpgrade = 2;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.CartCannonBlue:
			state.cartcannonUpgrade = 1;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.CartCannonPink:
			state.cartcannonUpgrade = 2;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.FryingPanBlue:
			state.fryingPanUpgrade = 1;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.FryingPanPink:
			state.fryingPanUpgrade = 2;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.CartLaserBlue:
			state.cartlaserUpgrade = 1;
			break;
		case WeaponUpgradeWatcher.WeaponUpgradeType.CartLaserPink:
			state.cartlaserUpgrade = 2;
			break;
		}
	}

	public static void Save()
	{
		Directory.CreateDirectory(Path.GetDirectoryName(SavePath));
		File.WriteAllText(SavePath, JsonConvert.SerializeObject((object)state));
	}

	public static void Load()
	{
		Directory.CreateDirectory(Path.GetDirectoryName(SavePath));
		if (File.Exists(SavePath))
		{
			state = JsonConvert.DeserializeObject<SavedUpgrades>(File.ReadAllText(SavePath)) ?? new SavedUpgrades();
			return;
		}
		Debug.Log((object)">>> No saved upgrades file found. Starting fresh.");
		state = new SavedUpgrades();
		Save();
	}

	public static void ResetUpgradeApplyFlag()
	{
		upgradesAlreadyApplied = false;
	}

	public static void ApplyWeaponUpgrades()
	{
		//IL_0bde: Unknown result type (might be due to invalid IL or missing references)
		//IL_0be3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0be5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bf4: Expected O, but got Unknown
		if (upgradesAlreadyApplied)
		{
			return;
		}
		upgradesAlreadyApplied = true;
		if (IsExcludedScene())
		{
			return;
		}
		GameObject obj = GameObject.Find("Level Generator");
		Transform val = ((obj != null) ? obj.transform.Find("Items") : null);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		List<GameObject> list = new List<GameObject>();
		List<GameObject> list2 = new List<GameObject>();
		List<GameObject> list3 = new List<GameObject>();
		List<GameObject> list4 = new List<GameObject>();
		List<GameObject> list5 = new List<GameObject>();
		List<GameObject> list6 = new List<GameObject>();
		List<GameObject> list7 = new List<GameObject>();
		GameObject val2 = null;
		GameObject val3 = null;
		GameObject val4 = null;
		GameObject val5 = null;
		for (int i = 0; i < val.childCount; i++)
		{
			GameObject gameObject = ((Component)val.GetChild(i)).gameObject;
			if (((Object)gameObject).name.StartsWith("Item Grenade Explosive") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				list.Add(gameObject);
			}
			if (((Object)gameObject).name.StartsWith("Item Grenade Stun") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				list2.Add(gameObject);
			}
			if (((Object)gameObject).name.StartsWith("Item Grenade Shockwave") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				list3.Add(gameObject);
			}
			if (((Object)gameObject).name.StartsWith("Item Mine Explosive") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				list4.Add(gameObject);
			}
			if (((Object)gameObject).name.StartsWith("Item Health Pack Large") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				list5.Add(gameObject);
			}
			if (((Object)gameObject).name.StartsWith("Item Health Pack Medium") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				list6.Add(gameObject);
			}
			if (((Object)gameObject).name.StartsWith("Item Health Pack Small") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				list7.Add(gameObject);
			}
			if (((Object)gameObject).name.StartsWith("Item Gun Handgun") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				val2 = gameObject;
			}
			if (((Object)gameObject).name.StartsWith("Item Cart Cannon") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				val3 = gameObject;
			}
			if (((Object)gameObject).name.StartsWith("Item Cart Laser") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				val4 = gameObject;
			}
			if (((Object)gameObject).name.StartsWith("Item Melee Frying Pan") && WeaponUpgradeWatcher.GetWeaponUpgradeRank(gameObject) == 0)
			{
				val5 = gameObject;
			}
		}
		List<object[]> list8 = new List<object[]>();
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		int num5 = 0;
		int num6 = 0;
		int num7 = 0;
		int num8 = 0;
		while (num8 < state.pinkGrenades && num < list.Count)
		{
			GameObject val6 = list[num];
			WeaponUpgrader.ApplyPinkGrenadeVisuals(val6);
			list8.Add(new object[2]
			{
				val6.transform.GetSiblingIndex(),
				2
			});
			num8++;
			num++;
		}
		int num9 = 0;
		while (num9 < state.blueGrenades && num < list.Count)
		{
			GameObject val7 = list[num];
			WeaponUpgrader.ApplyBlueGrenadeVisuals(val7);
			list8.Add(new object[2]
			{
				val7.transform.GetSiblingIndex(),
				1
			});
			num9++;
			num++;
		}
		int num10 = 0;
		while (num10 < state.blueStunGrenades && num2 < list2.Count)
		{
			GameObject val8 = list2[num2];
			WeaponUpgrader.ApplyBlueStunGrenadeVisuals(val8);
			list8.Add(new object[2]
			{
				val8.transform.GetSiblingIndex(),
				3
			});
			num10++;
			num2++;
		}
		int num11 = 0;
		while (num11 < state.pinkStunGrenades && num2 < list2.Count)
		{
			GameObject val9 = list2[num2];
			WeaponUpgrader.ApplyPinkStunGrenadeVisuals(val9);
			list8.Add(new object[2]
			{
				val9.transform.GetSiblingIndex(),
				4
			});
			num11++;
			num2++;
		}
		int num12 = 0;
		while (num12 < state.blueShockwaveGrenades && num3 < list3.Count)
		{
			GameObject val10 = list3[num3];
			WeaponUpgrader.ApplyBlueShockwaveGrenadeVisuals(val10);
			list8.Add(new object[2]
			{
				val10.transform.GetSiblingIndex(),
				5
			});
			num12++;
			num3++;
		}
		int num13 = 0;
		while (num13 < state.pinkShockwaveGrenades && num3 < list3.Count)
		{
			GameObject val11 = list3[num3];
			WeaponUpgrader.ApplyPinkShockwaveGrenadeVisuals(val11);
			list8.Add(new object[2]
			{
				val11.transform.GetSiblingIndex(),
				6
			});
			num13++;
			num3++;
		}
		int num14 = 0;
		while (num14 < state.pinkmines && num4 < list4.Count)
		{
			GameObject val12 = list4[num4];
			WeaponUpgrader.ApplyPinkMineVisuals(val12);
			list8.Add(new object[2]
			{
				val12.transform.GetSiblingIndex(),
				12
			});
			num14++;
			num4++;
		}
		int num15 = 0;
		while (num15 < state.bluemines && num4 < list4.Count)
		{
			GameObject val13 = list4[num4];
			WeaponUpgrader.ApplyBlueMineVisuals(val13);
			list8.Add(new object[2]
			{
				val13.transform.GetSiblingIndex(),
				11
			});
			num15++;
			num4++;
		}
		int num16 = 0;
		while (num16 < state.largeBlueHealthPacks && num5 < list5.Count)
		{
			GameObject val14 = list5[num5];
			WeaponUpgrader.ApplyBlueHealthPackVisuals(val14);
			list8.Add(new object[2]
			{
				val14.transform.GetSiblingIndex(),
				13
			});
			num16++;
			num5++;
		}
		int num17 = 0;
		while (num17 < state.largePinkHealthPacks && num5 < list5.Count)
		{
			GameObject val15 = list5[num5];
			WeaponUpgrader.ApplyPinkHealthPackVisuals(val15);
			list8.Add(new object[2]
			{
				val15.transform.GetSiblingIndex(),
				14
			});
			num17++;
			num5++;
		}
		int num18 = 0;
		while (num18 < state.mediumBlueHealthPacks && num6 < list6.Count)
		{
			GameObject val16 = list6[num6];
			WeaponUpgrader.ApplyBlueHealthPackVisuals(val16);
			list8.Add(new object[2]
			{
				val16.transform.GetSiblingIndex(),
				15
			});
			num18++;
			num6++;
		}
		int num19 = 0;
		while (num19 < state.mediumPinkHealthPacks && num6 < list6.Count)
		{
			GameObject val17 = list6[num6];
			WeaponUpgrader.ApplyPinkHealthPackVisuals(val17);
			list8.Add(new object[2]
			{
				val17.transform.GetSiblingIndex(),
				16
			});
			num19++;
			num6++;
		}
		int num20 = 0;
		while (num20 < state.smallBlueHealthPacks && num7 < list7.Count)
		{
			GameObject val18 = list7[num7];
			WeaponUpgrader.ApplyBlueHealthPackVisuals(val18);
			list8.Add(new object[2]
			{
				val18.transform.GetSiblingIndex(),
				17
			});
			num20++;
			num7++;
		}
		int num21 = 0;
		while (num21 < state.smallPinkHealthPacks && num7 < list7.Count)
		{
			GameObject val19 = list7[num7];
			WeaponUpgrader.ApplyPinkHealthPackVisuals(val19);
			list8.Add(new object[2]
			{
				val19.transform.GetSiblingIndex(),
				18
			});
			num21++;
			num7++;
		}
		if ((Object)(object)val2 != (Object)null)
		{
			switch (state.handgunUpgrade)
			{
			case 1:
				WeaponUpgrader.ApplyBlueHandgunVisuals(val2);
				WeaponUpgrader.ApplyBlueHandgunBulletVisuals(val2);
				list8.Add(new object[2]
				{
					val2.transform.GetSiblingIndex(),
					7
				});
				break;
			case 2:
				WeaponUpgrader.ApplyPinkHandgunVisuals(val2);
				WeaponUpgrader.ApplyPinkHandgunBulletVisuals(val2);
				list8.Add(new object[2]
				{
					val2.transform.GetSiblingIndex(),
					8
				});
				break;
			}
		}
		if ((Object)(object)val3 != (Object)null)
		{
			switch (state.cartcannonUpgrade)
			{
			case 1:
				WeaponUpgrader.ApplyBlueCartCannonVisuals(val3);
				WeaponUpgrader.ApplyBlueCartCannonBulletVisuals(val3);
				list8.Add(new object[2]
				{
					val3.transform.GetSiblingIndex(),
					19
				});
				break;
			case 2:
				WeaponUpgrader.ApplyPinkCartCannonVisuals(val3);
				WeaponUpgrader.ApplyPinkCartCannonBulletVisuals(val3);
				list8.Add(new object[2]
				{
					val3.transform.GetSiblingIndex(),
					20
				});
				break;
			}
		}
		if ((Object)(object)val5 != (Object)null)
		{
			switch (state.fryingPanUpgrade)
			{
			case 1:
				WeaponUpgrader.ApplyBlueFryingPanVisuals(val5);
				list8.Add(new object[2]
				{
					val5.transform.GetSiblingIndex(),
					9
				});
				break;
			case 2:
				WeaponUpgrader.ApplyPinkFryingPanVisuals(val5);
				list8.Add(new object[2]
				{
					val5.transform.GetSiblingIndex(),
					10
				});
				break;
			}
		}
		if ((Object)(object)val4 != (Object)null)
		{
			switch (state.cartlaserUpgrade)
			{
			case 1:
				WeaponUpgrader.ApplyBlueCartLaserVisuals(val4);
				list8.Add(new object[2]
				{
					val4.transform.GetSiblingIndex(),
					21
				});
				break;
			case 2:
				WeaponUpgrader.ApplyPinkCartLaserVisuals(val4);
				list8.Add(new object[2]
				{
					val4.transform.GetSiblingIndex(),
					22
				});
				break;
			}
		}
		Debug.Log((object)">>> Applied saved upgrades");
		if (PhotonNetwork.IsMasterClient && list8.Count > 0)
		{
			PhotonNetwork.RaiseEvent((byte)21, (object)list8.ToArray(), new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)1
			}, SendOptions.SendReliable);
		}
	}

	private static bool IsExcludedScene()
	{
		GameObject val = GameObject.Find("Level Generator");
		Transform val2 = ((val != null) ? val.transform.FindDeepChild("Level") : null);
		if ((Object)(object)val2 == (Object)null || val2.childCount == 0)
		{
			return true;
		}
		string name = ((Object)val2.GetChild(0)).name;
		return name.StartsWith("Start Room - Shop") || name.StartsWith("Start Room - Main Menu") || name.StartsWith("Start Room - Lobby Menu");
	}
}
[HarmonyPatch(typeof(ItemGun), "Shoot")]
public static class ShootPatch
{
	[HarmonyPrefix]
	public static void Prefix(ItemGun __instance)
	{
		PinkHandgun pinkHandgun = default(PinkHandgun);
		BlueHandgun blueHandgun = default(BlueHandgun);
		if (((Component)__instance).TryGetComponent<PinkHandgun>(ref pinkHandgun) || ((Component)__instance).TryGetComponent<BlueHandgun>(ref blueHandgun))
		{
			if ((Object)(object)((Component)__instance).GetComponent<PinkHandgun>() != (Object)null)
			{
				__instance.shootCooldown = 0.72f;
				__instance.gunRange = 37.5f;
				__instance.gunRecoilForce = 4.5f;
				__instance.gunRandomSpread = 2.7f;
			}
			else if ((Object)(object)((Component)__instance).GetComponent<BlueHandgun>() != (Object)null)
			{
				__instance.shootCooldown = 0.76f;
				__instance.gunRange = 31.25f;
				__instance.gunRecoilForce = 4.75f;
				__instance.gunRandomSpread = 2.85f;
			}
		}
	}
}
public class ShopItemWatcher : MonoBehaviour
{
	private readonly HashSet<GameObject> modifiedItems = new HashSet<GameObject>();

	private float scanInterval = 1f;

	private float timer = 0f;

	private Transform? itemParent;

	private bool startRoomShopFound = false;

	private const byte ShopPriceUpdateEventCode = 43;

	private const float ItemMultiplier = 0.5f;

	private void Update()
	{
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Expected O, but got Unknown
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Expected O, but got Unknown
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		if (!PhotonNetwork.IsMasterClient)
		{
			return;
		}
		timer -= Time.deltaTime;
		if (timer > 0f)
		{
			return;
		}
		timer = scanInterval;
		if (!startRoomShopFound)
		{
			GameObject val = GameObject.Find("Level Generator");
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			Transform val2 = val.transform.Find("Level");
			if (!((Object)(object)val2 != (Object)null))
			{
				return;
			}
			{
				foreach (Transform item in val2)
				{
					Transform val3 = item;
					if (((Object)val3).name.StartsWith("Start Room - Shop"))
					{
						startRoomShopFound = true;
						Debug.Log((object)">>> ShopItemWatcher: Found Start Room - Shop (clone)");
						break;
					}
				}
				return;
			}
		}
		if ((Object)(object)itemParent == (Object)null)
		{
			GameObject val4 = GameObject.Find("Level Generator");
			if ((Object)(object)val4 != (Object)null)
			{
				Transform val5 = val4.transform.Find("Items");
				if ((Object)(object)val5 != (Object)null)
				{
					itemParent = val5;
					Debug.Log((object)">>> ShopItemWatcher: Found 'Level Generator/Items'");
				}
			}
			return;
		}
		for (int i = 0; i < itemParent.childCount; i++)
		{
			GameObject gameObject = ((Component)itemParent.GetChild(i)).gameObject;
			if (!modifiedItems.Contains(gameObject))
			{
				ItemAttributes component = gameObject.GetComponent<ItemAttributes>();
				if ((Object)(object)component != (Object)null && component.shopItem && ((Object)gameObject).name.StartsWith("Item"))
				{
					int value = component.value;
					int num = (component.value = Mathf.Max(1, Mathf.CeilToInt((float)value * 0.5f)));
					modifiedItems.Add(gameObject);
					Debug.Log((object)$">>> Adjusted '{((Object)gameObject).name}' from {value} → {num}");
					object[] array = new object[2] { i, num };
					RaiseEventOptions val6 = new RaiseEventOptions
					{
						Receivers = (ReceiverGroup)0
					};
					PhotonNetwork.RaiseEvent((byte)43, (object)array, val6, SendOptions.SendReliable);
				}
			}
		}
	}
}
public static class TransformExtensions
{
	[CompilerGenerated]
	private sealed class <FindDeepChildren>d__1 : IEnumerable<Transform>, IEnumerable, IEnumerator<Transform>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private Transform <>2__current;

		private int <>l__initialThreadId;

		private Transform parent;

		public Transform <>3__parent;

		private string name;

		public string <>3__name;

		private IEnumerator <>s__1;

		private Transform <child>5__2;

		private IEnumerator<Transform> <>s__3;

		private Transform <match>5__4;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			int num = <>1__state;
			if ((uint)(num - -4) <= 1u || (uint)(num - 1) <= 1u)
			{
				try
				{
					if (num == -4 || num == 2)
					{
						try
						{
						}
						finally
						{
							<>m__Finally2();
						}
					}
				}
				finally
				{
					<>m__Finally1();
				}
			}
			<>s__1 = null;
			<child>5__2 = null;
			<>s__3 = null;
			<match>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			try
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>s__1 = parent.GetEnumerator();
					<>1__state = -3;
					goto IL_0126;
				case 1:
					<>1__state = -3;
					goto IL_00a5;
				case 2:
					{
						<>1__state = -4;
						<match>5__4 = null;
						goto IL_0103;
					}
					IL_0126:
					if (<>s__1.MoveNext())
					{
						<child>5__2 = (Transform)<>s__1.Current;
						if (((Object)<child>5__2).name == name)
						{
							<>2__current = <child>5__2;
							<>1__state = 1;
							return true;
						}
						goto IL_00a5;
					}
					<>m__Finally1();
					<>s__1 = null;
					return false;
					IL_00a5:
					<>s__3 = <child>5__2.FindDeepChildren(name).GetEnumerator();
					<>1__state = -4;
					goto IL_0103;
					IL_0103:
					if (<>s__3.MoveNext())
					{
						<match>5__4 = <>s__3.Current;
						<>2__current = <match>5__4;
						<>1__state = 2;
						return true;
					}
					<>m__Finally2();
					<>s__3 = null;
					<child>5__2 = null;
					goto IL_0126;
				}
			}
			catch
			{
				//try-fault
				((IDisposable)this).Dispose();
				throw;
			}
		}

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

		private void <>m__Finally1()
		{
			<>1__state = -1;
			if (<>s__1 is IDisposable disposable)
			{
				disposable.Dispose();
			}
		}

		private void <>m__Finally2()
		{
			<>1__state = -3;
			if (<>s__3 != null)
			{
				<>s__3.Dispose();
			}
		}

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

		[DebuggerHidden]
		IEnumerator<Transform> IEnumerable<Transform>.GetEnumerator()
		{
			<FindDeepChildren>d__1 <FindDeepChildren>d__;
			if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
			{
				<>1__state = 0;
				<FindDeepChildren>d__ = this;
			}
			else
			{
				<FindDeepChildren>d__ = new <FindDeepChildren>d__1(0);
			}
			<FindDeepChildren>d__.parent = <>3__parent;
			<FindDeepChildren>d__.name = <>3__name;
			return <FindDeepChildren>d__;
		}

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

	public static Transform? FindDeepChild(this Transform parent, string name)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		foreach (Transform item in parent)
		{
			Transform val = item;
			if (((Object)val).name == name)
			{
				return val;
			}
			Transform val2 = val.FindDeepChild(name);
			if ((Object)(object)val2 != (Object)null)
			{
				return val2;
			}
		}
		return null;
	}

	[IteratorStateMachine(typeof(<FindDeepChildren>d__1))]
	public static IEnumerable<Transform> FindDeepChildren(this Transform parent, string name)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <FindDeepChildren>d__1(-2)
		{
			<>3__parent = parent,
			<>3__name = name
		};
	}
}
public class UpgradeMenu : MonoBehaviour
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static Action <>9__4_13;

		public static ScrollViewBuilderDelegate <>9__4_1;

		public static Action <>9__16_3;

		public static ScrollViewBuilderDelegate <>9__16_1;

		public static Action <>9__16_4;

		public static ScrollViewBuilderDelegate <>9__16_2;

		public static Action <>9__17_3;

		public static ScrollViewBuilderDelegate <>9__17_1;

		public static Action <>9__17_4;

		public static ScrollViewBuilderDelegate <>9__17_2;

		public static Action <>9__18_3;

		public static ScrollViewBuilderDelegate <>9__18_1;

		public static Action <>9__18_4;

		public static ScrollViewBuilderDelegate <>9__18_2;

		public static Action <>9__19_3;

		public static ScrollViewBuilderDelegate <>9__19_1;

		public static Action <>9__19_4;

		public static ScrollViewBuilderDelegate <>9__19_2;

		public static Action <>9__20_3;

		public static ScrollViewBuilderDelegate <>9__20_1;

		public static Action <>9__20_4;

		public static ScrollViewBuilderDelegate <>9__20_2;

		public static Action <>9__21_3;

		public static ScrollViewBuilderDelegate <>9__21_1;

		public static Action <>9__21_4;

		public static ScrollViewBuilderDelegate <>9__21_2;

		public static Action <>9__22_3;

		public static ScrollViewBuilderDelegate <>9__22_1;

		public static Action <>9__22_4;

		public static ScrollViewBuilderDelegate <>9__22_2;

		public static Action <>9__23_3;

		public static ScrollViewBuilderDelegate <>9__23_1;

		public static Action <>9__23_4;

		public static ScrollViewBuilderDelegate <>9__23_2;

		public static Action <>9__24_3;

		public static ScrollViewBuilderDelegate <>9__24_1;

		public static Action <>9__24_4;

		public static ScrollViewBuilderDelegate <>9__24_2;

		public static Action <>9__25_3;

		public static ScrollViewBuilderDelegate <>9__25_1;

		public static Action <>9__25_4;

		public static ScrollViewBuilderDelegate <>9__25_2;

		public static Action <>9__26_3;

		public static ScrollViewBuilderDelegate <>9__26_1;

		public static Action <>9__26_4;

		public static ScrollViewBuilderDelegate <>9__26_2;

		public static ShouldCloseMenuDelegate <>9__27_0;

		internal RectTransform <CreateMainMenu>b__4_1(Transform parent)
		{
			//IL_0028: 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)
			REPOButton val = MenuAPI.CreateREPOButton("Show Money", (Action)delegate
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: 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_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Expected O, but got Unknown
				PhotonNetwork.RaiseEvent((byte)23, (object)null, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				}, SendOptions.SendReliable);
			}, parent, default(Vector2));
			return ((Component)val).GetComponent<RectTransform>();
		}

		internal void <CreateMainMenu>b__4_13()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			PhotonNetwork.RaiseEvent((byte)23, (object)null, new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)1
			}, SendOptions.SendReliable);
		}

		internal RectTransform <ShowOnlyHandgunUpgrades>b__16_1(Transform parent)
		{
			//IL_0028: 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)
			REPOButton val = MenuAPI.CreateREPOButton("Try Blue     $15k   95%", (Action)delegate
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: 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_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Expected O, but got Unknown
				PhotonNetwork.RaiseEvent((byte)20, (object)7, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)2
				}, SendOptions.SendReliable);
			}, parent, default(Vector2));
			return ((Component)val).GetComponent<RectTransform>();
		}

		in