Decompiled source of KuriiePlush v1.0.6

BepInEx\plugins\KuriiePlush\KuriiePlushMod.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using KuriiePlushMod.NetcodePatcher;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("KuriiePlushMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds a cute Kuriie plushie as scrap to Lethal Company")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: AssemblyInformationalVersion("1.0.6")]
[assembly: AssemblyProduct("KuriiePlushMod")]
[assembly: AssemblyTitle("KuriiePlushMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.6.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 KuriiePlushMod
{
	public class KuriiePlushBehaviour : PhysicsProp
	{
		[CompilerGenerated]
		private sealed class <SqueezeAnimationCoroutine>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public KuriiePlushBehaviour <>4__this;

			private float <squeezeDuration>5__2;

			private float <returnDuration>5__3;

			private Vector3 <squeezedScale>5__4;

			private float <elapsed>5__5;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_014f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_015c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				KuriiePlushBehaviour kuriiePlushBehaviour = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<squeezeDuration>5__2 = 0.15f;
					<returnDuration>5__3 = 0.4f;
					<squeezedScale>5__4 = new Vector3(kuriiePlushBehaviour.meshOriginalScale.x * 1.4f, kuriiePlushBehaviour.meshOriginalScale.y * 0.5f, kuriiePlushBehaviour.meshOriginalScale.z * 1.4f);
					<elapsed>5__5 = 0f;
					goto IL_00de;
				case 1:
					<>1__state = -1;
					goto IL_00de;
				case 2:
					{
						<>1__state = -1;
						break;
					}
					IL_00de:
					if (<elapsed>5__5 < <squeezeDuration>5__2)
					{
						<elapsed>5__5 += Time.deltaTime;
						float num2 = <elapsed>5__5 / <squeezeDuration>5__2;
						kuriiePlushBehaviour.meshTransform.localScale = Vector3.Lerp(kuriiePlushBehaviour.meshOriginalScale, <squeezedScale>5__4, num2);
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					<elapsed>5__5 = 0f;
					break;
				}
				if (<elapsed>5__5 < <returnDuration>5__3)
				{
					<elapsed>5__5 += Time.deltaTime;
					float num3 = <elapsed>5__5 / <returnDuration>5__3;
					float num4 = 1f - Mathf.Cos(num3 * MathF.PI * 2f) * Mathf.Pow(1f - num3, 2f);
					kuriiePlushBehaviour.meshTransform.localScale = Vector3.Lerp(<squeezedScale>5__4, kuriiePlushBehaviour.meshOriginalScale, num4);
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				kuriiePlushBehaviour.meshTransform.localScale = kuriiePlushBehaviour.meshOriginalScale;
				kuriiePlushBehaviour.squeezeCoroutine = 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 AudioSource audioSource;

		private float lastUseTime = -999f;

		private const float COOLDOWN = 1.5f;

		private Transform meshTransform;

		private Vector3 meshOriginalScale;

		private Coroutine squeezeCoroutine;

		public static AudioClip confettiSound;

		public override void Start()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Start();
			audioSource = ((Component)this).GetComponent<AudioSource>();
			meshTransform = ((Component)this).transform;
			meshOriginalScale = meshTransform.localScale;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && Time.time >= lastUseTime + 1.5f)
			{
				lastUseTime = Time.time;
				Vector3 position = ((Component)this).transform.position;
				Vector3 forward = Vector3.forward;
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.gameplayCamera != (Object)null)
				{
					forward = ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward;
				}
				int colorSeed = Random.Range(int.MinValue, int.MaxValue);
				if (((NetworkBehaviour)this).IsServer || ((NetworkBehaviour)this).IsHost)
				{
					PlayEffectsClientRpc(position, forward, colorSeed);
				}
				else
				{
					PlayEffectsServerRpc(position, forward, colorSeed);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void PlayEffectsServerRpc(Vector3 position, Vector3 lookDirection, int colorSeed)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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(3221706531u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref lookDirection);
					BytePacker.WriteValueBitPacked(val2, colorSeed);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3221706531u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					PlayEffectsClientRpc(position, lookDirection, colorSeed);
				}
			}
		}

		[ClientRpc]
		private void PlayEffectsClientRpc(Vector3 position, Vector3 lookDirection, int colorSeed)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3309559298u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref lookDirection);
					BytePacker.WriteValueBitPacked(val2, colorSeed);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3309559298u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					lastUseTime = Time.time;
					PlayConfetti(position, lookDirection, colorSeed);
					PlaySound();
					PlaySqueezeAnimation();
				}
			}
		}

		private void PlaySqueezeAnimation()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)meshTransform == (Object)null))
			{
				if (squeezeCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(squeezeCoroutine);
					meshTransform.localScale = meshOriginalScale;
				}
				squeezeCoroutine = ((MonoBehaviour)this).StartCoroutine(SqueezeAnimationCoroutine());
			}
		}

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

		private void PlaySound()
		{
			if (!((Object)(object)audioSource == (Object)null))
			{
				if ((Object)(object)confettiSound != (Object)null)
				{
					audioSource.PlayOneShot(confettiSound);
				}
				else if ((Object)(object)((GrabbableObject)this).itemProperties != (Object)null && (Object)(object)((GrabbableObject)this).itemProperties.grabSFX != (Object)null)
				{
					audioSource.PlayOneShot(((GrabbableObject)this).itemProperties.grabSFX);
				}
			}
		}

		private void PlayConfetti(Vector3 position, Vector3 lookDirection, int colorSeed)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (!TryUseGameConfetti(position, lookDirection))
			{
				CreateCustomConfetti(position, lookDirection, colorSeed);
			}
		}

		private bool TryUseGameConfetti(Vector3 position, Vector3 lookDirection)
		{
			//IL_008b: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				StartOfRound instance = StartOfRound.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return false;
				}
				FieldInfo[] fields = typeof(StartOfRound).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				FieldInfo[] array = fields;
				foreach (FieldInfo fieldInfo in array)
				{
					string text = fieldInfo.Name.ToLower();
					if (!text.Contains("confetti") && !text.Contains("birthday"))
					{
						continue;
					}
					object value = fieldInfo.GetValue(instance);
					ParticleSystem val = (ParticleSystem)((value is ParticleSystem) ? value : null);
					if (val != null && (Object)(object)val != (Object)null)
					{
						SpawnConfettiFromPrefab(((Component)val).gameObject, position, lookDirection);
						return true;
					}
					GameObject val2 = (GameObject)((value is GameObject) ? value : null);
					if (val2 != null && (Object)(object)val2 != (Object)null)
					{
						ParticleSystem component = val2.GetComponent<ParticleSystem>();
						if ((Object)(object)component != (Object)null)
						{
							SpawnConfettiFromPrefab(val2, position, lookDirection);
							return true;
						}
					}
				}
				foreach (Transform item in ((Component)instance).transform)
				{
					Transform val3 = item;
					if (((Object)val3).name.ToLower().Contains("confetti"))
					{
						ParticleSystem component2 = ((Component)val3).GetComponent<ParticleSystem>();
						if ((Object)(object)component2 != (Object)null)
						{
							SpawnConfettiFromPrefab(((Component)val3).gameObject, position, lookDirection);
							return true;
						}
					}
				}
			}
			catch (Exception)
			{
			}
			return false;
		}

		private void SpawnConfettiFromPrefab(GameObject confettiPrefab, Vector3 position, Vector3 lookDirection)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_000d: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = ((lookDirection != Vector3.zero) ? Quaternion.LookRotation(lookDirection) : Quaternion.identity);
			GameObject val2 = Object.Instantiate<GameObject>(confettiPrefab, position, val);
			val2.SetActive(true);
			ParticleSystem component = val2.GetComponent<ParticleSystem>();
			if ((Object)(object)component != (Object)null)
			{
				component.Play();
				MainModule main = component.main;
				float duration = ((MainModule)(ref main)).duration;
				main = component.main;
				MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
				Object.Destroy((Object)(object)val2, duration + ((MinMaxCurve)(ref startLifetime)).constantMax + 1f);
			}
			else
			{
				Object.Destroy((Object)(object)val2, 3f);
			}
		}

		private void CreateCustomConfetti(Vector3 position, Vector3 lookDirection, int colorSeed)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: 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_0385: 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_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Expected O, but got Unknown
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: 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)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Expected O, but got Unknown
			GameObject val = new GameObject("KuriieConfetti");
			val.transform.position = position;
			val.transform.rotation = ((lookDirection != Vector3.zero) ? Quaternion.LookRotation(lookDirection) : Quaternion.identity);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val2.main;
			((MainModule)(ref main)).duration = 0.3f;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(3f, 4.5f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(4f, 7f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.03f, 0.08f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, MathF.PI * 2f);
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.4f);
			((MainModule)(ref main)).maxParticles = 150;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).startSize3D = true;
			((MainModule)(ref main)).startSizeX = new MinMaxCurve(0.02f, 0.05f);
			((MainModule)(ref main)).startSizeY = new MinMaxCurve(0.06f, 0.12f);
			((MainModule)(ref main)).startSizeZ = new MinMaxCurve(0.01f, 0.02f);
			Color[] array = (Color[])(object)new Color[8]
			{
				new Color(1f, 0.3f, 0.5f),
				new Color(1f, 0.85f, 0.2f),
				new Color(0.3f, 1f, 0.4f),
				new Color(0.7f, 0.4f, 1f),
				new Color(1f, 0.5f, 0.2f),
				new Color(0.4f, 0.7f, 1f),
				new Color(1f, 0.4f, 0.4f),
				Color.white
			};
			Random random = new Random(colorSeed);
			int num = random.Next(0, array.Length);
			int num2 = random.Next(0, array.Length);
			((MainModule)(ref main)).startColor = new MinMaxGradient(array[num], array[num2]);
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
			{
				new Burst(0f, (short)80)
			});
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 35f;
			((ShapeModule)(ref shape)).radius = 0.15f;
			RotationOverLifetimeModule rotationOverLifetime = val2.rotationOverLifetime;
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = new MinMaxCurve(-MathF.PI, MathF.PI);
			CollisionModule collision = val2.collision;
			((CollisionModule)(ref collision)).enabled = true;
			((CollisionModule)(ref collision)).type = (ParticleSystemCollisionType)1;
			((CollisionModule)(ref collision)).mode = (ParticleSystemCollisionMode)0;
			((CollisionModule)(ref collision)).bounce = MinMaxCurve.op_Implicit(0.3f);
			((CollisionModule)(ref collision)).lifetimeLoss = MinMaxCurve.op_Implicit(0.05f);
			((CollisionModule)(ref collision)).dampen = MinMaxCurve.op_Implicit(0.2f);
			((CollisionModule)(ref collision)).collidesWith = LayerMask.op_Implicit(268437761);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)0;
			Shader val3 = Shader.Find("Legacy Shaders/Particles/Alpha Blended Premultiply") ?? Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color");
			if ((Object)(object)val3 != (Object)null)
			{
				((Renderer)component).material = new Material(val3);
			}
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val4 = new Gradient();
			val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(1f, 0.7f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val4);
			val2.Play();
			Object.Destroy((Object)(object)val, 5.5f);
		}

		protected override void __initializeVariables()
		{
			((PhysicsProp)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
			((NetworkBehaviour)this).__registerRpc(3221706531u, new RpcReceiveHandler(__rpc_handler_3221706531), "PlayEffectsServerRpc");
			((NetworkBehaviour)this).__registerRpc(3309559298u, new RpcReceiveHandler(__rpc_handler_3309559298), "PlayEffectsClientRpc");
			((PhysicsProp)this).__initializeRpcs();
		}

		private static void __rpc_handler_3221706531(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003d: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				Vector3 lookDirection = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref lookDirection);
				int colorSeed = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref colorSeed);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((KuriiePlushBehaviour)(object)target).PlayEffectsServerRpc(position, lookDirection, colorSeed);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3309559298(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003d: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				Vector3 lookDirection = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref lookDirection);
				int colorSeed = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref colorSeed);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((KuriiePlushBehaviour)(object)target).PlayEffectsClientRpc(position, lookDirection, colorSeed);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "KuriiePlushBehaviour";
		}
	}
	[BepInPlugin("com.kuriie.plushmod", "Kuriie Plush", "1.0.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "com.kuriie.plushmod";

		public const string ModName = "Kuriie Plush";

		public const string ModVersion = "1.0.6";

		private void Awake()
		{
			InitializeNetcodeRPCs();
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "kuriieplush"));
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load asset bundle!");
				return;
			}
			Item val2 = null;
			string[] allAssetNames = val.GetAllAssetNames();
			foreach (string text in allAssetNames)
			{
				if (text.EndsWith(".asset"))
				{
					Item val3 = val.LoadAsset<Item>(text);
					if ((Object)(object)val3 != (Object)null)
					{
						val2 = val3;
						break;
					}
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load KuriiePlushItem from asset bundle!");
				return;
			}
			if ((Object)(object)val2.spawnPrefab == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Item's spawnPrefab is null!");
				return;
			}
			GameObject spawnPrefab = val2.spawnPrefab;
			GrabbableObject component = spawnPrefab.GetComponent<GrabbableObject>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			KuriiePlushBehaviour kuriiePlushBehaviour = spawnPrefab.AddComponent<KuriiePlushBehaviour>();
			((GrabbableObject)kuriiePlushBehaviour).grabbable = true;
			((GrabbableObject)kuriiePlushBehaviour).grabbableToEnemies = true;
			((GrabbableObject)kuriiePlushBehaviour).isInFactory = true;
			((GrabbableObject)kuriiePlushBehaviour).itemProperties = val2;
			val2.spawnPrefab = spawnPrefab;
			string[] allAssetNames2 = val.GetAllAssetNames();
			foreach (string text2 in allAssetNames2)
			{
				if (text2.ToLower().Contains("confetti") && (text2.EndsWith(".wav") || text2.EndsWith(".mp3") || text2.EndsWith(".ogg")))
				{
					AudioClip val4 = val.LoadAsset<AudioClip>(text2);
					if ((Object)(object)val4 != (Object)null)
					{
						KuriiePlushBehaviour.confettiSound = val4;
						break;
					}
				}
			}
			Utilities.FixMixerGroups(spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(spawnPrefab);
			Items.RegisterScrap(val2, 45, (LevelTypes)(-1));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Kuriie Plush mod loaded!");
		}

		private static void InitializeNetcodeRPCs()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "KuriiePlushMod";

		public const string PLUGIN_NAME = "KuriiePlushMod";

		public const string PLUGIN_VERSION = "1.0.6";
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace KuriiePlushMod.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}