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.Configuration; using BepInEx.Logging; using CSync.Extensions; using CSync.Lib; using HarmonyLib; using Unity.Netcode; 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("ConfigurableJesterFear")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ConfigurableJesterFear")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1326e202-eaff-4334-bb70-647b792ff524")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace ConfigurableJesterFear; public class ConfigHandler : SyncedConfig2 { public enum FearModes { NoFear, LowFear, MidFear, HighFear } public ConfigEntry debugMode; [SyncedEntryField] public SyncedEntry windingFearLevel; [SyncedEntryField] public SyncedEntry poppedFearLevel; public ConfigHandler(ConfigFile cfg) : base("ZetaArcade.ConfigurableJesterFear") { windingFearLevel = SyncedBindingExtensions.BindSyncedEntry(cfg, "Fear Levels", "Winding Fear Level", FearModes.MidFear, "How much fear level a player should experience when inside when a Jester is winding."); poppedFearLevel = SyncedBindingExtensions.BindSyncedEntry(cfg, "Fear Levels", "Popped Fear Level", FearModes.HighFear, "How much fear level a player should experience when inside when a Jester has popped."); debugMode = cfg.Bind("Debugging", "Print Debug Info", false, "(Unused) If true, prints debug info into the log."); ConfigManager.Register((SyncedConfig2)this); } } [BepInPlugin("ZetaArcade.ConfigurableJesterFear", "ConfigurableJesterFear", "0.0.1")] [BepInDependency("com.sigurd.csync", "5.0.0")] public class ConfigurableJesterFear : BaseUnityPlugin { private Harmony harmony = new Harmony("ZetaArcade.ConfigurableJesterFear"); public static ManualLogSource Logger; public static ConfigurableJesterFear Instance; internal static ConfigHandler Config; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Logger = ((BaseUnityPlugin)this).Logger; Config = new ConfigHandler(((BaseUnityPlugin)this).Config); harmony.PatchAll(typeof(ConfigurableJesterFear)); harmony.PatchAll(typeof(NetworkPrefabPatch2)); harmony.PatchAll(typeof(NetworkManager)); harmony.PatchAll(typeof(JesterAI)); harmony.PatchAll(typeof(JesterAIPatch)); Logger.LogInfo((object)"Plugin is loaded!"); } } [HarmonyPatch(typeof(JesterAI))] internal class JesterAIPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void FearHandler(ref int ___previousState) { if (GameNetworkManager.Instance.localPlayerController.isInsideFactory) { float num = ConvertCfgToFear(SyncedEntry.op_Implicit(ConfigurableJesterFear.Config.windingFearLevel)); float num2 = ConvertCfgToFear(SyncedEntry.op_Implicit(ConfigurableJesterFear.Config.poppedFearLevel)); switch (___previousState) { case 0: break; case 1: GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(num, true); break; case 2: GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(num2, true); break; } } } private static float ConvertCfgToFear(ConfigHandler.FearModes cfgFearMode) { if (1 == 0) { } float result = cfgFearMode switch { ConfigHandler.FearModes.NoFear => 0f, ConfigHandler.FearModes.LowFear => 0.25f, ConfigHandler.FearModes.MidFear => 0.68f, ConfigHandler.FearModes.HighFear => 1f, _ => 0f, }; if (1 == 0) { } return result; } } [HarmonyPatch(typeof(NetworkManager))] internal static class NetworkPrefabPatch2 { private static readonly string MOD_GUID = "ZetaArcade.ConfigurableJesterFear"; [HarmonyPostfix] [HarmonyPatch("SetSingleton")] private static void RegisterPrefab() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(MOD_GUID + " Prefab"); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D); Object.DontDestroyOnLoad((Object)(object)val); NetworkObject obj = val.AddComponent(); FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(obj, GetHash(MOD_GUID)); NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val); static uint GetHash(string value) { return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0; } } } internal class PluginInfo { public const string modGUID = "ZetaArcade.ConfigurableJesterFear"; public const string modName = "ConfigurableJesterFear"; public const string modVersion = "0.0.1"; }