Decompiled source of Pinya v1.0.5

BepInEx/plugins/PinataScrap.dll

Decompiled 3 weeks 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 BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PinataScrap.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Kittenji")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PinataScrap")]
[assembly: AssemblyTitle("PinataScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Kittenji.PinataScrap
{
	public class PinataProp : GrabbableObject, IHittable
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass41_0
		{
			public float startTime;

			public NetworkObjectReference netObjectRef;

			public NetworkObject netObject;

			public PlayerControllerB player;

			internal bool <waitForMimicEnemySpawn>b__0()
			{
				if (!(Time.realtimeSinceStartup - startTime > 20f))
				{
					return ((NetworkObjectReference)(ref netObjectRef)).TryGet(ref netObject, (NetworkManager)null);
				}
				return true;
			}

			internal bool <waitForMimicEnemySpawn>b__1()
			{
				if (!(Time.realtimeSinceStartup - startTime > 20f))
				{
					return (Object)(object)player.deadBody != (Object)null;
				}
				return true;
			}
		}

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

			private object <>2__current;

			public bool ignoreDelay;

			public PinataProp <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Expected O, but got Unknown
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Unknown result type (might be due to invalid IL or missing references)
				//IL_0140: Unknown result type (might be due to invalid IL or missing references)
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0150: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				PinataProp pinataProp = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(ignoreDelay ? 0f : Random.Range(0.5f, 1.2f));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (Object.op_Implicit((Object)(object)pinataProp.poppingPlayer) && !pinataProp.poppingPlayer.isPlayerDead)
					{
						var (num2, num3) = pinataProp.GetWeightedEffect();
						pinataProp.SpawnEffectServerRpc(((Component)pinataProp.poppingPlayer).transform.position + Vector3.up * 0.5f, (byte)num2, (byte)num3);
						switch (num2)
						{
						case 1:
							pinataProp.poppingPlayer.KillPlayer(GetRandomUpVel(), true, (CauseOfDeath)2, 0, default(Vector3));
							break;
						case 2:
						{
							Vector3 position = ((Component)pinataProp.poppingPlayer).transform.position;
							pinataProp.poppingPlayer.KillPlayer(Vector3.zero, true, (CauseOfDeath)5, pinataProp.maskTypeId, default(Vector3));
							pinataProp.CreateMimicServerRpc(position, (int)pinataProp.poppingPlayer.playerClientId);
							break;
						}
						default:
							pinataProp.poppingPlayer.KillPlayer(Vector3.zero, false, (CauseOfDeath)0, 0, default(Vector3));
							break;
						}
					}
					((Collider)pinataProp.boxCollider).enabled = true;
					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 <waitForMimicEnemySpawn>d__41 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NetworkObjectReference netObjectRef;

			public int playerKilled;

			private <>c__DisplayClass41_0 <>8__1;

			public bool inFactory;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Expected O, but got Unknown
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>8__1 = new <>c__DisplayClass41_0();
					<>8__1.netObjectRef = netObjectRef;
					<>8__1.player = StartOfRound.Instance.allPlayerScripts[playerKilled];
					<>8__1.netObject = null;
					<>8__1.startTime = Time.realtimeSinceStartup;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - <>8__1.startTime > 20f || ((NetworkObjectReference)(ref <>8__1.netObjectRef)).TryGet(ref <>8__1.netObject, (NetworkManager)null)));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)<>8__1.player.deadBody == (Object)null)
					{
						<>8__1.startTime = Time.realtimeSinceStartup;
						<>2__current = (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - <>8__1.startTime > 20f || (Object)(object)<>8__1.player.deadBody != (Object)null));
						<>1__state = 2;
						return true;
					}
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if ((Object)(object)<>8__1.player.deadBody == (Object)null)
				{
					return false;
				}
				<>8__1.player.deadBody.DeactivateBody(false);
				if ((Object)(object)<>8__1.netObject != (Object)null)
				{
					MaskedPlayerEnemy component = ((Component)<>8__1.netObject).GetComponent<MaskedPlayerEnemy>();
					component.mimickingPlayer = <>8__1.player;
					component.SetSuit(<>8__1.player.currentSuitID);
					((EnemyAI)component).SetEnemyOutside(!inFactory);
					<>8__1.player.redirectToEnemy = (EnemyAI)(object)component;
				}
				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 const int cloneItemChance = 25;

		private const int cloneItemPrice = 40;

		[Header("Pinata Prop")]
		public Vector2 timerStart = new Vector2(3f, 15f);

		public Vector2 timerHalf = new Vector2(0.8f, 2f);

		public Vector2 timerFull = new Vector2(0.3f, 0.5f);

		[Header("Materials")]
		public Material materialBase;

		public Material materialHalf;

		[Header("Effects")]
		public AudioSource warningSound;

		public AudioSource itemSound;

		[Header("Weights")]
		public WeightedEffect[] effectsList;

		private int totalWeight;

		private bool itemGrabbed;

		private float effectTimer;

		private float effectTimerHalf;

		private float effectTimerFull;

		private bool skinHalf;

		private bool skinFull;

		private BoxCollider boxCollider;

		private PlayerControllerB poppingPlayer;

		private EnemyAI heldByEnemy;

		private float lastTimerAdd;

		private float lastDropTime;

		private int maskTypeId = 4;

		private void Awake()
		{
			boxCollider = ((Component)this).GetComponent<BoxCollider>();
			for (int i = 0; i < effectsList.Length; i++)
			{
				totalWeight += effectsList[i].weight;
			}
			if (base.scrapValue < 1)
			{
				((GrabbableObject)this).SetScrapValue(40);
			}
		}

		private static float GetRandomFromVec(Vector2 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Random.Range(pos.x, pos.y);
		}

		private static Vector3 GetRandomUpVel(float min = 50f, float max = 80f, float h = 5f)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(Random.Range(0f - h, h), Random.Range(min, max), Random.Range(0f - h, h));
		}

		private (int, int) GetWeightedEffect()
		{
			int num = Random.Range(0, totalWeight);
			int num2 = 0;
			int item = 0;
			int i;
			for (i = 0; i < effectsList.Length; i++)
			{
				num2 += effectsList[i].weight;
				if (num <= num2)
				{
					break;
				}
			}
			WeightedEffect weightedEffect = effectsList[i];
			if (weightedEffect.requiresOpenSky && (poppingPlayer.isInsideFactory || poppingPlayer.isInHangarShipRoom))
			{
				return GetWeightedEffect();
			}
			if (weightedEffect.clips != null && weightedEffect.clips.Length != 0)
			{
				item = 1 + Random.Range(0, weightedEffect.clips.Length);
			}
			return (i, item);
		}

		public override void GrabItem()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).GrabItem();
			float num = (Time.time - lastDropTime) * 1.1f;
			float num2 = ((num < lastTimerAdd) ? (lastTimerAdd * Mathf.Clamp01(num / lastTimerAdd)) : (lastTimerAdd = GetRandomFromVec(timerStart)));
			effectTimer = Time.time + num2;
			effectTimerFull = effectTimer - GetRandomFromVec(timerFull);
			effectTimerHalf = effectTimer - GetRandomFromVec(timerHalf);
			skinHalf = false;
			skinFull = false;
			itemGrabbed = true;
			base.isHeldByEnemy = false;
			((Renderer)base.mainObjectRenderer).sharedMaterial = materialBase;
		}

		public override void GrabItemFromEnemy(EnemyAI enemy)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).GrabItemFromEnemy(enemy);
			effectTimer = Time.time + GetRandomFromVec(timerStart);
			heldByEnemy = enemy;
			itemGrabbed = true;
			base.isHeldByEnemy = true;
		}

		public void OnDropItem()
		{
			((Renderer)base.mainObjectRenderer).sharedMaterial = materialBase;
			itemGrabbed = false;
			base.isHeldByEnemy = false;
			lastDropTime = Time.time;
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (!itemGrabbed)
			{
				return;
			}
			float time = Time.time;
			if (!base.isHeldByEnemy)
			{
				if (!Object.op_Implicit((Object)(object)base.playerHeldBy))
				{
					OnDropItem();
					return;
				}
				if (time > effectTimerHalf && !skinHalf)
				{
					skinHalf = true;
					((Renderer)base.mainObjectRenderer).sharedMaterial = materialHalf;
					base.playerHeldBy.JumpToFearLevel(1f, true);
				}
				if (time > effectTimerFull && !skinFull)
				{
					skinFull = true;
					if (!warningSound.isPlaying)
					{
						warningSound.Play();
					}
				}
			}
			if (!(time > effectTimer))
			{
				return;
			}
			bool isHeldByEnemy = base.isHeldByEnemy;
			OnDropItem();
			if (!StartOfRound.Instance.inShipPhase)
			{
				if (isHeldByEnemy)
				{
					PunishEnemy();
				}
				else
				{
					PunishPlayer();
				}
			}
		}

		private void PunishPlayer()
		{
			poppingPlayer = base.playerHeldBy;
			poppingPlayer.DropAllHeldItemsAndSync();
			((Collider)boxCollider).enabled = false;
			((MonoBehaviour)this).StartCoroutine(KillAnimation(ignoreDelay: true));
		}

		private void PunishEnemy()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)heldByEnemy) && ((NetworkBehaviour)this).IsServer && Object.op_Implicit((Object)(object)base.parentObject))
			{
				SpawnEffectServerRpc(((Component)heldByEnemy).transform.position + Vector3.up * 0.5f, 0, 0);
				ForceDropItemServerRpc();
				if (heldByEnemy.thisNetworkObject.IsSpawned)
				{
					heldByEnemy.thisNetworkObject.Despawn(true);
				}
			}
		}

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

		[ServerRpc(RequireOwnership = false)]
		private void SpawnEffectServerRpc(Vector3 pos, byte index, byte data)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2330172785u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
					((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref index, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref data, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2330172785u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SpawnEffectClientRpc(pos, index, data);
				}
			}
		}

		[ClientRpc]
		private void SpawnEffectClientRpc(Vector3 pos, byte index, byte data)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4166333787u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
				((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref index, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref data, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4166333787u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				WeightedEffect weightedEffect = effectsList[index];
				if (Object.op_Implicit((Object)(object)weightedEffect.prefab))
				{
					Object.Instantiate<GameObject>(weightedEffect.prefab, pos, Quaternion.Euler(0f, Random.Range(-180f, 180f), 0f));
				}
				if (weightedEffect.clips != null && weightedEffect.clips.Length != 0)
				{
					int num = Mathf.Max(Mathf.Min(data - 1, weightedEffect.clips.Length - 1), 0);
					AudioClip val3 = weightedEffect.clips[num];
					itemSound.PlayOneShot(val3);
					WalkieTalkie.TransmitOneShotAudio(itemSound, weightedEffect.clips[num], 1f);
					RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 25f, 1f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
				}
				if (((NetworkBehaviour)this).IsServer && !StartOfRound.Instance.inShipPhase && index == 0 && Random.Range(0, 100) < 25)
				{
					GameObject obj = Object.Instantiate<GameObject>(base.itemProperties.spawnPrefab, pos, Quaternion.Euler(0f, Random.Range(-180f, 180f), 0f), StartOfRound.Instance.propsContainer);
					((GrabbableObject)obj.GetComponent<PinataProp>()).fallTime = 0f;
					obj.GetComponent<NetworkObject>().Spawn(false);
				}
			}
		}

		[ServerRpc]
		private void ForceDropItemServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(874794095u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 874794095u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				ForceDropItemClientRpc();
			}
		}

		[ClientRpc]
		private void ForceDropItemClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1822016729u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1822016729u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (base.isHeld)
				{
					((GrabbableObject)this).DiscardItemFromEnemy();
					base.isHeldByEnemy = false;
					return;
				}
				Vector3 val3 = RoundManager.Instance.RandomlyOffsetPosition(((GrabbableObject)this).GetItemFloorPosition(default(Vector3)), 1.2f, 0.4f);
				base.parentObject = null;
				((Component)this).transform.SetParent(StartOfRound.Instance.propsContainer, true);
				((GrabbableObject)this).EnablePhysics(true);
				base.fallTime = 0f;
				base.startFallingPosition = ((Component)this).transform.parent.InverseTransformPoint(((Component)this).transform.position);
				base.targetFloorPosition = ((Component)this).transform.parent.InverseTransformPoint(val3);
				base.floorYRot = -1;
				((GrabbableObject)this).DiscardItemFromEnemy();
				base.isHeldByEnemy = false;
			}
		}

		public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitId = -1)
		{
			if ((Object)(object)playerWhoHit == (Object)null)
			{
				return false;
			}
			poppingPlayer = playerWhoHit;
			((MonoBehaviour)this).StartCoroutine(KillAnimation(ignoreDelay: true));
			return true;
		}

		[ServerRpc(RequireOwnership = false)]
		public void CreateMimicServerRpc(Vector3 playerPositionAtDeath, int playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(384698143u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref playerPositionAtDeath);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 384698143u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
			bool flag = ((Component)val3).transform.position.y < -80f;
			NetworkObjectReference netObjectRef = RoundManager.Instance.SpawnEnemyGameObject(GetGroundPosition(playerPositionAtDeath), ((Component)val3).transform.eulerAngles.y, -1, Plugin.mimicEnemy);
			NetworkObject val4 = default(NetworkObject);
			if (((NetworkObjectReference)(ref netObjectRef)).TryGet(ref val4, (NetworkManager)null))
			{
				MaskedPlayerEnemy component = ((Component)val4).GetComponent<MaskedPlayerEnemy>();
				component.SetSuit(val3.currentSuitID);
				component.mimickingPlayer = val3;
				((EnemyAI)component).SetEnemyOutside(!flag);
				val3.redirectToEnemy = (EnemyAI)(object)component;
				if ((Object)(object)val3.deadBody != (Object)null)
				{
					val3.deadBody.DeactivateBody(false);
				}
			}
			CreateMimicClientRpc(netObjectRef, flag, playerId);
		}

		[ClientRpc]
		public void CreateMimicClientRpc(NetworkObjectReference netObjectRef, bool inFactory, int playerKilled)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1017816859u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref inFactory, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, playerKilled);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1017816859u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (!((NetworkBehaviour)this).IsServer)
				{
					((MonoBehaviour)this).StartCoroutine(waitForMimicEnemySpawn(netObjectRef, inFactory, playerKilled));
				}
			}
		}

		[IteratorStateMachine(typeof(<waitForMimicEnemySpawn>d__41))]
		private IEnumerator waitForMimicEnemySpawn(NetworkObjectReference netObjectRef, bool inFactory, int playerKilled)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <waitForMimicEnemySpawn>d__41(0)
			{
				netObjectRef = netObjectRef,
				inFactory = inFactory,
				playerKilled = playerKilled
			};
		}

		private Vector3 GetGroundPosition(Vector3 startingPos)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(startingPos, default(NavMeshHit), 3f, -1);
			if (!RoundManager.Instance.GotNavMeshPositionResult)
			{
				return startingPos;
			}
			return navMeshPosition;
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2330172785u, new RpcReceiveHandler(__rpc_handler_2330172785), "SpawnEffectServerRpc");
			((NetworkBehaviour)this).__registerRpc(4166333787u, new RpcReceiveHandler(__rpc_handler_4166333787), "SpawnEffectClientRpc");
			((NetworkBehaviour)this).__registerRpc(874794095u, new RpcReceiveHandler(__rpc_handler_874794095), "ForceDropItemServerRpc");
			((NetworkBehaviour)this).__registerRpc(1822016729u, new RpcReceiveHandler(__rpc_handler_1822016729), "ForceDropItemClientRpc");
			((NetworkBehaviour)this).__registerRpc(384698143u, new RpcReceiveHandler(__rpc_handler_384698143), "CreateMimicServerRpc");
			((NetworkBehaviour)this).__registerRpc(1017816859u, new RpcReceiveHandler(__rpc_handler_1017816859), "CreateMimicClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_2330172785(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 pos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
				byte index = default(byte);
				((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref index, default(ForPrimitives));
				byte data = default(byte);
				((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref data, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PinataProp)(object)target).SpawnEffectServerRpc(pos, index, data);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4166333787(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 pos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
				byte index = default(byte);
				((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref index, default(ForPrimitives));
				byte data = default(byte);
				((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref data, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PinataProp)(object)target).SpawnEffectClientRpc(pos, index, data);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_874794095(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PinataProp)(object)target).ForceDropItemServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1822016729(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PinataProp)(object)target).ForceDropItemClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_384698143(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 playerPositionAtDeath = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref playerPositionAtDeath);
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PinataProp)(object)target).CreateMimicServerRpc(playerPositionAtDeath, playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1017816859(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
				bool inFactory = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref inFactory, default(ForPrimitives));
				int playerKilled = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerKilled);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PinataProp)(object)target).CreateMimicClientRpc(netObjectRef, inFactory, playerKilled);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "PinataProp";
		}
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/Kittenji/Pinata Scrap/Weighted Effect")]
	public class WeightedEffect : ScriptableObject
	{
		public int id;

		public int weight;

		public GameObject prefab;

		public AudioClip[] clips;

		public bool requiresOpenSky;
	}
	[BepInPlugin("Kittenji.PinataScrap", "PinataScrap", "1.0.5")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GameNetworkManager))]
		internal class GameNetworkManagerPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void StartPatch()
			{
				((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().AddNetworkPrefab(itemEntry.spawnPrefab);
			}
		}

		[HarmonyPatch(typeof(StartOfRound))]
		internal class StartOfRoundPatch
		{
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			private static void AwakePatch(ref StartOfRound __instance)
			{
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Expected O, but got Unknown
				SelectableLevel[] levels = __instance.levels;
				foreach (SelectableLevel val in levels)
				{
					if ((Object)(object)mimicEnemy == (Object)null)
					{
						SpawnableEnemyWithRarity val2 = val.Enemies.Find((SpawnableEnemyWithRarity e) => Object.op_Implicit((Object)(object)e.enemyType) && ((Object)e.enemyType).name == "MaskedPlayerEnemy");
						if (val2 != null && (Object)(object)val2.enemyType != (Object)null)
						{
							mimicEnemy = val2.enemyType;
							Debug.Log((object)"Found masked enemy!");
						}
					}
					if (!val.spawnableScrap.Any((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)itemEntry))
					{
						SpawnableItemWithRarity item = new SpawnableItemWithRarity
						{
							spawnableItem = itemEntry,
							rarity = Mathf.Max(1, spawnRate.Value)
						};
						val.spawnableScrap.Add(item);
					}
				}
				if (!__instance.allItemsList.itemsList.Contains(itemEntry))
				{
					__instance.allItemsList.itemsList.Add(itemEntry);
				}
			}
		}

		public const string pluginGUID = "Kittenji.PinataScrap";

		public const string pluginName = "PinataScrap";

		public const string pluginVersion = "1.0.5";

		public static readonly Harmony harmony = new Harmony("Kittenji.PinataScrap");

		public static readonly Assets assets = new Assets();

		public static Item itemEntry;

		public static ConfigEntry<int> spawnRate;

		public static EnemyType mimicEnemy;

		private void Awake()
		{
			itemEntry = assets.LoadByName<Item>("PinataToy.asset", nameOnly: false);
			spawnRate = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Spawn Rate", 10, "Defines the spawn rarity for the item.");
			harmony.PatchAll();
			InitNetcode();
		}

		private static void InitNetcode()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class ResourceUtils
	{
		public static Stream Get(string name)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			if (manifestResourceNames.Length == 0)
			{
				throw new FileNotFoundException("Assembly does not contain any resource stream names.");
			}
			string text = manifestResourceNames.FirstOrDefault((string n) => n.EndsWith(name));
			if (string.IsNullOrEmpty(text))
			{
				throw new FileNotFoundException("Assembly does not contain a resource stream ending with '" + name + "'");
			}
			return executingAssembly.GetManifestResourceStream(text);
		}

		public static string GetString(string name)
		{
			using Stream stream = Get(name);
			using StreamReader streamReader = new StreamReader(stream);
			return streamReader.ReadToEnd();
		}
	}
	public class Assets
	{
		private readonly AssetBundle mainAssetBundle;

		private readonly string[] allAssetNames;

		public Assets(string name = ".bundle")
		{
			mainAssetBundle = AssetBundle.LoadFromStream(ResourceUtils.Get(name));
			allAssetNames = mainAssetBundle.GetAllAssetNames();
		}

		public T Load<T>(string name) where T : Object
		{
			if (name == null)
			{
				return default(T);
			}
			return mainAssetBundle.LoadAsset<T>(name);
		}

		public T LoadByName<T>(string name, bool nameOnly = false) where T : Object
		{
			string name2 = allAssetNames.FirstOrDefault((string x) => (nameOnly ? Path.GetFileNameWithoutExtension(x) : Path.GetFileName(x)).Equals(name, StringComparison.OrdinalIgnoreCase));
			return Load<T>(name2);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace PinataScrap.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}