Decompiled source of KissModPlus v1.1.1

BepInEx\plugins\KissModPlus.dll

Decompiled an hour 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.Text;
using BepInEx;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KissModPlus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("KissModPlus")]
[assembly: AssemblyTitle("KissModPlus")]
[assembly: AssemblyVersion("1.1.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 KissModPlus
{
	[BepInPlugin("fan.kissmodplus.repo", "KissMod Plus", "1.1.1")]
	public sealed class KissPlugin : BaseUnityPlugin, IOnEventCallback
	{
		public const string PluginGuid = "fan.kissmodplus.repo";

		public const string PluginName = "KissMod Plus";

		public const string PluginVersion = "1.1.1";

		private const byte KissEventCode = 174;

		private const float PlayerKissRange = 3f;

		private ManualLogSource _log;

		private Font _font;

		private AudioClip _kissClip;

		private Material _sparkleMaterial;

		private Material _lipsMaterial;

		private bool _registered;

		private void Awake()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			_log = ((BaseUnityPlugin)this).Logger;
			_font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			_kissClip = LoadEmbeddedKissClip();
			if ((Object)(object)_kissClip == (Object)null)
			{
				_kissClip = CreateKissClip();
			}
			_lipsMaterial = LoadLipsMaterial();
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Unlit/Color");
			}
			if ((Object)(object)val != (Object)null)
			{
				_sparkleMaterial = new Material(val);
				_sparkleMaterial.color = new Color(1f, 0.45f, 0.78f, 1f);
			}
			_log.LogInfo((object)"KissMod Plus loaded. Press F to send a kiss effect.");
		}

		private void OnEnable()
		{
			TryRegisterPhotonCallback();
		}

		private void OnDisable()
		{
			if (_registered)
			{
				PhotonNetwork.RemoveCallbackTarget((object)this);
				_registered = false;
			}
		}

		private void Update()
		{
			TryRegisterPhotonCallback();
			if (Input.GetKeyDown((KeyCode)102))
			{
				SendKiss();
			}
		}

		private void TryRegisterPhotonCallback()
		{
			if (_registered)
			{
				return;
			}
			try
			{
				PhotonNetwork.AddCallbackTarget((object)this);
				_registered = true;
			}
			catch
			{
			}
		}

		private void SendKiss()
		{
			//IL_001f: 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_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_0044: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00a1: 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_00b8: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null || !HasNearbyOtherPlayer())
			{
				return;
			}
			Vector3 val = ((Component)main).transform.position + ((Component)main).transform.forward * 0.85f + ((Component)main).transform.up * -0.12f;
			Vector3 forward = ((Component)main).transform.forward;
			SpawnKiss(val, forward);
			if (!PhotonNetwork.InRoom)
			{
				return;
			}
			object obj = new float[6] { val.x, val.y, val.z, forward.x, forward.y, forward.z };
			try
			{
				PhotonNetwork.RaiseEvent((byte)174, obj, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0
				}, SendOptions.SendReliable);
			}
			catch (Exception ex)
			{
				_log.LogWarning((object)("Could not broadcast kiss effect: " + ex.Message));
			}
		}

		public void OnEvent(EventData photonEvent)
		{
			//IL_005c: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (photonEvent != null && photonEvent.Code == 174 && photonEvent.CustomData is float[] array && array.Length >= 6)
			{
				Vector3 origin = default(Vector3);
				((Vector3)(ref origin))..ctor(array[0], array[1], array[2]);
				Vector3 forward = default(Vector3);
				((Vector3)(ref forward))..ctor(array[3], array[4], array[5]);
				if (((Vector3)(ref forward)).sqrMagnitude < 0.001f)
				{
					forward = Vector3.forward;
				}
				SpawnKiss(origin, ((Vector3)(ref forward)).normalized);
			}
		}

		private bool HasNearbyOtherPlayer()
		{
			//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_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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
				if (list == null)
				{
					return false;
				}
				float num = 9f;
				Vector3 position = ((Component)val).transform.position;
				foreach (PlayerAvatar item in list)
				{
					if (!((Object)(object)item == (Object)null) && !((Object)(object)item == (Object)(object)val))
					{
						Vector3 val2 = ((Component)item).transform.position - position;
						if (((Vector3)(ref val2)).sqrMagnitude <= num)
						{
							return true;
						}
					}
				}
			}
			catch (Exception ex)
			{
				_log.LogWarning((object)("Could not check nearby players; kiss cancelled: " + ex.Message));
			}
			return false;
		}

		private AudioClip LoadEmbeddedKissClip()
		{
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				byte[] array;
				using (Stream stream = executingAssembly.GetManifestResourceStream("KissModPlus.Assets.KissSound.wav"))
				{
					if (stream == null)
					{
						_log.LogWarning((object)"Embedded KissSound.wav was not found. Using the fallback kiss sound.");
						return null;
					}
					using MemoryStream memoryStream = new MemoryStream();
					stream.CopyTo(memoryStream);
					array = memoryStream.ToArray();
				}
				if (array.Length < 44 || Encoding.ASCII.GetString(array, 0, 4) != "RIFF" || Encoding.ASCII.GetString(array, 8, 4) != "WAVE")
				{
					_log.LogWarning((object)"KissSound.wav is not a valid WAV file. Using the fallback kiss sound.");
					return null;
				}
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				int num4 = 0;
				int num5 = -1;
				int num6 = 0;
				int num7 = 12;
				while (num7 + 8 <= array.Length)
				{
					string text = Encoding.ASCII.GetString(array, num7, 4);
					int num8 = BitConverter.ToInt32(array, num7 + 4);
					int num9 = num7 + 8;
					if (num8 < 0 || num9 + num8 > array.Length)
					{
						break;
					}
					if (text == "fmt " && num8 >= 16)
					{
						num4 = BitConverter.ToUInt16(array, num9);
						num = BitConverter.ToUInt16(array, num9 + 2);
						num2 = BitConverter.ToInt32(array, num9 + 4);
						num3 = BitConverter.ToUInt16(array, num9 + 14);
					}
					else if (text == "data")
					{
						num5 = num9;
						num6 = num8;
					}
					num7 = num9 + num8 + (num8 & 1);
				}
				if (num4 != 1 || num < 1 || num2 < 1 || num3 != 16 || num5 < 0 || num6 < 2 || num6 % 2 != 0)
				{
					_log.LogWarning((object)"KissSound.wav must be 16-bit PCM. Using the fallback kiss sound.");
					return null;
				}
				int num10 = num6 / 2;
				float[] array2 = new float[num10];
				for (int i = 0; i < num10; i++)
				{
					short num11 = BitConverter.ToInt16(array, num5 + i * 2);
					array2[i] = (float)num11 / 32768f;
				}
				AudioClip val = AudioClip.Create("KissModPlus_UserKissSound", num10 / num, num, num2, false);
				if ((Object)(object)val == (Object)null || !val.SetData(array2, 0))
				{
					if ((Object)(object)val != (Object)null)
					{
						Object.Destroy((Object)(object)val);
					}
					_log.LogWarning((object)"Unity could not create the custom kiss audio clip. Using the fallback kiss sound.");
					return null;
				}
				_log.LogInfo((object)"Custom kiss sound loaded successfully.");
				return val;
			}
			catch (Exception ex)
			{
				_log.LogWarning((object)("Could not load embedded kiss sound: " + ex.Message + ". Using the fallback kiss sound."));
				return null;
			}
		}

		private void SpawnKiss(Vector3 origin, Vector3 forward)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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)
			//IL_0012: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0036: 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_003e: 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_002e: 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_0078: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00f7: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//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_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: 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_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			PlayKissSound(origin);
			Vector3 val = Vector3.Cross(Vector3.up, forward);
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = Vector3.right;
			}
			val = Vector3.Cross(forward, val2);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			for (int i = 0; i < 30; i++)
			{
				float num = (float)i / 30f * MathF.PI * 2f;
				float num2 = Random.Range(0.12f, 0.62f);
				Vector3 val3 = val2 * (Mathf.Cos(num) * num2) + normalized * (Mathf.Sin(num) * num2);
				Vector3 position = origin + val3 + forward * Random.Range(-0.05f, 0.18f);
				Vector3 velocity = val2 * Random.Range(-0.75f, 0.75f) + normalized * Random.Range(0.45f, 1.35f) + forward * Random.Range(-0.15f, 0.45f);
				float size = Random.Range(0.075f, 0.19f);
				Color color = ColorFromIndex(i);
				CreateHeart(position, velocity, size, color, Random.Range(1.4f, 2.25f));
			}
			for (int j = 0; j < 12; j++)
			{
				float num3 = (float)j / 12f * MathF.PI * 2f + Random.Range(-0.18f, 0.18f);
				float num4 = Random.Range(0.08f, 0.42f);
				Vector3 val4 = val2 * (Mathf.Cos(num3) * num4) + normalized * (Mathf.Sin(num3) * num4);
				Vector3 position2 = origin + val4 + forward * Random.Range(0.02f, 0.22f);
				Vector3 velocity2 = val2 * Random.Range(-0.6f, 0.6f) + normalized * Random.Range(0.35f, 1f) + forward * Random.Range(-0.1f, 0.35f);
				float size2 = Random.Range(0.14f, 0.25f);
				CreateLips(position2, velocity2, size2, Random.Range(1.45f, 2.1f), Random.Range(-55f, 55f));
			}
			for (int k = 0; k < 18; k++)
			{
				Vector3 onUnitSphere = Random.onUnitSphere;
				Vector3 position3 = origin + onUnitSphere * Random.Range(0.12f, 0.55f);
				CreateSparkle(position3, onUnitSphere * Random.Range(0.35f, 1.15f), Random.Range(0.025f, 0.065f), Random.Range(0.65f, 1.2f));
			}
		}

		private Color ColorFromIndex(int i)
		{
			//IL_0017: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0083: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			Color[] array = (Color[])(object)new Color[5]
			{
				new Color(1f, 0.22f, 0.48f),
				new Color(1f, 0.48f, 0.72f),
				new Color(1f, 0.72f, 0.86f),
				new Color(0.95f, 0.28f, 0.72f),
				new Color(1f, 0.88f, 0.94f)
			};
			return array[i % array.Length];
		}

		private void CreateHeart(Vector3 position, Vector3 velocity, float size, Color color, float lifetime)
		{
			//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_0023: 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_00a6: 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)
			GameObject val = new GameObject("KissModPlus_Heart");
			val.transform.position = position;
			val.transform.localScale = Vector3.one * size;
			TextMesh val2 = val.AddComponent<TextMesh>();
			val2.text = "♥";
			val2.fontSize = 100;
			val2.characterSize = 0.1f;
			val2.anchor = (TextAnchor)4;
			val2.alignment = (TextAlignment)1;
			val2.color = color;
			if ((Object)(object)_font != (Object)null)
			{
				val2.font = _font;
				MeshRenderer component = val.GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).sharedMaterial = _font.material;
				}
			}
			((MonoBehaviour)this).StartCoroutine(AnimateText(val, velocity, color, lifetime));
		}

		private void CreateLips(Vector3 position, Vector3 velocity, float size, float lifetime, float rollSpeed)
		{
			//IL_0027: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_00d7: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_lipsMaterial == (Object)null)
			{
				return;
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
			((Object)val).name = "KissModPlus_Lips";
			val.transform.position = position;
			val.transform.localScale = new Vector3(size * 1.38f, size, 1f);
			Collider component = val.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			MeshRenderer component2 = val.GetComponent<MeshRenderer>();
			Material material = new Material(_lipsMaterial);
			if ((Object)(object)component2 != (Object)null)
			{
				((Renderer)component2).material = material;
			}
			Camera main = Camera.main;
			if ((Object)(object)main != (Object)null)
			{
				Vector3 val2 = ((Component)main).transform.position - position;
				if (((Vector3)(ref val2)).sqrMagnitude > 0.001f)
				{
					val.transform.rotation = Quaternion.LookRotation(val2, ((Component)main).transform.up);
				}
			}
			((MonoBehaviour)this).StartCoroutine(AnimateLips(val, velocity, lifetime, rollSpeed, material));
		}

		private IEnumerator AnimateLips(GameObject go, Vector3 velocity, float lifetime, float rollSpeed, Material material)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			float elapsed = 0f;
			Vector3 startScale = go.transform.localScale;
			float roll = Random.Range(-15f, 15f);
			while (elapsed < lifetime && (Object)(object)go != (Object)null)
			{
				float deltaTime = Time.deltaTime;
				elapsed += deltaTime;
				Transform transform = go.transform;
				transform.position += velocity * deltaTime;
				velocity *= 1f - deltaTime * 0.5f;
				roll += rollSpeed * deltaTime;
				Camera main = Camera.main;
				if ((Object)(object)main != (Object)null)
				{
					Vector3 val = ((Component)main).transform.position - go.transform.position;
					if (((Vector3)(ref val)).sqrMagnitude > 0.001f)
					{
						Quaternion val2 = Quaternion.LookRotation(val, ((Component)main).transform.up);
						go.transform.rotation = val2 * Quaternion.Euler(0f, 0f, roll);
					}
				}
				float num = Mathf.Clamp01(elapsed / lifetime);
				float a = 1f - num;
				float num2 = 1f + Mathf.Sin(elapsed * 10f) * 0.12f;
				go.transform.localScale = startScale * num2;
				if ((Object)(object)material != (Object)null)
				{
					Color white = Color.white;
					white.a = a;
					material.color = white;
				}
				yield return null;
			}
			if ((Object)(object)go != (Object)null)
			{
				Object.Destroy((Object)(object)go);
			}
			if ((Object)(object)material != (Object)null)
			{
				Object.Destroy((Object)(object)material);
			}
		}

		private Material LoadLipsMaterial()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				byte[] array;
				using (Stream stream = executingAssembly.GetManifestResourceStream("KissModPlus.Assets.KissLips.png"))
				{
					if (stream == null)
					{
						_log.LogWarning((object)"Kiss lips texture was not embedded. Rebuild the project; lips icons will be skipped.");
						return null;
					}
					using MemoryStream memoryStream = new MemoryStream();
					stream.CopyTo(memoryStream);
					array = memoryStream.ToArray();
				}
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (!ImageConversion.LoadImage(val, array))
				{
					Object.Destroy((Object)(object)val);
					_log.LogWarning((object)"Could not decode KissLips.png; lips icons will be skipped.");
					return null;
				}
				((Object)val).name = "KissModPlus_LipsTexture";
				((Texture)val).wrapMode = (TextureWrapMode)1;
				((Texture)val).filterMode = (FilterMode)1;
				Shader val2 = Shader.Find("Unlit/Transparent");
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = Shader.Find("Sprites/Default");
				}
				if ((Object)(object)val2 == (Object)null)
				{
					Object.Destroy((Object)(object)val);
					_log.LogWarning((object)"No transparent shader found; lips icons will be skipped.");
					return null;
				}
				Material val3 = new Material(val2);
				((Object)val3).name = "KissModPlus_LipsMaterial";
				val3.mainTexture = (Texture)(object)val;
				val3.color = Color.white;
				return val3;
			}
			catch (Exception ex)
			{
				_log.LogWarning((object)("Could not load kiss lips texture: " + ex.Message));
				return null;
			}
		}

		private IEnumerator AnimateText(GameObject go, Vector3 velocity, Color color, float lifetime)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			float elapsed = 0f;
			Vector3 startScale = go.transform.localScale;
			TextMesh text = go.GetComponent<TextMesh>();
			while (elapsed < lifetime && (Object)(object)go != (Object)null)
			{
				float deltaTime = Time.deltaTime;
				elapsed += deltaTime;
				Transform transform = go.transform;
				transform.position += velocity * deltaTime;
				velocity *= 1f - deltaTime * 0.45f;
				Camera main = Camera.main;
				if ((Object)(object)main != (Object)null)
				{
					go.transform.rotation = ((Component)main).transform.rotation;
				}
				float a = 1f - Mathf.Clamp01(elapsed / lifetime);
				float num = 1f + Mathf.Sin(elapsed * 11f) * 0.1f;
				go.transform.localScale = startScale * num;
				if ((Object)(object)text != (Object)null)
				{
					Color color2 = color;
					color2.a = a;
					text.color = color2;
				}
				yield return null;
			}
			if ((Object)(object)go != (Object)null)
			{
				Object.Destroy((Object)(object)go);
			}
		}

		private void CreateSparkle(Vector3 position, Vector3 velocity, float size, float lifetime)
		{
			//IL_0018: 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_002a: 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)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val).name = "KissModPlus_Sparkle";
			val.transform.position = position;
			val.transform.localScale = Vector3.one * size;
			Collider component = val.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Renderer component2 = val.GetComponent<Renderer>();
			if ((Object)(object)component2 != (Object)null && (Object)(object)_sparkleMaterial != (Object)null)
			{
				component2.material = _sparkleMaterial;
			}
			((MonoBehaviour)this).StartCoroutine(AnimateSparkle(val, velocity, lifetime));
		}

		private IEnumerator AnimateSparkle(GameObject go, Vector3 velocity, float lifetime)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			float elapsed = 0f;
			Vector3 initialScale = go.transform.localScale;
			while (elapsed < lifetime && (Object)(object)go != (Object)null)
			{
				float deltaTime = Time.deltaTime;
				elapsed += deltaTime;
				Transform transform = go.transform;
				transform.position += velocity * deltaTime;
				velocity *= 1f - deltaTime * 1.5f;
				float num = 1f - Mathf.Clamp01(elapsed / lifetime);
				go.transform.localScale = initialScale * num;
				yield return null;
			}
			if ((Object)(object)go != (Object)null)
			{
				Object.Destroy((Object)(object)go);
			}
		}

		private void PlayKissSound(Vector3 position)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_kissClip == (Object)null))
			{
				GameObject val = new GameObject("KissModPlus_KissSound");
				val.transform.position = position;
				AudioSource val2 = val.AddComponent<AudioSource>();
				val2.clip = _kissClip;
				val2.volume = 0.9f;
				val2.spatialBlend = 1f;
				val2.minDistance = 2f;
				val2.maxDistance = 24f;
				val2.Play();
				Object.Destroy((Object)(object)val, _kissClip.length + 0.15f);
			}
		}

		private AudioClip CreateKissClip()
		{
			int num = 21168;
			float[] array = new float[num];
			Random random = new Random(173);
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i / 44100f;
				float num3 = (float)(random.NextDouble() * 2.0 - 1.0);
				float num4 = Mathf.Exp((0f - Mathf.Abs(num2 - 0.045f)) * 92f);
				float num5 = Mathf.Exp((0f - Mathf.Abs(num2 - 0.225f)) * 78f);
				float num6 = Mathf.Sin(MathF.PI * 2f * (255f - 125f * num2) * num2) * Mathf.Exp((0f - num2) * 14f) * 0.24f;
				float num7 = num3 * (num4 * 0.48f + num5 * 0.42f);
				float num8 = num3 * Mathf.Exp((0f - Mathf.Abs(num2 - 0.315f)) * 34f) * 0.11f;
				float num9 = Mathf.Sin(MathF.PI * 2f * (720f - 260f * num2) * num2) * Mathf.Exp((0f - Mathf.Abs(num2 - 0.105f)) * 24f) * 0.1f;
				float num10 = Mathf.Exp((0f - Mathf.Max(0f, num2 - 0.32f)) * 22f);
				array[i] = Mathf.Clamp((num6 + num7 + num8 + num9) * num10 * 0.78f, -1f, 1f);
			}
			AudioClip val = AudioClip.Create("KissModPlus_DoubleKiss", num, 1, 44100, false);
			val.SetData(array, 0);
			return val;
		}
	}
}