Decompiled source of MaleSlim v1.0.2

plugins/Femboy.dll

Decompiled 2 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Femboy")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Femboy")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Femboy;

[BepInPlugin("com.aeehyehssreeper.maleslim", "MaleSlim", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class Femboy : BaseUnityPlugin
{
	[HarmonyPatch]
	public static class ValheimPatch
	{
		[HarmonyPatch(typeof(PlayerCustomizaton), "OnEnable")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		public static void Patch_PlayerCustomizationAwake(PlayerCustomizaton __instance)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			if (headless)
			{
				return;
			}
			GameObject gameObject = ((Component)__instance).gameObject;
			object obj;
			if (gameObject == null)
			{
				obj = null;
			}
			else
			{
				Transform transform = gameObject.transform;
				obj = ((transform != null) ? transform.Find("CusomizationPanel") : null);
			}
			Transform val = (Transform)obj;
			Transform val2 = ((val != null) ? val.Find("SexPanel") : null);
			if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.Find("TwinkifyButton") != (Object)null))
			{
				GameObject val3 = GUIManager.Instance.CreateButton("Male Slimmify", ((Component)val2).transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -120f), 250f, 50f);
				((Object)val3).name = "TwinkifyButton";
				Button component = val3.GetComponent<Button>();
				((UnityEvent)component.onClick).AddListener((UnityAction)delegate
				{
					__instance.SetPlayerModel(oldModelCount.GetValueOrDefault(2));
				});
			}
		}

		[HarmonyPatch(typeof(Player), "Awake")]
		[HarmonyPostfix]
		[HarmonyPriority(800)]
		public static void Patch_PlayerAwake(Player __instance)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0069: Expected O, but got Unknown
			VisEquipment visEquipment = ((Humanoid)__instance).m_visEquipment;
			if ((Object)(object)femboyMesh != (Object)null && visEquipment.m_models.Length < 3)
			{
				if (femboyModel == null)
				{
					PlayerModel val = visEquipment.m_models.FirstOrDefault();
					femboyModel = new PlayerModel
					{
						m_mesh = femboyMesh,
						m_baseMaterial = new Material(val.m_baseMaterial)
					};
					oldModelCount = visEquipment.m_models.Length;
				}
				List<PlayerModel> list = new List<PlayerModel>(visEquipment.m_models) { femboyModel };
				visEquipment.m_models = list.ToArray();
			}
			else
			{
				Logger.LogInfo((object)"twink model present on player, skipping re-add");
			}
		}
	}

	public const string PluginGUID = "com.aeehyehssreeper.maleslim";

	public const string PluginName = "MaleSlim";

	public const string PluginVersion = "1.0.0";

	private static GameObject femboyAttempt;

	private static AssetBundle femboy;

	private static Mesh femboyMesh;

	private Assembly assembly;

	private static PlayerModel femboyModel;

	private static int? oldModelCount;

	private static bool headless;

	public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

	private void RegisterLocalization()
	{
	}

	private void Main()
	{
		femboy = AssetUtils.LoadAssetBundleFromResources("femboytwinknotreallylol");
		femboyAttempt = femboy.LoadAsset<GameObject>("FemboyAttempt");
		GameObject obj = femboyAttempt;
		SkinnedMeshRenderer val = ((obj != null) ? obj.GetComponentInChildren<SkinnedMeshRenderer>() : null);
		femboyMesh = ((val != null) ? val.sharedMesh : null);
	}

	private void Awake()
	{
		Main();
		assembly = Assembly.GetExecutingAssembly();
		headless = GUIManager.IsHeadless();
		Harmony.CreateAndPatchAll(assembly, (string)null);
	}
}