Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BreedingStatus v1.0.0
BreedingStatus.dll
Decompiled a day agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("BreedingStatus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BreedingStatus")] [assembly: AssemblyTitle("BreedingStatus")] [assembly: AssemblyVersion("1.0.0.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 BreedingStatus { [BepInPlugin("pieter.valheim.breedingstatus", "Breeding Status", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "pieter.valheim.breedingstatus"; public const string Name = "Breeding Status"; public const string Version = "1.0.0"; private static ConfigEntry<bool> _enabled; private static readonly FieldRef<Tameable, ZNetView> TameView = AccessTools.FieldRefAccess<Tameable, ZNetView>("m_nview"); private void Awake() { _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show breeding status", true, "Show why a tamed animal is or is not breeding when you hover over it."); Harmony.CreateAndPatchAll(typeof(Plugin), "pieter.valheim.breedingstatus"); } [HarmonyPatch(typeof(Tameable), "GetHoverText")] [HarmonyPostfix] [HarmonyPriority(0)] private static void HoverPostfix(Tameable __instance, ref string __result) { if (!_enabled.Value || (Object)(object)__instance == (Object)null || string.IsNullOrEmpty(__result)) { return; } try { string text = Status(__instance); if (text != null) { __result += text; } } catch (Exception) { } } private static string Status(Tameable tameable) { //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_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) if (!tameable.IsTamed()) { return null; } Procreation component = ((Component)tameable).GetComponent<Procreation>(); ZNetView val = TameView.Invoke(tameable); ZDO val2 = (((Object)(object)val != (Object)null && val.IsValid()) ? val.GetZDO() : null); if ((Object)(object)component == (Object)null || val2 == null || (Object)(object)ZNet.instance == (Object)null || (Object)(object)ZNetScene.instance == (Object)null) { return null; } DateTime time = ZNet.instance.GetTime(); Vector3 position = ((Component)tameable).transform.position; StringBuilder stringBuilder = new StringBuilder(); long num = val2.GetLong(ZDOVars.s_pregnant, 0L); if (num != 0L) { double num2 = (double)component.m_pregnancyDuration - (time - new DateTime(num)).TotalSeconds; stringBuilder.Append((num2 > 0.0) ? $"\n<color=#ff9ed8>Pregnant: offspring in {Math.Ceiling(num2)}s</color>" : "\n<color=#ff9ed8>Pregnant: offspring at the next check</color>"); return stringBuilder.ToString(); } int num3 = val2.GetInt(ZDOVars.s_lovePoints, 0); stringBuilder.Append($"\n<color=#ff9ed8>Breeding: love {num3}/{component.m_requiredLovePoints}</color>"); double num4 = (double)tameable.m_fedDuration - (time - new DateTime(val2.GetLong(ZDOVars.s_tameLastFeeding, 0L))).TotalSeconds; stringBuilder.Append((num4 > 0.0) ? Ok("Fed (" + Duration(num4) + " left)") : Bad("Hungry: feed it to breed")); BaseAI component2 = ((Component)tameable).GetComponent<BaseAI>(); if ((Object)(object)component2 != (Object)null && component2.IsAlerted()) { stringBuilder.Append(Bad("Alerted: no breeding during danger")); } GameObject prefab = ZNetScene.instance.GetPrefab(val2.GetPrefab()); GameObject val3 = (((Object)(object)component.m_offspring != (Object)null) ? ZNetScene.instance.GetPrefab(Utils.GetPrefabName(component.m_offspring)) : null); if ((Object)(object)prefab != (Object)null) { int num5 = SpawnSystem.GetNrOfInstances(prefab, position, component.m_totalCheckRange, false, false) + (((Object)(object)val3 != (Object)null && (Object)(object)val3 != (Object)(object)prefab) ? SpawnSystem.GetNrOfInstances(val3, position, component.m_totalCheckRange, false, false) : 0); string text = $"{num5}/{component.m_maxCreatures} within {component.m_totalCheckRange:0} m (incl. young)"; stringBuilder.Append((num5 >= component.m_maxCreatures) ? Bad("Too crowded: " + text) : Ok("Space: " + text)); if ((Object)(object)component.m_noPartnerOffspring == (Object)null) { int nrOfInstances = SpawnSystem.GetNrOfInstances(((Object)(object)component.m_seperatePartner != (Object)null) ? component.m_seperatePartner : prefab, position, component.m_partnerCheckRange, false, true); int num6 = (((Object)(object)component.m_seperatePartner != (Object)null) ? nrOfInstances : (nrOfInstances - (component.ReadyForProcreation() ? 1 : 0))); stringBuilder.Append((num6 > 0) ? Ok($"Partner within {component.m_partnerCheckRange:0} m") : Bad($"No ready partner within {component.m_partnerCheckRange:0} m")); } } return stringBuilder.ToString(); } private static string Ok(string text) { return "\n<color=#8fe08f>+ " + text + "</color>"; } private static string Bad(string text) { return "\n<color=#ff7070>- " + text + "</color>"; } private static string Duration(double seconds) { if (!(seconds >= 60.0)) { return $"{Math.Ceiling(seconds)}s"; } return $"{Math.Floor(seconds / 60.0)} min"; } } }