Decompiled source of Simple Multiplayer Blocky Avatars v1.0.1
BepInEx/plugins/StipBit.SimpleMultiplayerBlockyAvatars.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using WKMPMod.Components; using WKMPMod.Core; using WKMPMod.Data; using WKMPMod.NetWork; using WKMPMod.RemotePlayers; using WKMPMod.Util; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("StipBit")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("StipBit.SimpleMultiplayerBlockyAvatars")] [assembly: AssemblyTitle("StipBit.SimpleMultiplayerBlockyAvatars")] [assembly: AssemblyVersion("1.0.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 StipBit.BlockyAvatars { public static class AvatarAppearance { private static readonly string[] ColorProperties = new string[3] { "_BaseColor", "_Color", "_MainColor" }; public static void Apply(GameObject player, string faceId, AvatarColorSet colors, bool? tintOverride = null, bool flipFace = false) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00fd: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } Transform val = player.transform.Find("ModelContainer"); if (!((Object)(object)((val != null) ? val.Find("AvatarHead") : null) == (Object)null)) { SetColor(val.Find("AvatarHead"), colors.Head); SetColor(val.Find("AvatarTorso"), colors.Torso); SetColor(val.Find("LeftHand"), colors.Hands); SetColor(val.Find("RightHand"), colors.Hands); Transform obj = val.Find("LeftHand"); if (obj != null) { ((Component)obj).GetComponent<HandSilhouette>()?.SetColor(colors.Outline); } Transform obj2 = val.Find("RightHand"); if (obj2 != null) { ((Component)obj2).GetComponent<HandSilhouette>()?.SetColor(colors.Outline); } SetColor(val.Find("AvatarHeadOutline"), colors.Outline); SetColor(val.Find("AvatarTorsoOutline"), colors.Outline); AvatarFaceLibrary.Apply(player, faceId, colors.Face, tintOverride); Transform obj3 = val.Find("AvatarFace"); object obj4; if (obj3 == null) { obj4 = null; } else { MeshFilter component = ((Component)obj3).GetComponent<MeshFilter>(); obj4 = ((component != null) ? component.sharedMesh : null); } Mesh val2 = (Mesh)obj4; if ((Object)(object)val2 != (Object)null) { float num = (flipFace ? 0f : 1f); float num2 = (flipFace ? 1f : 0f); val2.uv = (Vector2[])(object)new Vector2[4] { new Vector2(num, 0f), new Vector2(num2, 0f), new Vector2(num2, 1f), new Vector2(num, 1f) }; } } } private static void SetColor(Transform part, Color32 color) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_008a: Unknown result type (might be due to invalid IL or missing references) MeshRenderer val = ((part != null) ? ((Component)part).GetComponent<MeshRenderer>() : null); if ((Object)(object)val == (Object)null) { return; } Material[] materials = ((Renderer)val).materials; foreach (Material val2 in materials) { if ((Object)(object)val2 == (Object)null) { continue; } string[] colorProperties = ColorProperties; foreach (string text in colorProperties) { if (val2.HasProperty(text)) { Color color2 = val2.GetColor(text); val2.SetColor(text, new Color((float)(int)color.r / 255f, (float)(int)color.g / 255f, (float)(int)color.b / 255f, color2.a)); } } } } } public struct AvatarColorSet { public Color32 Outline; public Color32 Head; public Color32 Torso; public Color32 Hands; public Color32 Face; public static AvatarColorSet Default => new AvatarColorSet { Outline = new Color32((byte)5, (byte)5, (byte)5, byte.MaxValue), Head = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), Torso = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), Hands = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), Face = new Color32((byte)33, (byte)31, (byte)31, byte.MaxValue) }; public Color32 Get(int index) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) return (Color32)(index switch { 0 => Outline, 1 => Head, 2 => Torso, 3 => Hands, 4 => Face, _ => Outline, }); } public void Set(int index, Color32 color) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) color.a = byte.MaxValue; switch (index) { case 0: Outline = color; break; case 1: Head = color; break; case 2: Torso = color; break; case 3: Hands = color; break; case 4: Face = color; break; } } public string Serialize() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) return string.Join("|", Hex(Outline), Hex(Head), Hex(Torso), Hex(Hands), Hex(Face)); } public static AvatarColorSet ParseOrDefault(string value) { if (!TryParse(value, out var colors)) { return Default; } return colors; } public static bool TryParse(string value, out AvatarColorSet colors) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) colors = Default; if (string.IsNullOrWhiteSpace(value)) { return false; } string[] array = value.Split('|'); if (array.Length != 5) { return false; } AvatarColorSet avatarColorSet = Default; for (int i = 0; i < 5; i++) { if (!TryParseHex(array[i].Trim(), out var color)) { return false; } avatarColorSet.Set(i, color); } colors = avatarColorSet; return true; } private static string Hex(Color32 color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return $"{color.r:X2}{color.g:X2}{color.b:X2}"; } private static bool TryParseHex(string hex, out Color32 color) { //IL_0001: 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_0088: Unknown result type (might be due to invalid IL or missing references) color = default(Color32); if (hex.StartsWith("#", StringComparison.Ordinal)) { hex = hex.Substring(1); } if (hex.Length != 6 || !byte.TryParse(hex.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result) || !byte.TryParse(hex.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result2) || !byte.TryParse(hex.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result3)) { return false; } color = new Color32(result, result2, result3, byte.MaxValue); return true; } } public static class AvatarFaceLibrary { public static readonly string[] GroupNames = new string[3] { "Original", "Memes", "Roblox" }; public static readonly string[][] FaceGroups = new string[3][] { new string[8] { "default", "happy", "surprised", "sleepy", "wink", "angry", "sad", "confused" }, new string[4] { "meme_trollface", "meme_rage", "meme_me_gusta", "meme_forever_alone" }, new string[4] { "roblox_man", "roblox_woman", "roblox_smile", "roblox_winning_smile" } }; public static readonly string[] FaceIds = FaceGroups.SelectMany((string[] group) => group).ToArray(); private static readonly Dictionary<string, Texture2D> Textures = new Dictionary<string, Texture2D>(); private static readonly Dictionary<string, Texture2D> TintMasks = new Dictionary<string, Texture2D>(); public static void Invalidate(string id) { if (TintMasks.Remove(id, out var value)) { Object.Destroy((Object)(object)value); } } public static bool IsTintable(string id) { if (!id.StartsWith("custom:", StringComparison.Ordinal)) { return GroupIndex(id) < 2; } return CustomFaceStore.IsTintable(id); } public static string DisplayName(string id) { return Normalize(id) switch { "default" => "Default", "happy" => "Happy", "surprised" => "Surprised", "sleepy" => "Sleepy", "wink" => "Wink", "angry" => "Angry", "sad" => "Sad", "confused" => "Determined", "meme_trollface" => "Trollface", "meme_rage" => "Rage Guy", "meme_me_gusta" => "Me Gusta", "meme_forever_alone" => "Forever Alone", "roblox_man" => "Man Face", "roblox_woman" => "Woman Face", "roblox_smile" => "Classic Smile", "roblox_winning_smile" => "Winning Smile", _ => id.StartsWith("custom:", StringComparison.Ordinal) ? CustomFaceStore.DisplayName(id) : "Default", }; } public static int GroupIndex(string id) { id = Normalize(id); for (int i = 0; i < FaceGroups.Length; i++) { if (Array.IndexOf(FaceGroups[i], id) >= 0) { return i; } } return 0; } public static string Normalize(string id) { if (CustomFaceStore.Contains(id)) { return id; } string[] faceIds = FaceIds; foreach (string text in faceIds) { if (string.Equals(id, text, StringComparison.OrdinalIgnoreCase)) { return text; } } return "default"; } public static string NormalizeRemote(string id) { if (!CustomFaceStore.IsValidId(id)) { return Normalize(id); } return id; } public static Texture2D GetTexture(string id) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown id = NormalizeRemote(id); if (id.StartsWith("custom:", StringComparison.Ordinal)) { return CustomFaceStore.GetTexture(id); } if (Textures.TryGetValue(id, out var value)) { return value; } string text = Path.Combine(BlockyAvatarsPlugin.AssetPath, "assets", "faces", id + ".png"); if (!File.Exists(text)) { BlockyAvatarsPlugin.LogError("[BlockyAvatar] Missing face texture: " + text); if (!(id == "default")) { return GetTexture("default"); } return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, File.ReadAllBytes(text))) { Object.Destroy((Object)(object)val); if (!(id == "default")) { return GetTexture("default"); } return null; } ((Object)val).name = "BlockyFace_" + id; ((Texture)val).filterMode = (FilterMode)1; Textures[id] = val; return val; } public static Texture2D GetTintMask(string id) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown id = NormalizeRemote(id); if (!id.StartsWith("custom:", StringComparison.Ordinal) && !IsTintable(id)) { return GetTexture(id); } if (TintMasks.TryGetValue(id, out var value)) { return value; } Texture2D texture = GetTexture(id); if ((Object)(object)texture == (Object)null) { return null; } Color32[] pixels = texture.GetPixels32(); for (int i = 0; i < pixels.Length; i++) { pixels[i].r = byte.MaxValue; pixels[i].g = byte.MaxValue; pixels[i].b = byte.MaxValue; } Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).height, (TextureFormat)4, false) { name = "BlockyFaceTintMask_" + id, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; val.SetPixels32(pixels); val.Apply(false, true); TintMasks[id] = val; return val; } public static void Apply(GameObject player, string id, Color32 lineColor, bool? tintOverride = null) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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) if ((Object)(object)player == (Object)null) { return; } Transform val = player.transform.Find("ModelContainer/AvatarFace"); if (!((Object)(object)val == (Object)null)) { MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>(); bool flag = tintOverride ?? IsTintable(id); Texture2D val2 = (flag ? GetTintMask(id) : GetTexture(id)); if (!((Object)(object)component == (Object)null) && !((Object)(object)val2 == (Object)null)) { Material material = ((Renderer)component).material; material.mainTexture = (Texture)(object)val2; material.color = (flag ? Color32.op_Implicit(lineColor) : Color.white); } } } } public sealed class AvatarMenu : MonoBehaviour { private static readonly string[] ColorTargets = new string[5] { "Outline", "Head", "Torso", "Hands", "Face" }; private static readonly string[] PresetNames = new string[12] { "Black", "White", "Warm cream", "Red", "Orange", "Yellow", "Green", "Cyan", "Blue", "Purple", "Pink", "Gray" }; private static readonly Color32[] Presets = (Color32[])(object)new Color32[12] { new Color32((byte)5, (byte)5, (byte)5, byte.MaxValue), new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), new Color32((byte)239, (byte)226, (byte)215, byte.MaxValue), new Color32((byte)215, (byte)65, (byte)64, byte.MaxValue), new Color32((byte)236, (byte)139, (byte)59, byte.MaxValue), new Color32((byte)247, (byte)215, (byte)80, byte.MaxValue), new Color32((byte)84, (byte)180, (byte)104, byte.MaxValue), new Color32((byte)73, (byte)199, (byte)211, byte.MaxValue), new Color32((byte)67, (byte)126, (byte)217, byte.MaxValue), new Color32((byte)158, (byte)102, (byte)209, byte.MaxValue), new Color32((byte)238, (byte)134, (byte)177, byte.MaxValue), new Color32((byte)129, (byte)136, (byte)148, byte.MaxValue) }; private bool _open; private int _group; private bool _colorPage; private bool _editorPage; private AvatarPreview _preview; private readonly GameMenuSkin _gameSkin = new GameMenuSkin(); private readonly ColorPicker _colorPicker = new ColorPicker(); private FaceEditor _editor; private string _previewFace; private string _previewColors; private bool _previewFlip; private GameObject _mainMenuButton; private GameObject _pauseMenuButton; private GameObject _pauseMenuRoot; private bool _pausedByAvatar; private CanvasGroup _pauseCanvasGroup; private bool _pauseCanvasInteracted; private bool _pauseCanvasBlocked; private bool _addedPauseCanvasGroup; private float _nextPauseButtonSearch; private readonly List<RectTransform> _shiftedPauseButtons = new List<RectTransform>(); private readonly List<Vector2> _originalPausePositions = new List<Vector2>(); private int _customPage; private string _deletePendingId; private float _deletePendingUntil; private string _customStatus; private int _colorTarget; private Color32 _draftColor; private bool _draftDirty; private Rect _window = new Rect(0f, 0f, 760f, 650f); private GUIStyle _windowStyle; private GUIStyle _titleStyle; private GUIStyle _labelStyle; private GUIStyle _smallLabelStyle; private GUIStyle _buttonStyle; private GUIStyle _selectedButtonStyle; private GUIStyle _sliderStyle; private GUIStyle _sliderThumbStyle; private Texture2D _panelTexture; private Texture2D _buttonTexture; private Texture2D _hoverTexture; private Texture2D _selectedTexture; private Texture2D _previewTexture; public static AvatarMenu Instance { get; private set; } private void Awake() { Instance = this; _preview = new AvatarPreview(((Component)this).transform); _editor = new FaceEditor(); } private void OnDestroy() { CommitColor(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } Object.Destroy((Object)(object)_panelTexture); Object.Destroy((Object)(object)_buttonTexture); Object.Destroy((Object)(object)_hoverTexture); Object.Destroy((Object)(object)_selectedTexture); Object.Destroy((Object)(object)_previewTexture); _preview?.Dispose(); _editor?.Dispose(); _gameSkin.Dispose(); _colorPicker.Dispose(); if ((Object)(object)_mainMenuButton != (Object)null) { Object.Destroy((Object)(object)_mainMenuButton); } if ((Object)(object)_pauseMenuButton != (Object)null) { Object.Destroy((Object)(object)_pauseMenuButton); } RestorePauseButtonPositions(); RestorePauseCanvas(); } public void Open() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (_open || !CanUseMenu()) { return; } if (!IsMainMenu()) { CL_GameManager gMan = CL_GameManager.gMan; _pausedByAvatar = !gMan.isPaused; if (_pausedByAvatar) { gMan.Pause(); } BlockPauseCanvas(gMan.pauseMenu); } else { _pausedByAvatar = false; } _open = true; _colorPage = false; _editorPage = false; _group = AvatarFaceLibrary.GroupIndex(BlockyAvatarsPlugin.FaceId); _colorTarget = 0; _draftColor = BlockyAvatarsPlugin.Colors.Get(_colorTarget); _draftDirty = false; ((Rect)(ref _window)).x = ((float)Screen.width - ((Rect)(ref _window)).width) / 2f; ((Rect)(ref _window)).y = ((float)Screen.height - ((Rect)(ref _window)).height) / 2f; _preview.Reset(faceView: true); } private void Update() { if (!CanUseMenu()) { if (_open) { CommitColor(); _open = false; _pausedByAvatar = false; RestorePauseCanvas(); } return; } if (IsMainMenu()) { EnsureMainMenuButton(); } else { EnsurePauseMenuButton(); } if (_open && !IsMainMenu() && !CL_GameManager.gMan.isPaused) { Close(); return; } if (Input.GetKeyDown((KeyCode)289)) { if (_open) { Close(); } else { Open(); } } if (_open && _editorPage) { _editor.HandleShortcuts(); } } private void LateUpdate() { if (_open && CanUseMenu()) { if (_editorPage) { _editor.Tick(); } else { _preview.Tick(); } } } private void OnGUI() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (_open && CanUseMenu()) { EnsureStyles(); Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.42f); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture); GUI.color = color; _window = GUI.Window(182710, _window, new WindowFunction(DrawWindow), "", _windowStyle); } } private static Texture2D Solid(Color color) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, color); val.Apply(); return val; } private void EnsureStyles() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Expected O, but got Unknown //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Expected O, but got Unknown //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Expected O, but got Unknown //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Expected O, but got Unknown //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Expected O, but got Unknown //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Expected O, but got Unknown if (_windowStyle == null) { _panelTexture = Solid(new Color(0.075f, 0.092f, 0.115f, 1f)); _buttonTexture = Solid(new Color(0.17f, 0.21f, 0.26f, 1f)); _hoverTexture = Solid(new Color(0.23f, 0.3f, 0.37f, 1f)); _selectedTexture = Solid(new Color(0.32f, 0.48f, 0.54f, 1f)); _previewTexture = Solid(new Color(0.94f, 0.9f, 0.86f, 1f)); Color textColor = default(Color); ((Color)(ref textColor))..ctor(0.97f, 0.95f, 0.91f, 1f); _windowStyle = new GUIStyle(); _titleStyle = new GUIStyle(GUI.skin.label) { fontSize = 16, alignment = (TextAnchor)4 }; _titleStyle.normal.textColor = textColor; _labelStyle = new GUIStyle(GUI.skin.label) { fontSize = 14, wordWrap = true }; _labelStyle.normal.textColor = textColor; _smallLabelStyle = new GUIStyle(_labelStyle) { fontSize = 12, alignment = (TextAnchor)3 }; _buttonStyle = new GUIStyle(GUI.skin.button) { fontSize = 14, alignment = (TextAnchor)4 }; _buttonStyle.normal.background = _buttonTexture; _buttonStyle.hover.background = _hoverTexture; _buttonStyle.active.background = _hoverTexture; _buttonStyle.onNormal.background = _selectedTexture; _buttonStyle.onHover.background = _selectedTexture; _buttonStyle.normal.textColor = textColor; _buttonStyle.hover.textColor = textColor; _buttonStyle.active.textColor = textColor; _buttonStyle.onNormal.textColor = textColor; _buttonStyle.onHover.textColor = textColor; _buttonStyle.border = new RectOffset(0, 0, 0, 0); _selectedButtonStyle = new GUIStyle(_buttonStyle); _selectedButtonStyle.normal.background = _selectedTexture; _sliderStyle = new GUIStyle(GUI.skin.horizontalSlider); _sliderStyle.normal.background = _buttonTexture; _sliderStyle.hover.background = _buttonTexture; _sliderStyle.active.background = _buttonTexture; _sliderStyle.focused.background = _buttonTexture; _sliderStyle.fixedHeight = 10f; _sliderStyle.border = new RectOffset(0, 0, 0, 0); _sliderThumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb); _sliderThumbStyle.normal.background = _selectedTexture; _sliderThumbStyle.hover.background = _hoverTexture; _sliderThumbStyle.active.background = _selectedTexture; _sliderThumbStyle.focused.background = _selectedTexture; _sliderThumbStyle.fixedWidth = 15f; _sliderThumbStyle.fixedHeight = 20f; _sliderThumbStyle.border = new RectOffset(0, 0, 0, 0); } } private void DrawWindow(int id) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref _window)).width, ((Rect)(ref _window)).height), (Texture)(object)_panelTexture); GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref _window)).width, 27f), (Texture)(object)_buttonTexture); if (!_editorPage && !_colorPage) { GUI.DrawTexture(new Rect(20f, 385f, 720f, 1f), (Texture)(object)_hoverTexture); } GUI.Label(new Rect(0f, 3f, ((Rect)(ref _window)).width, 24f), "Simple Multiplayer Blocky Avatars", _titleStyle); if (_editorPage) { GUIStyle label = GUI.skin.label; GUIStyle button = GUI.skin.button; GUIStyle toggle = GUI.skin.toggle; GUIStyle horizontalSlider = GUI.skin.horizontalSlider; GUIStyle horizontalSliderThumb = GUI.skin.horizontalSliderThumb; GUI.skin.label = _labelStyle; GUI.skin.button = _buttonStyle; if (_gameSkin.Toggle != null) { GUI.skin.toggle = _gameSkin.Toggle; } GUI.skin.horizontalSlider = _sliderStyle; GUI.skin.horizontalSliderThumb = _sliderThumbStyle; try { _editor.Draw(new Rect(20f, 32f, 720f, 580f), BackFromEditor, SelectFace); } finally { GUI.skin.label = label; GUI.skin.button = button; GUI.skin.toggle = toggle; GUI.skin.horizontalSlider = horizontalSlider; GUI.skin.horizontalSliderThumb = horizontalSliderThumb; } } else if (_colorPage) { DrawColorPage(); } else { DrawFacePage(); } GUI.Label(new Rect(20f, 619f, 700f, 22f), "F8 opens or closes this menu", _smallLabelStyle); GUI.DragWindow(new Rect(0f, 0f, 760f, 25f)); } private void DrawFacePage() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) DrawPreview(new Rect(20f, 58f, 250f, 250f)); if (GUI.Button(new Rect(20f, 311f, 250f, 28f), "Reset view", _buttonStyle)) { _preview.Reset(faceView: true); } GUI.Label(new Rect(290f, 70f, 430f, 30f), AvatarFaceLibrary.DisplayName(BlockyAvatarsPlugin.FaceId), _labelStyle); GUI.Label(new Rect(290f, 115f, 430f, 24f), "Your choice is saved automatically.", _labelStyle); GUI.Label(new Rect(290f, 145f, 430f, 50f), "Drag to rotate, scroll to zoom, right drag to pan.", _labelStyle); bool flag = GUI.Toggle(new Rect(290f, 184f, 225f, 28f), BlockyAvatarsPlugin.FlipFace, "Flip face", _buttonStyle); if (flag != BlockyAvatarsPlugin.FlipFace) { BlockyAvatarsPlugin.FlipFace = flag; } if (GUI.Button(new Rect(290f, 220f, 140f, 36f), "Create Custom...", _buttonStyle)) { OpenEditor(createNew: true); } GUI.enabled = CustomFaceStore.Contains(BlockyAvatarsPlugin.FaceId); if (GUI.Button(new Rect(436f, 220f, 110f, 36f), "Edit face...", _buttonStyle)) { OpenEditor(createNew: false); } GUI.enabled = true; if (GUI.Button(new Rect(552f, 220f, 95f, 36f), "Colors...", _buttonStyle)) { _colorPage = true; _preview.Reset(faceView: false); } if (GUI.Button(new Rect(653f, 220f, 87f, 36f), "Close", _buttonStyle)) { Close(); } string[] array = new string[5] { "Original", "Memes", "Roblox", "Custom", "Clothes" }; for (int i = 0; i < array.Length; i++) { GUIStyle val = ((i == _group) ? _selectedButtonStyle : _buttonStyle); GUI.enabled = i != 4; if (GUI.Button(new Rect((float)(20 + i * 145), 348f, 138f, 32f), array[i], val)) { _group = i; } GUI.enabled = true; } if (_group == 3) { DrawCustomChoices(); return; } string[] array2 = AvatarFaceLibrary.FaceGroups[_group]; for (int j = 0; j < array2.Length; j++) { string text = array2[j]; int num = 20 + j % 4 * 181; int num2 = 394 + j / 4 * 83; Rect val2 = new Rect((float)num, (float)num2, 174f, 76f); GUIStyle val3 = ((text == BlockyAvatarsPlugin.FaceId) ? _selectedButtonStyle : _buttonStyle); bool num3 = GUI.Button(val2, "", val3); GUI.DrawTexture(new Rect((float)(num + 5), (float)(num2 + 5), 66f, 66f), (Texture)(object)_previewTexture); DrawFaceTexture(new Rect((float)(num + 5), (float)(num2 + 5), 66f, 66f), text); string text2 = AvatarFaceLibrary.DisplayName(text).Replace(" ", "\n"); GUI.Label(new Rect((float)(num + 78), (float)(num2 + 10), 90f, 56f), text2, _smallLabelStyle); if (num3) { SelectFace(text); } } } private static void DrawFaceTexture(Rect rect, string faceId) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0035: Unknown result type (might be due to invalid IL or missing references) bool flag = AvatarFaceLibrary.IsTintable(faceId); Texture2D val = (flag ? AvatarFaceLibrary.GetTintMask(faceId) : AvatarFaceLibrary.GetTexture(faceId)); if (!((Object)(object)val == (Object)null)) { Color color = GUI.color; if (flag) { GUI.color = Color32.op_Implicit(BlockyAvatarsPlugin.Colors.Face); } GUI.DrawTexture(rect, (Texture)(object)val, (ScaleMode)2, true); GUI.color = color; } } private void DrawColorPage() { //IL_0014: 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) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: 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_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Invalid comparison between Unknown and I4 //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Expected O, but got Unknown //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(20f, 31f, 500f, 22f), "Choose a part, then pick its color", _labelStyle); if (GUI.Button(new Rect(560f, 60f, 180f, 30f), "Back to faces", _buttonStyle)) { CommitColor(); _colorPage = false; _preview.Reset(faceView: true); return; } DrawPreview(new Rect(560f, 145f, 180f, 180f)); GUI.Label(new Rect(560f, 330f, 180f, 54f), "Drag: rotate\nScroll: zoom\nRight drag: pan", _smallLabelStyle); if (GUI.Button(new Rect(560f, 390f, 180f, 28f), "Reset view", _buttonStyle)) { _preview.Reset(faceView: false); } for (int i = 0; i < ColorTargets.Length; i++) { GUIStyle val = ((i == _colorTarget) ? _selectedButtonStyle : _buttonStyle); if (GUI.Button(new Rect((float)(20 + i * 104), 104f, 98f, 32f), ColorTargets[i], val)) { SelectColorTarget(i); } } GUI.Label(new Rect(20f, 146f, 180f, 22f), ColorTargets[_colorTarget], _labelStyle); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(20f, 172f, 175f, 95f); if (_colorTarget == 4) { GUI.DrawTexture(val2, (Texture)(object)_previewTexture); string faceId = BlockyAvatarsPlugin.FaceId; bool flag = AvatarFaceLibrary.IsTintable(faceId); Texture2D val3 = (flag ? AvatarFaceLibrary.GetTintMask(faceId) : AvatarFaceLibrary.GetTexture(faceId)); if ((Object)(object)val3 != (Object)null) { Color color = GUI.color; if (flag) { GUI.color = Color32.op_Implicit(_draftColor); } GUI.DrawTexture(val2, (Texture)(object)val3, (ScaleMode)2, true); GUI.color = color; } } else { Color color2 = GUI.color; GUI.color = Color32.op_Implicit(_draftColor); GUI.DrawTexture(val2, (Texture)(object)Texture2D.whiteTexture); GUI.color = color2; } GUI.Label(new Rect(20f, 275f, 175f, 22f), $"#{_draftColor.r:X2}{_draftColor.g:X2}{_draftColor.b:X2}", _labelStyle); Color32 val4 = _colorPicker.Draw(new Rect(222f, 150f, 288f, 220f), _draftColor); if (val4.r != _draftColor.r || val4.g != _draftColor.g || val4.b != _draftColor.b) { _draftColor = val4; _draftDirty = true; } string text = ((_colorTarget == 4) ? "Face color applies to Original and Memes; Roblox keeps its own colors." : "Pick a shade or choose a preset. Your choice is saved automatically."); GUI.Label(new Rect(20f, 390f, 520f, 30f), text, _smallLabelStyle); Rect val5 = default(Rect); for (int j = 0; j < Presets.Length; j++) { ((Rect)(ref val5))..ctor((float)(20 + j % 6 * 87), (float)(430 + j / 6 * 43), 80f, 36f); bool flag2 = Presets[j].r == _draftColor.r && Presets[j].g == _draftColor.g && Presets[j].b == _draftColor.b; if (GUI.Button(val5, new GUIContent("", PresetNames[j]), flag2 ? _selectedButtonStyle : _buttonStyle)) { _draftColor = Presets[j]; _draftDirty = true; } Color color3 = GUI.color; GUI.color = Color32.op_Implicit(Presets[j]); GUI.DrawTexture(new Rect(((Rect)(ref val5)).x + 5f, ((Rect)(ref val5)).y + 5f, ((Rect)(ref val5)).width - 10f, ((Rect)(ref val5)).height - 10f), (Texture)(object)Texture2D.whiteTexture); GUI.color = color3; } if (GUI.Button(new Rect(20f, 530f, 175f, 28f), "Reset this color", _buttonStyle)) { _draftColor = AvatarColorSet.Default.Get(_colorTarget); _draftDirty = true; } if (!string.IsNullOrEmpty(GUI.tooltip)) { GUI.Label(new Rect(220f, 532f, 300f, 24f), GUI.tooltip, _smallLabelStyle); } if ((int)Event.current.type == 1) { CommitColor(); } } private void SelectColorTarget(int target) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (target != _colorTarget) { CommitColor(); _colorTarget = target; _draftColor = BlockyAvatarsPlugin.Colors.Get(target); } } private void CommitColor() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_draftDirty) { AvatarColorSet colors = BlockyAvatarsPlugin.Colors; colors.Set(_colorTarget, _draftColor); BlockyAvatarsPlugin.Colors = colors; _draftDirty = false; } } private void Close() { CommitColor(); _open = false; RestorePauseCanvas(); if (_pausedByAvatar && !IsMainMenu() && (Object)(object)CL_GameManager.gMan != (Object)null && CL_GameManager.gMan.isPaused) { CL_GameManager.gMan.UnPause(); } _pausedByAvatar = false; } private static bool IsMainMenu() { //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) Scene activeScene = SceneManager.GetActiveScene(); return ((Scene)(ref activeScene)).name == "Main-Menu"; } private static bool CanUseMenu() { if (!IsMainMenu()) { if ((Object)(object)CL_GameManager.gMan != (Object)null && (Object)(object)CL_GameManager.gMan.pauseMenu != (Object)null) { return CL_GameManager.gMan.canPause; } return false; } return true; } private void BlockPauseCanvas(GameObject pauseRoot) { if (!((Object)(object)pauseRoot == (Object)null)) { _pauseCanvasGroup = pauseRoot.GetComponent<CanvasGroup>(); _addedPauseCanvasGroup = (Object)(object)_pauseCanvasGroup == (Object)null; if (_addedPauseCanvasGroup) { _pauseCanvasGroup = pauseRoot.AddComponent<CanvasGroup>(); } _pauseCanvasInteracted = _pauseCanvasGroup.interactable; _pauseCanvasBlocked = _pauseCanvasGroup.blocksRaycasts; _pauseCanvasGroup.interactable = false; _pauseCanvasGroup.blocksRaycasts = false; } } private void RestorePauseCanvas() { if (!((Object)(object)_pauseCanvasGroup == (Object)null)) { _pauseCanvasGroup.interactable = _pauseCanvasInteracted; _pauseCanvasGroup.blocksRaycasts = _pauseCanvasBlocked; if (_addedPauseCanvasGroup) { Object.Destroy((Object)(object)_pauseCanvasGroup); } _pauseCanvasGroup = null; _addedPauseCanvasGroup = false; } } private static void SelectFace(string faceId) { BlockyAvatarsPlugin.FaceId = faceId; } private void DrawPreview(Rect area) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) AvatarColorSet colors = BlockyAvatarsPlugin.Colors; if (_colorPage && _draftDirty) { colors.Set(_colorTarget, _draftColor); } string text = colors.Serialize(); string faceId = BlockyAvatarsPlugin.FaceId; if (_previewFace != faceId || _previewColors != text || _previewFlip != BlockyAvatarsPlugin.FlipFace) { _preview.Apply(faceId, colors, BlockyAvatarsPlugin.FlipFace); _previewFace = faceId; _previewColors = text; _previewFlip = BlockyAvatarsPlugin.FlipFace; } _preview.Draw(area); } private void DrawCustomChoices() { //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) IReadOnlyList<FaceProject> saved = CustomFaceStore.Saved; int num = Mathf.Max(1, (saved.Count + 7) / 8); _customPage = Mathf.Clamp(_customPage, 0, num - 1); for (int i = _customPage * 8; i < Mathf.Min(saved.Count, (_customPage + 1) * 8); i++) { FaceProject faceProject = saved[i]; int num2 = i - _customPage * 8; int num3 = 20 + num2 % 4 * 181; int num4 = 394 + num2 / 4 * 83; GUIStyle val = ((faceProject.Id == BlockyAvatarsPlugin.FaceId) ? _selectedButtonStyle : _buttonStyle); bool flag = GUI.Button(new Rect((float)num3, (float)num4, 174f, 76f), "", val); GUI.DrawTexture(new Rect((float)(num3 + 5), (float)(num4 + 5), 66f, 66f), (Texture)(object)_previewTexture); DrawFaceTexture(new Rect((float)(num3 + 5), (float)(num4 + 5), 66f, 66f), faceProject.Id); GUI.Label(new Rect((float)(num3 + 78), (float)(num4 + 10), 90f, 56f), faceProject.Name, _smallLabelStyle); if (flag) { SelectFace(faceProject.Id); } } if (saved.Count == 0) { GUI.Label(new Rect(20f, 395f, 690f, 35f), "No saved custom faces yet. Use Create Custom to make one.", _labelStyle); } if (num > 1) { if (GUI.Button(new Rect(20f, 570f, 80f, 30f), "Previous", _buttonStyle)) { _customPage = Mathf.Max(0, _customPage - 1); } GUI.Label(new Rect(110f, 573f, 100f, 25f), $"{_customPage + 1} / {num}", _smallLabelStyle); if (GUI.Button(new Rect(200f, 570f, 80f, 30f), "Next", _buttonStyle)) { _customPage = Mathf.Min(num - 1, _customPage + 1); } } string faceId = BlockyAvatarsPlugin.FaceId; if (CustomFaceStore.Contains(faceId)) { bool flag2 = _deletePendingId == faceId && Time.realtimeSinceStartup < _deletePendingUntil; if (GUI.Button(new Rect(530f, 570f, 210f, 30f), flag2 ? "Confirm delete" : "Delete selected face", _buttonStyle)) { if (flag2) { try { if (CustomFaceStore.Delete(faceId)) { BlockyAvatarsPlugin.FaceId = "default"; _previewFace = null; _customStatus = "Custom face deleted."; } } catch (Exception ex) { _customStatus = "Could not delete face: " + ex.Message; } _deletePendingId = null; } else { _deletePendingId = faceId; _deletePendingUntil = Time.realtimeSinceStartup + 8f; } } } if (!string.IsNullOrEmpty(_customStatus)) { GUI.Label(new Rect(295f, 573f, 225f, 26f), _customStatus, _smallLabelStyle); } } private void OpenEditor(bool createNew) { _editorPage = true; _editor.Open(createNew ? null : BlockyAvatarsPlugin.FaceId); } private void BackFromEditor() { _editorPage = false; _group = 3; _previewFace = null; _preview.Reset(faceView: true); } private void EnsureMainMenuButton() { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown if ((Object)(object)_mainMenuButton != (Object)null) { return; } GameObject obj = GameObject.Find("Multi Play"); Transform val = ((obj != null) ? obj.transform.parent : null); object obj2; if (val == null) { obj2 = null; } else { Transform obj3 = val.Find("Cosmetics"); obj2 = ((obj3 != null) ? ((Component)obj3).gameObject : null); } GameObject val2 = (GameObject)obj2; if (!((Object)(object)val2 == (Object)null)) { _mainMenuButton = Object.Instantiate<GameObject>(val2, val); ((Object)_mainMenuButton).name = "StipBit Avatar"; _mainMenuButton.transform.SetSiblingIndex(2); Transform obj4 = _mainMenuButton.transform.Find("Text (TMP)"); TextMeshProUGUI val3 = ((obj4 != null) ? ((Component)obj4).GetComponent<TextMeshProUGUI>() : null); if ((Object)(object)val3 != (Object)null) { ((TMP_Text)val3).text = "AVATAR"; } UI_MenuButton component = _mainMenuButton.GetComponent<UI_MenuButton>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } Button component2 = _mainMenuButton.GetComponent<Button>(); if ((Object)(object)component2 != (Object)null) { component2.onClick = new ButtonClickedEvent(); ((UnityEvent)component2.onClick).AddListener(new UnityAction(Open)); } VerticalLayoutGroup component3 = ((Component)val).GetComponent<VerticalLayoutGroup>(); if ((Object)(object)component3 != (Object)null) { ((HorizontalOrVerticalLayoutGroup)component3).spacing = ((HorizontalOrVerticalLayoutGroup)component3).spacing - 12f; LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)val); } } } private void EnsurePauseMenuButton() { //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: 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_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) GameObject val = CL_GameManager.gMan?.pauseMenu; if ((Object)(object)val == (Object)null) { return; } if ((Object)(object)_pauseMenuRoot != (Object)(object)val) { if ((Object)(object)_pauseMenuButton != (Object)null) { Object.Destroy((Object)(object)_pauseMenuButton); } RestorePauseButtonPositions(); _pauseMenuButton = null; _pauseMenuRoot = val; } if ((Object)(object)_pauseMenuButton != (Object)null || Time.unscaledTime < _nextPauseButtonSearch) { return; } _nextPauseButtonSearch = Time.unscaledTime + 2f; Button val2 = null; Button[] componentsInChildren = val.GetComponentsInChildren<Button>(true); Button[] array = componentsInChildren; foreach (Button val3 in array) { if (ButtonLabel(val3).ToUpperInvariant().Contains("SETTINGS")) { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null) { return; } RectTransform component = ((Component)val2).GetComponent<RectTransform>(); Transform obj = ((component != null) ? ((Transform)component).parent : null); RectTransform val4 = (RectTransform)(object)((obj is RectTransform) ? obj : null); if ((Object)(object)val4 == (Object)null) { return; } _pauseMenuButton = Object.Instantiate<GameObject>(((Component)val2).gameObject, (Transform)(object)val4); ((Object)_pauseMenuButton).name = "StipBit Avatar Pause Button"; _pauseMenuButton.transform.SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1); TextMeshProUGUI[] componentsInChildren2 = _pauseMenuButton.GetComponentsInChildren<TextMeshProUGUI>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((TMP_Text)componentsInChildren2[i]).text = "AVATAR"; } Text[] componentsInChildren3 = _pauseMenuButton.GetComponentsInChildren<Text>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { componentsInChildren3[i].text = "AVATAR"; } UI_ButtonSettings[] componentsInChildren4 = _pauseMenuButton.GetComponentsInChildren<UI_ButtonSettings>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { ((Behaviour)componentsInChildren4[i]).enabled = false; } UI_MenuButton[] componentsInChildren5 = _pauseMenuButton.GetComponentsInChildren<UI_MenuButton>(true); for (int i = 0; i < componentsInChildren5.Length; i++) { ((Behaviour)componentsInChildren5[i]).enabled = false; } Button component2 = _pauseMenuButton.GetComponent<Button>(); component2.onClick = new ButtonClickedEvent(); ((UnityEvent)component2.onClick).AddListener(new UnityAction(Open)); if ((Object)(object)((Component)val4).GetComponent<LayoutGroup>() != (Object)null) { LayoutRebuilder.ForceRebuildLayoutImmediate(val4); return; } Rect rect = component.rect; float num = ((Rect)(ref rect)).height + 28f; _pauseMenuButton.GetComponent<RectTransform>().anchoredPosition = component.anchoredPosition + Vector2.down * num; array = componentsInChildren; foreach (Button val5 in array) { string text = ButtonLabel(val5).ToUpperInvariant(); if (!(text != "RESTART") || !(text != "END RUN")) { RectTransform component3 = ((Component)val5).GetComponent<RectTransform>(); if (!((Object)(object)component3 == (Object)null)) { _shiftedPauseButtons.Add(component3); _originalPausePositions.Add(component3.anchoredPosition); component3.anchoredPosition += Vector2.down * num; } } } } private static string ButtonLabel(Button button) { TextMeshProUGUI componentInChildren = ((Component)button).GetComponentInChildren<TextMeshProUGUI>(true); if ((Object)(object)componentInChildren != (Object)null) { return ((TMP_Text)componentInChildren).text ?? ""; } Text componentInChildren2 = ((Component)button).GetComponentInChildren<Text>(true); if (!((Object)(object)componentInChildren2 != (Object)null)) { return ((Object)button).name; } return componentInChildren2.text ?? ""; } private void RestorePauseButtonPositions() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _shiftedPauseButtons.Count; i++) { if ((Object)(object)_shiftedPauseButtons[i] != (Object)null) { _shiftedPauseButtons[i].anchoredPosition = _originalPausePositions[i]; } } _shiftedPauseButtons.Clear(); _originalPausePositions.Clear(); } } public sealed class AvatarPreview : IDisposable { private readonly GameObject _root; private readonly Camera _camera; private readonly RenderTexture _texture; private readonly List<Material> _flatMaterials = new List<Material>(); private int _dragButton = -1; private float _yaw; private float _pitch; private float _distance; private Vector3 _focus; private bool _dirty = true; private bool _flipFace; public Texture Texture => (Texture)(object)_texture; public AvatarPreview(Transform parent) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown _root = new GameObject("StipBit Avatar Preview") { hideFlags = (HideFlags)61 }; _root.transform.SetParent(parent, false); _root.transform.localPosition = new Vector3(10000f, 10000f, 10000f); GameObject val = new GameObject("ModelContainer"); val.transform.SetParent(_root.transform, false); Material sharedMaterial = new Material(Shader.Find("Standard") ?? Shader.Find("Diffuse")) { color = Color.white }; GameObject obj = GameObject.CreatePrimitive((PrimitiveType)1); ((Object)obj).name = "Capsule"; obj.transform.SetParent(val.transform, false); Object.Destroy((Object)(object)obj.GetComponent<Collider>()); ((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = sharedMaterial; CreateHand(val.transform, "LeftHand", new Vector3(-0.69f, 0.1f, 0f)); CreateHand(val.transform, "RightHand", new Vector3(0.69f, 0.1f, 0f)); new BlockyModelExtension().OnPlayerInstanceCreated(_root); Shader val2 = Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default"); if ((Object)(object)val2 != (Object)null) { string[] array = new string[4] { "AvatarHead", "AvatarTorso", "LeftHand", "RightHand" }; foreach (string text in array) { Transform obj2 = val.transform.Find(text); MeshRenderer val3 = ((obj2 != null) ? ((Component)obj2).GetComponent<MeshRenderer>() : null); if (!((Object)(object)val3 == (Object)null)) { Material val4 = new Material(val2) { color = Color.white }; _flatMaterials.Add(val4); ((Renderer)val3).sharedMaterial = val4; } } } SetLayer(_root.transform, 30); GameObject val5 = new GameObject("Preview Camera") { hideFlags = (HideFlags)61 }; val5.transform.SetParent(parent, false); val5.layer = 30; _camera = val5.AddComponent<Camera>(); ((Behaviour)_camera).enabled = false; _camera.cullingMask = 1073741824; _camera.clearFlags = (CameraClearFlags)2; _camera.backgroundColor = new Color(0.15f, 0.18f, 0.21f, 1f); _camera.fieldOfView = 40f; _camera.nearClipPlane = 0.05f; _camera.farClipPlane = 50f; _texture = new RenderTexture(512, 512, 24, (RenderTextureFormat)0) { name = "Blocky Avatar Preview", filterMode = (FilterMode)1 }; _texture.Create(); _camera.targetTexture = _texture; Reset(faceView: true); } private static void CreateHand(Transform parent, string name, Vector3 position) { //IL_0001: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = position; val.AddComponent<MeshFilter>(); ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = new Material(Shader.Find("Standard") ?? Shader.Find("Diffuse")); } private static void SetLayer(Transform transform, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown ((Component)transform).gameObject.layer = layer; foreach (Transform item in transform) { SetLayer(item, layer); } } public void Reset(bool faceView) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) _yaw = 0f; _pitch = 0f; _focus = _root.transform.position + new Vector3(0f, faceView ? 0.68f : 0f, 0f); _distance = (faceView ? 1.6f : 3.9f); _dirty = true; } public void Apply(string faceId, AvatarColorSet colors, bool flipFace) { _flipFace = flipFace; GameObject root = _root; bool flipFace2 = _flipFace; AvatarAppearance.Apply(root, faceId, colors, null, flipFace2); _dirty = true; } public void Draw(Rect area) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Invalid comparison between Unknown and I4 //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Invalid comparison between Unknown and I4 //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if (((Rect)(ref area)).Contains(current.mousePosition)) { if ((int)current.type == 6) { _distance = Mathf.Clamp(_distance * Mathf.Exp(current.delta.y * 0.09f), 0.5f, 8f); _dirty = true; current.Use(); } else if ((int)current.type == 0 && (current.button == 0 || current.button == 1)) { _dragButton = current.button; current.Use(); } } if ((int)current.type == 3 && _dragButton >= 0) { if (_dragButton == 0) { _yaw += current.delta.x * 0.5f; _pitch = Mathf.Clamp(_pitch - current.delta.y * 0.5f, -80f, 80f); } else { float num = _distance * 0.002f; _focus -= ((Component)_camera).transform.right * (current.delta.x * num); _focus += ((Component)_camera).transform.up * (current.delta.y * num); } _dirty = true; current.Use(); } if ((int)current.type == 1 && current.button == _dragButton) { _dragButton = -1; current.Use(); } if ((int)current.type == 7) { GUI.DrawTexture(area, (Texture)(object)_texture, (ScaleMode)2, false); } } public void Tick() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (_dirty) { _dirty = false; if (!((Object)(object)_camera == (Object)null) && !((Object)(object)_texture == (Object)null)) { Quaternion val = Quaternion.Euler(_pitch, _yaw, 0f); ((Component)_camera).transform.position = _focus + val * (Vector3.forward * _distance); ((Component)_camera).transform.LookAt(_focus, Vector3.up); _camera.Render(); } } } public void Dispose() { if ((Object)(object)_camera != (Object)null) { Object.Destroy((Object)(object)((Component)_camera).gameObject); } foreach (Material flatMaterial in _flatMaterials) { if ((Object)(object)flatMaterial != (Object)null) { Object.Destroy((Object)(object)flatMaterial); } } if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } if ((Object)(object)_texture != (Object)null) { _texture.Release(); Object.Destroy((Object)(object)_texture); } } } [BepInPlugin("StipBit.SimpleMultiplayerBlockyAvatars", "Simple Multiplayer Blocky Avatars", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class BlockyAvatarsPlugin : BaseUnityPlugin { private sealed class RemoteAppearance { internal string FaceId = "default"; internal AvatarColorSet Colors = AvatarColorSet.Default; internal bool Tintable = true; internal bool FlipFace; } [HarmonyPatch(typeof(MPCore), "ChangeRPFactoryId")] private static class KeepBlockyModelPatch { private static bool Prefix() { if ((Object)(object)MonoSingleton<LocalPlayer>.Instance != (Object)null) { MonoSingleton<LocalPlayer>.Instance.FactoryId = "stipbit_blocky"; } return false; } } [HarmonyPatch(typeof(RPManager), "ProcessMemberData")] private static class ApplyMemberAppearancePatch { private static void Postfix(ulong playerId) { Instance?.ApplyRemote(playerId); } } public const string Guid = "StipBit.SimpleMultiplayerBlockyAvatars"; public const string ModelId = "stipbit_blocky"; public const string MemberFace = "stipbit.avatar.face"; public const string MemberColors = "stipbit.avatar.colors"; public const string MemberTint = "stipbit.avatar.tint"; public const string MemberFlip = "stipbit.avatar.flip"; private static ConfigEntry<string> _face; private static ConfigEntry<string> _colors; private static ConfigEntry<bool> _flipFace; private readonly Dictionary<ulong, RemoteAppearance> _remote = new Dictionary<ulong, RemoteAppearance>(); private Harmony _harmony; private AvatarMenu _menu; private FaceTransfer _transfer; public static BlockyAvatarsPlugin Instance { get; private set; } public static string AssetPath { get; private set; } public static string UserDataPath { get; private set; } internal FaceTransfer Transfer => _transfer; public static string FaceId { get { return AvatarFaceLibrary.Normalize(_face.Value); } set { _face.Value = AvatarFaceLibrary.Normalize(value); Instance?.PublishAppearance(); } } public static AvatarColorSet Colors { get { return AvatarColorSet.ParseOrDefault(_colors.Value); } set { _colors.Value = value.Serialize(); Instance?.PublishAppearance(); } } public static bool FlipFace { get { return _flipFace.Value; } set { _flipFace.Value = value; Instance?.PublishAppearance(); } } private void Awake() { //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown Instance = this; AssetPath = Path.GetDirectoryName(((object)this).GetType().Assembly.Location) ?? string.Empty; UserDataPath = Path.Combine(Paths.ConfigPath, "StipBit.SimpleMultiplayerBlockyAvatars"); Directory.CreateDirectory(UserDataPath); (string, string) tuple = ((!File.Exists(Path.Combine(Paths.ConfigPath, "StipBit.SimpleMultiplayerBlockyAvatars.cfg"))) ? ReadLegacySettings() : ("default", AvatarColorSet.Default.Serialize())); _face = ((BaseUnityPlugin)this).Config.Bind<string>("Avatar", "Face", tuple.Item1, "Selected face ID"); _colors = ((BaseUnityPlugin)this).Config.Bind<string>("Avatar", "Colors", tuple.Item2, "Outline, head, torso, hands, face RGB colors"); _flipFace = ((BaseUnityPlugin)this).Config.Bind<bool>("Avatar", "FlipFace", false, "Mirror the selected face horizontally on the 3D avatar"); CustomFaceStore.Initialize(Path.Combine(UserDataPath, "faces")); string path = Path.GetDirectoryName(typeof(RPFactoryManager).Assembly.Location) ?? string.Empty; RPFactoryManager.RegisterModelExtension((ICustomModelExtension)(object)new BlockyModelExtension(), Path.Combine(path, "player_prefab")); MPConfig.RemotePlayerModel = "stipbit_blocky"; _harmony = new Harmony("StipBit.SimpleMultiplayerBlockyAvatars"); _harmony.PatchAll(((object)this).GetType().Assembly); _transfer = new FaceTransfer(this); _transfer.Start(); _menu = ((Component)this).gameObject.AddComponent<AvatarMenu>(); MPEventBusNet.OnLobbyEntered += LobbyEntered; MPEventBusNet.OnPlayerConnected += PlayerConnected; MPEventBusNet.OnPlayerDisconnected += PlayerDisconnected; MPEventBusNet.OnMemberDataChanged += MemberDataChanged; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Simple Multiplayer Blocky Avatars 1.0.1 loaded"); } private void OnDestroy() { MPEventBusNet.OnLobbyEntered -= LobbyEntered; MPEventBusNet.OnPlayerConnected -= PlayerConnected; MPEventBusNet.OnPlayerDisconnected -= PlayerDisconnected; MPEventBusNet.OnMemberDataChanged -= MemberDataChanged; _transfer?.Stop(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void LobbyEntered(Lobby lobby) { PublishAppearance(); } private void PlayerConnected(SteamId id) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _transfer.SendSelectedFaceTo(id); } private void PlayerDisconnected(SteamId id) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) _remote.Remove(SteamId.op_Implicit(id)); _transfer.ForgetPeer(SteamId.op_Implicit(id)); } private void MemberDataChanged(Friend friend, Dictionary<string, string> data) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (SteamId.op_Implicit(friend.Id) != MPSteamworks.UserSteamId) { if (!_remote.TryGetValue(SteamId.op_Implicit(friend.Id), out var value)) { value = new RemoteAppearance(); } if (data.TryGetValue("stipbit.avatar.face", out var value2)) { value.FaceId = AvatarFaceLibrary.NormalizeRemote(value2); } if (data.TryGetValue("stipbit.avatar.colors", out var value3)) { value.Colors = AvatarColorSet.ParseOrDefault(value3); } if (data.TryGetValue("stipbit.avatar.tint", out var value4)) { value.Tintable = value4 == "1"; } if (data.TryGetValue("stipbit.avatar.flip", out var value5)) { value.FlipFace = value5 == "1"; } _remote[SteamId.op_Implicit(friend.Id)] = value; ApplyRemote(SteamId.op_Implicit(friend.Id)); } } internal void ApplyRemote(ulong steamId) { if (_remote.TryGetValue(steamId, out var value)) { GameObject playerObject = Singleton<RPManager>.Instance.GetPlayerObject(steamId); if (!((Object)(object)playerObject == (Object)null)) { AvatarAppearance.Apply(playerObject, value.FaceId, value.Colors, value.Tintable, value.FlipFace); } } } internal void PublishAppearance() { MPConfig.RemotePlayerModel = "stipbit_blocky"; if (MPCore.IsInLobby && !((Object)(object)MonoSingleton<MPSteamworks>.Instance == (Object)null)) { MonoSingleton<MPSteamworks>.Instance.SetMemberData("prefab id", "stipbit_blocky"); MonoSingleton<MPSteamworks>.Instance.SetMemberData("stipbit.avatar.face", FaceId); MonoSingleton<MPSteamworks>.Instance.SetMemberData("stipbit.avatar.colors", Colors.Serialize()); MonoSingleton<MPSteamworks>.Instance.SetMemberData("stipbit.avatar.tint", AvatarFaceLibrary.IsTintable(FaceId) ? "1" : "0"); MonoSingleton<MPSteamworks>.Instance.SetMemberData("stipbit.avatar.flip", FlipFace ? "1" : "0"); _transfer.SendSelectedFaceToAll(); } } internal static void LogError(string message) { BlockyAvatarsPlugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogError((object)message); } } internal static void LogWarning(string message) { BlockyAvatarsPlugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)message); } } internal static void LogInfo(string message) { BlockyAvatarsPlugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } } private static (string, string) ReadLegacySettings() { string text = "default"; string text2 = AvatarColorSet.Default.Serialize(); string path = Path.Combine(Paths.ConfigPath, "shenxl.MultiPlayerMod.cfg"); if (!File.Exists(path)) { return (text, text2); } bool flag = false; string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string text3 = array[i].Trim(); if (text3.StartsWith("[")) { flag = text3 == "[Avatar]"; } else if (flag && !text3.StartsWith("#")) { if (text3.StartsWith("Face = ", StringComparison.Ordinal)) { text = text3.Substring(7).Trim(); } if (text3.StartsWith("Colors = ", StringComparison.Ordinal)) { text2 = text3.Substring(9).Trim(); } } } return (AvatarFaceLibrary.Normalize(text), AvatarColorSet.ParseOrDefault(text2).Serialize()); } } public sealed class BlockyModelExtension : ICustomModelExtension { public sealed class MeshData { public float[] vertices = Array.Empty<float>(); public int[] triangles = Array.Empty<int>(); } private static Dictionary<string, MeshData> _meshData; private static readonly int[] OutlineEdges = new int[24] { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 }; public string ModelId => "stipbit_blocky"; public string PrefabAssetName => "CapsulePlayerPrefab"; public string SpawnEffectAssetName => null; public string DeathEffectAssetName => null; public string DamageEffectAssetName => null; public void OnPrefabLoaded(GameObject prefab, IAssetHelper assetHelper) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) new DefaultModelExtension().OnPrefabLoaded(prefab, assetHelper); } public void OnPlayerInstanceCreated(GameObject instance) { try { if (!LoadAssets()) { return; } Transform val = instance.transform.Find("ModelContainer"); Transform obj = ((val != null) ? val.Find("Capsule") : null); Transform val2 = ((val != null) ? val.Find("Eyes") : null); Transform val3 = ((val != null) ? val.Find("LeftHand") : null); Transform val4 = ((val != null) ? val.Find("RightHand") : null); MeshRenderer val5 = ((obj != null) ? ((Component)obj).GetComponent<MeshRenderer>() : null); if ((Object)(object)val == (Object)null || (Object)(object)val5 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null) { BlockyAvatarsPlugin.LogError("[BlockyAvatar] Capsule prefab hierarchy changed; keeping the original model."); return; } Material sharedMaterial = ((Renderer)val5).sharedMaterial; CreatePart("AvatarTorso", _meshData["torso"], val, sharedMaterial); CreatePart("AvatarHead", _meshData["head"], val, sharedMaterial); CreateOutlinePart("AvatarTorsoOutline", _meshData["torso"], val); CreateOutlinePart("AvatarHeadOutline", _meshData["head"], val); ((Component)val3).GetComponent<MeshFilter>().sharedMesh = CreateMesh("AvatarHandLeft", _meshData["hand"]); ((Component)val4).GetComponent<MeshFilter>().sharedMesh = CreateMesh("AvatarHandRight", _meshData["hand"]); ((Renderer)((Component)val3).GetComponent<MeshRenderer>()).sharedMaterial = CreateColorMaterial(sharedMaterial); ((Renderer)((Component)val4).GetComponent<MeshRenderer>()).sharedMaterial = CreateColorMaterial(sharedMaterial); HandSilhouette.Attach(((Component)val3).gameObject); HandSilhouette.Attach(((Component)val4).gameObject); CreateFace(val); ((Renderer)val5).enabled = false; Renderer val6 = default(Renderer); if ((Object)(object)val2 != (Object)null && ((Component)val2).TryGetComponent<Renderer>(ref val6)) { val6.enabled = false; } } catch (Exception arg) { BlockyAvatarsPlugin.LogError($"[BlockyAvatar] Could not construct avatar: {arg}"); } } private static bool LoadAssets() { if (_meshData != null && (Object)(object)AvatarFaceLibrary.GetTexture("default") != (Object)null) { return true; } string text = Path.Combine(BlockyAvatarsPlugin.AssetPath, "assets"); string path = Path.Combine(text, "avatar_meshes.json"); if (!File.Exists(path) || (Object)(object)AvatarFaceLibrary.GetTexture("default") == (Object)null) { BlockyAvatarsPlugin.LogError("[BlockyAvatar] Missing model asset at " + text + "; using the capsule model."); return false; } _meshData = JsonConvert.DeserializeObject<Dictionary<string, MeshData>>(File.ReadAllText(path)); if (_meshData == null || !_meshData.ContainsKey("head") || !_meshData.ContainsKey("torso") || !_meshData.ContainsKey("hand")) { BlockyAvatarsPlugin.LogError("[BlockyAvatar] Mesh data is incomplete; using the capsule model."); return false; } return true; } private static Mesh CreateMesh(string name, MeshData data) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown if (data.vertices.Length % 3 != 0 || data.triangles.Length % 3 != 0) { throw new InvalidDataException("Invalid mesh: " + name); } Vector3[] array = (Vector3[])(object)new Vector3[data.vertices.Length / 3]; for (int i = 0; i < array.Length; i++) { array[i] = new Vector3(data.vertices[i * 3], data.vertices[i * 3 + 1], data.vertices[i * 3 + 2]); } Mesh val = new Mesh { name = name, vertices = array, triangles = data.triangles }; val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static void CreatePart(string name, MeshData data, Transform parent, Material baseMaterial) { //IL_0001: 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_0013: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.AddComponent<MeshFilter>().sharedMesh = CreateMesh(name, data); ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = CreateColorMaterial(baseMaterial); } private static Material CreateColorMaterial(Material fallback) { //IL_0028: 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) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown Material val = new Material(Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Diffuse") ?? ((fallback != null) ? fallback.shader : null)) { name = "BlockyAvatarColorMaterial", color = Color.white }; val.mainTexture = (Texture)(object)Texture2D.whiteTexture; if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.05f); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } return val; } private static void CreateOutlinePart(string name, MeshData data, Transform parent) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Expected O, but got Unknown //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { BlockyAvatarsPlugin.LogWarning("[BlockyAvatar] Outline shader unavailable; keeping the base avatar."); return; } if (data.vertices.Length != 24) { throw new InvalidDataException("Invalid outline source: " + name); } Vector3[] array = (Vector3[])(object)new Vector3[8]; for (int i = 0; i < array.Length; i++) { array[i] = new Vector3(data.vertices[i * 3], data.vertices[i * 3 + 1], data.vertices[i * 3 + 2]); } List<Vector3> list = new List<Vector3>(96); List<int> list2 = new List<int>(432); for (int j = 0; j < OutlineEdges.Length; j += 2) { Vector3 val2 = array[OutlineEdges[j]]; Vector3 val3 = array[OutlineEdges[j + 1]]; Vector3 val4 = val3 - val2; Vector3 normalized = ((Vector3)(ref val4)).normalized; Vector3 val5 = ((Mathf.Abs(Vector3.Dot(normalized, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up); val4 = Vector3.Cross(normalized, val5); Vector3 val6 = ((Vector3)(ref val4)).normalized * 0.008f; val4 = Vector3.Cross(normalized, val6); Vector3 val7 = ((Vector3)(ref val4)).normalized * 0.008f; val2 -= normalized * 0.008f; val3 += normalized * 0.008f; int count = list.Count; list.AddRange((IEnumerable<Vector3>)(object)new Vector3[8] { val2 - val6 - val7, val2 + val6 - val7, val2 + val6 + val7, val2 - val6 + val7, val3 - val6 - val7, val3 + val6 - val7, val3 + val6 + val7, val3 - val6 + val7 }); AddQuad(list2, count, count + 3, count + 2, count + 1); AddQuad(list2, count + 4, count + 5, count + 6, count + 7); AddQuad(list2, count, count + 1, count + 5, count + 4); AddQuad(list2, count + 1, count + 2, count + 6, count + 5); AddQuad(list2, count + 2, count + 3, count + 7, count + 6); AddQuad(list2, count + 3, count, count + 4, count + 7); } GameObject val8 = new GameObject(name); val8.transform.SetParent(parent, false); Mesh val9 = new Mesh { name = name, vertices = list.ToArray(), triangles = list2.ToArray() }; val9.RecalculateNormals(); val9.RecalculateBounds(); val8.AddComponent<MeshFilter>().sharedMesh = val9; Material sharedMaterial = new Material(val) { name = "BlockyOutlineMaterial", color = new Color(0.02f, 0.02f, 0.02f, 1f) }; MeshRenderer obj = val8.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = sharedMaterial; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; } private static void AddQuad(List<int> triangles, int a, int b, int c, int d) { triangles.AddRange(new int[6] { a, b, c, a, c, d }); } private static void CreateFace(Transform parent) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) Shader obj = Shader.Find("Unlit/Transparent") ?? Shader.Find("Sprites/Default"); if ((Object)(object)obj == (Object)null) { throw new InvalidOperationException("Transparent face shader unavailable"); } Material sharedMaterial = new Material(obj) { name = "BlockyDefaultFaceMaterial", mainTexture = (Texture)(object)AvatarFaceLibrary.GetTexture("default") }; GameObject v