Decompiled source of BetterBabies v0.2.0

BetterBabies.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 BetterBabies.Patches;
using CSync.Extensions;
using CSync.Lib;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("MasterAli2.BetterBabies")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+f732a14c7a1a72b61960a607cdfb56e0ebb9b685")]
[assembly: AssemblyProduct("BetterBabies")]
[assembly: AssemblyTitle("MasterAli2.BetterBabies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BetterBabies
{
	[BepInPlugin("MasterAli2.BetterBabies", "BetterBabies", "0.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BetterBabies : BaseUnityPlugin
	{
		internal static ConfigManager config;

		public const int babyItemId = 123984;

		public List<CaveDwellerAI> babiesInShip = new List<CaveDwellerAI>();

		public List<CaveDwellerPhysicsProp> babyItemsInShip = new List<CaveDwellerPhysicsProp>();

		public bool babyInInv;

		public static BetterBabies Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			config = new ConfigManager(((BaseUnityPlugin)this).Config);
			Patch();
			Logger.LogInfo((object)"MasterAli2.BetterBabies v0.2.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("MasterAli2.BetterBabies");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll(typeof(BabyOutside));
			Harmony.PatchAll(typeof(BabyLeave));
			Harmony.PatchAll(typeof(BabyGeneral));
			Harmony.PatchAll(typeof(BabySell));
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}

		public void babyInInventory(PlayerControllerB __)
		{
			GrabbableObject[] itemSlots = __.ItemSlots;
			foreach (GrabbableObject val in itemSlots)
			{
				if (!((Object)(object)val == (Object)null) && val.itemProperties.itemId == 123984)
				{
					babyInInv = true;
				}
			}
			babyInInv = false;
		}

		public static bool babyInShipState(CaveDwellerAI __)
		{
			if (Instance.babiesInShip.Contains(__))
			{
				return true;
			}
			return false;
		}

		public static void setBabyPrice(CaveDwellerPhysicsProp __)
		{
			Random random = new Random((((EnemyAI)__.caveDwellerScript).thisEnemyIndex + 1) * Object.FindObjectOfType<Terminal>().groupCredits + 123984);
			((GrabbableObject)__).scrapValue = random.Next(ConfigManager.BabyPriceMinInclusive.Value, ConfigManager.BabyPriceMaxExclusive.Value);
			((GrabbableObject)__).itemProperties.isScrap = true;
		}

		public static bool shouldBabyPersist(CaveDwellerAI _)
		{
			if (((GrabbableObject)_.propScript).isHeld && ((GrabbableObject)_.propScript).playerHeldBy.isInHangarShipRoom && ((EnemyAI)_).currentBehaviourStateIndex == 0)
			{
				return true;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.NoOptimization)]
		public static void aaa()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			EnemyAI[] array = null;
			bool flag = false;
			bool flag2 = false;
			int num = 0;
			if (array[num] is CaveDwellerAI)
			{
				CaveDwellerAI val = (CaveDwellerAI)array[num];
				if (shouldBabyPersist(val))
				{
					Instance.babiesInShip.Add(val);
					Instance.babyItemsInShip.Add(val.propScript);
					aab();
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoOptimization)]
		public static void aab()
		{
		}
	}
	internal class ConfigManager : SyncedConfig2<ConfigManager>
	{
		[SyncedEntryField]
		public static SyncedEntry<bool> CanBabyGoOutside;

		[SyncedEntryField]
		public static SyncedEntry<bool> CanBabyGoIntoOrbit;

		[SyncedEntryField]
		public static SyncedEntry<bool> CanBabyGrowUp;

		[SyncedEntryField]
		public static SyncedEntry<bool> CanSellBaby;

		[SyncedEntryField]
		public static SyncedEntry<int> BabyPriceMinInclusive;

		[SyncedEntryField]
		public static SyncedEntry<int> BabyPriceMaxExclusive;

		[SyncedEntryField]
		public static SyncedEntry<bool> DecreaseBabyGrowthMeter;

		[SyncedEntryField]
		public static SyncedEntry<float> BabyGrowthMeterDecreasePersecond;

		public ConfigManager(ConfigFile configFile)
			: base("MasterAli2.BetterBabies")
		{
			CreateConfigs(configFile);
			ConfigManager.Register<ConfigManager>((SyncedConfig2<ConfigManager>)(object)this);
		}

		public void CreateConfigs(ConfigFile cfg)
		{
			CanBabyGoOutside = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "General", "CanBabyGoOutside", true, "Can the baby go outside without crying?");
			CanBabyGoIntoOrbit = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "General", "CanBabyGoIntoOrbit", true, "Can the baby go into orbit? (unstable)");
			CanBabyGrowUp = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "General", "CanBabyGrowUp", true, "Can the baby become an adult?");
			CanSellBaby = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Selling", "CanSellBaby", true, "Can the Baby be sold at the company");
			BabyPriceMinInclusive = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Selling", "BabyPriceMinInclusive", 100, "Minimum baby price when sold. (inclusive");
			BabyPriceMaxExclusive = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Selling", "BabyPriceMaxExclusive", 150, "Maximum baby price when sold. (exclusive");
			DecreaseBabyGrowthMeter = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "AI", "DecreaseBabyGrowthMeter", true, "Should the baby growth meter slowly decrease over time");
			BabyGrowthMeterDecreasePersecond = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "AI", "BabyGrowthMeterDecreasePersecond", 0.035f, "Decreased baby growth meter per second");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MasterAli2.BetterBabies";

		public const string PLUGIN_NAME = "BetterBabies";

		public const string PLUGIN_VERSION = "0.2.0";
	}
}
namespace BetterBabies.Patches
{
	internal class BabyGeneral
	{
		public static bool wasTwoHanded;

		[HarmonyPatch(typeof(CaveDwellerAI), "TransformIntoAdult")]
		[HarmonyPrefix]
		private static bool DisableTransformOfBaby(CaveDwellerAI __instance)
		{
			if (BetterBabies.babyInShipState(__instance))
			{
				return false;
			}
			DepositItemsDesk val = Object.FindObjectOfType<DepositItemsDesk>();
			if (val != null && val.itemsOnCounter.Contains((GrabbableObject)(object)__instance.propScript))
			{
				return false;
			}
			if (!ConfigManager.CanBabyGrowUp.Value)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")]
		[HarmonyPrefix]
		private static void enableBabyScrollPrefix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && !((Object)(object)__instance.currentlyHeldObjectServer == (Object)null) && __instance.currentlyHeldObjectServer.itemProperties.itemId == 123984)
			{
				__instance.twoHanded = false;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")]
		[HarmonyPostfix]
		private static void enableBabyScrollPostfix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && !((Object)(object)__instance.currentlyHeldObjectServer == (Object)null) && __instance.currentlyHeldObjectServer.itemProperties.itemId == 123984)
			{
				__instance.twoHanded = true;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPrefix]
		private static void disable2HandedInteractionsIfHoldingBabyPrefix(PlayerControllerB __instance)
		{
			if (BetterBabies.Instance.babyInInv && StartOfRound.Instance.shipHasLanded)
			{
				wasTwoHanded = __instance.twoHanded;
				__instance.twoHanded = true;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void disable2HandedInteractionsIfHoldingBabyPostfix(PlayerControllerB __instance)
		{
			if (BetterBabies.Instance.babyInInv && StartOfRound.Instance.shipHasLanded)
			{
				__instance.twoHanded = wasTwoHanded;
				wasTwoHanded = false;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")]
		[HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")]
		[HarmonyPatch(typeof(PlayerControllerB), "BeginGrabObject")]
		[HarmonyPrefix]
		private static void updateBabyInInvState(PlayerControllerB __instance)
		{
			BetterBabies.Logger.LogDebug((object)"Updating baby inventory state");
			BetterBabies.Instance.babyInInventory(__instance);
		}

		[HarmonyPatch(typeof(CaveDwellerAI), "IncreaseBabyGrowthMeter")]
		[HarmonyPostfix]
		private static void babyGrowPostfix(CaveDwellerAI __instance)
		{
			if (!ConfigManager.CanBabyGrowUp.Value)
			{
				__instance.growthMeter = 0f;
				__instance.nearTransforming = false;
			}
			if (ConfigManager.DecreaseBabyGrowthMeter.Value && !__instance.babyCrying && !__instance.nearTransforming)
			{
				__instance.growthMeter = Mathf.Clamp(__instance.growthMeter - SyncedEntry<float>.op_Implicit(ConfigManager.BabyGrowthMeterDecreasePersecond) * Time.deltaTime, 0f, 25f);
			}
		}
	}
	internal class BabyLeave
	{
		public static bool wasLeaving;

		[HarmonyPatch(typeof(CaveDwellerAI), "BabyUpdate")]
		[HarmonyPrefix]
		private static void BabyUpdateIsLeavingPrefix()
		{
			if (ConfigManager.CanBabyGoIntoOrbit.Value)
			{
				wasLeaving = StartOfRound.Instance.shipIsLeaving;
				StartOfRound.Instance.shipIsLeaving = false;
			}
		}

		[HarmonyPatch(typeof(CaveDwellerAI), "BabyUpdate")]
		[HarmonyPostfix]
		private static void BabyUpdateIsLeavingPostfix()
		{
			if (ConfigManager.CanBabyGoIntoOrbit.Value)
			{
				StartOfRound.Instance.shipIsLeaving = wasLeaving;
				wasLeaving = false;
			}
		}

		[HarmonyPatch(typeof(RoundManager), "UnloadSceneObjectsEarly")]
		[HarmonyPrefix]
		private static bool DontDespawnBaby(RoundManager __instance)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			if (!ConfigManager.CanBabyGoIntoOrbit.Value)
			{
				return true;
			}
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return false;
			}
			Debug.Log((object)"Despawning props and enemies #3");
			__instance.isSpawningEnemies = false;
			EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>();
			Debug.Log((object)$"Enemies on map: {array.Length}");
			for (int i = 0; i < array.Length; i++)
			{
				if (((object)array[i]).GetType() == typeof(CaveDwellerAI))
				{
					CaveDwellerAI val = (CaveDwellerAI)array[i];
					BetterBabies.Logger.LogDebug((object)"Found a wild baby!");
					if (BetterBabies.shouldBabyPersist(val))
					{
						BetterBabies.Logger.LogDebug((object)"Kidnaping the wild baby!");
						BetterBabies.Instance.babiesInShip.Add(val);
						BetterBabies.Instance.babyItemsInShip.Add(val.propScript);
						continue;
					}
				}
				if (array[i].thisNetworkObject.IsSpawned)
				{
					Debug.Log((object)"despawn enemies on map");
					array[i].thisNetworkObject.Despawn(true);
				}
				else
				{
					Debug.Log((object)$"{array[i].thisNetworkObject} was not spawned on network, so it could not be removed.");
				}
			}
			__instance.SpawnedEnemies.Clear();
			EnemyAINestSpawnObject[] array2 = Object.FindObjectsByType<EnemyAINestSpawnObject>((FindObjectsSortMode)0);
			for (int j = 0; j < array2.Length; j++)
			{
				NetworkObject component = ((Component)array2[j]).gameObject.GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null && component.IsSpawned)
				{
					Debug.Log((object)"despawn nest spawn object");
					component.Despawn(true);
				}
				else
				{
					Object.Destroy((Object)(object)((Component)array2[j]).gameObject);
				}
			}
			__instance.currentEnemyPower = 0f;
			__instance.currentDaytimeEnemyPower = 0f;
			__instance.currentOutsideEnemyPower = 0f;
			return false;
		}

		[HarmonyPatch(typeof(StartOfRound), "StartGame")]
		[HarmonyPrefix]
		private static void RespawnBaby(StartOfRound __instance)
		{
			if (!ConfigManager.CanBabyGoIntoOrbit.Value || (!((NetworkBehaviour)__instance).IsServer && !__instance.inShipPhase))
			{
				return;
			}
			foreach (CaveDwellerAI item in BetterBabies.Instance.babiesInShip.ToList())
			{
				if (!((Object)(object)item == (Object)null))
				{
					item.SetCryingLocalClient(false);
					item.SetBabyCryingServerRpc(false);
					item.growthMeter = 0f;
					item.nearTransforming = false;
					BetterBabies.Instance.babiesInShip.Remove(item);
				}
			}
			foreach (CaveDwellerPhysicsProp item2 in BetterBabies.Instance.babyItemsInShip.ToList())
			{
				if (!((Object)(object)item2 == (Object)null))
				{
					BetterBabies.Instance.babyItemsInShip.Remove(item2);
				}
			}
		}

		[HarmonyPatch(typeof(CaveDwellerAI), "IncreaseBabyGrowthMeter")]
		[HarmonyPrefix]
		private static bool disableBabyGrowth(CaveDwellerAI __instance)
		{
			if (!ConfigManager.CanBabyGoIntoOrbit.Value)
			{
				return true;
			}
			if (BetterBabies.babyInShipState(__instance))
			{
				__instance.SetCryingLocalClient(false);
				__instance.SetBabyCryingServerRpc(false);
				__instance.SetBabyRunningServerRpc(false);
				__instance.growthMeter = 0f;
				return false;
			}
			return true;
		}
	}
	internal class BabyOutside
	{
		private static bool wasOutside;

		[HarmonyPatch(typeof(CaveDwellerAI), "BabyUpdate")]
		[HarmonyPrefix]
		private static void babyOutsidePrefix(CaveDwellerAI __instance)
		{
			if (SyncedEntry<bool>.op_Implicit(ConfigManager.CanBabyGoOutside))
			{
				wasOutside = ((EnemyAI)__instance).isOutside;
				((EnemyAI)__instance).isOutside = false;
			}
		}

		[HarmonyPatch(typeof(CaveDwellerAI), "BabyUpdate")]
		[HarmonyPostfix]
		private static void babyOutsidePostfix(CaveDwellerAI __instance)
		{
			if (SyncedEntry<bool>.op_Implicit(ConfigManager.CanBabyGoOutside))
			{
				((EnemyAI)__instance).isOutside = wasOutside;
			}
		}
	}
	internal class BabySell
	{
		[HarmonyPatch(typeof(DepositItemsDesk), "PlaceItemOnCounter")]
		[HarmonyPrefix]
		private static bool disableBabyOnSell(object[] __args)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			PlayerControllerB val = (PlayerControllerB)__args[0];
			if (((object)val.currentlyHeldObjectServer).GetType() != typeof(CaveDwellerPhysicsProp))
			{
				return true;
			}
			if (!ConfigManager.CanSellBaby.Value)
			{
				return false;
			}
			CaveDwellerPhysicsProp val2 = (CaveDwellerPhysicsProp)val.currentlyHeldObjectServer;
			CaveDwellerAI caveDwellerScript = val2.caveDwellerScript;
			BetterBabies.setBabyPrice(val2);
			((Behaviour)val2).enabled = false;
			((Behaviour)caveDwellerScript).enabled = false;
			((Behaviour)((EnemyAI)caveDwellerScript).agent).enabled = false;
			return true;
		}

		[HarmonyPatch(typeof(CaveDwellerPhysicsProp), "DiscardItem")]
		[HarmonyFinalizer]
		private static Exception babySellErrorHandle()
		{
			return null;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}