using System;
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;
using System.Security.Permissions;
using BepInEx;
using BepInEx.IL2CPP;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using SteamworksNative;
using UnhollowerBaseLib;
using UnhollowerRuntimeLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Antro.MoreCosmetics")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Antro.MoreCosmetics")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Antro.MoreCosmetics")]
[assembly: AssemblyTitle("Antro.MoreCosmetics")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Antro.MoreCosmetics
{
[BepInPlugin("Antro.MoreCosmetics", "More Cosmetics by Antropomeda", "1.0.0.0")]
public class Plugin : BasePlugin
{
public static string SavePath;
public override void Load()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
SavePath = Path.Combine(Paths.ConfigPath, "AntroCosmeticsSave.txt");
ClassInjector.RegisterTypeInIl2Cpp<HatMenuController>();
GameObject val = new GameObject("AntroCosmetics_UI");
Object.DontDestroyOnLoad((Object)(object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<HatMenuController>();
((BasePlugin)this).Log.LogInfo((object)"Antro More Cosmetics: Loaded");
}
}
public class HatTransformSettings
{
public Vector3 Pos;
public Vector3 Rot;
public Vector3 Scale;
public HatTransformSettings(Vector3 p, Vector3 r, Vector3 s)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: 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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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)
Pos = p;
Rot = r;
Scale = s;
}
public HatTransformSettings Clone()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
return new HatTransformSettings(Pos, Rot, Scale);
}
}
public class HatMenuController : MonoBehaviour
{
private bool _isOpen = false;
private Rect _windowRect = new Rect(50f, 50f, 950f, 600f);
private Vector2 _scrollPlayers;
private Vector2 _scrollItems;
private ulong _selectedPlayerId = 0uL;
private string _selectedPlayerName = "None";
private int _selectedItemId = -1;
private string _selectedItemName = "";
private Dictionary<int, string> _displayItems = new Dictionary<int, string>();
private Dictionary<int, GameObject> _cachedPrefabs = new Dictionary<int, GameObject>();
private Dictionary<ulong, Dictionary<int, List<GameObject>>> _activeCosmetics = new Dictionary<ulong, Dictionary<int, List<GameObject>>>();
private Dictionary<ulong, HashSet<int>> _savedCosmetics = new Dictionary<ulong, HashSet<int>>();
private HatTransformSettings _currentEditSettings;
private string[] _posStr = new string[3];
private string[] _rotStr = new string[3];
private string[] _sclStr = new string[3];
private GUIStyle _headerStyle;
private bool _stylesInit = false;
private const int MAX_SLOTS = 4;
private readonly Dictionary<int, HatTransformSettings> _defaultTransforms = new Dictionary<int, HatTransformSettings>
{
{
4,
new HatTransformSettings(new Vector3(-1.1f, -1f, 1f), new Vector3(150f, -180f, -15f), new Vector3(0.3f, 0.3f, 0.3f))
},
{
3,
new HatTransformSettings(new Vector3(0.7f, 1.5f, -1f), new Vector3(-40f, 100f, -5f), new Vector3(1f, 1f, 1f))
},
{
2,
new HatTransformSettings(new Vector3(1.39f, -0.5f, -0.5f), new Vector3(-80f, -180f, 0f), new Vector3(1f, 1f, 1f))
},
{
1,
new HatTransformSettings(new Vector3(1.5f, -0.9f, 0f), new Vector3(-80f, -180f, 0f), new Vector3(0.5f, 0.5f, 0.5f))
},
{
0,
new HatTransformSettings(new Vector3(0.7f, 1.5f, -1f), new Vector3(-40f, 100f, -5f), new Vector3(1.5f, 1.5f, 1.5f))
},
{
2001,
new HatTransformSettings(new Vector3(0f, 0.6f, -1.7f), new Vector3(0f, 90f, -90f), new Vector3(1f, 1f, 1f))
},
{
2002,
new HatTransformSettings(new Vector3(2f, 1.3f, 0f), new Vector3(-11f, 90f, 90f), new Vector3(1f, 1f, 1f))
},
{
2022,
new HatTransformSettings(new Vector3(0f, 2f, -0.09f), new Vector3(-100f, 0f, 0f), new Vector3(260f, 260f, 260f))
},
{
5,
new HatTransformSettings(new Vector3(0f, 0.8f, 0f), new Vector3(0f, 0f, 0f), new Vector3(2.5f, 2.5f, 2.5f))
},
{
9,
new HatTransformSettings(new Vector3(0f, 1.1f, 0f), new Vector3(0f, 0f, 0f), new Vector3(2.8f, 2.8f, 2.8f))
},
{
13,
new HatTransformSettings(new Vector3(-0.1f, 0.15f, 0.8f), new Vector3(90f, 90f, 0f), new Vector3(2f, 2f, 2f))
},
{
10,
new HatTransformSettings(new Vector3(-1f, -0.11f, 0f), new Vector3(0f, 180f, 80f), new Vector3(1f, 1f, 1f))
},
{
11,
new HatTransformSettings(new Vector3(0f, 2f, 0f), new Vector3(0f, 90f, 0f), new Vector3(2.2f, 2.2f, 2.2f))
},
{
12,
new HatTransformSettings(new Vector3(0f, 0.8f, -0.9f), new Vector3(-30f, 0f, 0f), new Vector3(1.7f, 1.7f, 1.7f))
},
{
6,
new HatTransformSettings(new Vector3(-2f, 1f, 0f), new Vector3(90f, 90f, 0f), new Vector3(1f, 1f, 1f))
},
{
7,
new HatTransformSettings(new Vector3(1.3f, 2.2f, 0.5f), new Vector3(118f, -90f, 20f), new Vector3(1f, 1f, 1f))
},
{
8,
new HatTransformSettings(new Vector3(-3.5f, 2.7f, -1.5f), new Vector3(-100f, -112f, 0f), new Vector3(1.3f, 1.3f, 1.3f))
},
{
99,
new HatTransformSettings(new Vector3(0f, 1.2f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f))
}
};
private Dictionary<int, HatTransformSettings> _sessionTransforms = new Dictionary<int, HatTransformSettings>();
private readonly HatTransformSettings _moneyDuplicateSettings = new HatTransformSettings(new Vector3(-2f, 1.3f, 0f), new Vector3(11f, 90f, 90f), new Vector3(1f, 1f, 1f));
private readonly int[] _bodyAttachmentIds = new int[7] { 0, 1, 2, 3, 4, 2001, 2002 };
private readonly Dictionary<int, string> _vanillaNames = new Dictionary<int, string>
{
{ 0, "AK" },
{ 1, "GLOCK" },
{ 2, "REVOLVER" },
{ 3, "DUAL" },
{ 4, "BAT" },
{ 5, "BOMB" },
{ 6, "KATANA" },
{ 7, "KNIFE" },
{ 8, "PIPE" },
{ 9, "SNOWBALL" },
{ 10, "STICK" },
{ 11, "MILK" },
{ 12, "PIZZA" },
{ 13, "GRENADE" }
};
public HatMenuController(IntPtr ptr)
: base(ptr)
{
}//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: 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_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: 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_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: 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_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: 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_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_037f: Unknown result type (might be due to invalid IL or missing references)
//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0413: Unknown result type (might be due to invalid IL or missing references)
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
//IL_0449: Unknown result type (might be due to invalid IL or missing references)
//IL_045d: Unknown result type (might be due to invalid IL or missing references)
//IL_047f: Unknown result type (might be due to invalid IL or missing references)
//IL_0493: Unknown result type (might be due to invalid IL or missing references)
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0511: Unknown result type (might be due to invalid IL or missing references)
//IL_0525: Unknown result type (might be due to invalid IL or missing references)
//IL_0539: Unknown result type (might be due to invalid IL or missing references)
//IL_055a: Unknown result type (might be due to invalid IL or missing references)
//IL_056e: Unknown result type (might be due to invalid IL or missing references)
//IL_0582: Unknown result type (might be due to invalid IL or missing references)
//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0610: Unknown result type (might be due to invalid IL or missing references)
//IL_0624: Unknown result type (might be due to invalid IL or missing references)
private void Start()
{
foreach (KeyValuePair<int, HatTransformSettings> defaultTransform in _defaultTransforms)
{
_sessionTransforms[defaultTransform.Key] = defaultTransform.Value.Clone();
}
LoadSavedHats();
foreach (KeyValuePair<int, string> vanillaName in _vanillaNames)
{
_displayItems[vanillaName.Key] = vanillaName.Value;
}
_displayItems[99] = "CRAB (Mob)";
((MonoBehaviour)this).Invoke("ScanAssets", 2f);
}
private void Update()
{
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown((KeyCode)289))
{
_isOpen = !_isOpen;
if (_isOpen)
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
if (_cachedPrefabs.Count == 0)
{
ScanAssets();
}
}
else if ((Object)(object)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance != (Object)null && MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.Count > 0)
{
Cursor.lockState = (CursorLockMode)1;
Cursor.visible = false;
}
}
if ((Object)(object)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance != (Object)null && MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers != null)
{
Enumerator<ulong, MonoBehaviourPublicCSstReshTrheObplBojuUnique> enumerator = MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.GetEnumerator();
while (enumerator.MoveNext())
{
KeyValuePair<ulong, MonoBehaviourPublicCSstReshTrheObplBojuUnique> current = enumerator.Current;
ulong key = current.Key;
MonoBehaviourPublicCSstReshTrheObplBojuUnique value = current.Value;
if (!_savedCosmetics.ContainsKey(key) || !((Object)(object)value != (Object)null) || value.dead)
{
continue;
}
HashSet<int> hashSet = _savedCosmetics[key];
if (!_activeCosmetics.ContainsKey(key))
{
_activeCosmetics[key] = new Dictionary<int, List<GameObject>>();
}
foreach (int item in hashSet)
{
bool flag = false;
if (!_activeCosmetics[key].ContainsKey(item))
{
flag = true;
}
else if (_activeCosmetics[key][item].Count == 0 || (Object)(object)_activeCosmetics[key][item][0] == (Object)null)
{
flag = true;
}
if (flag)
{
SpawnItem(key, item);
}
}
}
}
if (_selectedPlayerId != 0L && _currentEditSettings != null && _activeCosmetics.ContainsKey(_selectedPlayerId) && _activeCosmetics[_selectedPlayerId].ContainsKey(_selectedItemId))
{
List<GameObject> list = _activeCosmetics[_selectedPlayerId][_selectedItemId];
if (list != null && list.Count > 0 && (Object)(object)list[0] != (Object)null)
{
GameObject val = list[0];
val.transform.localPosition = _currentEditSettings.Pos;
val.transform.localRotation = Quaternion.Euler(_currentEditSettings.Rot);
val.transform.localScale = _currentEditSettings.Scale;
}
}
CleanUpInvalidHats();
}
private void LoadSavedHats()
{
if (!File.Exists(Plugin.SavePath))
{
return;
}
try
{
string[] array = File.ReadAllLines(Plugin.SavePath);
string[] array2 = array;
foreach (string text in array2)
{
string[] array3 = text.Split(new char[1] { ':' });
if (array3.Length == 2 && ulong.TryParse(array3[0], out var result) && int.TryParse(array3[1], out var result2))
{
if (!_savedCosmetics.ContainsKey(result))
{
_savedCosmetics[result] = new HashSet<int>();
}
_savedCosmetics[result].Add(result2);
}
}
}
catch
{
}
}
private void SaveHats()
{
List<string> list = new List<string>();
foreach (KeyValuePair<ulong, HashSet<int>> savedCosmetic in _savedCosmetics)
{
foreach (int item in savedCosmetic.Value)
{
list.Add($"{savedCosmetic.Key}:{item}");
}
}
File.WriteAllLines(Plugin.SavePath, list);
}
private void OnGUI()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0039: 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_004f: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
if (_isOpen)
{
if (!_stylesInit)
{
_headerStyle = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4,
fontStyle = (FontStyle)1,
fontSize = 14
};
_headerStyle.normal.textColor = Color.yellow;
_stylesInit = true;
}
GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.95f);
GUI.contentColor = Color.white;
_windowRect = GUI.Window(8008, _windowRect, WindowFunction.op_Implicit((Action<int>)DrawWindow), "More Cosmetics by Antropomeda \"Version 1.0.0.0\"");
}
}
private void DrawWindow(int id)
{
//IL_0015: 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_007e: 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_023c: 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_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_0381: Unknown result type (might be due to invalid IL or missing references)
//IL_0386: Unknown result type (might be due to invalid IL or missing references)
//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0429: Unknown result type (might be due to invalid IL or missing references)
//IL_0883: Unknown result type (might be due to invalid IL or missing references)
//IL_0888: Unknown result type (might be due to invalid IL or missing references)
//IL_089a: Expected O, but got Unknown
//IL_0469: Unknown result type (might be due to invalid IL or missing references)
//IL_044d: Unknown result type (might be due to invalid IL or missing references)
//IL_0782: Unknown result type (might be due to invalid IL or missing references)
//IL_0752: Unknown result type (might be due to invalid IL or missing references)
//IL_0757: Unknown result type (might be due to invalid IL or missing references)
//IL_076a: Expected O, but got Unknown
//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
//IL_0850: Unknown result type (might be due to invalid IL or missing references)
//IL_0575: Unknown result type (might be due to invalid IL or missing references)
//IL_057a: Unknown result type (might be due to invalid IL or missing references)
//IL_057f: Unknown result type (might be due to invalid IL or missing references)
GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
GUILayout.Label("Players", _headerStyle, Array.Empty<GUILayoutOption>());
_scrollPlayers = GUILayout.BeginScrollView(_scrollPlayers, GUIStyle.op_Implicit("box"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(510f) });
if ((Object)(object)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance != (Object)null && MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers != null)
{
ulong steamID = MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.field_Private_CSteamID_0.m_SteamID;
Enumerator<ulong, MonoBehaviourPublicCSstReshTrheObplBojuUnique> enumerator = MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.GetEnumerator();
while (enumerator.MoveNext())
{
KeyValuePair<ulong, MonoBehaviourPublicCSstReshTrheObplBojuUnique> current = enumerator.Current;
ulong key = current.Key;
if (!((Object)(object)current.Value == (Object)null))
{
string text = "Unk";
try
{
text = SteamFriends.GetFriendPersonaName(new CSteamID(key));
}
catch
{
}
bool flag = key == steamID;
int num = (_savedCosmetics.ContainsKey(key) ? _savedCosmetics[key].Count : 0);
if (key == _selectedPlayerId)
{
GUI.backgroundColor = Color.green;
}
else if (flag)
{
GUI.backgroundColor = Color.gray;
}
else if (num > 0)
{
GUI.backgroundColor = new Color(0.2f, 0.5f, 0.8f);
}
else
{
GUI.backgroundColor = new Color(0.2f, 0.2f, 0.2f);
}
string text2 = (flag ? " (ME)" : ((num > 0) ? $" [{num}]" : ""));
if (GUILayout.Button(text + text2, Array.Empty<GUILayoutOption>()) && !flag)
{
_selectedPlayerId = key;
_selectedPlayerName = text;
}
}
}
}
GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f);
GUILayout.EndScrollView();
if (_selectedPlayerId != 0)
{
GUI.backgroundColor = new Color(0.8f, 0.2f, 0.2f);
if (GUILayout.Button("Clear All Items", Array.Empty<GUILayoutOption>()))
{
RemoveAllHats(_selectedPlayerId);
}
GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f);
}
GUILayout.EndVertical();
GUILayout.Space(5f);
GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(350f) });
int num2 = 0;
if (_selectedPlayerId != 0L && _savedCosmetics.ContainsKey(_selectedPlayerId))
{
num2 = _savedCosmetics[_selectedPlayerId].Count;
}
GUILayout.Label($"Cosmetics - Active: {num2} / {4}", _headerStyle, Array.Empty<GUILayoutOption>());
if (GUILayout.Button("RE-SCAN ASSETS", Array.Empty<GUILayoutOption>()))
{
ScanAssets();
}
_scrollItems = GUILayout.BeginScrollView(_scrollItems, GUIStyle.op_Implicit("box"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(510f) });
List<int> list = _displayItems.Keys.ToList();
list.Sort();
foreach (int item in list)
{
string text3 = _displayItems[item];
bool flag2 = _cachedPrefabs.ContainsKey(item);
bool flag3 = false;
if (_selectedPlayerId != 0L && _savedCosmetics.ContainsKey(_selectedPlayerId) && _savedCosmetics[_selectedPlayerId].Contains(item))
{
flag3 = true;
}
if (flag3)
{
GUI.backgroundColor = Color.green;
}
else if (flag2)
{
GUI.backgroundColor = new Color(0.8f, 0.2f, 0.2f);
}
else
{
GUI.backgroundColor = new Color(0.3f, 0f, 0f);
}
string arg = (flag3 ? "[EQUIPPED]" : (flag2 ? "" : "(Missing)"));
string text4 = $"[{item}] {text3} {arg}";
if (!GUILayout.Button(text4, Array.Empty<GUILayoutOption>()) || !flag2 || _selectedPlayerId == 0)
{
continue;
}
ToggleHat(_selectedPlayerId, item);
if (_savedCosmetics[_selectedPlayerId].Contains(item))
{
_selectedItemId = item;
_selectedItemName = text3;
if (_sessionTransforms.ContainsKey(item))
{
_currentEditSettings = _sessionTransforms[item].Clone();
}
else if (_defaultTransforms.ContainsKey(item))
{
_currentEditSettings = _defaultTransforms[item].Clone();
}
else
{
_currentEditSettings = new HatTransformSettings(Vector3.zero, Vector3.zero, Vector3.one);
}
UpdateEditorBuffers();
}
}
GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f);
GUILayout.EndScrollView();
GUILayout.EndVertical();
GUILayout.Space(5f);
GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
GUILayout.Label("LIVE EDITOR", _headerStyle, Array.Empty<GUILayoutOption>());
if (_selectedPlayerId != 0L && _selectedItemId != -1 && _currentEditSettings != null)
{
if (_savedCosmetics.ContainsKey(_selectedPlayerId) && _savedCosmetics[_selectedPlayerId].Contains(_selectedItemId))
{
string text5 = (_bodyAttachmentIds.Contains(_selectedItemId) ? "BODY" : "HEAD");
GUILayout.Label("Editing: " + _selectedItemName, _headerStyle, Array.Empty<GUILayoutOption>());
GUILayout.Label("Slot: " + text5, _headerStyle, Array.Empty<GUILayoutOption>());
DrawVector3Fields(ref _currentEditSettings.Pos, _posStr, "Pos");
DrawVector3Fields(ref _currentEditSettings.Rot, _rotStr, "Rot");
DrawVector3Fields(ref _currentEditSettings.Scale, _sclStr, "Scl");
if (_selectedItemId == 2002)
{
GUILayout.Label("Note: Duplicate Money (Left) is static.", new GUIStyle(GUI.skin.label)
{
fontSize = 10
}, Array.Empty<GUILayoutOption>());
}
GUILayout.Space(10f);
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUI.backgroundColor = Color.cyan;
if (GUILayout.Button("SAVE CHANGES", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
{
_sessionTransforms[_selectedItemId] = _currentEditSettings.Clone();
}
GUI.backgroundColor = Color.yellow;
if (GUILayout.Button("RESET TO DEFAULT", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }) && _defaultTransforms.ContainsKey(_selectedItemId))
{
_currentEditSettings = _defaultTransforms[_selectedItemId].Clone();
UpdateEditorBuffers();
}
GUILayout.EndHorizontal();
GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f);
}
else
{
GUILayout.Label("Item not equipped on player.", Array.Empty<GUILayoutOption>());
}
}
else
{
GUILayout.Label("Select an equipped item to edit", new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4
}, Array.Empty<GUILayoutOption>());
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
private string F(float f)
{
return f.ToString("F2").Replace(',', '.') + "f";
}
private void DrawVector3Fields(ref Vector3 vec, string[] buffers, string label)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) });
buffers[0] = GUILayout.TextField(buffers[0], Array.Empty<GUILayoutOption>());
buffers[1] = GUILayout.TextField(buffers[1], Array.Empty<GUILayoutOption>());
buffers[2] = GUILayout.TextField(buffers[2], Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
float.TryParse(buffers[0].Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture, out vec.x);
float.TryParse(buffers[1].Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture, out vec.y);
float.TryParse(buffers[2].Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture, out vec.z);
}
private void ScanAssets()
{
_cachedPrefabs.Clear();
Type type = Type.GetType("UnityEngine.GameObject, UnityEngine.CoreModule");
if (type == (Type)null)
{
type = Type.GetType("UnityEngine.GameObject");
}
Il2CppReferenceArray<Object> val = Resources.FindObjectsOfTypeAll(type);
if (val == null)
{
return;
}
int num = 0;
foreach (Object item in (Il2CppArrayBase<Object>)(object)val)
{
GameObject val2 = ((Il2CppObjectBase)item).TryCast<GameObject>();
if ((Object)(object)val2 == (Object)null)
{
continue;
}
string text = ((Object)val2).name.ToLower();
if (text.Contains("ui") || text.Contains("text") || text.Contains("skin") || text.Contains("chunk") || text.Contains("particle") || text.Contains("shatter") || text.Contains("fragment"))
{
continue;
}
foreach (KeyValuePair<int, string> vanillaName in _vanillaNames)
{
if (vanillaName.Key != 3 && IsVanillaMatch(vanillaName.Key, text) && ((Object)(object)val2.GetComponentInChildren<MeshRenderer>() != (Object)null || (Object)(object)val2.GetComponentInChildren<SkinnedMeshRenderer>() != (Object)null) && !_cachedPrefabs.ContainsKey(vanillaName.Key))
{
_cachedPrefabs[vanillaName.Key] = val2;
}
}
if ((text == "crab" || text == "enemy_crab") && !_cachedPrefabs.ContainsKey(99))
{
_cachedPrefabs[99] = val2;
}
if (text.Contains("barrel") && !text.Contains("lid") && !_cachedPrefabs.ContainsKey(3))
{
_cachedPrefabs[3] = val2;
}
if (!((Object)(object)val2.GetComponentInChildren<MeshRenderer>() != (Object)null) && !((Object)(object)val2.GetComponentInChildren<SkinnedMeshRenderer>() != (Object)null))
{
continue;
}
if (text.Contains("crabbox1") && !_cachedPrefabs.ContainsKey(2001))
{
_displayItems[2001] = "CrabBox1";
_cachedPrefabs[2001] = val2;
}
else if ((text == "money" || text.Contains("moneybundle")) && !_cachedPrefabs.ContainsKey(2002))
{
_displayItems[2002] = "Money (Dual)";
_cachedPrefabs[2002] = val2;
}
else if (text.Contains("crown") && text.Contains("2"))
{
if (num == 2 && !_cachedPrefabs.ContainsKey(2022))
{
_displayItems[2022] = "Crown 2 (2)";
_cachedPrefabs[2022] = val2;
}
num++;
}
if (!text.StartsWith("item_") && !text.StartsWith("weapon_"))
{
continue;
}
bool flag = false;
foreach (KeyValuePair<int, string> vanillaName2 in _vanillaNames)
{
if (IsVanillaMatch(vanillaName2.Key, text))
{
flag = true;
}
}
if (text.Contains("stick") || text.Contains("bomb") || text.Contains("crab"))
{
flag = true;
}
if (!flag)
{
string text2 = ((Object)val2).name.Replace("Item_", "").Replace("Weapon_", "").Replace("(Clone)", "")
.Trim();
int key = Math.Abs(text2.GetHashCode()) % 800 + 14;
if (!_displayItems.ContainsKey(key))
{
_displayItems.Add(key, text2);
_cachedPrefabs.Add(key, val2);
}
}
}
}
private bool IsVanillaMatch(int id, string goName)
{
return id switch
{
0 => goName == "item_rifle" || goName.Contains("ak47") || goName == "rifle",
1 => goName.Contains("pistol") && !goName.Contains("dual"),
2 => goName.Contains("revolver"),
4 => goName.Contains("bat") && !goName.Contains("battery"),
5 => goName == "bomb" || goName.Contains("item_bomb") || goName.Contains("weapon_bomb"),
6 => goName.Contains("katana"),
7 => goName.Contains("knife"),
8 => goName.Contains("pipe"),
9 => goName.Contains("snowball"),
10 => goName == "stick" || goName.Contains("item_stick"),
11 => goName.Contains("milk"),
12 => goName.Contains("pizza"),
13 => goName.Contains("grenade"),
_ => false,
};
}
private void ToggleHat(ulong playerId, int itemId)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (playerId == MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.field_Private_CSteamID_0.m_SteamID)
{
return;
}
if (!_savedCosmetics.ContainsKey(playerId))
{
_savedCosmetics[playerId] = new HashSet<int>();
}
if (_savedCosmetics[playerId].Contains(itemId))
{
_savedCosmetics[playerId].Remove(itemId);
if (_activeCosmetics.ContainsKey(playerId) && _activeCosmetics[playerId].ContainsKey(itemId))
{
List<GameObject> list = _activeCosmetics[playerId][itemId];
if (list != null)
{
foreach (GameObject item in list)
{
if ((Object)(object)item != (Object)null)
{
Object.Destroy((Object)(object)item);
}
}
}
_activeCosmetics[playerId].Remove(itemId);
}
SaveHats();
}
else if (_savedCosmetics[playerId].Count < 4)
{
_savedCosmetics[playerId].Add(itemId);
SpawnItem(playerId, itemId);
SaveHats();
}
}
private void SpawnItem(ulong playerId, int itemId)
{
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
if (!_activeCosmetics.ContainsKey(playerId))
{
_activeCosmetics[playerId] = new Dictionary<int, List<GameObject>>();
}
if (_activeCosmetics[playerId].ContainsKey(itemId))
{
foreach (GameObject item in _activeCosmetics[playerId][itemId])
{
if ((Object)(object)item != (Object)null)
{
Object.Destroy((Object)(object)item);
}
}
_activeCosmetics[playerId].Remove(itemId);
}
if (!_cachedPrefabs.ContainsKey(itemId) || (Object)(object)_cachedPrefabs[itemId] == (Object)null)
{
ScanAssets();
if (!_cachedPrefabs.ContainsKey(itemId) || (Object)(object)_cachedPrefabs[itemId] == (Object)null)
{
return;
}
}
if ((Object)(object)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance == (Object)null || !MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.ContainsKey(playerId))
{
return;
}
MonoBehaviourPublicCSstReshTrheObplBojuUnique val = MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers[playerId];
if ((Object)(object)val == (Object)null || val.dead)
{
return;
}
Transform val2 = null;
val2 = ((!_bodyAttachmentIds.Contains(itemId)) ? FindHead(((Component)val).transform) : FindSpine(((Component)val).transform));
if (!((Object)(object)val2 == (Object)null))
{
List<GameObject> list = new List<GameObject>();
GameObject val3 = _cachedPrefabs[itemId];
GameObject val4 = Object.Instantiate<GameObject>(val3);
CleanupHatObject(val4);
val4.transform.SetParent(val2);
HatTransformSettings hatTransformSettings = (_sessionTransforms.ContainsKey(itemId) ? _sessionTransforms[itemId].Clone() : ((!_defaultTransforms.ContainsKey(itemId)) ? new HatTransformSettings(new Vector3(0f, 1f, 0f), Vector3.zero, Vector3.one) : _defaultTransforms[itemId].Clone()));
val4.transform.localPosition = hatTransformSettings.Pos;
val4.transform.localRotation = Quaternion.Euler(hatTransformSettings.Rot);
val4.transform.localScale = hatTransformSettings.Scale;
list.Add(val4);
if (itemId == 2002)
{
GameObject val5 = Object.Instantiate<GameObject>(val3);
CleanupHatObject(val5);
val5.transform.SetParent(val2);
val5.transform.localPosition = _moneyDuplicateSettings.Pos;
val5.transform.localRotation = Quaternion.Euler(_moneyDuplicateSettings.Rot);
val5.transform.localScale = _moneyDuplicateSettings.Scale;
list.Add(val5);
}
_activeCosmetics[playerId][itemId] = list;
}
}
private void UpdateEditorBuffers()
{
_posStr[0] = _currentEditSettings.Pos.x.ToString("F2");
_posStr[1] = _currentEditSettings.Pos.y.ToString("F2");
_posStr[2] = _currentEditSettings.Pos.z.ToString("F2");
_rotStr[0] = _currentEditSettings.Rot.x.ToString("F2");
_rotStr[1] = _currentEditSettings.Rot.y.ToString("F2");
_rotStr[2] = _currentEditSettings.Rot.z.ToString("F2");
_sclStr[0] = _currentEditSettings.Scale.x.ToString("F2");
_sclStr[1] = _currentEditSettings.Scale.y.ToString("F2");
_sclStr[2] = _currentEditSettings.Scale.z.ToString("F2");
}
private void RemoveAllHats(ulong playerId)
{
if (_savedCosmetics.ContainsKey(playerId))
{
_savedCosmetics[playerId].Clear();
SaveHats();
}
if (!_activeCosmetics.ContainsKey(playerId))
{
return;
}
foreach (List<GameObject> value in _activeCosmetics[playerId].Values)
{
if (value == null)
{
continue;
}
foreach (GameObject item in value)
{
if ((Object)(object)item != (Object)null)
{
Object.Destroy((Object)(object)item);
}
}
}
_activeCosmetics[playerId].Clear();
}
private void CleanUpInvalidHats()
{
List<ulong> list = new List<ulong>();
foreach (ulong key in _activeCosmetics.Keys)
{
if (!((Object)(object)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance == (Object)null) && MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.ContainsKey(key))
{
continue;
}
Dictionary<int, List<GameObject>> dictionary = _activeCosmetics[key];
foreach (List<GameObject> value in dictionary.Values)
{
if (value == null)
{
continue;
}
foreach (GameObject item in value)
{
if ((Object)(object)item != (Object)null)
{
Object.Destroy((Object)(object)item);
}
}
}
list.Add(key);
}
foreach (ulong item2 in list)
{
_activeCosmetics.Remove(item2);
}
}
private void CleanupHatObject(GameObject obj)
{
Rigidbody component = obj.GetComponent<Rigidbody>();
if (Object.op_Implicit((Object)(object)component))
{
Object.Destroy((Object)(object)component);
}
Il2CppArrayBase<Collider> componentsInChildren = obj.GetComponentsInChildren<Collider>();
foreach (Collider item in componentsInChildren)
{
Object.Destroy((Object)(object)item);
}
Il2CppArrayBase<MonoBehaviour> componentsInChildren2 = obj.GetComponentsInChildren<MonoBehaviour>();
foreach (MonoBehaviour item2 in componentsInChildren2)
{
Object.Destroy((Object)(object)item2);
}
obj.SetActive(true);
}
private Transform FindHead(Transform current)
{
if (((Object)current).name.ToLower().Contains("head") || ((Object)current).name == "Spine.002")
{
return current;
}
for (int i = 0; i < current.childCount; i++)
{
Transform val = FindHead(current.GetChild(i));
if ((Object)(object)val != (Object)null)
{
return val;
}
}
return null;
}
private Transform FindSpine(Transform current)
{
if (((Object)current).name == "Spine.001" || ((Object)current).name == "Spine")
{
return current;
}
for (int i = 0; i < current.childCount; i++)
{
Transform val = FindSpine(current.GetChild(i));
if ((Object)(object)val != (Object)null)
{
return val;
}
}
return null;
}
}
}