using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using HumanToolkit.HumanData;
using Multiplayer;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HumanToolkit")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HumanToolkit")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("E90388E4-662D-4548-AC9E-B327DE735857")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HumanToolkit
{
public static class GameCommands
{
public static void RegisterChatCommand(string commandName, Action commandCallback, string helpMessage, bool canServerExecute = true, bool canClientExecute = true)
{
NetChat.RegisterCommand(canServerExecute, canClientExecute, commandName, commandCallback, "/" + commandName + " - " + helpMessage);
}
public static void RegisterChatCommand(string commandName, string argumentName, Action<string> commandCallback, string helpMessage, bool canServerExecute = true, bool canClientExecute = true)
{
NetChat.RegisterCommand(canServerExecute, canClientExecute, commandName, commandCallback, "/" + commandName + " <" + argumentName + "> - " + helpMessage);
}
public static void ShowChatMessage(string chatMessage)
{
NetChat.Print(chatMessage);
}
public static void ShowPluginChatMessage(string pluginGuid, string chatMessage)
{
PluginInfo? obj = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo p) => p.Metadata.GUID == pluginGuid));
string text = ((obj != null) ? obj.Metadata.Name : null);
if (text != null)
{
NetChat.Print("[" + text + "] " + chatMessage);
}
}
}
public static class GameElements
{
public static GameObject FpsCounter { get; internal set; }
public static Human[] Humans { get; internal set; }
public static List<OnlineHuman> Players { get; internal set; } = new List<OnlineHuman>();
public static GameObject FreeRoamCamera { get; internal set; }
internal static void TryGetAll()
{
if (!Object.op_Implicit((Object)(object)FpsCounter))
{
FpsCounter = GameObject.Find("Game(Clone)/FPS");
}
Humans = Human.all.ToArray();
if (!Object.op_Implicit((Object)(object)FreeRoamCamera))
{
FreeRoamCamera = GameObject.Find("FreeRoamCamera");
}
if (Humans.Length == Players.Count && Players.Any((OnlineHuman human) => human.IsAnyNull()))
{
Players.Clear();
}
if (Humans.Length != Players.Count)
{
Players.Clear();
Human[] humans = Humans;
foreach (Human dataObject in humans)
{
Players.Add(new OnlineHuman(dataObject));
}
}
}
}
public static class LocalHuman
{
public static Human Data;
public static GameObject Human;
public static GameObject Camera;
public static GameObject RigRoot;
public static GameObject MovementReference;
public static GameObject Ragdoll;
public static GameObject Hips;
public static GameObject Waist;
public static GameObject Chest;
public static GameObject Head;
public static HumanArm LeftArm;
public static HumanArm RightArm;
public static HumanLeg LeftLeg;
public static HumanLeg RightLeg;
public static bool IsAnyNull()
{
if ((Object)(object)Data == (Object)null)
{
return true;
}
if ((Object)(object)Human == (Object)null)
{
return true;
}
if ((Object)(object)Camera == (Object)null)
{
return true;
}
if ((Object)(object)RigRoot == (Object)null)
{
return true;
}
if ((Object)(object)MovementReference == (Object)null)
{
return true;
}
if ((Object)(object)Ragdoll == (Object)null)
{
return true;
}
if ((Object)(object)Hips == (Object)null)
{
return true;
}
if ((Object)(object)Waist == (Object)null)
{
return true;
}
if ((Object)(object)Chest == (Object)null)
{
return true;
}
if ((Object)(object)Head == (Object)null)
{
return true;
}
if (LeftArm == null)
{
return true;
}
if (LeftLeg == null)
{
return true;
}
if (RightArm == null)
{
return true;
}
if (RightLeg == null)
{
return true;
}
return false;
}
internal static void Setup(Human humanData)
{
if (IsAnyNull())
{
Data = humanData;
Camera = GameObject.Find("CameraController");
Human = ((Component)Camera.transform.parent).gameObject;
RigRoot = ((Component)Human.transform.Find("Ball")).gameObject;
MovementReference = ((Component)RigRoot.transform.Find("Sphere")).gameObject;
Ragdoll = ((Component)RigRoot.transform.Find("Ragdoll(Clone)")).gameObject;
Hips = ((Component)Ragdoll.transform.Find("Hips")).gameObject;
Waist = ((Component)Hips.transform.Find("Waist")).gameObject;
Chest = ((Component)Waist.transform.Find("Chest")).gameObject;
Head = ((Component)Chest.transform.Find("Head")).gameObject;
LeftArm = new HumanArm(Chest, "Left");
RightArm = new HumanArm(Chest, "Right");
LeftLeg = new HumanLeg(Hips, "Left");
RightLeg = new HumanLeg(Hips, "Right");
}
}
}
public class OnlineHuman
{
public Human Data;
public GameObject Human;
public GameObject RigRoot;
public GameObject Ragdoll;
public GameObject Hips;
public GameObject Waist;
public GameObject Chest;
public GameObject Head;
public HumanArm LeftArm;
public HumanArm RightArm;
public HumanLeg LeftLeg;
public HumanLeg RightLeg;
public bool IsAnyNull()
{
if ((Object)(object)Data == (Object)null)
{
return true;
}
if ((Object)(object)Human == (Object)null)
{
return true;
}
if ((Object)(object)RigRoot == (Object)null)
{
return true;
}
if ((Object)(object)Ragdoll == (Object)null)
{
return true;
}
if ((Object)(object)Hips == (Object)null)
{
return true;
}
if ((Object)(object)Waist == (Object)null)
{
return true;
}
if ((Object)(object)Chest == (Object)null)
{
return true;
}
if ((Object)(object)Head == (Object)null)
{
return true;
}
if (LeftArm == null)
{
return true;
}
if (LeftLeg == null)
{
return true;
}
if (RightArm == null)
{
return true;
}
if (RightLeg == null)
{
return true;
}
return false;
}
public OnlineHuman(Human dataObject)
{
Data = dataObject;
RigRoot = ((Component)Data).gameObject;
Human = ((Component)RigRoot.transform.parent).gameObject;
Ragdoll = ((Component)RigRoot.transform.Find("Ragdoll(Clone)")).gameObject;
Hips = ((Component)Ragdoll.transform.Find("Hips")).gameObject;
Waist = ((Component)Hips.transform.Find("Waist")).gameObject;
Chest = ((Component)Waist.transform.Find("Chest")).gameObject;
Head = ((Component)Chest.transform.Find("Head")).gameObject;
LeftArm = new HumanArm(Chest, "Left");
RightArm = new HumanArm(Chest, "Right");
LeftLeg = new HumanLeg(Hips, "Left");
RightLeg = new HumanLeg(Hips, "Right");
}
}
public static class MenuButtonTools
{
private static TMP_FontAsset _font;
private static Material _fontMaterial;
static MenuButtonTools()
{
_font = (from font in Resources.FindObjectsOfTypeAll<TMP_FontAsset>()
where ((Object)font).name == "Menu SDF"
select font).First();
_fontMaterial = (from material in Resources.FindObjectsOfTypeAll<Material>()
where ((Object)material).name == "Menu SDF Material"
select material).First();
}
public static void AddButton(string menu, string name, string text, int order, UnityAction callback)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: 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_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: 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_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: 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_0202: 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_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)GameObject.Find("/Game(Clone)/Menu/MenuSystem/" + menu + "(Clone)").GetComponentInChildren<VerticalLayoutGroup>(true)).gameObject;
GameObject val = new GameObject(name, new Type[5]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(Image),
typeof(Button),
typeof(LayoutElement)
});
val.layer = LayerMask.NameToLayer("UI");
val.transform.SetParent(gameObject.transform);
val.transform.localScale = Vector3.one;
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
val.GetComponent<LayoutElement>().preferredHeight = 70f;
val.transform.SetSiblingIndex(order);
Button component = val.GetComponent<Button>();
ColorBlock colors = default(ColorBlock);
((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0.2549f);
((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 1f, 1f, 1f);
((ColorBlock)(ref colors)).pressedColor = new Color(0.7843f, 0.7843f, 0.7843f, 1f);
((ColorBlock)(ref colors)).disabledColor = new Color(0.7843f, 0.7843f, 0.7843f, 0.502f);
((ColorBlock)(ref colors)).colorMultiplier = 1f;
((ColorBlock)(ref colors)).fadeDuration = 0.1f;
((Selectable)component).colors = colors;
((UnityEvent)val.GetComponent<Button>().onClick).AddListener(callback);
GameObject val2 = new GameObject("TextMeshPro Text", new Type[3]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(TextMeshProUGUI)
});
val2.transform.SetParent(val.transform);
val2.transform.localRotation = Quaternion.identity;
val2.transform.localScale = Vector3.one;
val2.layer = LayerMask.NameToLayer("UI");
TextMeshProUGUI component2 = val2.GetComponent<TextMeshProUGUI>();
((Graphic)component2).color = Color.black;
((TMP_Text)component2).fontSize = 40f;
((TMP_Text)component2).fontSizeMax = 40f;
((TMP_Text)component2).font = _font;
((TMP_Text)component2).fontMaterial = _fontMaterial;
((TMP_Text)component2).enableWordWrapping = false;
((TMP_Text)component2).enableAutoSizing = true;
((TMP_Text)component2).enableKerning = false;
((TMP_Text)component2).alignment = (TextAlignmentOptions)513;
((TMP_Text)component2).text = text;
RectTransform component3 = val2.GetComponent<RectTransform>();
component3.anchorMin = Vector2.zero;
component3.anchorMax = Vector2.one;
component3.anchoredPosition3D = Vector3.zero;
component3.offsetMax = new Vector2(-20f, 0f);
component3.offsetMin = new Vector2(20f, 0f);
}
public static void DestroyButton(string menu, string name)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
foreach (Transform item in ((Component)GameObject.Find("/Game(Clone)/Menu/MenuSystem/" + menu + "(Clone)").GetComponentInChildren<VerticalLayoutGroup>(true)).gameObject.transform)
{
Transform val = item;
if (((Object)val).name == name)
{
Object.Destroy((Object)(object)((Component)val).gameObject);
break;
}
}
}
public static void EnableDisableButton(string menu, string name, bool enable)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
foreach (Transform item in ((Component)GameObject.Find("/Game(Clone)/Menu/MenuSystem/" + menu + "(Clone)").GetComponentInChildren<VerticalLayoutGroup>(true)).gameObject.transform)
{
Transform val = item;
if (((Object)val).name == name)
{
((Component)val).gameObject.SetActive(enable);
break;
}
}
}
}
public static class ModInfo
{
public const string Name = "HumanToolkit";
public const string Guid = "de.lighty.humantoolkit";
public const string Version = "1.1.1";
}
public static class MouseLock
{
private static readonly HashSet<string> _locks = new HashSet<string>();
public static void AddLock(string guid)
{
_locks.Add(guid);
UpdateGlobalMouseLock();
}
public static void RemoveLock(string guid)
{
_locks.Remove(guid);
UpdateGlobalMouseLock();
}
private static void UpdateGlobalMouseLock()
{
PluginMain.DoForceMouse = _locks.Count > 0;
}
}
[BepInPlugin("de.lighty.humantoolkit", "HumanToolkit", "1.1.1")]
internal class PluginMain : BaseUnityPlugin
{
internal static bool DoForceMouse;
private string _pluginList = "";
private GameObject _pluginListObject;
internal static int PluginsUseHtCount;
private void Start()
{
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
bool flag = false;
foreach (BepInDependency dependency in pluginInfo.Value.Dependencies)
{
if (dependency.DependencyGUID == "de.lighty.humantoolkit")
{
flag = true;
}
}
if (flag)
{
_pluginList += "<color=yellow>(HT)</color> ";
PluginsUseHtCount++;
}
_pluginList = _pluginList + pluginInfo.Value.Metadata.Name + " " + pluginInfo.Value.Metadata.Version?.ToString() + "\n";
}
if (Object.op_Implicit((Object)(object)_pluginListObject))
{
TMP_Text component = ((Component)_pluginListObject.transform.GetChild(0)).GetComponent<TMP_Text>();
if (Object.op_Implicit((Object)(object)component))
{
component.text = _pluginList;
}
}
}
private void Awake()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogInfo((object)"HumanToolkit v.1.1.1 is loading...");
new Harmony("de.lighty.humantoolkit").PatchAll();
SceneManager.sceneLoaded += OnSceneLoaded;
((BaseUnityPlugin)this).Logger.LogInfo((object)"HumanToolkit v.1.1.1 has loaded!");
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
if (!(((Scene)(ref scene)).path == "Assets/Scenes/Startup.unity"))
{
return;
}
MenuButtonTools.AddButton("ExtrasMenu", "HumanToolkitPlugins", "PLUGINS", 1, (UnityAction)delegate
{
if (Object.op_Implicit((Object)(object)_pluginListObject))
{
_pluginListObject.SetActive(!_pluginListObject.activeSelf);
}
});
GameObject val = Object.Instantiate<GameObject>(GameObject.Find("Game(Clone)/Menu/MenuSystem/TutorialLogMenu(Clone)/NormalLayout/"), GameObject.Find("Game(Clone)/Menu/MenuSystem/ExtrasMenu(Clone)").transform, false);
val.GetComponent<RectTransform>().anchoredPosition = new Vector2(86.7348f, 0f);
TMP_Text component = ((Component)val.transform.GetChild(0)).GetComponent<TMP_Text>();
if (Object.op_Implicit((Object)(object)component))
{
component.text = _pluginList;
}
_pluginListObject = val;
_pluginListObject.SetActive(false);
}
private void Update()
{
try
{
UiHijack.VersionNumber();
GameElements.TryGetAll();
LocalHuman.Setup(Human.all[0]);
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
}
}
internal class UiHijack
{
private static TMP_Text version;
internal static void VersionNumber()
{
if ((Object)(object)version == (Object)null)
{
version = GameObject.Find("Game(Clone)/Menu/MenuSystem/MainMenuWithMultiplayer(Clone)/VersionNumber").GetComponent<TMP_Text>();
}
if (!version.text.Contains("HumanToolkit"))
{
version.text = string.Format("<color=green>HumanToolkit {0}</color>\n({1} plugins loaded. {2} w. HumanToolkit)\n{3}</color>", "1.1.1", Chainloader.PluginInfos.Count, PluginMain.PluginsUseHtCount, version.text);
}
}
}
}
namespace HumanToolkit.Patches
{
internal static class PatchMenuSystem
{
[HarmonyPatch(typeof(MenuSystem), "BindCursor")]
private static class BindCursor
{
private static bool Prefix(MenuSystem __instance, ref bool force)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if (!PluginMain.DoForceMouse)
{
return true;
}
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
Cursor.SetCursor((Texture2D)null, Vector2.zero, (CursorMode)0);
if (Object.op_Implicit((Object)(object)__instance.mouseBlocker))
{
__instance.mouseBlocker.SetActive(false);
}
return false;
}
}
}
}
namespace HumanToolkit.HumanData
{
public class HumanArm
{
public GameObject Arm;
public GameObject Forearm;
public GameObject Hand;
public HumanArm(GameObject chest, string armSide)
{
Arm = ((Component)chest.transform.Find(armSide + "Arm")).gameObject;
Forearm = ((Component)Arm.transform.Find(armSide + "Forearm")).gameObject;
Hand = ((Component)Forearm.transform.Find(armSide + "Hand")).gameObject;
}
}
public class HumanLeg
{
public GameObject Thigh;
public GameObject Leg;
public GameObject LegEnd;
public GameObject Foot;
public HumanLeg(GameObject hips, string legSide)
{
Thigh = ((Component)hips.transform.Find(legSide + "Thigh")).gameObject;
Leg = ((Component)Thigh.transform.Find(legSide + "Leg")).gameObject;
Foot = ((Component)Leg.transform.Find(legSide + "Foot")).gameObject;
LegEnd = ((Component)Leg.transform.Find(legSide + "Leg_end")).gameObject;
}
}
}