Decompiled source of BreedForLove v0.1.2

BreedForLove.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BreedForLove")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BreedForLove")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f21d2e46-cdd4-4fd7-a5d7-5925aff75ab7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public class AedenthornUtils
{
	public static bool IgnoreKeyPresses(bool extra = false)
	{
		if (!extra)
		{
			int result;
			if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog())
			{
				Chat instance = Chat.instance;
				result = ((instance != null && instance.HasFocus()) ? 1 : 0);
			}
			else
			{
				result = 1;
			}
			return (byte)result != 0;
		}
		int result2;
		if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog())
		{
			Chat instance2 = Chat.instance;
			if ((instance2 == null || !instance2.HasFocus()) && !StoreGui.IsVisible() && !InventoryGui.IsVisible() && !Menu.IsVisible())
			{
				TextViewer instance3 = TextViewer.instance;
				result2 = ((instance3 != null && instance3.IsVisible()) ? 1 : 0);
				goto IL_00d2;
			}
		}
		result2 = 1;
		goto IL_00d2;
		IL_00d2:
		return (byte)result2 != 0;
	}

	public static bool CheckKeyDown(string value)
	{
		try
		{
			string[] array = value.Split(new char[1] { ',' });
			foreach (string text in array)
			{
				if (Input.GetKeyDown(text.ToLower()))
				{
					return true;
				}
			}
		}
		catch
		{
		}
		return false;
	}

	public static bool CheckKeyUp(string value)
	{
		try
		{
			string[] array = value.Split(new char[1] { ',' });
			foreach (string text in array)
			{
				if (Input.GetKeyUp(text.ToLower()))
				{
					return true;
				}
			}
		}
		catch
		{
		}
		return false;
	}

	public static bool CheckKeyHeld(string value, bool req = true)
	{
		try
		{
			string[] array = value.Split(new char[1] { ',' });
			foreach (string text in array)
			{
				if (Input.GetKey(text.ToLower()))
				{
					return true;
				}
			}
		}
		catch
		{
		}
		return !req;
	}

	public static void ShuffleList<T>(List<T> list)
	{
		int num = list.Count;
		while (num > 1)
		{
			num--;
			int index = Random.Range(0, num);
			T value = list[index];
			list[index] = list[num];
			list[num] = value;
		}
	}

	public static string GetAssetPath(object obj, bool create = false)
	{
		return GetAssetPath(obj.GetType().Namespace, create);
	}

	public static string GetAssetPath(string name, bool create = false)
	{
		string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
		if (create && !Directory.Exists(text))
		{
			Directory.CreateDirectory(text);
		}
		return text;
	}

	public static string GetTransformPath(Transform t)
	{
		if (!Object.op_Implicit((Object)(object)t.parent))
		{
			return ((Object)t).name;
		}
		return GetTransformPath(t.parent) + "/" + ((Object)t).name;
	}

	public static byte[] EncodeToPNG(Texture2D texture)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		RenderTexture temporary = RenderTexture.GetTemporary(((Texture)texture).width, ((Texture)texture).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)0);
		Graphics.Blit((Texture)(object)texture, temporary);
		RenderTexture active = RenderTexture.active;
		RenderTexture.active = temporary;
		Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).height, (TextureFormat)4, true, false);
		val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0);
		val.Apply();
		RenderTexture.active = active;
		RenderTexture.ReleaseTemporary(temporary);
		Texture2D val2 = new Texture2D(((Texture)texture).width, ((Texture)texture).height);
		val2.SetPixels(val.GetPixels());
		val2.Apply();
		return ImageConversion.EncodeToPNG(val2);
	}
}
namespace BreedForLove;

[BepInPlugin("gizmorphium.BreedForLove", "Breed For Love", "0.1.2")]
public class BepInExPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Procreation), "Procreate")]
	private static class Procreate_Patch
	{
		private static void Prefix(ref int __state, Procreation __instance, ZNetView ___m_nview, Character ___m_character, Tameable ___m_tameable, BaseAI ___m_baseAI, GameObject ___m_myPrefab, GameObject ___m_offspringPrefab)
		{
			__state = ___m_nview.GetZDO().GetInt("lovePoints", 0);
		}

		private static void Postfix(int __state, Procreation __instance, ZNetView ___m_nview, Character ___m_character, Tameable ___m_tameable, BaseAI ___m_baseAI, GameObject ___m_myPrefab, GameObject ___m_offspringPrefab, GameObject ___m_noPartnerOffspring, GameObject ___m_seperatePartner)
		{
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_0660: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Unknown result type (might be due to invalid IL or missing references)
			if (!modEnabled.Value || !isOn.Value || (Object)(object)__instance == (Object)null || !Object.op_Implicit((Object)(object)__instance) || !___m_nview.IsValid() || !___m_nview.IsOwner() || !Object.op_Implicit((Object)(object)___m_character) || (Object)(object)___m_myPrefab == (Object)null || !Object.op_Implicit((Object)(object)___m_myPrefab) || !Object.op_Implicit((Object)(object)___m_offspringPrefab) || !___m_character.IsTamed() || ___m_baseAI.IsAlerted() || (Object)(object)___m_tameable == (Object)null || !Object.op_Implicit((Object)(object)___m_tameable) || (!loveIgnoresHunger.Value && ___m_tameable.IsHungry()))
			{
				return;
			}
			Dbgl(((Object)___m_myPrefab).name + " checked for breeding.");
			if (!___m_tameable.IsHungry() && __state != ___m_nview.GetZDO().GetInt("lovePoints", 0))
			{
				MethodInfo method = typeof(Procreation).GetMethod("IsPregnant", BindingFlags.Instance | BindingFlags.NonPublic);
				bool flag = false;
				if (method != null)
				{
					flag = (bool)method.Invoke(__instance, null);
				}
				if (flag)
				{
					Dbgl(((Object)___m_myPrefab).name + " is pregnant.");
					Dbgl($"{((Object)___m_myPrefab).name} Previous love points: {__state}");
					Dbgl(string.Format("{0} Current love points: {1}", ((Object)___m_myPrefab).name, ___m_nview.GetZDO().GetInt("lovePoints", 0)));
					Dbgl($"{((Object)___m_myPrefab).name} Required love points: {__instance.m_requiredLovePoints}");
					int num = ((__state >= __instance.m_requiredLovePoints) ? (__state - __instance.m_requiredLovePoints + 1) : 0);
					Dbgl($"{((Object)___m_myPrefab).name} Setting love points to {num}");
					___m_nview.GetZDO().Set("lovePoints", num);
				}
				return;
			}
			Dbgl(" --- ");
			Dbgl(((Object)___m_myPrefab).name + " didn't breed in vanilla code.");
			int nrOfInstances = SpawnSystem.GetNrOfInstances(___m_myPrefab, ((Component)___m_baseAI).transform.position, __instance.m_partnerCheckRange, false, true);
			bool flag2 = Object.op_Implicit((Object)(object)___m_noPartnerOffspring) || ((Object.op_Implicit((Object)(object)___m_seperatePartner) || nrOfInstances >= 2) && (!Object.op_Implicit((Object)(object)___m_seperatePartner) || nrOfInstances >= 1));
			bool flag3 = false;
			if (!flag2)
			{
				Dbgl("Satiated mating pair not found.");
				if (___m_tameable.IsHungry())
				{
					Dbgl("Tamable is hungry.");
					int nrOfInstances2 = SpawnSystem.GetNrOfInstances(___m_myPrefab, ((Component)___m_baseAI).transform.position, __instance.m_totalCheckRange, false, false);
					int nrOfInstances3 = SpawnSystem.GetNrOfInstances(___m_offspringPrefab, ((Component)___m_baseAI).transform.position, __instance.m_totalCheckRange, false, false);
					if (nrOfInstances2 + nrOfInstances3 >= __instance.m_maxCreatures)
					{
						Dbgl("There isn't enough room in this space.");
					}
					else
					{
						int nrOfTamedInstances = GetNrOfTamedInstances(___m_myPrefab, ((Component)___m_baseAI).transform.position, __instance.m_partnerCheckRange, breedersNotPregnantOnly: true);
						flag3 = Object.op_Implicit((Object)(object)___m_noPartnerOffspring) || ((Object.op_Implicit((Object)(object)___m_seperatePartner) || nrOfTamedInstances >= 2) && (!Object.op_Implicit((Object)(object)___m_seperatePartner) || nrOfTamedInstances >= 1));
						if (flag3)
						{
							Dbgl("Hungry mating pair found.");
						}
						else
						{
							Dbgl("Hungry mating pair not found.");
						}
					}
				}
			}
			if (!(flag2 || flag3))
			{
				return;
			}
			Dbgl("No lovepoint change and there is a mating pair.");
			int num2 = ___m_nview.GetZDO().GetInt("lovePoints", 0);
			Dbgl($"lovePoints: {num2}");
			Dbgl($"requiredLovePoints: {__instance.m_requiredLovePoints}");
			int num3 = (int)(lovePointLimitMulitplier.Value * (float)__instance.m_requiredLovePoints);
			Dbgl($"nonbreedingLovePointLimit: {num3}");
			if (flag3)
			{
				int num4 = (int)((float)__instance.m_requiredLovePoints * hungryBreedingCostMultiplier.Value);
				Dbgl($"hungryMatingLovePointsCost: {num4}");
				if (num2 < num4)
				{
					Dbgl("Not enough love points to breed hungry");
					return;
				}
				float num5 = Mathf.InverseLerp((float)num4, (float)num3, (float)num2);
				num5 = Mathf.Lerp(minHungerBreedChance.Value, maxHungerBreedChance.Value, num5);
				Dbgl($"chanceForHungerBreed: {num5}");
				float value = Random.value;
				Dbgl($"randomRoll: {value}");
				if (value <= num5)
				{
					Dbgl($"Setting lovePoints to {num2 - num4}");
					__instance.m_loveEffects.Create(((Component)___m_baseAI).transform.position, ((Component)___m_baseAI).transform.rotation, (Transform)null, 1f, -1);
					___m_nview.GetZDO().Set("lovePoints", num2 - num4);
				}
				MethodInfo method2 = typeof(Procreation).GetMethod("MakePregnant", BindingFlags.Instance | BindingFlags.NonPublic);
				method2.Invoke(__instance, null);
			}
			else if (flag2 && num2 < num3)
			{
				float num6 = ((num2 < num3 / 2) ? (0.5f + (float)num2) : ((num2 == num3 / 2) ? ((float)(num3 / 2) - 0.25f) : ((float)Math.Abs(num2 - num3) + 0.5f)));
				num6 = num6 / (float)num3 * 2f;
				Dbgl($"chanceForLoveBreed: {num6}");
				float value2 = Random.value;
				Dbgl($"randomRoll: {value2}");
				if (value2 <= num6)
				{
					Dbgl($"Setting lovePoints to {num2 + 1}");
					__instance.m_loveEffects.Create(((Component)___m_baseAI).transform.position, ((Component)___m_baseAI).transform.rotation, (Transform)null, 1f, -1);
					___m_nview.GetZDO().Set("lovePoints", num2 + 1);
				}
			}
		}
	}

	[HarmonyPatch(typeof(Tameable), "GetStatusString")]
	private static class GetStatusString_Patch
	{
		private static void Prefix(ref int __state, Tameable __instance, ZNetView ___m_nview, Character ___m_character)
		{
			__state = ___m_nview.GetZDO().GetInt("lovePoints", 0);
		}

		private static void Postfix(int __state, Tameable __instance, ZNetView ___m_nview, Character ___m_character, ref string __result)
		{
			if (!modEnabled.Value || !isOn.Value || (Object)(object)__instance == (Object)null || !Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance) || !___m_nview.IsValid() || !___m_nview.IsOwner() || !Object.op_Implicit((Object)(object)___m_character) || !___m_character.IsTamed())
			{
				return;
			}
			Dbgl(__instance.GetName() + " setting status text.");
			if (__state <= 0)
			{
				return;
			}
			Dbgl(__instance.GetName() + " Love points found: " + __state);
			Procreation component = ((Component)__instance).GetComponent<Procreation>();
			if (!((Object)(object)component == (Object)null) && Object.op_Implicit((Object)(object)component))
			{
				Dbgl(__instance.GetName() + " Procreation found.");
				Dbgl(__instance.GetName() + " Love points needed: " + component.m_requiredLovePoints);
				if (__state >= component.m_requiredLovePoints)
				{
					__result += loveStatusString;
					Dbgl(__instance.GetName() + " Is in love.");
				}
				else
				{
					Dbgl(__instance.GetName() + " is not in love.");
				}
				MethodInfo method = typeof(Procreation).GetMethod("IsPregnant", BindingFlags.Instance | BindingFlags.NonPublic);
				bool flag = false;
				if (method != null)
				{
					flag = (bool)method.Invoke(component, null);
					Dbgl(__instance.GetName() + " tested for pregnancy.");
				}
				if (flag)
				{
					__result += pregnantStatusString;
					Dbgl(__instance.GetName() + " is pregnant.");
				}
				else
				{
					Dbgl(__instance.GetName() + " is not pregnant.");
				}
			}
		}
	}

	[HarmonyPatch(typeof(Terminal), "InputText")]
	private static class InputText_Patch
	{
		private static bool Prefix(Terminal __instance)
		{
			if (!modEnabled.Value)
			{
				return true;
			}
			string text = ((TMP_InputField)__instance.m_input).text;
			if (text.ToLower().Equals(typeof(BepInExPlugin).Namespace.ToLower() + " reset"))
			{
				((BaseUnityPlugin)context).Config.Reload();
				((BaseUnityPlugin)context).Config.Save();
				__instance.AddString(text);
				__instance.AddString(((BaseUnityPlugin)context).Info.Metadata.Name + " config reloaded");
				return false;
			}
			return true;
		}
	}

	public static ConfigEntry<bool> isDebug;

	public static ConfigEntry<string> toggleKey;

	public static ConfigEntry<string> toggleString;

	public static ConfigEntry<bool> isOn;

	public static ConfigEntry<bool> modEnabled;

	public static ConfigEntry<int> nexusID;

	public static ConfigEntry<float> lovePointLimitMulitplier;

	public static ConfigEntry<bool> loveIgnoresHunger;

	public static ConfigEntry<float> hungryBreedingCostMultiplier;

	public static ConfigEntry<float> minHungerBreedChance;

	public static ConfigEntry<float> maxHungerBreedChance;

	public static ConfigEntry<bool> showLoveStatus;

	public static ConfigEntry<bool> showPregnancyStatus;

	public static ConfigEntry<bool> useTextStatus;

	public static ConfigEntry<bool> useEmojiStatus;

	public static ConfigEntry<int> loveEmojiNumber;

	public static ConfigEntry<int> pregnantEmojiNumber;

	private static string inLoveString = "In Love";

	private static string pregnantString = "Pregnant";

	private static string loveStatusString = "";

	private static string pregnantStatusString = "";

	private static BepInExPlugin context;

	public static ManualLogSource MyLogger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name);

	private Harmony _harmony;

	public static void Dbgl(string str = "", bool pref = true, bool overrideDbg = false)
	{
		if (isDebug.Value || overrideDbg)
		{
			string text = (pref ? (typeof(BepInExPlugin).Namespace + " ") : "") + str;
			MyLogger.LogInfo((object)text);
		}
	}

	private void Awake()
	{
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Expected O, but got Unknown
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Expected O, but got Unknown
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Expected O, but got Unknown
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Expected O, but got Unknown
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Expected O, but got Unknown
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Expected O, but got Unknown
		context = this;
		toggleKey = ((BaseUnityPlugin)this).Config.Bind<string>("General", "ToggleKey", "", "Key to toggle behaviour. Leave blank to disable the toggle key. Use https://docs.unity3d.com/Manual/ConventionalGameInput.html");
		toggleString = ((BaseUnityPlugin)this).Config.Bind<string>("General", "ToggleString", "Breed for Love: {0}", "Text to show on toggle. {0} is replaced with true/false");
		modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod");
		lovePointLimitMulitplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "LovePointLimitMulitplier", 2.5f, new ConfigDescription("Stop storing additional love points once the animal's total reaches this many times the number needed to get pregnant.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>()));
		loveIgnoresHunger = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LoveIgnoresHunger", true, "If true, creatures that have built up enough love points for pregnancy will breed even when hungry if they have enough room, but will use more love points to do so.");
		hungryBreedingCostMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HungryBreedingCostMultiplier", 1.9f, new ConfigDescription("Penalty for breeding when hungry. Breeding when hungry cost this many times the normal number of love points to get pregnant. Must be less than lovePointLimitMulitplier to breed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>()));
		minHungerBreedChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinHungerBreedChance", 0.1f, new ConfigDescription("Minimum chance of breeding for pregnancy when hungry (with enough points to do so).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		maxHungerBreedChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxHungerBreedChance", 0.65f, new ConfigDescription("Maximum chance of breeding for pregnancy when hungry (with love points totalling the maximum allowed). Must be more than the minimum to function.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		showLoveStatus = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowLoveStatus", true, "Show if the creature is in love (enough points for a pregnancy) in the creature's status.");
		showPregnancyStatus = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowPregnancyStatus", true, "Show if the creature is pregnant in the creature's status.");
		useTextStatus = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseTextStatus", true, "Uses text (" + inLoveString + " & " + pregnantString + ") for related statuses.\nThis is overwritten to true if a status us set to be shown and emojis are off.");
		useEmojiStatus = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseEmojiStatus", true, "Uses emojis (ie: ♥ and \ud83c\udf7c) for related statuses.");
		loveEmojiNumber = ((BaseUnityPlugin)this).Config.Bind<int>("General", "LoveEmoji", 0, new ConfigDescription("Uses emojis (ie: ♥ and \ud83c\udf7c) for related statuses.\n 0: ♥\n 1: \ud83d\udc95\n 2: \ud83d\udc96\n 3: \ud83d\udc9e", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 3), Array.Empty<object>()));
		pregnantEmojiNumber = ((BaseUnityPlugin)this).Config.Bind<int>("General", "PregnantEmoji", 3, new ConfigDescription("Uses emojis (ie: ♥ and \ud83c\udf7c) for related statuses.\n 0: ✨\n 1: \ud83d\udc76\n 2: \ud83c\udf7c\n 3: \ud83e\udd30\n 4: \ud83e\udd5a\n 5: \ud83d\udc23", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
		isDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IsDebug", false, "Show debug logs");
		nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 985, "Nexus mod ID for updates");
		isOn = ((BaseUnityPlugin)this).Config.Bind<bool>("ZAuto", "IsOn", true, "Behaviour is currently on or not");
		if (!modEnabled.Value)
		{
			return;
		}
		_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		if (showLoveStatus.Value)
		{
			string text = "";
			if (useEmojiStatus.Value)
			{
				text = loveEmojiNumber.Value switch
				{
					0 => "♥", 
					1 => "\ud83d\udc95", 
					2 => "\ud83d\udc96", 
					3 => "\ud83d\udc9e", 
					_ => "♥", 
				};
			}
			loveStatusString = ((useTextStatus.Value || !useEmojiStatus.Value) ? inLoveString : "");
			loveStatusString += text;
			if (loveStatusString != "")
			{
				loveStatusString = ", " + loveStatusString;
			}
		}
		if (showPregnancyStatus.Value)
		{
			string text2 = "";
			if (useEmojiStatus.Value)
			{
				text2 = pregnantEmojiNumber.Value switch
				{
					0 => "✨", 
					1 => "\ud83d\udc76", 
					2 => "\ud83c\udf7c", 
					3 => "\ud83e\udd30", 
					4 => "\ud83e\udd5a", 
					5 => "\ud83d\udc23", 
					_ => "♥", 
				};
			}
			pregnantStatusString = ((useTextStatus.Value || !useEmojiStatus.Value) ? pregnantString : "");
			pregnantStatusString += text2;
			if (pregnantStatusString != "")
			{
				pregnantStatusString = ", " + pregnantStatusString;
			}
		}
		Dbgl("Breed For Love by Gizmorphium loaded.", pref: false, overrideDbg: true);
	}

	private void Update()
	{
		if (AedenthornUtils.CheckKeyDown(toggleKey.Value) && !AedenthornUtils.IgnoreKeyPresses(extra: true))
		{
			isOn.Value = !isOn.Value;
			((BaseUnityPlugin)this).Config.Save();
			((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(toggleString.Value, isOn.Value), 0, (Sprite)null);
		}
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}

	public static int GetNrOfTamedInstances(GameObject prefab, Vector3 center, float maxRange, bool breedersNotPregnantOnly = false)
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		string text = ((Object)prefab).name + "(Clone)";
		if ((Object)(object)prefab.GetComponent<BaseAI>() != (Object)null)
		{
			List<BaseAI> baseAIInstances = BaseAI.BaseAIInstances;
			int num = 0;
			foreach (BaseAI item in baseAIInstances)
			{
				if (((Object)((Component)item).gameObject).name != text || (maxRange > 0f && Vector3.Distance(center, ((Component)item).transform.position) > maxRange))
				{
					continue;
				}
				Tameable component = ((Component)item).GetComponent<Tameable>();
				if (!Object.op_Implicit((Object)(object)component) || !component.IsTamed())
				{
					continue;
				}
				if (breedersNotPregnantOnly)
				{
					Procreation component2 = ((Component)item).GetComponent<Procreation>();
					if (!Object.op_Implicit((Object)(object)component2) || Traverse.Create((object)component2).Method("IsPregnant", Array.Empty<object>()).GetValue<bool>())
					{
						continue;
					}
				}
				num++;
			}
			return num;
		}
		return 0;
	}
}