Decompiled source of BetterGoldenEggChances v1.0.1

plugins/BetterGoldenEggChances.dll

Decompiled a month 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;
using UnityEngine;

[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("BetterGoldenEggChances")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+09264c9369bcd2cde65ab218892b3378c39332f7")]
[assembly: AssemblyProduct("BetterGoldenEggChances")]
[assembly: AssemblyTitle("BetterGoldenEggChances")]
[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 BetterGoldenEggChances
{
	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("reithegoat.dev.BetterGoldenEggChances", "BetterGoldenEggChances", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Structures_MatingTent), "SetEggInfo")]
		public static class SetEggInfoPatch
		{
			public static void Postfix(Structures_MatingTent __instance, FollowerBrain f1, FollowerBrain f2, float chanceForSuccess)
			{
				((StructureBrain)__instance).Data.EggInfo.Golden = DetermineIfEggIsGolden(f1, f2);
			}

			private static bool DetermineIfEggIsGolden(FollowerBrain f1, FollowerBrain f2)
			{
				_ = GoldenEggChance.Value;
				if (!DataManager.Instance.ForceGoldenEgg && DataManager.Instance.EggsProduced != 1 && !(Random.value <= GoldenEggChance.Value))
				{
					return f1.Info.Traits.Contains((TraitType)55);
				}
				return true;
			}
		}

		public const string PluginGuid = "reithegoat.dev.BetterGoldenEggChances";

		public const string PluginName = "BetterGoldenEggChances";

		public const string PluginVer = "1.0.0";

		internal static ManualLogSource Log;

		internal static readonly Harmony Harmony = new Harmony("reithegoat.dev.BetterGoldenEggChances");

		internal static string PluginPath;

		internal static ConfigEntry<float> GoldenEggChance = null;

		private void Awake()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			GoldenEggChance = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Chance for Golden Egg", 0.5f, new ConfigDescription("The chance for a golden egg to be produced. 0.2 = 20% chance (vanilla default), 0.5 = 50% chance (mod default), etc..", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		}

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

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