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 HexChestHacks v1.0.0
plugins/HexChestHacks.dll
Decompiled 2 days agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using HexChestHacks.Core; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("HexChestHacks")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HexChestHacks")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("593071b2-1408-41b4-93ef-e0d5eccca657")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace HexChestHacks { [BepInPlugin("com.hex.chesthacks", "HexChestHacks", "1.0.0")] public class Plugin : BaseUnityPlugin { private const string PluginGuid = "com.hex.chesthacks"; private const string PluginName = "HexChestHacks"; private const string PluginVersion = "1.0.0"; private Harmony _harmonyInstance; internal static ManualLogSource Log; internal static Plugin Instance; private void Awake() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmonyInstance = new Harmony("com.hex.chesthacks"); _harmonyInstance.PatchAll(executingAssembly); Log.LogInfo((object)"HexChestHacks v1.0.0 loaded."); } private void OnDestroy() { Log.LogInfo((object)"HexChestHacks v1.0.0 unloaded."); Harmony harmonyInstance = _harmonyInstance; if (harmonyInstance != null) { harmonyInstance.UnpatchSelf(); } _harmonyInstance = null; Instance = null; Log = null; } } } namespace HexChestHacks.Patches { [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetScenePatch { [HarmonyPostfix] private static void Postfix(ZNetScene __instance) { SnappointService.AddSnappoints(__instance); } } } namespace HexChestHacks.Core { internal static class SnappointService { private const string TreasureChestPrefab = "piece_chest_treasure"; private static readonly HashSet<string> SupportedPrefabs = new HashSet<string> { "piece_chest_wood", "piece_chest", "piece_chest_blackmetal", "piece_chest_grausten", "piece_chest_private", "piece_chest_barrel", "piece_chest_warderobe", "piece_chest_treasure" }; internal static bool IsSupportedChest(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return false; } string item = prefabName.Replace("(Clone)", "").Trim(); return SupportedPrefabs.Contains(item); } internal static void AddSnappoints(ZNetScene zNetScene) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject prefab in zNetScene.m_prefabs) { if ((Object)(object)prefab == (Object)null || !IsSupportedChest(((Object)prefab).name)) { continue; } Piece component = prefab.GetComponent<Piece>(); if ((Object)(object)component == (Object)null || (((Object)prefab).name != "piece_chest_treasure" && (Object)(object)prefab.GetComponent<Container>() == (Object)null)) { continue; } DisableSupportDamage(prefab); if (!HasSnappoints(((Component)component).transform)) { if (!TryGetMeshBounds(((Component)component).transform, out var bounds)) { Plugin.Log.LogWarning((object)("No visible meshes found: " + ((Object)component).name)); continue; } AddChestSnappoints(((Component)component).transform, bounds); AddVerticalSnappoints(((Component)component).transform, bounds); } } } private static bool HasSnappoints(Transform root) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) foreach (Transform item in root) { if (((Component)item).CompareTag("snappoint")) { return true; } } return false; } private static void AddChestSnappoints(Transform root, Bounds bounds) { //IL_0008: 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_0023: 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) //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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) CreateSnappoint(root, "top_left", new Vector3(((Bounds)(ref bounds)).min.x, 0f, ((Bounds)(ref bounds)).max.z)); CreateSnappoint(root, "top_right", new Vector3(((Bounds)(ref bounds)).max.x, 0f, ((Bounds)(ref bounds)).max.z)); CreateSnappoint(root, "bottom_left", new Vector3(((Bounds)(ref bounds)).min.x, 0f, ((Bounds)(ref bounds)).min.z)); CreateSnappoint(root, "bottom_right", new Vector3(((Bounds)(ref bounds)).max.x, 0f, ((Bounds)(ref bounds)).min.z)); } private static void AddVerticalSnappoints(Transform root, Bounds bounds) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_003c: 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_0054: 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) CreateSnappoint(root, "top_center", new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.y, ((Bounds)(ref bounds)).center.z)); CreateSnappoint(root, "bottom_center", new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).center.z)); } private static bool TryGetMeshBounds(Transform root, out Bounds bounds) { //IL_0001: 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_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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_009d: 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_00b2: 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_00c8: 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_00d6: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_01a2: 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) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_01e8: 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_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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_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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: 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_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022d: 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_0237: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); bool flag = false; MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val in componentsInChildren) { if (!IsMeshActive(((Component)val).transform, root)) { continue; } MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>(); if ((Object)(object)component == (Object)null || !((Renderer)component).enabled || (Object)(object)val.sharedMesh == (Object)null) { continue; } Bounds bounds2 = val.sharedMesh.bounds; Vector3[] obj = new Vector3[8] { new Vector3(((Bounds)(ref bounds2)).min.x, ((Bounds)(ref bounds2)).min.y, ((Bounds)(ref bounds2)).min.z), new Vector3(((Bounds)(ref bounds2)).min.x, ((Bounds)(ref bounds2)).min.y, ((Bounds)(ref bounds2)).max.z), new Vector3(((Bounds)(ref bounds2)).min.x, ((Bounds)(ref bounds2)).max.y, ((Bounds)(ref bounds2)).min.z), new Vector3(((Bounds)(ref bounds2)).min.x, ((Bounds)(ref bounds2)).max.y, ((Bounds)(ref bounds2)).max.z), new Vector3(((Bounds)(ref bounds2)).max.x, ((Bounds)(ref bounds2)).min.y, ((Bounds)(ref bounds2)).min.z), new Vector3(((Bounds)(ref bounds2)).max.x, ((Bounds)(ref bounds2)).min.y, ((Bounds)(ref bounds2)).max.z), new Vector3(((Bounds)(ref bounds2)).max.x, ((Bounds)(ref bounds2)).max.y, ((Bounds)(ref bounds2)).min.z), new Vector3(((Bounds)(ref bounds2)).max.x, ((Bounds)(ref bounds2)).max.y, ((Bounds)(ref bounds2)).max.z) }; Matrix4x4 val2 = root.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix; Vector3[] array = (Vector3[])(object)obj; foreach (Vector3 val3 in array) { Vector3 val4 = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(val3); if (!flag) { bounds = new Bounds(val4, Vector3.zero); flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val4); } } } return flag; } private static bool IsMeshActive(Transform transform, Transform root) { while ((Object)(object)transform != (Object)(object)root) { if (!((Component)transform).gameObject.activeSelf) { return false; } transform = transform.parent; if ((Object)(object)transform == (Object)null) { return false; } } return true; } private static void CreateSnappoint(Transform root, string name, Vector3 position) { //IL_000b: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) GameObject val = new GameObject("$hud_snappoint_" + name); val.transform.SetParent(root, false); val.transform.localPosition = position; val.tag = "snappoint"; val.layer = LayerMask.NameToLayer("piece"); } private static void DisableSupportDamage(GameObject prefab) { WearNTear component = prefab.GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_noSupportWear = false; component.m_supports = true; } } } }