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 CheckpointWard v1.0.0
Plugins/CheckpointWard.dll
Decompiled 5 days agousing System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("CheckpointWard")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CheckpointWard")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("2cd44209-f1a3-4d96-bd15-469a91117d1a")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace MyBepInExPlugin; [HarmonyPatch(typeof(Bed), "IsMine")] public static class Bed_IsMine_Patch { private static void Postfix(Bed __instance, ref bool __result) { if (((Object)((Component)__instance).gameObject).name.Contains("CheckpointWard")) { __result = true; } } } [HarmonyPatch(typeof(Bed), "GetOwner")] public static class Bed_GetOwner_Patch { private static void Postfix(Bed __instance, ref long __result) { if ((Object)(object)((Component)__instance).GetComponent<CheckpointWardTag>() != (Object)null && __result == 0) { __result = 1L; } } } [HarmonyPatch(typeof(Bed), "Interact")] public static class Bed_Interact_Override { private static bool Prefix(Bed __instance, Humanoid human, bool repeat, bool alt, ref bool __result) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)__instance).GetComponent<CheckpointWardTag>() != (Object)null) { if (repeat) { __result = false; return false; } Player val = (Player)(object)((human is Player) ? human : null); if ((Object)(object)val == (Object)null) { __result = false; return false; } PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); Vector3 spawnPoint = __instance.GetSpawnPoint(); Vector3 customSpawnPoint = playerProfile.GetCustomSpawnPoint(); if (Input.GetKey((KeyCode)304)) { if (Vector3.Distance(customSpawnPoint, spawnPoint) < 1f) { playerProfile.SetCustomSpawnPoint(Vector3.zero); ((Character)val).Message((MessageType)2, "Checkpoint cleared", 0, (Sprite)null); EffectList wardDeactivateEffect = Main.WardDeactivateEffect; if (wardDeactivateEffect != null) { wardDeactivateEffect.Create(((Component)__instance).transform.position, Quaternion.identity, (Transform)null, 1f, -1); } } else { ((Character)val).Message((MessageType)2, "This is not your active checkpoint", 0, (Sprite)null); } __result = true; return false; } if (Vector3.Distance(customSpawnPoint, spawnPoint) < 1f) { ((Character)val).Message((MessageType)2, "Checkpoint already active", 0, (Sprite)null); __result = true; return false; } playerProfile.SetCustomSpawnPoint(spawnPoint); ((Character)val).Message((MessageType)2, "Checkpoint set", 0, (Sprite)null); EffectList wardActivateEffect = Main.WardActivateEffect; if (wardActivateEffect != null) { wardActivateEffect.Create(((Component)__instance).transform.position, Quaternion.identity, (Transform)null, 1f, -1); } __result = true; return false; } return true; } } [HarmonyPatch(typeof(EnvMan), "CanSleep")] public static class EnvMan_CanSleep_Patch { private static void Postfix(ref bool __result) { if (CheckpointContext.IsCheckpointInteraction) { __result = true; } } } [HarmonyPatch(typeof(Bed), "GetHoverText")] public static class Bed_GetHoverText_Patch { private static bool Prefix(Bed __instance, ref string __result) { //IL_001e: 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_0025: 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_002b: 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) if ((Object)(object)((Component)__instance).GetComponent<CheckpointWardTag>() != (Object)null) { PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); Vector3 customSpawnPoint = playerProfile.GetCustomSpawnPoint(); Vector3 spawnPoint = __instance.GetSpawnPoint(); if (Vector3.Distance(customSpawnPoint, spawnPoint) < 1f) { __result = "Checkpoint Ward (Current)\n[<color=yellow>Shift+E</color>] Clear Spawn Point"; } else { __result = "Checkpoint Ward\n[<color=yellow>E</color>] Set Spawn Point"; } return false; } return true; } } public class CheckpointWardInteract : MonoBehaviour { } public class CheckpointWardTag : MonoBehaviour { } public static class CheckpointContext { private static int _depth; public static bool IsCheckpointInteraction => _depth > 0; public static void Enter() { _depth++; } public static void Exit() { if (_depth > 0) { _depth--; } } } [BepInPlugin("com.example.checkpointward", "Checkpoint Ward", "1.0.0")] public class Main : BaseUnityPlugin { private const string pluginGUID = "com.example.checkpointward"; private const string pluginName = "Checkpoint Ward"; private const string pluginVersion = "1.0.0"; public static EffectList WardActivateEffect; public static EffectList WardDeactivateEffect; private readonly Harmony HarmonyInstance = new Harmony("com.example.checkpointward"); public static ManualLogSource logger = Logger.CreateLogSource("Checkpoint Ward"); private AssetBundle assetBundle; private void Awake() { logger.LogInfo((object)"CheckpointWard loaded"); HarmonyInstance.PatchAll(Assembly.GetExecutingAssembly()); PrefabManager.OnVanillaPrefabsAvailable += OnPrefabsReady; } private void OnPrefabsReady() { PrefabManager.OnVanillaPrefabsAvailable -= OnPrefabsReady; LoadAssetBundle(); GameObject prefab = PrefabManager.Instance.GetPrefab("guard_stone"); if ((Object)(object)prefab != (Object)null) { PrivateArea component = prefab.GetComponent<PrivateArea>(); WardActivateEffect = component.m_activateEffect; WardDeactivateEffect = component.m_deactivateEffect; logger.LogInfo((object)"Ward effects loaded"); } else { logger.LogError((object)"guard_stone prefab not found"); } } private void LoadAssetBundle() { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "checkpointward"); assetBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)assetBundle == (Object)null) { logger.LogError((object)"Failed to load AssetBundle"); return; } logger.LogInfo((object)"AssetBundle loaded"); RegisterPrefab(); } private void RegisterPrefab() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown GameObject val = assetBundle.LoadAsset<GameObject>("CheckpointWard"); if ((Object)(object)val == (Object)null) { logger.LogError((object)"Prefab not found in AssetBundle"); return; } val.AddComponent<CheckpointWardTag>(); val.AddComponent<CheckpointWardInteract>(); logger.LogInfo((object)("Prefab loaded OK: " + ((Object)val).name)); CustomPrefab val2 = new CustomPrefab(val, true); PrefabManager.Instance.AddPrefab(val2); logger.LogInfo((object)"Prefab registered"); RegisterPiece(val); } private void RegisterPiece(GameObject prefab) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown PieceConfig val = new PieceConfig { Name = "Checkpoint Ward", Description = "Sets a multiplayer spawn point anywhere.", PieceTable = "Hammer", Category = PieceCategories.Misc, CraftingStation = "piece_stonecutter" }; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("GreydwarfEye", 5, 0, true), new RequirementConfig("Wisp", 1, 0, true) }; CustomPiece val2 = new CustomPiece(prefab, false, val); PieceManager.Instance.AddPiece(val2); logger.LogInfo((object)"Piece registered"); } }