Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Clodhopper v1.1.1
Clodhopper.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Clodhopper")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Custom shoes for Lethal Company")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+642a7d333fbcfc06a1ed45439d7f8a59881ebbd1")] [assembly: AssemblyProduct("Clodhopper")] [assembly: AssemblyTitle("Clodhopper")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.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 Clodhopper { internal static class Patcher { public static void Init() { //IL_0005: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_00a2: 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_00b4: Expected O, but got Unknown //IL_00e5: 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_00f8: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown Harmony val = new Harmony("ShoePatcher"); MethodInfo methodInfo = AccessTools.Method(typeof(PlayerControllerB), "ConnectClientToPlayerObject", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Patcher), "AttachAllShoes", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(StartOfRound), "OnPlayerConnectedClientRpc", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo4 = AccessTools.Method(typeof(Patcher), "SendCustomChatClientRPC", (Type[])null, (Type[])null); MethodInfo methodInfo5 = AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo5, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo6 = AccessTools.Method(typeof(Patcher), "RequestShoesOnJoinServer", (Type[])null, (Type[])null); MethodInfo methodInfo7 = AccessTools.Method(typeof(PlayerControllerB), "SpawnPlayerAnimation", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo7, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo8 = AccessTools.Method(typeof(Patcher), "LoadPlugin", (Type[])null, (Type[])null); MethodInfo methodInfo9 = AccessTools.Method(typeof(PreInitSceneScript), "Awake", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo9, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void AddShoes(Transform parentObj) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown ShoeSpawner shoeSpawner = ((Component)parentObj).gameObject.AddComponent<ShoeSpawner>(); shoeSpawner.shoesLeft = new List<GameObject>(); shoeSpawner.shoesRight = new List<GameObject>(); foreach (AssetBundle shoe in ShoeManager.Instance.shoes) { GameObject val = Object.Instantiate<GameObject>((GameObject)shoe.LoadAsset("ShoeObjectR"), ((Component)parentObj).transform.Find("thigh.R/shin.R/foot.R/heel.02.R")); GameObject val2 = Object.Instantiate<GameObject>((GameObject)shoe.LoadAsset("ShoeObject"), ((Component)parentObj).transform.Find("thigh.L/shin.L/foot.L/heel.02.L")); shoeSpawner.shoesRight.Add(val); shoeSpawner.shoesLeft.Add(val2); val.tag = "Untagged"; val.layer = 0; val2.tag = "Untagged"; val2.layer = 0; ((Collider)val.GetComponent<BoxCollider>()).enabled = false; ((Collider)val2.GetComponent<BoxCollider>()).enabled = false; val.SetActive(false); val2.SetActive(false); } } public static void AttachAllShoes() { foreach (PlayerControllerB otherClient in StartOfRound.Instance.OtherClients) { if (((Component)otherClient).transform.Find("ScavengerModel/metarig/spine/thigh.L/shin.L/foot.L/heel.02.L").childCount == 1) { AddShoes(((Component)otherClient).transform.Find("ScavengerModel/metarig/spine")); } } if (((Component)StartOfRound.Instance.localPlayerController).transform.Find("ScavengerModel/metarig/spine/thigh.L/shin.L/foot.L/heel.02.L").childCount == 1) { AddShoes(((Component)StartOfRound.Instance.localPlayerController).transform.Find("ScavengerModel/metarig/spine")); } } public static bool SendCustomChatClientRPC(string chatMessage, string nameOfUserWhoTyped) { if (chatMessage.StartsWith("Clodhopper Custom RPC Send Custom Message Shoe Type")) { string text = chatMessage.Split(new char[1] { ';' })[1]; ulong num = ulong.Parse(chatMessage.Split(new char[1] { ';' })[2]); Transform val = null; bool flag = false; if (((NetworkBehaviour)StartOfRound.Instance.localPlayerController).NetworkObjectId == num) { val = ((Component)StartOfRound.Instance.localPlayerController).transform; flag = true; } else { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if (((NetworkBehaviour)val2).NetworkObjectId == num) { val = ((Component)val2).transform; break; } } } if (((Component)val.Find("ScavengerModel/metarig/spine")).GetComponent<ShoeSpawner>().enabledShoe == text || (flag && !((Component)val.Find("ScavengerModel/metarig/spine")).GetComponent<ShoeSpawner>().showShoes)) { ((Component)val.Find("ScavengerModel/metarig/spine")).GetComponent<ShoeSpawner>().enabledShoe = text; return false; } foreach (GameObject item in ((Component)val.Find("ScavengerModel/metarig/spine")).GetComponent<ShoeSpawner>().shoesLeft) { if (item.GetComponent<ShoeObject>().shoeID == text) { item.SetActive(true); } else { item.SetActive(false); } } foreach (GameObject item2 in ((Component)val.Find("ScavengerModel/metarig/spine")).GetComponent<ShoeSpawner>().shoesRight) { if (item2.GetComponent<ShoeObject>().shoeID == text) { item2.SetActive(true); } else { item2.SetActive(false); } } ((Component)val.Find("ScavengerModel/metarig/spine")).GetComponent<ShoeSpawner>().enabledShoe = text; Plugin.Instance.SendLog("Message: " + chatMessage + " - User: " + num + " - Shoe ID: " + text); return false; } if (chatMessage.StartsWith("Clodhopper Custom RPC Request Custom Message Shoe Type")) { if (ulong.Parse(chatMessage.Split(new char[1] { ';' })[1]) == ((NetworkBehaviour)StartOfRound.Instance.localPlayerController).NetworkObjectId) { return false; } SetShoesOnClientJoin(); return false; } return true; } public static void LoadPlugin() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if ((Object)(object)Plugin.Instance == (Object)null) { Object.Instantiate<GameObject>(new GameObject()).AddComponent<Plugin>().Init(); } } public static void RequestShoesOnJoinServer() { if (!Plugin.Instance.requestedShoes && !((NetworkBehaviour)StartOfRound.Instance).IsHost && !((NetworkBehaviour)StartOfRound.Instance).IsServer) { Plugin.Instance.SendLog("Connected To Server - Requesting Shoes"); PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; HUDManager.Instance.AddTextToChatOnServer("Clodhopper Custom RPC Request Custom Message Shoe Type;" + ((NetworkBehaviour)localPlayerController).NetworkObjectId, -1); Plugin.Instance.requestedShoes = true; } } public static void SetShoesOnClientJoin() { Plugin.Instance.SendLog("Shoes Requested - Attempting To Send Shoe Message"); PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; string enabledShoe = ((Component)((Component)localPlayerController).transform.Find("ScavengerModel/metarig/spine")).GetComponent<ShoeSpawner>().enabledShoe; HUDManager.Instance.AddTextToChatOnServer("Clodhopper Custom RPC Send Custom Message Shoe Type;" + enabledShoe + ";" + ((NetworkBehaviour)localPlayerController).NetworkObjectId, -1); } } [BepInPlugin("Clodhopper", "Clodhopper", "1.1.1")] public class Plugin : BaseUnityPlugin { public static Plugin Instance; private bool addedManager; private bool addedToRack = true; public bool requestedShoes; private ConfigEntry<string> configToggleKey; private ConfigEntry<string> configRemoveKey; public static InputAction localShoeToggleAction; public static InputAction removeShoeAction; private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Clodhopper is loaded!"); Patcher.Init(); } public void Init() { if ((Object)(object)Instance == (Object)null) { Instance = this; Object.DontDestroyOnLoad((Object)(object)this); CheckConfig(); } else { Object.Destroy((Object)(object)this); } } public void Update() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "MainMenu") { if (!Instance.addedManager) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Creating Shoe Manager"); Object.Instantiate<GameObject>((GameObject)AssetBundle.LoadFromFile(Path.Combine(Paths.PluginPath, "Makarew-Clodhopper", "shoe.manager")).LoadAsset("ShoeManager")); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Shoe Manager Created"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading Shoes"); Instance.addedManager = true; ShoeManager.Instance.LoadShoes(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Shoes Loaded"); } if (Instance.addedToRack) { Instance.addedToRack = false; Instance.requestedShoes = false; if (localShoeToggleAction != null) { localShoeToggleAction.Disable(); } if (removeShoeAction != null) { removeShoeAction.Disable(); } } } activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "SampleSceneRelay" && !Instance.addedToRack) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Adding Shoe Objects To Rack"); ShoeManager.Instance.AddShoesToRack(); Instance.addedToRack = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Shoes Added To Rack"); localShoeToggleAction.Enable(); removeShoeAction.Enable(); } } public void SendLog(string message) { ((BaseUnityPlugin)this).Logger.LogMessage((object)message); } private void CheckConfig() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown configToggleKey = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PlayerViewToggle", "<Keyboard>/p", "The key used to toggle visibility of the local player's shoes."); localShoeToggleAction = new InputAction("ShoeToggle", (InputActionType)0, configToggleKey.Value, "Press", (string)null, (string)null); localShoeToggleAction.performed += ToggleEvent; configRemoveKey = ((BaseUnityPlugin)this).Config.Bind<string>("General", "RemoveShoe", "<Keyboard>/o", "The key used to remove the local player's shoes."); removeShoeAction = new InputAction("ShoeRemove", (InputActionType)0, configRemoveKey.Value, "Press", (string)null, (string)null); removeShoeAction.performed += RemoveShoeEvent; } public static void ToggleEvent(CallbackContext context) { if (Instance.CheckIfCanUseHotkey()) { ((BaseUnityPlugin)Instance).Logger.LogMessage((object)"Toggling Local Player Shoe Visibility"); ((Component)((Component)StartOfRound.Instance.localPlayerController).transform.Find("ScavengerModel/metarig/spine")).GetComponent<ShoeSpawner>().ToggleLocalPlayerShoes(); } } public static void RemoveShoeEvent(CallbackContext context) { if (Instance.CheckIfCanUseHotkey()) { HUDManager.Instance.AddTextToChatOnServer("Clodhopper Custom RPC Send Custom Message Shoe Type;Default;" + ((NetworkBehaviour)StartOfRound.Instance.localPlayerController).NetworkObjectId, -1); } } public bool CheckIfCanUseHotkey() { PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; if (localPlayerController.inTerminalMenu || localPlayerController.isFreeCamera || localPlayerController.isPlayerDead || localPlayerController.isTypingChat || Object.FindObjectOfType<QuickMenuManager>().isMenuOpen) { return false; } return true; } } public class ShoeManager : MonoBehaviour { public List<AssetBundle> shoes; public static ShoeManager Instance { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; Object.DontDestroyOnLoad((Object)(object)this); } } public void LoadShoes() { string[] files = Directory.GetFiles(Path.Combine(Paths.PluginPath), "*.shoe", SearchOption.AllDirectories); foreach (string text in files) { shoes.Add(AssetBundle.LoadFromFile(text)); } } public void AddShoesToRack() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0072: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < shoes.Count; i++) { GameObject obj = Object.Instantiate<GameObject>((GameObject)shoes[i].LoadAsset("ShoeObject")); obj.GetComponent<ShoeObject>().SetupAsDisplay(); AutoParentToShip component = obj.GetComponent<AutoParentToShip>(); component.overrideOffset = true; component.positionOffset = new Vector3(-2.45f + 0.3f * (float)i, 2.9f, -8.41f); component.rotationOffset = new Vector3(-90f, 130f, 0f); } } } public class ShoeObject : MonoBehaviour { public string shoeID; public void SetupAsDisplay() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown ((Component)this).gameObject.AddComponent<AutoParentToShip>(); InteractTrigger obj = ((Component)this).gameObject.AddComponent<InteractTrigger>(); obj.animationWaitTime = 2f; obj.cooldownTime = 1f; obj.disableTriggerMesh = true; obj.holdInteraction = true; obj.hoverTip = "Change Shoes: " + shoeID; obj.interactable = true; obj.interactCooldown = true; obj.oneHandedItemAllowed = true; obj.stopAnimationString = "SA_stopAnimation"; obj.timeToHold = 0.5f; obj.holdingInteractEvent = new InteractEventFloat(); obj.onCancelAnimation = new InteractEvent(); obj.onInteract = new InteractEvent(); ((UnityEvent<PlayerControllerB>)(object)obj.onInteract).AddListener((UnityAction<PlayerControllerB>)SwitchShoesToThis); obj.onInteractEarly = new InteractEvent(); obj.onStopInteract = new InteractEvent(); obj.hoverIcon = ((Component)Object.FindObjectOfType<UnlockableSuit>()).gameObject.GetComponent<InteractTrigger>().hoverIcon; } public void SwitchShoesToThis(PlayerControllerB player = null) { if ((Object)(object)player == (Object)null) { player = GameNetworkManager.Instance.localPlayerController; } HUDManager.Instance.AddTextToChatOnServer("Clodhopper Custom RPC Send Custom Message Shoe Type;" + shoeID + ";" + ((NetworkBehaviour)player).NetworkObjectId, -1); } } internal class ShoeSpawner : MonoBehaviour { public List<GameObject> shoesLeft; public List<GameObject> shoesRight; public string enabledShoe = "Default"; public bool showShoes = true; public void ToggleLocalPlayerShoes() { if (showShoes) { foreach (GameObject item in shoesLeft) { item.SetActive(false); } foreach (GameObject item2 in shoesRight) { item2.SetActive(false); } showShoes = false; return; } foreach (GameObject item3 in shoesLeft) { if (item3.GetComponent<ShoeObject>().shoeID == enabledShoe) { item3.SetActive(true); } else { item3.SetActive(false); } } foreach (GameObject item4 in shoesRight) { if (item4.GetComponent<ShoeObject>().shoeID == enabledShoe) { item4.SetActive(true); } else { item4.SetActive(false); } } showShoes = true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Clodhopper"; public const string PLUGIN_NAME = "Clodhopper"; public const string PLUGIN_VERSION = "1.1.1"; } }