using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using DooDesch.AvatarKit; using DooDesch.UI; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne.AvatarFramework; using Il2CppScheduleOne.UI.MainMenu; using Il2CppSystem.Collections.Generic; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Personify; using Personify.Editor; using Personify.Editor.Widgets; using S1API.Entities.Appearances.AccessoryFields; using S1API.Entities.Appearances.BodyLayerFields; using S1API.Entities.Appearances.CustomizationFields; using S1API.Entities.Appearances.FaceLayerFields; using S1API.Rendering; using S1API.UI; using SideHustle; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Core), "Personify", "1.3.0", "DooDesch", "https://github.com/DooDesch-Mods/ScheduleOne-Personify")] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: MelonOptionalDependencies(new string[] { "SideHustle" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("DooDesch")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © DooDesch")] [assembly: AssemblyDescription("In-game NPC editor for Schedule I, launched as a Side Hustle gamemode.")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0+e52e6b8529cd6b4e00197e9560047faf8a24621f")] [assembly: AssemblyProduct("Personify")] [assembly: AssemblyTitle("Personify")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DooDesch { internal static class ModVersion { internal const string Current = "1.3.0"; } } namespace DooDesch.AvatarKit { public static class AvatarDistortion { public static readonly string[] BoneKeys = new string[9] { "HeadBone", "HipBone", "LeftFootBone", "RightFootBone", "LeftShoulder", "RightShoulder", "MiddleSpine", "LowerSpine", "LowestSpine" }; public const string FaceMeshKey = "FaceMesh"; public const string BodyMeshKeyPrefix = "BodyMesh"; private static Transform BoneByName(Avatar avatar, string key) { return (Transform)(key switch { "HeadBone" => avatar.HeadBone, "HipBone" => avatar.HipBone, "LeftFootBone" => avatar.LeftFootBone, "RightFootBone" => avatar.RightFootBone, "LeftShoulder" => avatar.LeftShoulder, "RightShoulder" => avatar.RightShoulder, "MiddleSpine" => avatar.MiddleSpine, "LowerSpine" => avatar.LowerSpine, "LowestSpine" => avatar.LowestSpine, _ => null, }); } public static void Apply(Avatar avatar, IReadOnlyDictionary entries) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null) { return; } AvatarEffects component = ((Component)avatar).GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = entries == null || entries.Count == 0; } string[] boneKeys = BoneKeys; foreach (string key in boneKeys) { Transform val = BoneByName(avatar, key); if (!((Object)(object)val == (Object)null)) { if (entries != null && entries.TryGetValue(key, out (Vector3, bool) value)) { val.localScale = (value.Item2 ? Vector3.zero : value.Item1); } else { val.localScale = Vector3.one; } } } if ((Object)(object)avatar.FaceMesh != (Object)null) { (Vector3, bool) value2; bool flag = entries != null && entries.TryGetValue("FaceMesh", out value2) && value2.Item2; ((Renderer)avatar.FaceMesh).enabled = !flag; } Il2CppReferenceArray bodyMeshes = avatar.BodyMeshes; if (bodyMeshes == null) { return; } for (int j = 0; j < ((Il2CppArrayBase)(object)bodyMeshes).Length; j++) { if (!((Object)(object)((Il2CppArrayBase)(object)bodyMeshes)[j] == (Object)null)) { (Vector3, bool) value3; bool flag2 = entries != null && entries.TryGetValue("BodyMesh" + j, out value3) && value3.Item2; ((Renderer)((Il2CppArrayBase)(object)bodyMeshes)[j]).enabled = !flag2; } } } } public static class AvatarLayerSlots { public const int BodySlots = 8; public const int VanillaClearedSlots = 6; public const int FaceSlots = 6; public const int FixedFaceEntries = 2; public const int FreeFaceEntries = 3; public const string EmptyFacePath = "Avatar/Layers/None"; private const string MouthPrefix = "Avatar/Layers/Face/Face_"; private const string FacialHairPrefix = "Avatar/Layers/Face/FacialHair"; public static bool IsMouthLayer(string path) { return path?.StartsWith("Avatar/Layers/Face/Face_", StringComparison.OrdinalIgnoreCase) ?? false; } public static bool IsFacialHairLayer(string path) { return path?.StartsWith("Avatar/Layers/Face/FacialHair", StringComparison.OrdinalIgnoreCase) ?? false; } public static void OrderFaceLayers(List list) { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) if (list == null) { return; } List<(string, Color)> list2 = new List<(string, Color)>(); List<(string, Color)> list3 = new List<(string, Color)>(); List<(string, Color)> list4 = new List<(string, Color)>(); for (int i = 0; i < list.Count; i++) { LayerSetting val = list[i]; string layerPath = val.layerPath; if (!string.IsNullOrEmpty(layerPath) && !(layerPath == "Avatar/Layers/None")) { if (list2.Count == 0 && IsMouthLayer(layerPath)) { list2.Add((layerPath, val.layerTint)); } else if (list3.Count == 0 && IsFacialHairLayer(layerPath)) { list3.Add((layerPath, val.layerTint)); } else { list4.Add((layerPath, val.layerTint)); } } } list.Clear(); list.Add((list2.Count > 0) ? Setting(list2[0].Item1, list2[0].Item2) : Setting("Avatar/Layers/None", Color.white)); list.Add((list3.Count > 0) ? Setting(list3[0].Item1, list3[0].Item2) : Setting("Avatar/Layers/None", Color.white)); for (int j = 0; j < list4.Count; j++) { list.Add(Setting(list4[j].Item1, list4[j].Item2)); } } public static List TrimFaceToBudget(List list, Func rank) { List list2 = new List(); if (list == null || rank == null || list.Count <= 5) { return list2; } for (int num = CountRenderable(list, 2) - 3; num > 0; num--) { int num2 = -1; int num3 = int.MaxValue; for (int i = 2; i < list.Count; i++) { if (Renders(list[i].layerPath)) { int num4 = rank(list[i].layerPath); if (num4 < num3) { num3 = num4; num2 = i; } } } if (num2 < 0) { break; } list2.Add(list[num2]); list.RemoveAt(num2); } return list2; } private static LayerSetting Setting(string path, Color tint) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown return new LayerSetting { layerPath = path, layerTint = tint }; } public static void LoadAndClean(Avatar avatar, AvatarSettings settings) { if (!((Object)(object)avatar == (Object)null) && !((Object)(object)settings == (Object)null)) { avatar.LoadAvatarSettings(settings); List bodyLayerSettings = settings.BodyLayerSettings; int used = ((bodyLayerSettings != null && bodyLayerSettings.Count > 6) ? CountRenderable(bodyLayerSettings) : 6); ClearStaleBodySlots(avatar, used); } } public static int CountRenderable(List list, int startIndex = 0) { if (list == null) { return 0; } int num = 0; for (int i = Math.Max(0, startIndex); i < list.Count; i++) { if (Renders(list[i].layerPath)) { num++; } } return num; } public static void ClearStaleBodySlots(Avatar avatar, int used) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null || used >= 8) { return; } if (used < 0) { used = 0; } try { Il2CppReferenceArray bodyMeshes = avatar.BodyMeshes; for (int i = used + 1; i <= 8; i++) { avatar.SetBodyLayer(i, string.Empty, Color.white); if (bodyMeshes == null) { continue; } for (int j = 0; j < ((Il2CppArrayBase)(object)bodyMeshes).Length; j++) { SkinnedMeshRenderer val = ((Il2CppArrayBase)(object)bodyMeshes)[j]; if ((Object)(object)val != (Object)null && (Object)(object)((Renderer)val).material != (Object)null) { ((Renderer)val).material.SetTexture("_Layer_" + i + "_Normal", (Texture)null); } } } } catch (Exception) { } } public static List TrimToBudget(List list, Func rank, int max = 8) { List list2 = new List(); if (list == null || rank == null || list.Count <= max) { return list2; } for (int num = CountRenderable(list) - max; num > 0; num--) { int num2 = -1; int num3 = int.MaxValue; for (int i = 0; i < list.Count; i++) { if (Renders(list[i].layerPath)) { int num4 = rank(list[i].layerPath); if (num4 < num3) { num3 = num4; num2 = i; } } } if (num2 < 0) { break; } list2.Add(list[num2]); list.RemoveAt(num2); } return list2; } public static bool AddOnce(List list, string path, Color tint) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (list == null || string.IsNullOrEmpty(path)) { return false; } for (int i = 0; i < list.Count; i++) { if (list[i].layerPath == path) { return false; } } LayerSetting val = new LayerSetting(); val.layerPath = path; val.layerTint = tint; list.Add(val); return true; } private static bool Renders(string layerPath) { if (!string.IsNullOrEmpty(layerPath)) { return Resources.Load(layerPath) != (Object)null; } return false; } } } namespace DooDesch.UI { public static class Theme { public static readonly Color BgDeep = new Color(0.043f, 0.047f, 0.063f, 1f); public static readonly Color BgBase = new Color(0.063f, 0.071f, 0.094f, 1f); public static readonly Color BgPanel = new Color(0.086f, 0.098f, 0.133f, 1f); public static readonly Color BgElevated = new Color(0.114f, 0.129f, 0.173f, 1f); public static readonly Color SurfaceInput = new Color(0.051f, 0.059f, 0.082f, 1f); public static readonly Color Clear = new Color(0f, 0f, 0f, 0f); public static readonly Color Hairline = new Color(1f, 1f, 1f, 0.08f); public static readonly Color HairlineStrong = new Color(1f, 1f, 1f, 0.14f); public static readonly Color ScrimPanel = new Color(0.063f, 0.071f, 0.094f, 0.82f); public static readonly Color ScrimRow = new Color(0.114f, 0.129f, 0.173f, 0.72f); public static readonly Color TextPrimary = new Color(0.925f, 0.929f, 0.945f, 1f); public static readonly Color TextMuted = new Color(0.541f, 0.561f, 0.62f, 1f); public static readonly Color TextDisabled = new Color(0.337f, 0.357f, 0.408f, 1f); public static readonly Color Accent = new Color(0.369f, 0.416f, 0.824f, 1f); public static readonly Color AccentHover = new Color(0.431f, 0.475f, 0.859f, 1f); public static readonly Color AccentPressed = new Color(0.298f, 0.341f, 0.737f, 1f); public static readonly Color AccentSubtle = new Color(0.125f, 0.133f, 0.227f, 1f); public static readonly Color AccentBorder = new Color(0.486f, 0.525f, 0.91f, 1f); public static readonly Color Button = new Color(0.2f, 0.212f, 0.263f, 1f); public static readonly Color Danger = new Color(0.784f, 0.29f, 0.329f, 1f); public static readonly Color DangerText = new Color(0.945f, 0.439f, 0.478f, 1f); public static readonly Color DangerSubtle = new Color(0.165f, 0.082f, 0.094f, 1f); public static readonly Color Warning = new Color(0.788f, 0.569f, 0.18f, 1f); public static readonly Color WarningText = new Color(0.902f, 0.706f, 0.314f, 1f); public static readonly Color WarningSubtle = new Color(0.165f, 0.133f, 0.071f, 1f); public static readonly Color Success = new Color(0.184f, 0.659f, 0.467f, 1f); public static readonly Color SuccessText = new Color(0.373f, 0.816f, 0.604f, 1f); public static readonly Color SuccessSubtle = new Color(0.071f, 0.165f, 0.125f, 1f); public static readonly Color Info = new Color(0.239f, 0.498f, 0.753f, 1f); public static readonly Color InfoText = new Color(0.435f, 0.659f, 0.902f, 1f); public static readonly Color InfoSubtle = new Color(0.071f, 0.125f, 0.192f, 1f); public const int RadiusMd = 6; public const float Fade = 0.12f; public const int Caption = 11; public const int Body = 13; public const int Label = 14; public const int H3 = 16; public const int H2 = 20; public const int H1 = 28; private static Sprite _rounded; private static Sprite _frame; public static Color Lighten(Color c, float amount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) return new Color(Mathf.Clamp01(c.r + amount), Mathf.Clamp01(c.g + amount), Mathf.Clamp01(c.b + amount), c.a); } public static Color Darken(Color c, float amount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return Lighten(c, 0f - amount); } public static Color WithAlpha(Color c, float a) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) return new Color(c.r, c.g, c.b, a); } public static Sprite RoundedSprite() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_rounded != (Object)null) { return _rounded; } Texture2D val = new Texture2D(32, 32, (TextureFormat)5, false); ((Object)val).hideFlags = (HideFlags)32; Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { bool flag = ((float)j < 6f && (float)i < 6f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(6f, 6f)) > 6f) || ((float)j > 25f && (float)i < 6f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(25f, 6f)) > 6f) || ((float)j < 6f && (float)i > 25f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(6f, 25f)) > 6f) || ((float)j > 25f && (float)i > 25f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(25f, 25f)) > 6f); val.SetPixel(j, i, Color32.op_Implicit(flag ? val2 : val3)); } } val.Apply(); _rounded = Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(8f, 8f, 8f, 8f)); return _rounded; } public static Sprite FrameSprite() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_frame != (Object)null) { return _frame; } Texture2D val = new Texture2D(32, 32, (TextureFormat)5, false); ((Object)val).hideFlags = (HideFlags)32; Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { bool flag = j < 3 || j >= 29 || i < 3 || i >= 29; val.SetPixel(j, i, Color32.op_Implicit(flag ? val3 : val2)); } } val.Apply(); _frame = Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(4f, 4f, 4f, 4f)); return _frame; } } public static class Interactions { public static void PolishButtons(Transform root, bool round = true) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return; } Il2CppArrayBase