Decompiled source of AlwaysMate v1.0.0

AlwaysMate.dll

Decompiled 8 months ago
using System;
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 BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("AlwaysMate")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6562ff34347302ca43d3aadb0956ea44ee01d752")]
[assembly: AssemblyProduct("AlwaysMate")]
[assembly: AssemblyTitle("AlwaysMate")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 AlwaysMate
{
	public static class Logging
	{
		public static ManualLogSource Logger => Plugin.Log;

		public static void Log(LogLevel level, string message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Logger.Log(level, (object)message);
		}

		public static void LogInfo(string message)
		{
			Logger.LogInfo((object)message);
		}

		public static void LogDebug(string message)
		{
			Logger.LogDebug((object)message);
		}

		public static void LogWarning(string message)
		{
			Logger.LogWarning((object)message);
		}

		public static void LogError(string message)
		{
			Logger.LogError((object)message);
		}

		public static void LogFatal(string message)
		{
			Logger.LogFatal((object)message);
		}
	}
	[BepInPlugin("JadeJuno.cotl.CotLTemplateMod", "AlwaysMate", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "JadeJuno.cotl.CotLTemplateMod";

		public const string PluginName = "AlwaysMate";

		public const string PluginVer = "1.0.0";

		internal static ManualLogSource Log;

		internal static readonly Harmony Harmony = new Harmony("JadeJuno.cotl.CotLTemplateMod");

		internal static string PluginPath;

		internal static ConfigEntry<bool> AllowSiblingMating = null;

		internal static ConfigEntry<bool> AllowChildrenMating = null;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			AllowSiblingMating = ((BaseUnityPlugin)this).Config.Bind<bool>("AlwaysMate", "Allow Siblings to Mate", true, "Should Sibling Followers be able to mate with each other 100% of the time? (i.e. Narinder with Leshy)");
			AllowChildrenMating = ((BaseUnityPlugin)this).Config.Bind<bool>("AlwaysMate", "Allow Children to Mate", false, "Should Child Followers be able to mate 100% of the time? (why?)");
		}

		private void OnEnable()
		{
			Harmony.PatchAll();
			Logging.LogInfo("Loaded AlwaysMate!");
		}

		private void OnDisable()
		{
			Harmony.UnpatchSelf();
			Logging.LogInfo("Unloaded AlwaysMate!");
		}

		[HarmonyPatch(typeof(Interaction_MatingTent), "GetChanceToMate", new Type[]
		{
			typeof(FollowerBrain),
			typeof(FollowerBrain)
		})]
		[HarmonyPostfix]
		public static void MatingTent_GetChanceToMate(FollowerBrain f1, FollowerBrain f2, ref float __result)
		{
			Logging.LogInfo($"Chance of Mating between {f1.Info.Name} and {f2.Info.Name} is {__result * 100f}%.");
			if ((AllowSiblingMating.Value || !FollowerManager.AreSiblings(f1.Info.ID, f2.Info.ID)) && (AllowChildrenMating.Value || (!FollowerManager.IsChild(f1.Info.ID, f2.Info.ID) && !FollowerManager.IsChild(f2.Info.ID, f1.Info.ID))))
			{
				__result = 1f;
				Logging.LogInfo("Changed to 100%");
			}
		}

		[HarmonyPatch(typeof(Interaction_MatingTent), "GetResponse")]
		[HarmonyPostfix]
		public static void MatingTent_GetResponse(FollowerBrain f1, FollowerBrain f2, ref FollowerResponse __result)
		{
			if ((AllowSiblingMating.Value || !FollowerManager.AreSiblings(f1.Info.ID, f2.Info.ID)) && (AllowChildrenMating.Value || (!FollowerManager.IsChild(f1.Info.ID, f2.Info.ID) && !FollowerManager.IsChild(f2.Info.ID, f1.Info.ID))))
			{
				__result = (FollowerResponse)100;
			}
		}
	}
}