using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using HumanoidAPI.HumanData;
using Microsoft.CodeAnalysis;
using TMPro;
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("HumanoidAPI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HumanoidAPI")]
[assembly: AssemblyTitle("HumanoidAPI")]
[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 HumanoidAPI
{
public static class GameElements
{
public static GameObject FpsCounter;
public static Human[] Humans;
public static List<OnlineHuman> Players = new List<OnlineHuman>();
public static GameObject FreeRoamCamera;
}
public static class HAPI
{
internal static ManualLogSource Logger;
internal static readonly Dictionary<string, string> Plugins = new Dictionary<string, string>();
internal static readonly List<string> LoadedPlugins = new List<string>();
internal static int UsesHapiCount;
public static bool ForceMouseShow { get; private set; }
public static void InitPlugin(string guid, string compatibleVersion)
{
Plugins.Add(guid, compatibleVersion);
Logger.LogInfo((object)("Plugin with GUID " + guid + " added!"));
if (compatibleVersion != "0.2.0")
{
Logger.LogInfo((object)"Plugin Compatible Version does not match HumanoidAPI Version!");
Logger.LogInfo((object)"Please update your Plugin or HumanoidAPI for Proper functionality!");
}
UpdatePluginList();
}
internal static void UpdatePluginList()
{
LoadedPlugins.Clear();
UsesHapiCount = 0;
for (int i = 0; i < Chainloader.PluginInfos.Count; i++)
{
UsesHapiCount++;
string key = Chainloader.PluginInfos.Keys.ToList()[i];
PluginInfo val = Chainloader.PluginInfos[key];
BepInPlugin metadata = val.Metadata;
if (!(metadata.GUID == "de.Lighty.HumanoidAPI"))
{
string text = "<color=#FFFF7F><b>" + metadata.Name + "</b></color>";
Version version = metadata.Version;
text += $"({version} -> {metadata.GUID})";
if (!Plugins.ContainsKey(metadata.GUID))
{
text += "<color=#FFa000> No H-API</color>";
UsesHapiCount--;
}
else if (Plugins[metadata.GUID] != "0.2.0")
{
text = text + "<color=#FF0000>HumanoidAPI Version Incorrect! (" + Plugins[metadata.GUID] + " != 0.2.0)</color>";
}
LoadedPlugins.Add(text);
}
}
}
public static void SetMouseForce(bool value)
{
ForceMouseShow = value;
Cursor.visible = value;
}
}
public static class HumanoidAPIInfo
{
public const string PluginGuid = "de.Lighty.HumanoidAPI";
public const string PluginName = "HumanoidAPI";
public const string PluginVersion = "0.2.0";
}
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;
}
}
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 static class MyPluginInfo
{
public const string PLUGIN_GUID = "HumanoidAPI";
public const string PLUGIN_NAME = "HumanoidAPI";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace HumanoidAPI.Patch
{
[HarmonyPatch(typeof(MenuSystem), "BindCursor")]
internal class PatchMenuSystem
{
private static bool Prefix(MenuSystem __instance, ref bool force)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if (!HAPI.ForceMouseShow)
{
return true;
}
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
Cursor.SetCursor((Texture2D)null, Vector2.zero, (CursorMode)0);
if ((Object)(object)__instance.mouseBlocker != (Object)null)
{
__instance.mouseBlocker.SetActive(false);
}
return false;
}
}
}
namespace HumanoidAPI.Internal
{
internal class HapiPlugin
{
public string Guid;
public string CompatibleVersion;
public HapiPlugin(string guid, string compatibleVersion)
{
Guid = guid;
CompatibleVersion = compatibleVersion;
base..ctor();
}
}
[BepInPlugin("de.Lighty.HumanoidAPI", "HumanoidAPI", "0.2.0")]
internal class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private void Awake()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
HAPI.Logger = Logger;
Logger.LogInfo((object)"Plugin de.Lighty.HumanoidAPI is loaded!");
new Harmony("de.Lighty.HumanoidAPI").PatchAll();
}
private void Start()
{
UIHijack.TutorialLogButton();
}
private void Update()
{
try
{
UIHijack.VersionNumber();
UIHijack.TutorialLog();
Setup.SetupLocalHuman();
Setup.SetupGameElements();
Setup.SetupOnlineHumans();
}
catch (Exception ex)
{
Debug.Log((object)ex);
}
}
}
internal static class Setup
{
internal static void SetupLocalHuman()
{
if (LocalHuman.IsAnyNull())
{
LocalHuman.Data = Human.all[0];
LocalHuman.Camera = GameObject.Find("CameraController");
LocalHuman.Human = ((Component)LocalHuman.Camera.transform.parent).gameObject;
LocalHuman.RigRoot = ((Component)LocalHuman.Human.transform.Find("Ball")).gameObject;
LocalHuman.MovementReference = ((Component)LocalHuman.RigRoot.transform.Find("Sphere")).gameObject;
LocalHuman.Ragdoll = ((Component)LocalHuman.RigRoot.transform.Find("Ragdoll(Clone)")).gameObject;
LocalHuman.Hips = ((Component)LocalHuman.Ragdoll.transform.Find("Hips")).gameObject;
LocalHuman.Waist = ((Component)LocalHuman.Hips.transform.Find("Waist")).gameObject;
LocalHuman.Chest = ((Component)LocalHuman.Waist.transform.Find("Chest")).gameObject;
LocalHuman.Head = ((Component)LocalHuman.Chest.transform.Find("Head")).gameObject;
LocalHuman.LeftArm = new HumanArm(LocalHuman.Chest, "Left");
LocalHuman.RightArm = new HumanArm(LocalHuman.Chest, "Right");
LocalHuman.LeftLeg = new HumanLeg(LocalHuman.Hips, "Left");
LocalHuman.RightLeg = new HumanLeg(LocalHuman.Hips, "Right");
}
}
internal static void SetupOnlineHumans()
{
if (GameElements.Humans.Length == GameElements.Players.Count)
{
foreach (OnlineHuman player in GameElements.Players)
{
if (player.IsAnyNull())
{
GameElements.Players.Clear();
break;
}
}
}
if (GameElements.Humans.Length != GameElements.Players.Count)
{
GameElements.Players.Clear();
Human[] humans = GameElements.Humans;
foreach (Human val in humans)
{
OnlineHuman onlineHuman = new OnlineHuman
{
Data = val,
RigRoot = ((Component)val).gameObject
};
onlineHuman.Human = ((Component)onlineHuman.RigRoot.transform.parent).gameObject;
onlineHuman.Ragdoll = ((Component)onlineHuman.RigRoot.transform.Find("Ragdoll(Clone)")).gameObject;
onlineHuman.Hips = ((Component)onlineHuman.Ragdoll.transform.Find("Hips")).gameObject;
onlineHuman.Waist = ((Component)onlineHuman.Hips.transform.Find("Waist")).gameObject;
onlineHuman.Chest = ((Component)onlineHuman.Waist.transform.Find("Chest")).gameObject;
onlineHuman.Head = ((Component)onlineHuman.Chest.transform.Find("Head")).gameObject;
onlineHuman.LeftArm = new HumanArm(onlineHuman.Chest, "Left");
onlineHuman.RightArm = new HumanArm(onlineHuman.Chest, "Right");
onlineHuman.LeftLeg = new HumanLeg(onlineHuman.Hips, "Left");
onlineHuman.RightLeg = new HumanLeg(onlineHuman.Hips, "Right");
GameElements.Players.Add(onlineHuman);
}
}
}
internal static void SetupGameElements()
{
GameElements.FpsCounter = GameObject.Find("Game(Clone)/FPS");
GameElements.Humans = Human.all.ToArray();
GameElements.FreeRoamCamera = GameObject.Find("FreeRoamCamera");
}
}
internal static class UIHijack
{
internal static string ModListText = "";
internal static void VersionNumber()
{
GameObject val = GameObject.Find("Game(Clone)/Menu/MenuSystem/MainMenuWithMultiplayer(Clone)/VersionNumber");
TMP_Text component = val.GetComponent<TMP_Text>();
if (!component.text.Contains("HumanoidAPI"))
{
component.text = string.Format("<color=green>HumanoidAPI {0}</color>\n({1} plugins loaded. {2} w. HumanoidAPI)\n{3}</color>", "0.2.0", HAPI.LoadedPlugins.Count, HAPI.UsesHapiCount, component.text);
}
}
internal static void TutorialLogButton()
{
GameObject val = GameObject.Find("Game(Clone)/Menu/MenuSystem/ExtrasMenu(Clone)/MenuPanel/Buttons/LogButton/TextMeshPro Text");
GameObject val2 = GameObject.Find("Game(Clone)/Menu/MenuSystem/TutorialLogMenu(Clone)/MenuPanel/Title");
val.GetComponent<TMP_Text>().text = "<color=#444404>Plugins</color>";
val2.GetComponent<TMP_Text>().text = "<color=#444404>Plugins</color>";
HAPI.UpdatePluginList();
foreach (string loadedPlugin in HAPI.LoadedPlugins)
{
ModListText = ModListText + loadedPlugin + "\n";
}
}
internal static void TutorialLog()
{
GameObject val = GameObject.Find("Game(Clone)/Menu/MenuSystem/TutorialLogMenu(Clone)/NormalLayout/TextArea");
val.GetComponent<TMP_Text>().text = ModListText;
}
}
}
namespace HumanoidAPI.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;
}
}
}