using System;
using System.Collections.Generic;
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 BabyManeater.Helpers;
using BabyManeater.Patches;
using BabyManeater.Scripts;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DarthLilo.BabyManeater.NetcodePatcher;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DarthLilo.BabyManeater")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2")]
[assembly: AssemblyProduct("BabyManeater")]
[assembly: AssemblyTitle("DarthLilo.BabyManeater")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
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 BabyManeater
{
[BepInPlugin("DarthLilo.BabyManeater", "BabyManeater", "1.1.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BabyManeater : BaseUnityPlugin
{
public static ConfigFile Config_Data;
private AssetBundle LiloBabyManeaterBundle;
public static GameObject PropellerHat;
public static GameObject BabyCandy;
public static GameObject Mustache;
public static GameObject Monocle;
public static GameObject LeftHorn;
public static GameObject RightHorn;
public static GameObject Pacifier;
public static BabyManeater 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_Data = ((BaseUnityPlugin)this).Config;
BabyManeaterConfigHelper.SetLethalConfig(Config_Data);
Patch();
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "lilobabymaneaterassets");
LiloBabyManeaterBundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)LiloBabyManeaterBundle == (Object)null)
{
Logger.LogError((object)"Could not find the required asset bundle! Please make sure the file \"lilobabymaneaterassets\" is in the same directory as this dll!");
}
PropellerHat = LiloBabyManeaterBundle.LoadAsset<GameObject>("Assets/BabyManeater/Prefabs/PropellerHat.prefab");
BabyCandy = LiloBabyManeaterBundle.LoadAsset<GameObject>("Assets/BabyManeater/Prefabs/BabyCandy.prefab");
Mustache = LiloBabyManeaterBundle.LoadAsset<GameObject>("Assets/BabyManeater/Prefabs/Mustache.prefab");
Monocle = LiloBabyManeaterBundle.LoadAsset<GameObject>("Assets/BabyManeater/Prefabs/Monocle.prefab");
LeftHorn = LiloBabyManeaterBundle.LoadAsset<GameObject>("Assets/BabyManeater/Prefabs/HornLeft.prefab");
RightHorn = LiloBabyManeaterBundle.LoadAsset<GameObject>("Assets/BabyManeater/Prefabs/HornRight.prefab");
Pacifier = LiloBabyManeaterBundle.LoadAsset<GameObject>("Assets/BabyManeater/Prefabs/Pacifier.prefab");
BabyManeaterRandomHelper.Init();
Logger.LogInfo((object)"DarthLilo.BabyManeater v1.1.2 has loaded!");
}
public static bool Chance(float weight)
{
float num = Random.Range(0f, 1f);
return num < weight;
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("DarthLilo.BabyManeater");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DarthLilo.BabyManeater";
public const string PLUGIN_NAME = "BabyManeater";
public const string PLUGIN_VERSION = "1.1.2";
}
}
namespace BabyManeater.Scripts
{
public enum CosmeticType
{
PropellerHat,
CandyItem
}
public class BabyManeaterTransform : MonoBehaviour
{
public Vector3 BabyLocation;
public Vector3 BabyRotation;
public Vector3 BabyScale;
public Vector3 AdultLocation;
public Vector3 AdultRotation;
public Vector3 AdultScale;
public CosmeticType CosmeticType;
}
}
namespace BabyManeater.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
public class GameNetworkManagerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(GameNetworkManager __instance)
{
((Component)__instance).gameObject.AddComponent<BabyManeaterNetworkHelper>();
((Component)__instance).gameObject.AddComponent<NetworkObject>();
BabyManeater.Logger.LogInfo((object)"Network Helper Added!");
}
}
[HarmonyPatch(typeof(CaveDwellerAI))]
public class BabyifyManeaterPatch
{
public static Transform AnimContainer;
public static Transform AdultAnimContainer;
public static Transform HeadTransform;
public static Transform HandTransformL;
public static Transform AdultHeadTransform;
public static Transform AdultHandTransformL;
public static string ManeaterType;
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void BabyifyManeater(CaveDwellerAI __instance)
{
BabyManeater.Logger.LogInfo((object)"New Maneater spawned, starting setup");
AnimContainer = ((Component)((Component)__instance).gameObject.transform.Find("BabyMeshContainer")).transform.Find("BabyAnimContainer");
AdultAnimContainer = ((Component)((Component)__instance).gameObject.transform.Find("MeshContainer")).transform.Find("AnimContainer");
HeadTransform = ((Component)((Component)((Component)AnimContainer).transform.Find("Spine1")).transform.Find("Spine3")).transform;
HandTransformL = ((Component)((Component)((Component)((Component)((Component)((Component)AnimContainer).transform.Find("Spine1")).transform.Find("Spine2")).transform.Find("TopLeg_L")).transform.Find("TopLeg2_L")).transform.Find("TopFoot_L")).transform;
AdultHeadTransform = ((Component)((Component)((Component)((Component)((Component)AdultAnimContainer).transform.Find("Spine")).transform.Find("Spine1")).transform.Find("Spine2")).transform.Find("Bone.003")).transform;
AdultHandTransformL = ((Component)((Component)((Component)((Component)((Component)((Component)AdultAnimContainer).transform.Find("Spine")).transform.Find("Spine1")).transform.Find("Thigh_A_L")).transform.Find("Leg_A_L")).transform.Find("Foot_A_L")).transform;
if (((NetworkBehaviour)HUDManager.Instance).IsHost)
{
string hostManeaterType = (ManeaterType = BabyManeaterRandomHelper.RollManeaterChances());
BabyManeaterNetworkHelper.Instance.SyncManeaterChancesClientRpc(hostManeaterType);
}
BabyManeater.Logger.LogInfo((object)("Chose " + ManeaterType));
switch (ManeaterType)
{
case "SillyManeater":
SetSillyManeater();
break;
case "FancyManeater":
SetFancyManeater();
break;
case "EvilManeater":
SetEvilManeater();
break;
case "PaciferManeater":
SetPacifierManeater();
break;
}
}
public static void SetSillyManeater()
{
GameObject targetCosmetic = Object.Instantiate<GameObject>(BabyManeater.PropellerHat, HeadTransform);
UpdateCosmeticPosition(targetCosmetic, adultForm: false);
BabyManeater.Logger.LogInfo((object)"Spawned new PropellerHat");
GameObject targetCosmetic2 = Object.Instantiate<GameObject>(BabyManeater.BabyCandy, HandTransformL);
UpdateCosmeticPosition(targetCosmetic2, adultForm: false);
BabyManeater.Logger.LogInfo((object)"Spawned new CandyItem");
if (BabyManeaterConfigHelper.AdultManeaterCosmetics.Value)
{
GameObject targetCosmetic3 = Object.Instantiate<GameObject>(BabyManeater.PropellerHat, AdultHeadTransform);
UpdateCosmeticPosition(targetCosmetic3, adultForm: true);
GameObject targetCosmetic4 = Object.Instantiate<GameObject>(BabyManeater.BabyCandy, AdultHandTransformL);
UpdateCosmeticPosition(targetCosmetic4, adultForm: true);
}
}
public static void SetFancyManeater()
{
GameObject targetCosmetic = Object.Instantiate<GameObject>(BabyManeater.Mustache, HeadTransform);
UpdateCosmeticPosition(targetCosmetic, adultForm: false);
BabyManeater.Logger.LogInfo((object)"Spawned new Mustache");
GameObject targetCosmetic2 = Object.Instantiate<GameObject>(BabyManeater.Monocle, HeadTransform);
UpdateCosmeticPosition(targetCosmetic2, adultForm: false);
BabyManeater.Logger.LogInfo((object)"Spawned new Monocle");
if (BabyManeaterConfigHelper.AdultManeaterCosmetics.Value)
{
GameObject targetCosmetic3 = Object.Instantiate<GameObject>(BabyManeater.Mustache, AdultHeadTransform);
UpdateCosmeticPosition(targetCosmetic3, adultForm: false);
GameObject targetCosmetic4 = Object.Instantiate<GameObject>(BabyManeater.Monocle, AdultHeadTransform);
UpdateCosmeticPosition(targetCosmetic4, adultForm: true);
}
}
public static void SetEvilManeater()
{
GameObject targetCosmetic = Object.Instantiate<GameObject>(BabyManeater.LeftHorn, HeadTransform);
UpdateCosmeticPosition(targetCosmetic, adultForm: false);
BabyManeater.Logger.LogInfo((object)"Spawned new Left Horn");
GameObject targetCosmetic2 = Object.Instantiate<GameObject>(BabyManeater.RightHorn, HeadTransform);
UpdateCosmeticPosition(targetCosmetic2, adultForm: false);
BabyManeater.Logger.LogInfo((object)"Spawned new Right Horn");
if (BabyManeaterConfigHelper.AdultManeaterCosmetics.Value)
{
GameObject targetCosmetic3 = Object.Instantiate<GameObject>(BabyManeater.LeftHorn, AdultHeadTransform);
UpdateCosmeticPosition(targetCosmetic3, adultForm: true);
GameObject targetCosmetic4 = Object.Instantiate<GameObject>(BabyManeater.RightHorn, AdultHeadTransform);
UpdateCosmeticPosition(targetCosmetic4, adultForm: true);
}
}
public static void SetPacifierManeater()
{
GameObject targetCosmetic = Object.Instantiate<GameObject>(BabyManeater.Pacifier, HeadTransform);
UpdateCosmeticPosition(targetCosmetic, adultForm: false);
BabyManeater.Logger.LogInfo((object)"Spawned new Pacifier");
if (BabyManeaterConfigHelper.AdultManeaterCosmetics.Value)
{
GameObject targetCosmetic2 = Object.Instantiate<GameObject>(BabyManeater.Pacifier, AdultHeadTransform);
UpdateCosmeticPosition(targetCosmetic2, adultForm: true);
}
}
public static void UpdateCosmeticPosition(GameObject TargetCosmetic, bool adultForm)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
BabyManeaterTransform component = TargetCosmetic.GetComponent<BabyManeaterTransform>();
if ((Object)(object)component != (Object)null)
{
Transform transform = TargetCosmetic.transform;
if (adultForm)
{
transform.localPosition = component.AdultLocation;
transform.localEulerAngles = component.AdultRotation;
transform.localScale = component.AdultScale;
}
else
{
transform.localPosition = component.BabyLocation;
transform.localEulerAngles = component.BabyRotation;
transform.localScale = component.BabyScale;
}
BabyManeater.Logger.LogInfo((object)"Applied custom translation from custom component!");
}
else
{
BabyManeater.Logger.LogError((object)"GameObject had no custom transform component!");
}
}
}
}
namespace BabyManeater.Helpers
{
public static class BabyManeaterConfigHelper
{
public static ConfigEntry<bool> AdultManeaterCosmetics;
public static ConfigEntry<int> NormalManeaterWeight;
public static ConfigEntry<int> BabyManeaterWeight;
public static ConfigEntry<int> FancyManeaterWeight;
public static ConfigEntry<int> EvilManeaterWeight;
public static ConfigEntry<int> PacifierManeaterWeight;
public static void SetLethalConfig(ConfigFile config)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected O, but got Unknown
AdultManeaterCosmetics = config.Bind<bool>("Main Config", "AdultManeaterCosmetics", true, "Should the adult form of the maneater have cosmetics too?");
BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(AdultManeaterCosmetics, true);
NormalManeaterWeight = config.Bind<int>("Main Config", "NormalManeaterWeight", 6, "How common should it be for a normal maneater to spawn?");
IntInputFieldConfigItem val2 = new IntInputFieldConfigItem(NormalManeaterWeight, true);
BabyManeaterWeight = config.Bind<int>("Main Config", "BabyManeaterWeight", 10, "How common should it be for a maneater with a silly outfit to spawn?");
IntInputFieldConfigItem val3 = new IntInputFieldConfigItem(BabyManeaterWeight, true);
FancyManeaterWeight = config.Bind<int>("Main Config", "FancyManeaterWeight", 5, "How common should it be for a maneater with a fancy outfit to spawn?");
IntInputFieldConfigItem val4 = new IntInputFieldConfigItem(FancyManeaterWeight, true);
EvilManeaterWeight = config.Bind<int>("Main Config", "EvilManeaterWeight", 4, "How common should it be for a maneater with evil horns to spawn?");
IntInputFieldConfigItem val5 = new IntInputFieldConfigItem(EvilManeaterWeight, true);
PacifierManeaterWeight = config.Bind<int>("Main Config", "PacifierManeaterWeight", 5, "How common should it be for a maneater with a pacifier to spawn?");
IntInputFieldConfigItem val6 = new IntInputFieldConfigItem(PacifierManeaterWeight, true);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
LethalConfigManager.SetModDescription("Adds different types of silly maneaters");
}
}
internal class BabyManeaterNetworkHelper : NetworkBehaviour
{
public static BabyManeaterNetworkHelper Instance { get; private set; }
private void Start()
{
Instance = this;
BabyManeater.Logger.LogInfo((object)"BabyManeaterNetworkHelper.Start() initialized!");
}
[ClientRpc]
public void SyncManeaterChancesClientRpc(string HostManeaterType)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2676810277u, val, (RpcDelivery)0);
bool flag = HostManeaterType != null;
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val2)).WriteValueSafe(HostManeaterType, false);
}
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2676810277u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && HostManeaterType != null)
{
BabyifyManeaterPatch.ManeaterType = HostManeaterType;
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_BabyManeaterNetworkHelper()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(2676810277u, new RpcReceiveHandler(__rpc_handler_2676810277));
}
private static void __rpc_handler_2676810277(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string hostManeaterType = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref hostManeaterType, false);
}
target.__rpc_exec_stage = (__RpcExecStage)2;
((BabyManeaterNetworkHelper)(object)target).SyncManeaterChancesClientRpc(hostManeaterType);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "BabyManeaterNetworkHelper";
}
}
public static class BabyManeaterRandomHelper
{
public static List<string> ManeaterLetsGoGambling = new List<string>();
public static void Init()
{
ManeaterLetsGoGambling.Clear();
for (int i = 0; i < BabyManeaterConfigHelper.NormalManeaterWeight.Value; i++)
{
ManeaterLetsGoGambling.Add("NormalManeater");
}
for (int j = 0; j < BabyManeaterConfigHelper.BabyManeaterWeight.Value; j++)
{
ManeaterLetsGoGambling.Add("SillyManeater");
}
for (int k = 0; k < BabyManeaterConfigHelper.FancyManeaterWeight.Value; k++)
{
ManeaterLetsGoGambling.Add("FancyManeater");
}
for (int l = 0; l < BabyManeaterConfigHelper.EvilManeaterWeight.Value; l++)
{
ManeaterLetsGoGambling.Add("EvilManeater");
}
for (int m = 0; m < BabyManeaterConfigHelper.PacifierManeaterWeight.Value; m++)
{
ManeaterLetsGoGambling.Add("PaciferManeater");
}
BabyManeater.Logger.LogInfo((object)"Generated maneater weights based off config");
}
public static string RollManeaterChances()
{
Random random = new Random();
int num = random.Next(ManeaterLetsGoGambling.Count);
BabyManeater.Logger.LogInfo((object)num);
return ManeaterLetsGoGambling[num];
}
}
}
namespace DarthLilo.BabyManeater.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}