using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using NewSkinLayersPatch;
using Ostranauts.InputControl;
using Ostranauts.Inventory;
using Ostranauts.UI.MegaToolTip.DataModules;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("NewSkinLayersPatch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+7f5b93c85490c11a5b9a94fd1c0da539d149809f")]
[assembly: AssemblyProduct("NewSkinLayersPatch")]
[assembly: AssemblyTitle("NewSkinLayersPatch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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]
[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;
}
}
}
public static class ClothingVisibilityHelper
{
public static string[] BreastvisiblitySlots = new string[6] { "NewSkinTitRSlot", "NewSkinTitLSlot", "NewSkinBraSlot", "shirt_in", "shirt_mid", "shirt_out" };
public static string[] GenitalsvisiblitySlots = new string[8] { "NewSkinVagSlot", "NewSkinPubicHairSlot", "NewSkinShaftSlot", "NewSkinBallsSlot", "NewSkinUnderpantSlot", "pants_in", "pants_mid", "pants_out" };
public static void ClothingVisibility(Slots slotsInstance, CondOwner slotObject, string slotName, GUIPaperDollManager paperDollMan, bool unslotted = false)
{
StringBuilder stringBuilder = new StringBuilder();
List<Slot> slotsDepthFirst = slotsInstance.GetSlotsDepthFirst(false);
slotsDepthFirst.Reverse();
StringBuilder stringBuilder2 = new StringBuilder();
stringBuilder2.AppendLine("");
foreach (Slot item in slotsDepthFirst)
{
stringBuilder2.AppendLine(((object)item).ToString());
}
Plugin.Log.LogDebug((object)("CoveredByNonNewSkin: " + stringBuilder2.ToString()));
bool flag = true;
bool flag2 = true;
bool flag3 = ((Object)(object)slotObject != (Object)null || unslotted) && (Array.Exists(BreastvisiblitySlots, (string element) => element == slotName) || Array.Exists(GenitalsvisiblitySlots, (string element) => element == slotName));
if (slotName == "null")
{
flag3 = true;
}
if (flag3)
{
Plugin.LogDebug("--------------------");
if (!unslotted)
{
Plugin.LogDebug("Getting UnSlotted");
}
else
{
Plugin.LogDebug("Getting Slotted");
}
Plugin.LogDebug("- __instance: " + ((object)slotsInstance).ToString());
if (slotName != null)
{
Plugin.LogDebug("- Parameter 0 'strSlot': " + slotName);
}
if (!unslotted && (Object)(object)slotObject != (Object)null)
{
Plugin.LogDebug("- Parameter 1 'co': " + ((object)slotObject).ToString());
}
if (slotName != null)
{
Plugin.LogDebug("Slot " + slotName + " is a breast/genital slot.");
}
PersonSpec pspec = paperDollMan.coUs.pspec;
foreach (Slot slot in slotsDepthFirst)
{
try
{
if (slot == null || slot.aCOs == null || slot.aCOs.Length == 0)
{
Plugin.LogDebug("Slot " + slot?.strName + " is null or has no items.");
}
else
{
if (slot?.aCOs == null || slot.aCOs.Length == 0 || !((Object)(object)slot.aCOs[0] != (Object)null))
{
continue;
}
CondOwner val = slot.aCOs[0];
Plugin.LogDebug($"- {slot}");
if (slot.strName == "NewSkinBodySlot")
{
string shortName = slot.aCOs[0].ShortName;
string text = shortName.Substring(shortName.Length - 2);
if (text == "01")
{
text = "";
}
if (text != pspec.strBodyType)
{
string text2 = pspec.strBodyType;
Plugin.LogDebug("Current body type: " + text2);
if (text2 == "" || text2 == null)
{
Plugin.LogDebug("Setting body type 01.");
text2 = "01";
}
string text3 = "ItmBodyType" + pspec.strSkin + text2;
List<CondOwner> cOLoot = DataHandler.GetLoot(text3).GetCOLoot(pspec.co, false, (string)null);
foreach (CondOwner item2 in cOLoot)
{
if ((Object)(object)item2 != (Object)null)
{
pspec.EquipLoot(item2);
}
}
}
}
if (val.mapConds.ContainsKey("IsNewSkin"))
{
Plugin.LogDebug("Slot " + slot.strName + " is NewSkin.");
if (((Object)(object)slotObject != (Object)null || unslotted) && Array.Exists(BreastvisiblitySlots, (string element) => element == slot.strName))
{
if (!flag)
{
Plugin.LogDebug("Slot " + slot.strName + " is a breast slot and NewSkin.");
paperDollMan.mapCOIDsToGO[val.strID].SetActive(false);
continue;
}
if (!val.mapConds.ContainsKey("IsNSLBreastVisible") && !val.mapConds.ContainsKey("IsNSRBreastVisible"))
{
Plugin.LogDebug("Clothing " + val.strName + " marked breasts False!");
flag = false;
}
Plugin.LogDebug("Slot " + slot.strName + " is a breast, name of the condowner is " + val.strName + ".");
Plugin.LogDebug(string.Format("Does Size Matter {0}", val.mapConds.ContainsKey("IsNSBreastSizeMatters")));
if ((val.mapConds.ContainsKey("IsRacialNewSkin") || val.mapConds.ContainsKey("IsNSBreastSizeMatters")) && !val.mapConds.ContainsKey("IsNSBreast"))
{
RawImage component = paperDollMan.mapCOIDsToGO[val.strID].GetComponent<RawImage>();
string text4 = val.strPortraitImg;
Plugin.LogDebug("Part Path: " + text4);
if (val.mapConds.ContainsKey("IsNSBreastSizeMatters"))
{
text4 += getBreastSize(slotsInstance);
}
if (val.mapConds.ContainsKey("IsRacialNewSkin"))
{
text4 += getRaceGender(slotsInstance)[1];
}
Plugin.LogDebug("Part Path: " + text4);
Texture2D val2 = DataHandler.LoadPNG(text4 + ".png", false, false);
if ((Object)(object)val2 == (Object)null || ((Object)val2).name == "missing.png")
{
Plugin.LogDebug("Failed to load texture for " + text4 + ".png");
}
else
{
component.texture = (Texture)(object)val2;
}
}
paperDollMan.mapCOIDsToGO[val.strID].SetActive(true);
}
else
{
if ((!((Object)(object)slotObject != (Object)null) && !unslotted) || !Array.Exists(GenitalsvisiblitySlots, (string element) => element == slot.strName))
{
continue;
}
if (!flag2)
{
Plugin.LogDebug("Slot " + slot.strName + " is a genital slot and NewSkin.");
paperDollMan.mapCOIDsToGO[val.strID].SetActive(false);
continue;
}
Plugin.LogDebug("Slot " + slot.strName + " is a genital slot and NewSkin, but IsGenitalsVisible is true.");
paperDollMan.mapCOIDsToGO[val.strID].SetActive(true);
if (!val.mapConds.ContainsKey("IsNSGenitalsVisible"))
{
flag2 = false;
Plugin.LogDebug("Clothing " + val.strName + " marked genitals False!");
}
Plugin.LogDebug("Slot " + slot.strName + " is a Genital, name of the condowner is " + val.strName + ".");
Plugin.LogDebug(string.Format("Does Size Matter {0}", val.mapConds.ContainsKey("IsNSGenitalsSizeMatters")));
if ((val.mapConds.ContainsKey("IsRacialNewSkin") || val.mapConds.ContainsKey("IsNSGenitalsSizeMatters")) && !val.mapConds.ContainsKey("IsNSGenitals"))
{
RawImage component2 = paperDollMan.mapCOIDsToGO[val.strID].GetComponent<RawImage>();
string text5 = val.strPortraitImg;
Plugin.LogDebug("Part Path: " + text5);
if (val.mapConds.ContainsKey("IsNSGenitalsSizeMatters"))
{
text5 += getPenisSize(slotsInstance);
}
if (val.mapConds.ContainsKey("IsRacialNewSkin"))
{
text5 += getRaceGender(slotsInstance)[1];
}
Plugin.LogDebug("Part Path: " + text5);
Texture2D val3 = DataHandler.LoadPNG(text5 + ".png", false, false);
if ((Object)(object)val3 == (Object)null || ((Object)val3).name == "missing.png")
{
Plugin.LogDebug("Failed to load texture for " + text5 + ".png");
}
else
{
component2.texture = (Texture)(object)val3;
}
}
}
}
else if (Array.Exists(BreastvisiblitySlots, (string element) => element == slot.strName))
{
Plugin.LogDebug("Slot " + slot.strNameFriendly + " is a breast slot and not NewSkin.");
if (((Object)(object)slotObject != (Object)null || unslotted) && (val.mapConds.ContainsKey("IsRacialNewSkin") || val.mapConds.ContainsKey("IsNSBreastSizeMatters")))
{
Plugin.LogDebug("While not Newskin, " + slot.strName + " is breast compatiable");
RawImage component3 = paperDollMan.mapCOIDsToGO[val.strID].GetComponent<RawImage>();
string text6 = val.strPortraitImg;
Plugin.LogDebug("Part Path: " + text6);
if (val.mapConds.ContainsKey("IsNSBreastSizeMatters"))
{
text6 += getBreastSize(slotsInstance);
}
if (val.mapConds.ContainsKey("IsRacialNewSkin"))
{
text6 += getRaceGender(slotsInstance)[1];
}
Plugin.LogDebug("Part Path: " + text6);
Texture2D val4 = DataHandler.LoadPNG(text6 + ".png", false, false);
if ((Object)(object)val4 == (Object)null)
{
Plugin.LogDebug("Failed to load texture for " + text6 + ".png");
}
else if (((Object)val4).name == "missing.png")
{
Plugin.LogDebug("Failed to load texture for " + text6 + ".png, missing.png");
}
else
{
component3.texture = (Texture)(object)val4;
}
}
flag = false;
}
else
{
if (!Array.Exists(GenitalsvisiblitySlots, (string element) => element == slot.strName))
{
continue;
}
if (((Object)(object)slotObject != (Object)null || unslotted) && (val.mapConds.ContainsKey("IsRacialNewSkin") || val.mapConds.ContainsKey("IsNSGenitalsSizeMatters")) && !val.mapConds.ContainsKey("IsNSGenitals"))
{
Plugin.LogDebug("While not Newskin, " + slot.strName + " is genital compatiable");
RawImage component4 = paperDollMan.mapCOIDsToGO[val.strID].GetComponent<RawImage>();
string text7 = val.strPortraitImg;
Plugin.LogDebug("Part Path: " + text7);
if (val.mapConds.ContainsKey("IsNSGenitalsSizeMatters"))
{
text7 += getPenisSize(slotsInstance);
}
if (val.mapConds.ContainsKey("IsRacialNewSkin"))
{
text7 += getRaceGender(slotsInstance)[1];
}
Plugin.LogDebug("Part Path: " + text7);
Texture2D val5 = DataHandler.LoadPNG(text7 + ".png", false, false);
if ((Object)(object)val5 == (Object)null || ((Object)val5).name == "missing.png")
{
Plugin.LogDebug("Failed to load texture for " + text7 + ".png");
}
else
{
component4.texture = (Texture)(object)val5;
}
}
Plugin.LogDebug("Slot " + slot.strNameFriendly + " is a genital slot and not NewSkin.");
flag2 = false;
}
continue;
}
}
catch (Exception arg)
{
Plugin.LogDebug($"Exception in ClothingVisibility for slot {slot.strName}: {arg}");
}
}
}
Plugin.LogDebug($"IsBreastVisible: {flag}");
Plugin.LogDebug($"IsGenitalsVisible: {flag2}");
Plugin.LogDebug(stringBuilder.ToString());
}
public static string[] getRaceGender(Slots slotsInstance)
{
return new string[2]
{
slotsInstance.coUs.pspec.strGender,
slotsInstance.coUs.pspec.strSkin
};
}
public static string getBreastSize(Slots slotsInstance)
{
foreach (Slot item in slotsInstance.GetSlotsDepthFirst(true))
{
if ((item.strName == "NewSkinTitLSlot" || item.strName == "NewSkinTitRSlot") && item.aCOs != null && item.aCOs.Length != 0 && (Object)(object)item.aCOs[0] != (Object)null)
{
CondOwner val = item.aCOs[0];
if (val.mapConds.ContainsKey("IsNSBreastBig"))
{
return "Big";
}
if (val.mapConds.ContainsKey("IsNSBreastMed"))
{
return "Med";
}
if (val.mapConds.ContainsKey("IsNSBreastSmall"))
{
return "Small";
}
return "Flat";
}
}
return "Flat";
}
public static string getGenitalType(Slots slotsInstance)
{
foreach (Slot item in slotsInstance.GetSlotsDepthFirst(true))
{
if ((item.strName == "NewSkinVagSlot" || item.strName == "NewSkinShaftSlot") && item.aCOs != null && item.aCOs.Length != 0 && (Object)(object)item.aCOs[0] != (Object)null)
{
CondOwner val = item.aCOs[0];
if (item.strName == "NewSkinVagSlot")
{
return "Vag";
}
if (item.strName == "NewSkinShaftSlot")
{
return "Pen";
}
}
}
return "None";
}
public static string getPenisSize(Slots slotsInstance)
{
foreach (Slot item in slotsInstance.GetSlotsDepthFirst(true))
{
if (item.strName == "NewSkinShaftSlot" && item.aCOs != null && item.aCOs.Length != 0 && (Object)(object)item.aCOs[0] != (Object)null)
{
CondOwner val = item.aCOs[0];
if (val.mapConds.ContainsKey("IsNSGenitalsBig"))
{
return "Big";
}
if (val.mapConds.ContainsKey("IsNSGenitalsMed"))
{
return "Med";
}
if (val.mapConds.ContainsKey("IsNSGenitalsSmall"))
{
return "Small";
}
}
}
return "Flat";
}
}
public class CommandInventory_Patches
{
[HarmonyPatch(typeof(CommandInventory), "ToggleInventory")]
[HarmonyPostfix]
public static void ToggleInventory_Postfix(CondOwner __0)
{
try
{
GUIPaperDollManager paperDollManager = CrewSim.inventoryGUI.PaperDollManager;
GUIInventory inventoryGUI = CrewSim.inventoryGUI;
bool flag = false;
bool flag2 = __0.mapConds.ContainsKey("DcNewBodyEquipped");
Plugin.Log.LogInfo((object)$"ToggleInventory_Postfix called for {__0}, DcNewBodyEquipped: {flag2}.");
if (!flag2)
{
Plugin.Log.LogInfo((object)$"ToggleInventory_Postfix called for {__0} with no DcNewBodyEquipped condition, filling (empty) slots.");
COPatchHelper.EnsureSlotsAndConditions(ref __0);
COPatchHelper.AddBodyLoot(ref __0);
}
for (int num = inventoryGUI.activeWindows.Count - 1; num >= 0; num--)
{
flag = true;
}
if (flag && (Object)(object)__0 != (Object)null && (Object)(object)__0.compSlots != (Object)null)
{
ClothingVisibilityHelper.ClothingVisibility(__0.compSlots, __0, "null", paperDollManager);
}
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of bool Slots::SlotItem(string strSlot, CondOwner co):\n{arg}");
}
}
}
public static class CondOwner_Patches
{
}
public static class COPatchHelper
{
public static string[] NewSkinSlots = new string[10] { "NewSkinBodySlot", "NewSkinTitLSlot", "NewSkinTitRSlot", "NewSkinPubicHairSlot", "NewSkinGenitalsSlot", "NewSkinVagSlot", "NewSkinBallsSlot", "NewSkinShaftSlot", "NewSkinBraSlot", "NewSkinUnderpantSlot" };
public static string[] NewSkinConditions = new string[3] { "DcNudityLevels", "DcGenitalLevels", "DcNewBodyEquipped" };
public static void EnsureSlotsAndConditions(ref CondOwner __condOwner)
{
Plugin.LogDebug("SkinGenHelper.EnsureSlots() called for " + __condOwner.strName);
List<Slot> slots = __condOwner.GetSlots(false, (SortOrder)0);
List<string> list = new List<string>();
foreach (Slot item in slots)
{
list.Add(item.strName);
}
List<string> list2 = new List<string>();
string[] newSkinSlots = NewSkinSlots;
foreach (string text in newSkinSlots)
{
if (!list.Contains(text))
{
Plugin.LogDebug("Adding condition: " + text);
JsonSlot slot = DataHandler.GetSlot(text);
try
{
__condOwner.compSlots.AddSlot(slot);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)ex.Message);
}
}
else
{
list2.Add(text);
}
}
if (list2.Count > 0)
{
Plugin.Log.LogDebug((object)("Slots already present: " + string.Join(", ", list2)));
}
List<string> list3 = new List<string>();
List<string> list4 = new List<string>();
foreach (string key in __condOwner.mapConds.Keys)
{
list4.Add(key);
}
Plugin.LogDebug("Current conditions: " + string.Join(", ", list4));
string[] newSkinConditions = NewSkinConditions;
foreach (string text2 in newSkinConditions)
{
if (!list4.Contains(text2))
{
Plugin.LogDebug("Adding condition: " + text2);
Condition cond = DataHandler.GetCond(text2);
try
{
__condOwner.mapConds.Add(text2, cond);
}
catch (Exception ex2)
{
Plugin.Log.LogError((object)ex2.Message);
}
}
else
{
list3.Add(text2);
}
}
if (list3.Count > 0)
{
Plugin.LogDebug("Conditions already present: " + string.Join(", ", list3));
}
}
public static void AddBodyLoot(ref CondOwner __condOwner)
{
PersonSpec pspec = __condOwner.pspec;
Plugin.Log.LogInfo((object)("AddBodyLoot() called for " + __condOwner.strNameFriendly + ", strLoot: " + pspec.strLoot));
if (__condOwner.HasCond("IsPlayer"))
{
return;
}
string[] newSkinSlots = NewSkinSlots;
foreach (string text in newSkinSlots)
{
__condOwner._compSlots.UnSlotItem(text, (CondOwner)null, true);
}
if (pspec.strSkin == null || pspec.strSkin == "")
{
Plugin.Log.LogError((object)("MakeCondOwner_Postfix called for " + __condOwner.strNameFriendly + " with no skin!"));
pspec.strSkin = "A";
}
string text2 = pspec.strBodyType;
string text3 = "ItmIsFemale" + pspec.strSkin;
if (pspec.strGender == "IsMale")
{
Plugin.LogDebug("IsMale");
text3 = "ItmIsMale" + pspec.strSkin;
text2 = "01";
}
else if (pspec.strGender == "IsNB")
{
Plugin.LogDebug("IsNB");
text3 = "ItmIsNB" + pspec.strSkin;
if (pspec.strBodyType == null)
{
pspec.strBodyType = "01";
}
}
else if (pspec.strGender == "IsFemale")
{
Plugin.LogDebug("IsFemale");
text3 = "ItmIsFemale" + pspec.strSkin;
if (pspec.strBodyType == null)
{
text2 = "02";
}
}
else
{
Plugin.Log.LogError((object)("MakeCondOwner_Postfix called for " + pspec.strGender));
}
List<CondOwner> cOLoot = DataHandler.GetLoot(text3).GetCOLoot(pspec.co, false, (string)null);
foreach (CondOwner item in cOLoot)
{
if ((Object)(object)item != (Object)null)
{
pspec.EquipLoot(item);
}
}
string text4 = "ItmBodyType" + pspec.strSkin + text2;
List<CondOwner> cOLoot2 = DataHandler.GetLoot(text4).GetCOLoot(pspec.co, false, (string)null);
foreach (CondOwner item2 in cOLoot2)
{
if ((Object)(object)item2 != (Object)null)
{
pspec.EquipLoot(item2);
}
}
}
}
public class GUIChargenBody_Patches
{
private static Button? btnBreastSizeNext;
private static Button? btnBreastSizeBack;
private static TMP_Text? txtBreastSizeNum;
private static CondOwner? coUser;
private static Button? btnGenitalsTypeNext;
private static Button? btnGenitalsTypeBack;
private static TMP_Text? txtGenitalsTypeNum;
private static Button? btnPenisSizeNext;
private static Button? btnPenisSizeBack;
private static TMP_Text? txtPenisSizeNum;
private static bool? isPenisShown;
private static List<GameObject>? GO_Penis_Size_Array;
private static bool? isInitialized = false;
private static bool? isBroken = false;
[HarmonyPatch(typeof(GUIChargenBody), "Awake")]
[HarmonyPostfix]
public static void Awake_Postfix(GUIChargenBody __instance)
{
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_0346: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_058e: Unknown result type (might be due to invalid IL or missing references)
//IL_059f: Unknown result type (might be due to invalid IL or missing references)
//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0600: Unknown result type (might be due to invalid IL or missing references)
//IL_060a: Unknown result type (might be due to invalid IL or missing references)
//IL_0622: Unknown result type (might be due to invalid IL or missing references)
//IL_0633: Unknown result type (might be due to invalid IL or missing references)
//IL_064a: Unknown result type (might be due to invalid IL or missing references)
//IL_0654: Unknown result type (might be due to invalid IL or missing references)
//IL_066c: Unknown result type (might be due to invalid IL or missing references)
//IL_067d: Unknown result type (might be due to invalid IL or missing references)
//IL_0694: Unknown result type (might be due to invalid IL or missing references)
//IL_069e: Unknown result type (might be due to invalid IL or missing references)
//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
//IL_06de: Unknown result type (might be due to invalid IL or missing references)
//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0700: Unknown result type (might be due to invalid IL or missing references)
//IL_0711: Unknown result type (might be due to invalid IL or missing references)
//IL_0728: Unknown result type (might be due to invalid IL or missing references)
//IL_0732: Unknown result type (might be due to invalid IL or missing references)
//IL_074a: Unknown result type (might be due to invalid IL or missing references)
//IL_075b: Unknown result type (might be due to invalid IL or missing references)
//IL_0772: Unknown result type (might be due to invalid IL or missing references)
//IL_077c: Unknown result type (might be due to invalid IL or missing references)
//IL_0794: Unknown result type (might be due to invalid IL or missing references)
//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
//IL_07bc: Unknown result type (might be due to invalid IL or missing references)
//IL_07c6: Unknown result type (might be due to invalid IL or missing references)
//IL_07de: Unknown result type (might be due to invalid IL or missing references)
//IL_07ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0806: Unknown result type (might be due to invalid IL or missing references)
//IL_0810: Unknown result type (might be due to invalid IL or missing references)
//IL_0828: Unknown result type (might be due to invalid IL or missing references)
//IL_0839: Unknown result type (might be due to invalid IL or missing references)
//IL_0850: Unknown result type (might be due to invalid IL or missing references)
//IL_085a: Unknown result type (might be due to invalid IL or missing references)
//IL_0872: Unknown result type (might be due to invalid IL or missing references)
//IL_0883: Unknown result type (might be due to invalid IL or missing references)
//IL_089a: Unknown result type (might be due to invalid IL or missing references)
//IL_08a4: Unknown result type (might be due to invalid IL or missing references)
//IL_08bc: Unknown result type (might be due to invalid IL or missing references)
//IL_08cd: Unknown result type (might be due to invalid IL or missing references)
//IL_08e4: Unknown result type (might be due to invalid IL or missing references)
//IL_08ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0b91: Unknown result type (might be due to invalid IL or missing references)
//IL_0b9b: Expected O, but got Unknown
//IL_0ba9: Unknown result type (might be due to invalid IL or missing references)
//IL_0bb3: Expected O, but got Unknown
//IL_0c30: Unknown result type (might be due to invalid IL or missing references)
//IL_0c3a: Expected O, but got Unknown
//IL_0c48: Unknown result type (might be due to invalid IL or missing references)
//IL_0c52: Expected O, but got Unknown
//IL_0cbf: Unknown result type (might be due to invalid IL or missing references)
//IL_0cc9: Expected O, but got Unknown
//IL_0cd7: Unknown result type (might be due to invalid IL or missing references)
//IL_0ce1: Expected O, but got Unknown
try
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("--------------------");
stringBuilder.AppendLine("void GUIChargenBody::Awake()");
Plugin.Log.LogInfo((object)stringBuilder.ToString());
Plugin.Log.LogInfo((object)"Moving Body buttons");
Plugin.Log.LogInfo((object)"Moving Body buttons");
Transform val = ((Component)__instance).transform.Find("pnlFaceBtns/btnBody");
Transform val2 = ((Component)__instance).transform.Find("pnlFaceBtns/btnBodyNext");
Transform val3 = ((Component)__instance).transform.Find("pnlFaceBtns/btnBodyBack");
Transform val4 = ((Component)__instance).transform.Find("pnlFaceBtns/pnlBodyNum");
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null)
{
Plugin.Log.LogInfo((object)"One or more UI elements not found!");
return;
}
Plugin.Log.LogInfo((object)"Found all UI elements for body buttons!");
((Component)val).transform.position = new Vector3(((Component)val).transform.position.x, 448.659f, ((Component)val).transform.position.z);
((Component)val2).transform.position = new Vector3(((Component)val2).transform.position.x, 448.659f, ((Component)val2).transform.position.z);
((Component)val3).transform.position = new Vector3(((Component)val3).transform.position.x, 448.659f, ((Component)val3).transform.position.z);
((Component)val4).transform.position = new Vector3(((Component)val4).transform.position.x, 448.659f, ((Component)val4).transform.position.z);
Transform val5 = ((Component)__instance).transform.Find("pnlFaceBtns/btnHead");
Transform val6 = ((Component)__instance).transform.Find("pnlFaceBtns/btnHeadNext");
Transform val7 = ((Component)__instance).transform.Find("pnlFaceBtns/btnHeadBack");
Transform val8 = ((Component)__instance).transform.Find("pnlFaceBtns/pnlHeadNum");
((Component)val5).transform.position = new Vector3(((Component)val5).transform.position.x, ((Component)val5).transform.position.x + 30.5f, ((Component)val5).transform.position.z);
((Component)val6).transform.position = new Vector3(((Component)val6).transform.position.x, ((Component)val6).transform.position.y + 30.5f, ((Component)val6).transform.position.z);
((Component)val7).transform.position = new Vector3(((Component)val7).transform.position.x, ((Component)val7).transform.position.y + 30.5f, ((Component)val7).transform.position.z);
((Component)val8).transform.position = new Vector3(((Component)val8).transform.position.x, ((Component)val8).transform.position.y + 30.5f, ((Component)val8).transform.position.z);
if ((Object)(object)val6 == (Object)null || (Object)(object)val7 == (Object)null || (Object)(object)val8 == (Object)null)
{
Plugin.Log.LogInfo((object)"One or more UI elements not found!");
return;
}
Plugin.Log.LogInfo((object)"Found all UI elements for breast size buttons!");
Transform val9 = Object.Instantiate<Transform>(val5, ((Component)val5).transform.parent);
Transform val10 = Object.Instantiate<Transform>(val6, ((Component)val6).transform.parent);
Transform val11 = Object.Instantiate<Transform>(val7, ((Component)val7).transform.parent);
Transform val12 = Object.Instantiate<Transform>(val8, ((Component)val8).transform.parent);
Transform val13 = Object.Instantiate<Transform>(val5, ((Component)val5).transform.parent);
Transform val14 = Object.Instantiate<Transform>(val6, ((Component)val6).transform.parent);
Transform val15 = Object.Instantiate<Transform>(val7, ((Component)val7).transform.parent);
Transform val16 = Object.Instantiate<Transform>(val8, ((Component)val8).transform.parent);
Transform val17 = Object.Instantiate<Transform>(val5, ((Component)val5).transform.parent);
Transform val18 = Object.Instantiate<Transform>(val6, ((Component)val6).transform.parent);
Transform val19 = Object.Instantiate<Transform>(val7, ((Component)val7).transform.parent);
Transform val20 = Object.Instantiate<Transform>(val8, ((Component)val8).transform.parent);
if ((Object)(object)val9 == (Object)null || (Object)(object)val10 == (Object)null || (Object)(object)val11 == (Object)null || (Object)(object)val12 == (Object)null || (Object)(object)val13 == (Object)null || (Object)(object)val14 == (Object)null || (Object)(object)val15 == (Object)null || (Object)(object)val16 == (Object)null || (Object)(object)val17 == (Object)null || (Object)(object)val18 == (Object)null || (Object)(object)val19 == (Object)null || (Object)(object)val20 == (Object)null)
{
Plugin.Log.LogInfo((object)"One or more UI components not found!");
return;
}
GO_Penis_Size_Array = new List<GameObject>();
GO_Penis_Size_Array.Add(((Component)val17).gameObject);
GO_Penis_Size_Array.Add(((Component)val18).gameObject);
GO_Penis_Size_Array.Add(((Component)val19).gameObject);
GO_Penis_Size_Array.Add(((Component)val20).gameObject);
Plugin.Log.LogInfo((object)"Cloned all UI elements for breast size buttons!");
((Component)val9).transform.position = new Vector3(((Component)val9).transform.localPosition.x, ((Component)val9).transform.localPosition.y - 30f, ((Component)val9).transform.localPosition.z);
((Component)val10).transform.position = new Vector3(((Component)val10).transform.localPosition.x, ((Component)val10).transform.localPosition.y - 30f, ((Component)val10).transform.localPosition.z);
((Component)val11).transform.position = new Vector3(((Component)val11).transform.localPosition.x, ((Component)val11).transform.localPosition.y - 30f, ((Component)val11).transform.localPosition.z);
((Component)val12).transform.position = new Vector3(((Component)val12).transform.localPosition.x, ((Component)val12).transform.localPosition.y - 30f, ((Component)val12).transform.localPosition.z);
((Component)val13).transform.position = new Vector3(((Component)val13).transform.localPosition.x, ((Component)val13).transform.localPosition.y - 60f, ((Component)val13).transform.localPosition.z);
((Component)val14).transform.position = new Vector3(((Component)val14).transform.localPosition.x, ((Component)val14).transform.localPosition.y - 60f, ((Component)val14).transform.localPosition.z);
((Component)val15).transform.position = new Vector3(((Component)val15).transform.localPosition.x, ((Component)val15).transform.localPosition.y - 60f, ((Component)val15).transform.localPosition.z);
((Component)val16).transform.position = new Vector3(((Component)val16).transform.localPosition.x, ((Component)val16).transform.localPosition.y - 60f, ((Component)val16).transform.localPosition.z);
((Component)val17).transform.position = new Vector3(((Component)val17).transform.localPosition.x, ((Component)val17).transform.localPosition.y - 90f, ((Component)val17).transform.localPosition.z);
((Component)val18).transform.position = new Vector3(((Component)val18).transform.localPosition.x, ((Component)val18).transform.localPosition.y - 90f, ((Component)val18).transform.localPosition.z);
((Component)val19).transform.position = new Vector3(((Component)val19).transform.localPosition.x, ((Component)val19).transform.localPosition.y - 90f, ((Component)val19).transform.localPosition.z);
((Component)val20).transform.position = new Vector3(((Component)val20).transform.localPosition.x, ((Component)val20).transform.localPosition.y - 90f, ((Component)val20).transform.localPosition.z);
TMP_Text component = ((Component)((Component)val9).transform.Find("txt")).GetComponent<TMP_Text>();
Button component2 = ((Component)val10).GetComponent<Button>();
Button component3 = ((Component)val11).GetComponent<Button>();
TMP_Text component4 = ((Component)((Component)val12).transform.Find("txt")).GetComponent<TMP_Text>();
TMP_Text component5 = ((Component)((Component)val13).transform.Find("txt")).GetComponent<TMP_Text>();
Button component6 = ((Component)val14).GetComponent<Button>();
Button component7 = ((Component)val15).GetComponent<Button>();
TMP_Text component8 = ((Component)((Component)val16).transform.Find("txt")).GetComponent<TMP_Text>();
TMP_Text component9 = ((Component)((Component)val17).transform.Find("txt")).GetComponent<TMP_Text>();
Button component10 = ((Component)val18).GetComponent<Button>();
Button component11 = ((Component)val19).GetComponent<Button>();
TMP_Text component12 = ((Component)((Component)val20).transform.Find("txt")).GetComponent<TMP_Text>();
Plugin.Log.LogInfo((object)"Successfully cloned and adjusted positions for breast size buttons!");
Plugin.Log.LogInfo((object)"Assigning cloned components to instance fields...");
component.text = "Breasts";
component5.text = "Genitals";
component9.text = "Penis";
Plugin.Log.LogInfo((object)"Assigned cloned components to instance fields!");
if ((Object)(object)val12 != (Object)null)
{
Component[] components = ((Component)val12).GetComponents<Component>();
Plugin.Log.LogInfo((object)("Components on: " + ((Object)val12).name));
Component[] array = components;
foreach (Component val21 in array)
{
Plugin.Log.LogInfo((object)("- " + ((object)val21).GetType().Name));
}
}
else
{
Plugin.Log.LogInfo((object)"Could not find the target GameObject.");
}
if ((Object)(object)component2 != (Object)null && (Object)(object)__instance != (Object)null)
{
Plugin.Log.LogInfo((object)"Setting up breast size in text.");
int num = 1;
switch ("Flat")
{
case "Small":
num = 1;
break;
case "Med":
num = 2;
break;
case "Big":
num = 3;
break;
case "Huge":
num = 4;
break;
}
component4.text = num.ToString();
Plugin.Log.LogInfo((object)"Setting Current Gentials");
if (__instance.chkHe.isOn)
{
Plugin.Log.LogInfo((object)"Setting genitals type to Pen.");
component8.text = "Pen";
}
else
{
Plugin.Log.LogInfo((object)"Setting genitals type to Vag.");
component8.text = "Vag";
}
Plugin.Log.LogInfo((object)"Setting up breast size next button listener.");
((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
{
UpdatePart(__instance.coUser, 1, 1, __instance);
});
((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
{
UpdatePart(__instance.coUser, 1, -1, __instance);
});
Plugin.Log.LogInfo((object)"Added listener for breast size next button.");
AudioManager.AddBtnAudio(((Component)component2).gameObject, "ShipUIBtnDatingAppButton", "ShipUIBtnDatingAppRandomize");
AudioManager.AddBtnAudio(((Component)component3).gameObject, "ShipUIBtnDatingAppButton", "ShipUIBtnDatingAppRandomize");
Plugin.Log.LogInfo((object)"Added audio to breast size next button.");
coUser = __instance.coUser;
btnBreastSizeNext = component2;
btnBreastSizeBack = component3;
txtBreastSizeNum = component4;
((UnityEvent)component6.onClick).AddListener((UnityAction)delegate
{
UpdatePart(__instance.coUser, 2, 1, __instance);
});
((UnityEvent)component7.onClick).AddListener((UnityAction)delegate
{
UpdatePart(__instance.coUser, 2, -1, __instance);
});
Plugin.Log.LogInfo((object)"Added listener for genitals type next button.");
AudioManager.AddBtnAudio(((Component)component6).gameObject, "ShipUIBtnDatingAppButton", "ShipUIBtnDatingAppRandomize");
AudioManager.AddBtnAudio(((Component)component7).gameObject, "ShipUIBtnDatingAppButton", "ShipUIBtnDatingAppRandomize");
Plugin.Log.LogInfo((object)"Added audio to genitals type next button.");
btnGenitalsTypeNext = component6;
btnGenitalsTypeBack = component7;
txtGenitalsTypeNum = component8;
((UnityEvent)component10.onClick).AddListener((UnityAction)delegate
{
UpdatePart(__instance.coUser, 3, 1, __instance);
});
((UnityEvent)component11.onClick).AddListener((UnityAction)delegate
{
UpdatePart(__instance.coUser, 3, -1, __instance);
});
Plugin.Log.LogInfo((object)"Added listener for penis size next button.");
AudioManager.AddBtnAudio(((Component)component10).gameObject, "ShipUIBtnDatingAppButton", "ShipUIBtnDatingAppRandomize");
AudioManager.AddBtnAudio(((Component)component11).gameObject, "ShipUIBtnDatingAppButton", "ShipUIBtnDatingAppRandomize");
Plugin.Log.LogInfo((object)"Added audio to penis size next button.");
btnPenisSizeNext = component10;
btnPenisSizeBack = component11;
txtPenisSizeNum = component12;
}
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of void GUIChargenBody::Awake():\n{arg}");
}
}
[HarmonyPatch(typeof(GUIChargenBody), "Init")]
[HarmonyPostfix]
public static void Init_Postfix(GUIChargenBody __instance, CondOwner coSelf, Dictionary<string, string> mapGPMData, string strGPMKey)
{
try
{
if (isInitialized == false)
{
Plugin.Log.LogInfo((object)"Initializing breast size and genitals type.");
LoadParts(__instance);
if (isBroken == true)
{
SexChange(coSelf.pspec, coSelf, __instance);
Plugin.Log.LogInfo((object)"SexChange called to fix broken state.");
}
isInitialized = true;
Plugin.Log.LogInfo((object)"Breasts and Gentials initialized successfully.");
}
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of void GUIChargenBody::Update():\n{arg}");
}
}
public static void LoadParts(GUIChargenBody __instance)
{
if ((Object)(object)txtGenitalsTypeNum == (Object)null)
{
return;
}
string genitalType = ClothingVisibilityHelper.getGenitalType(__instance.coUser._compSlots);
Plugin.Log.LogInfo((object)("Current genitals type: " + genitalType));
if (genitalType == "None" || genitalType == "Broken")
{
isBroken = true;
Plugin.Log.LogInfo((object)"Current genitals type is None, setting isBroken to true.");
}
txtGenitalsTypeNum.text = genitalType;
if ((Object)(object)txtPenisSizeNum == (Object)null)
{
return;
}
string penisSize = ClothingVisibilityHelper.getPenisSize(__instance.coUser._compSlots);
Plugin.Log.LogInfo((object)("Current penis size: " + penisSize));
if (penisSize == "Big")
{
txtPenisSizeNum.text = "3";
}
else if (penisSize == "Med")
{
txtPenisSizeNum.text = "2";
}
else
{
txtPenisSizeNum.text = "1";
}
if (txtGenitalsTypeNum.text == "Pen")
{
togglePenisButtons(setMode: true, isVisible: true);
}
else
{
togglePenisButtons(setMode: true);
}
if (!((Object)(object)txtBreastSizeNum == (Object)null))
{
int num = 1;
string breastSize = ClothingVisibilityHelper.getBreastSize(__instance.coUser._compSlots);
Plugin.Log.LogInfo((object)("Current breast size: " + breastSize));
switch (breastSize)
{
case "Small":
num = 1;
break;
case "Med":
num = 2;
break;
case "Big":
num = 3;
break;
case "Huge":
num = 4;
break;
}
txtBreastSizeNum.text = num.ToString();
}
}
public static void UpdatePart(CondOwner condOwner, int part, int dir, GUIChargenBody GUIChargenBody_Instanced)
{
Plugin.Log.LogInfo((object)$"Part change called with part: {part}, dir: {dir}");
try
{
if ((Object)(object)btnBreastSizeNext == (Object)null || (Object)(object)btnBreastSizeBack == (Object)null || (Object)(object)btnGenitalsTypeNext == (Object)null || (Object)(object)btnGenitalsTypeBack == (Object)null || (Object)(object)btnPenisSizeNext == (Object)null || (Object)(object)btnPenisSizeBack == (Object)null)
{
Plugin.Log.LogInfo((object)"Buttons or text components are not initialized.");
return;
}
if ((Object)(object)txtBreastSizeNum == (Object)null || (Object)(object)txtGenitalsTypeNum == (Object)null || (Object)(object)txtPenisSizeNum == (Object)null)
{
Plugin.Log.LogInfo((object)"A text is not initialized.");
return;
}
switch (part)
{
case 1:
{
int num2 = int.Parse(txtBreastSizeNum.text);
num2 += dir;
if (num2 < 1)
{
num2 = 4;
}
else if (num2 > 4)
{
num2 = 1;
}
txtBreastSizeNum.text = num2.ToString();
Plugin.Log.LogInfo((object)$"Changed breast size to {num2}");
UpdateBreastSize(condOwner, num2);
break;
}
case 2:
{
Plugin.Log.LogInfo((object)"Changing genitals type.");
string text = txtGenitalsTypeNum.text;
if (text == "Pen")
{
text = "Vag";
togglePenisButtons(setMode: true);
}
else
{
text = "Pen";
togglePenisButtons(setMode: true, isVisible: true);
}
txtGenitalsTypeNum.text = text;
Plugin.Log.LogInfo((object)("Changed genitals type to " + text));
UpdateGenitalsType(condOwner, text);
break;
}
case 3:
{
Plugin.Log.LogInfo((object)"Changing penis size.");
int num = int.Parse(txtPenisSizeNum.text);
num += dir;
if (num < 1)
{
num = 3;
}
else if (num > 3)
{
num = 1;
}
txtPenisSizeNum.text = num.ToString();
Plugin.Log.LogInfo((object)$"Changed Penis size to {num}");
UpdatePenisSize(condOwner, num);
break;
}
}
GUIChargenBody_Instanced.ToggleBodyView(true);
GUIChargenBody_Instanced._paperDollManager.ctFilter = DataHandler.GetCondTrigger("TIsBodyPart");
GUIChargenBody_Instanced._paperDollManager.SetPaperDoll(GUIChargenBody_Instanced.coUser);
GUIChargenBody_Instanced._paperDollManager.HideBackDrag();
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in Part change: {arg}");
}
}
public static void UpdateBreastSize(CondOwner condOwner, int currentSize)
{
try
{
if ((Object)(object)btnBreastSizeNext == (Object)null || (Object)(object)btnBreastSizeBack == (Object)null || (Object)(object)txtBreastSizeNum == (Object)null)
{
Plugin.Log.LogInfo((object)"Buttons or text components are not initialized.");
return;
}
Plugin.Log.LogInfo((object)"UpdateBreastSize called.");
if ((Object)(object)condOwner == (Object)null || (Object)(object)condOwner._compSlots == (Object)null)
{
if ((Object)(object)condOwner == (Object)null)
{
Plugin.Log.LogInfo((object)"coUser is null, cannot update breast size.");
}
else if ((Object)(object)condOwner._compSlots == (Object)null)
{
Plugin.Log.LogInfo((object)"coUser._compSlots is null, cannot update breast size.");
}
return;
}
string text = "";
Plugin.Log.LogInfo((object)$"Current breast size: {currentSize}");
switch (currentSize)
{
case 1:
text = "Flat";
break;
case 2:
text = "Small";
break;
case 3:
text = "Med";
break;
case 4:
text = "Big";
break;
}
string text2 = "";
if (!condOwner.HasCond("IsInChargen"))
{
Plugin.Log.LogInfo((object)"Not in chargen, setting hasBra to NoBra.");
text2 = "NoBra";
}
else
{
condOwner._compSlots.UnSlotItem("NewSkinBraSlot", (CondOwner)null, true);
}
condOwner._compSlots.UnSlotItem("NewSkinTitLSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinTitRSlot", (CondOwner)null, true);
List<CondOwner> cOLoot = DataHandler.GetLoot("Itm" + text + "Breasts" + condOwner.pspec.strSkin + text2).GetCOLoot(condOwner, false, (string)null);
foreach (CondOwner item in cOLoot)
{
if ((Object)(object)item != (Object)null)
{
Plugin.Log.LogInfo((object)("Equipping new breast size: " + item.strName));
condOwner.pspec.EquipLoot(item);
}
}
Plugin.Log.LogInfo((object)("Itm" + text + "Breasts" + condOwner.pspec.strSkin));
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in UpdateBreastSize: {arg}");
}
}
public static void UpdateGenitalsType(CondOwner condOwner, string currentType)
{
try
{
if ((Object)(object)btnGenitalsTypeNext == (Object)null || (Object)(object)btnGenitalsTypeBack == (Object)null || (Object)(object)txtGenitalsTypeNum == (Object)null)
{
Plugin.Log.LogInfo((object)"Buttons or text components are not initialized.");
return;
}
Plugin.Log.LogInfo((object)"UpdateGenitalsType called.");
if ((Object)(object)condOwner == (Object)null || (Object)(object)condOwner._compSlots == (Object)null)
{
if ((Object)(object)condOwner == (Object)null)
{
Plugin.Log.LogInfo((object)"coUser is null, cannot update genitals type.");
}
else if ((Object)(object)condOwner._compSlots == (Object)null)
{
Plugin.Log.LogInfo((object)"coUser._compSlots is null, cannot update genitals type.");
}
return;
}
Plugin.Log.LogInfo((object)("Current genitals type: " + currentType));
if (currentType == "None" || currentType == "Broken")
{
isBroken = true;
Plugin.Log.LogInfo((object)"Current genitals type is None, setting isBroken to true.");
}
condOwner._compSlots.UnSlotItem("NewSkinVagSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinShaftSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinBallsSlot", (CondOwner)null, true);
string text = "";
if (!condOwner.HasCond("IsInChargen"))
{
Plugin.Log.LogInfo((object)"Not in chargen, setting hasUnderwear to NoUnderwear.");
text = "NoUnderwear";
}
else
{
condOwner._compSlots.UnSlotItem("NewSkinUnderpantSlot", (CondOwner)null, true);
}
List<CondOwner> cOLoot = DataHandler.GetLoot("Itm" + currentType + condOwner.pspec.strSkin + text).GetCOLoot(condOwner, false, (string)null);
foreach (CondOwner item in cOLoot)
{
if ((Object)(object)item != (Object)null)
{
Plugin.Log.LogInfo((object)("Equipping new genitals type: " + item.strName));
condOwner.pspec.EquipLoot(item);
}
}
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in UpdateGenitalsType: {arg}");
}
}
public static void UpdatePenisSize(CondOwner condOwner, int currentSize)
{
try
{
if ((Object)(object)btnPenisSizeNext == (Object)null || (Object)(object)btnPenisSizeBack == (Object)null || (Object)(object)txtPenisSizeNum == (Object)null)
{
Plugin.Log.LogInfo((object)"Buttons or text components are not initialized.");
return;
}
Plugin.Log.LogInfo((object)"UpdatePenisSize called.");
if ((Object)(object)condOwner == (Object)null || (Object)(object)condOwner._compSlots == (Object)null)
{
if ((Object)(object)condOwner == (Object)null)
{
Plugin.Log.LogInfo((object)"coUser is null, cannot update genitals type.");
}
else if ((Object)(object)condOwner._compSlots == (Object)null)
{
Plugin.Log.LogInfo((object)"coUser._compSlots is null, cannot update genitals type.");
}
return;
}
Plugin.Log.LogInfo((object)$"Current genitals type: {currentSize}");
condOwner._compSlots.UnSlotItem("NewSkinShaftSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinBallsSlot", (CondOwner)null, true);
string text = "";
switch (currentSize)
{
case 1:
text = "Small";
break;
case 2:
text = "Med";
break;
case 3:
text = "Big";
break;
}
string text2 = "";
if (!condOwner.HasCond("IsInChargen"))
{
text2 = "NoUnderwear";
}
else
{
condOwner._compSlots.UnSlotItem("NewSkinUnderpantSlot", (CondOwner)null, true);
}
List<CondOwner> cOLoot = DataHandler.GetLoot("ItmPen" + text + condOwner.pspec.strSkin + text2).GetCOLoot(condOwner, false, (string)null);
foreach (CondOwner item in cOLoot)
{
if ((Object)(object)item != (Object)null)
{
Plugin.Log.LogInfo((object)("Equipping new Penis Size: " + item.strName));
condOwner.pspec.EquipLoot(item);
}
}
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in UpdatePenisSize: {arg}");
}
}
public static bool togglePenisButtons(bool setMode = false, bool isVisible = false)
{
if (GO_Penis_Size_Array == null)
{
return false;
}
if ((!setMode && isPenisShown == false) || (setMode && isVisible))
{
isPenisShown = true;
foreach (GameObject item in GO_Penis_Size_Array)
{
item.SetActive(true);
}
return true;
}
isPenisShown = false;
foreach (GameObject item2 in GO_Penis_Size_Array)
{
item2.SetActive(false);
}
return false;
}
[HarmonyPatch(typeof(GUIChargenBody), "ChangePronoun")]
[HarmonyPostfix]
public static void ChangePronoun_Postfix(ref GUIChargenBody __instance, ref string __0, ref bool __1)
{
try
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("--------------------");
stringBuilder.AppendLine("void GUIChargenBody::ChangePronoun(string strPronoun, bool value)");
stringBuilder.Append("- __instance: ").AppendLine(((object)__instance).ToString());
stringBuilder.Append("- Parameter 0 'strPronoun': ").AppendLine(__0?.ToString() ?? "null");
stringBuilder.Append("- Parameter 2 'CondOwner': ").AppendLine(((object)__instance.coUser).ToString());
SexChange(__instance.coUser.pspec, __instance.coUser, __instance);
Plugin.Log.LogInfo((object)stringBuilder.ToString());
LoadParts(__instance);
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of void GUIChargenBody::ChangePronoun(string strPronoun, bool value):\n{arg}");
}
}
[HarmonyPatch(typeof(GUIChargenBody), "ChangeAppearance")]
[HarmonyPostfix]
public static void ChangeAppearance_Postfix(GUIChargenBody __instance)
{
try
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("--------------------");
stringBuilder.AppendLine("void GUIChargenBody::ChangeAppearance()");
stringBuilder.Append("- __instance: ").AppendLine(((object)__instance).ToString());
SexChange(__instance.coUser.pspec, __instance.coUser, __instance);
Plugin.Log.LogInfo((object)stringBuilder.ToString());
LoadParts(__instance);
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of void GUIChargenBody::ChangeAppearance():\n{arg}");
}
}
private static void SexChange(PersonSpec __instance, CondOwner condOwner, GUIChargenBody GUIChargenBody_instance)
{
if (!condOwner.HasCond("IsInChargen"))
{
Plugin.Log.LogInfo((object)"SexChange called before initialization, skipping.");
return;
}
List<CondOwner> list = new List<CondOwner>();
if (__instance.strLoot != null)
{
Plugin.Log.LogInfo((object)("SexChange called for " + __instance.strLoot));
Plugin.Log.LogInfo((object)("person " + __instance.strFirstName));
Plugin.Log.LogInfo((object)("Skin: " + __instance.strSkin));
if (__instance.strSkin == null || __instance.strSkin == "")
{
Plugin.Log.LogInfo((object)"Skin is null or empty, setting to default 'Human'.");
__instance.strSkin = "A";
}
string text = "ItmIsFemale" + __instance.strSkin;
if (__instance.strGender == "IsMale")
{
text = "ItmIsMale" + __instance.strSkin;
}
else if (__instance.strGender == "IsNB")
{
text = "ItmIsNB" + __instance.strSkin;
}
Plugin.Log.LogInfo((object)("SexLoot: " + text));
condOwner._compSlots.UnSlotItem("NewSkinBodySlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinGenitalsSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinBallsSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinShaftSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinVagSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinTitLSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinTitRSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinBraSlot", (CondOwner)null, true);
condOwner._compSlots.UnSlotItem("NewSkinUnderpantSlot", (CondOwner)null, true);
List<CondOwner> cOLoot = DataHandler.GetLoot(text).GetCOLoot(__instance.co, false, (string)null);
foreach (CondOwner item in cOLoot)
{
if ((Object)(object)item != (Object)null)
{
__instance.EquipLoot(item);
}
}
}
string text2 = __instance.strBodyType;
Plugin.Log.LogInfo((object)("BodyType: " + __instance.strBodyType));
if (__instance.strBodyType == "" || __instance.strBodyType == null || text2 == "" || text2 == null)
{
text2 = "01";
}
Plugin.Log.LogInfo((object)("BodyType: " + text2));
string text3 = "ItmBodyType" + __instance.strSkin + text2;
Plugin.Log.LogInfo((object)("SexLootBody: " + text3));
List<CondOwner> cOLoot2 = DataHandler.GetLoot(text3).GetCOLoot(__instance.co, false, (string)null);
foreach (CondOwner item2 in cOLoot2)
{
if ((Object)(object)item2 != (Object)null)
{
__instance.EquipLoot(item2);
}
}
GUIChargenBody_instance.ToggleBodyView(true);
GUIChargenBody_instance._paperDollManager.ctFilter = DataHandler.GetCondTrigger("TIsBodyPart");
GUIChargenBody_instance._paperDollManager.SetPaperDoll(GUIChargenBody_instance.coUser);
GUIChargenBody_instance._paperDollManager.HideBackDrag();
}
[HarmonyPatch(typeof(GUIChargenBody), "ChangeSkin")]
[HarmonyPostfix]
private static void ChangeSkin_Postfix(GUIChargenBody __instance, int __0)
{
try
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("--------------------");
stringBuilder.AppendLine("void GUIChargenBody::ChangeSkin(int nDir)");
stringBuilder.Append("- __instance: ").AppendLine(((object)__instance).ToString());
Plugin.Log.LogInfo((object)stringBuilder.ToString());
SexChange(__instance.coUser.pspec, __instance.coUser, __instance);
LoadParts(__instance);
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of void GUIChargenBody::ChangeSkin(int nDir):\n{arg}");
}
}
[HarmonyPatch(typeof(GUIChargenBody), "BodyNext")]
[HarmonyPostfix]
private static void BodyNext_Postfix(GUIChargenBody __instance, int __0)
{
try
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("--------------------");
stringBuilder.AppendLine("void GUIChargenBody::BodyNext(int nDir)");
stringBuilder.Append("- __instance: ").AppendLine(((object)__instance).ToString());
Plugin.Log.LogInfo((object)stringBuilder.ToString());
__instance.coUser._compSlots.UnSlotItem("NewSkinBodySlot", (CondOwner)null, true);
PersonSpec pspec = __instance.coUser.pspec;
if (pspec.strSkin == null || pspec.strSkin == "")
{
Plugin.Log.LogInfo((object)"Skin is null or empty, checking button");
Transform val = ((Component)__instance).transform.Find("pnlFaceBtns/pnlSkinNum");
TMP_Text component = ((Component)((Component)val).transform.Find("txt")).GetComponent<TMP_Text>();
if (component.text == "1/3")
{
Plugin.Log.LogInfo((object)"Setting skin to 'A'.");
pspec.strSkin = "A";
}
else if (component.text == "2/3")
{
Plugin.Log.LogInfo((object)"Setting skin to 'B'.");
pspec.strSkin = "B";
}
else if (component.text == "3/3")
{
Plugin.Log.LogInfo((object)"Setting skin to 'C'.");
pspec.strSkin = "C";
}
else
{
Plugin.Log.LogInfo((object)"Setting skin to 'A' as default.");
pspec.strSkin = "A";
}
}
Plugin.Log.LogInfo((object)"BodyNext called, updating body type.");
Transform val2 = ((Component)__instance).transform.Find("pnlFaceBtns/pnlBodyNum");
TMP_Text component2 = ((Component)((Component)val2).transform.Find("txt")).GetComponent<TMP_Text>();
Plugin.Log.LogInfo((object)("Current body type text: " + component2.text));
string text = "";
if (component2.text == "1/2")
{
if (pspec.strBodyType == "")
{
Plugin.Log.LogInfo((object)"Body type is empty.");
Plugin.Log.LogInfo((object)"Setting body type to '01'.");
pspec.strBodyType = "01";
}
text = "01";
}
else if (component2.text == "2/2")
{
if (pspec.strBodyType == "")
{
Plugin.Log.LogInfo((object)"Body type is empty.");
Plugin.Log.LogInfo((object)"Setting body type to '02'.");
pspec.strBodyType = "02";
}
text = "02";
}
else
{
if (pspec.strBodyType == "")
{
Plugin.Log.LogInfo((object)"Body type is empty.");
Plugin.Log.LogInfo((object)"Setting body type to '01' as default.");
pspec.strBodyType = "01";
}
text = "01";
}
if (text != pspec.strBodyType)
{
Plugin.Log.LogInfo((object)("Setting body type to " + text + "."));
pspec.strBodyType = text;
}
Plugin.Log.LogInfo((object)("Current body type: " + pspec.strBodyType));
string text2 = "ItmBodyType" + pspec.strSkin + pspec.strBodyType;
List<CondOwner> cOLoot = DataHandler.GetLoot(text2).GetCOLoot(pspec.co, false, (string)null);
foreach (CondOwner item in cOLoot)
{
if ((Object)(object)item != (Object)null)
{
pspec.EquipLoot(item);
}
}
Plugin.Log.LogInfo((object)("Equipped body type: " + text2));
LoadParts(__instance);
__instance.ToggleBodyView(true);
__instance._paperDollManager.ctFilter = DataHandler.GetCondTrigger("TIsBodyPart");
__instance._paperDollManager.SetPaperDoll(__instance.coUser);
__instance._paperDollManager.HideBackDrag();
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of void GUIChargenBody::BodyNext(int nDir):\n{arg}");
}
}
[HarmonyPatch(typeof(GUIChargenBody), "UpdatePartNums")]
[HarmonyPostfix]
private static void UpdatePartNums_Postfix(GUIChargenBody __instance)
{
try
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("--------------------");
stringBuilder.AppendLine("void GUIChargenBody::UpdatePartNums()");
stringBuilder.Append("- __instance: ").AppendLine(((object)__instance).ToString());
Plugin.Log.LogInfo((object)stringBuilder.ToString());
LoadParts(__instance);
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of void GUIChargenBody::UpdatePartNums():\n{arg}");
}
}
}
public class GUIPaperDollManager_Patches
{
[HarmonyPatch(typeof(GUIPaperDollManager), "SetMttPaperDoll")]
[HarmonyPostfix]
public static void SetMttPaperDoll_Postfix(ref GUIPaperDollManager __instance, ref CondOwner __0)
{
try
{
Plugin.Log.LogInfo((object)$"SetMttPaperDoll_Postfix() called for {__0} with skin: '{__0.pspec.strSkin}'");
if (!__0.mapConds.ContainsKey("DcNewBodyEquipped"))
{
COPatchHelper.EnsureSlotsAndConditions(ref __0);
COPatchHelper.AddBodyLoot(ref __0);
}
ClothingVisibilityHelper.ClothingVisibility(__0.compSlots, __0, "null", __instance);
__instance.bmpBody.texture = (Texture)(object)DataHandler.LoadPNG("/paperdoll/clothing/blank.png", false, false);
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of void GUIPaperDollManager::SetMttPaperDoll(CondOwner co):\n{arg}");
}
}
[HarmonyPatch(typeof(GUIPaperDollManager), "SetPaperDoll")]
[HarmonyPostfix]
public static void SetPaperDoll_Postfix(ref GUIPaperDollManager __instance, ref CondOwner __0)
{
try
{
Plugin.Log.LogInfo((object)$"SetPaperDoll_Postfix() called for {__0} with skin: '{__0.pspec.strSkin}'");
__instance.bmpBody.texture = (Texture)(object)DataHandler.LoadPNG("/paperdoll/clothing/blank.png", false, false);
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of void GUIPaperDollManager::SetPaperDoll(CondOwner co):\n{arg}");
}
}
}
public class PersonModule_Patches
{
[HarmonyPatch(typeof(PersonModule), "CollectAboutInformation")]
[HarmonyPostfix]
public static void CollectAboutInformation_Postfix(PersonModule __instance, ref string __result, ref CondOwner __0)
{
try
{
string text = __0.pspec.strGender.ToString();
string text2 = "Gender: <color=#999999>" + text switch
{
"IsMale" => "Male",
"IsFemale" => "Female",
"IsNB" => "Non-binary",
_ => text,
} + "</color>";
if (__result != null)
{
string[] array = __result.Split(new char[2] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
StringBuilder stringBuilder = new StringBuilder();
bool flag = false;
string[] array2 = array;
foreach (string text3 in array2)
{
if (!text3.StartsWith("Gender:", StringComparison.OrdinalIgnoreCase))
{
stringBuilder.AppendLine(text3);
if (text3.StartsWith("Age:", StringComparison.OrdinalIgnoreCase) && !flag)
{
stringBuilder.AppendLine(text2);
stringBuilder.AppendLine();
flag = true;
}
else if (text3.StartsWith("My Standings:", StringComparison.OrdinalIgnoreCase))
{
stringBuilder.AppendLine();
}
}
}
__result = stringBuilder.ToString().TrimEnd('\r', '\n');
}
else
{
__result = text2;
}
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of string Ostranauts.UI.MegaToolTip.DataModules.PersonModule::CollectAboutInformation(CondOwner co):\n{arg}");
}
}
}
public class PersonSpec_Patches
{
[HarmonyPatch(typeof(PersonSpec), "MakeCondOwner")]
[HarmonyPostfix]
public static void MakeCondOwner_Postfix(ref PersonSpec __instance, ref CondOwner __result, ref StartShip __0, ref string __1)
{
try
{
if (!__result.mapConds.ContainsKey("DcNewBodyEquipped"))
{
PersonSpec pspec = __result.pspec;
if ((Object)(object)pspec.GetCO() != (Object)null)
{
Plugin.Log.LogInfo((object)$"MakeCondOwner_Postfix called for {__result} with skin {pspec.strSkin})");
COPatchHelper.AddBodyLoot(ref __result);
}
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Exception in patch of CondOwner PersonSpec::MakeCondOwner(PersonSpec+StartShip nStart, string strRegID):\n{arg}");
}
}
}
public class Slots_Patches
{
[HarmonyPatch(typeof(Slots), "SlotItem")]
[HarmonyPostfix]
public static void SlotItem_Postfix(Slots __instance, bool __result, string __0, CondOwner __1)
{
try
{
GUIPaperDollManager paperDollManager = CrewSim.inventoryGUI.PaperDollManager;
if (GUIInventory.instance.IsInventoryVisible && (!GUIInventory.instance.IsInventoryVisible || !((Object)(object)__instance.coUs != (Object)(object)paperDollManager.coUs)) && __result && !((Object)(object)__1 == (Object)null) && __0 != null)
{
ClothingVisibilityHelper.ClothingVisibility(__instance, __1, __0, paperDollManager);
}
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of bool Slots::SlotItem(string strSlot, CondOwner co):\n{arg}");
}
}
[HarmonyPatch(typeof(Slots), "UnSlotItem", new Type[]
{
typeof(string),
typeof(CondOwner),
typeof(bool)
})]
[HarmonyPostfix]
public static void UnSlotItem_Postfix(Slots __instance, CondOwner __result, string __0, CondOwner __1, bool __2)
{
try
{
GUIPaperDollManager paperDollManager = CrewSim.inventoryGUI.PaperDollManager;
if (GUIInventory.instance.IsInventoryVisible && (!GUIInventory.instance.IsInventoryVisible || !((Object)(object)__instance.coUs != (Object)(object)paperDollManager.coUs)) && Object.op_Implicit((Object)(object)__result) && __0 != null)
{
ClothingVisibilityHelper.ClothingVisibility(__instance, __1, __0, paperDollManager, unslotted: true);
}
}
catch (Exception arg)
{
Plugin.Log.LogInfo((object)$"Exception in patch of void Slots::UnSlotItem(string strSlot, CondOwner co, bool bForce):\n{arg}");
}
}
}
internal static class LCMPluginInfo
{
public const string PLUGIN_GUID = "NewSkinLayersPatch";
public const string PLUGIN_NAME = "NewSkinLayersPatch";
public const string PLUGIN_VERSION = "1.1.0";
}
namespace NewSkinLayersPatch
{
[BepInPlugin("NewSkinLayersPatch", "NewSkinLayersPatch", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
internal static ConfigEntry<bool> configDebugMode;
private void Awake()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
configDebugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DebugMode", false, "Toggles logging more debug information to the console and log file.");
Log.LogInfo((object)"Plugin NewSkinLayersPatch version 1.1.0 is loaded!");
try
{
Harmony val = new Harmony("NewSkinLayersPatch");
val.PatchAll(typeof(Slots_Patches));
val.PatchAll(typeof(CommandInventory_Patches));
val.PatchAll(typeof(PersonSpec_Patches));
val.PatchAll(typeof(GUIChargenBody_Patches));
val.PatchAll(typeof(GUIPaperDollManager_Patches));
Log.LogInfo((object)"Successfully initialized Project New Skin patches");
}
catch (Exception arg)
{
Log.LogError((object)$"Error while initializing:\n{arg}\n");
}
}
public static void LogDebug(string text)
{
if (configDebugMode.Value)
{
Log.LogDebug((object)text);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}