Please disclose if your mod was created primarily 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 FearOverhauled v1.1.1
plugins/FearOverhauled/FearOverhauled.dll
Decompiled 2 years agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FearOverhauled.Patches; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; 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("FearOverhauled")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FearOverhauled")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("060ddf36-7d3b-4285-bc40-c173497782c4")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace FearOverhauled { public class Logger { public enum LogLevelConfig { None, Important, Everything } internal ManualLogSource MLS; public string modName = "No-Name"; public string modVersion = "No-Ver"; public void Init(string modGUID = "") { MLS = Logger.CreateLogSource(modGUID); } public bool LogLevelAllow(LogLevelConfig severity = LogLevelConfig.Important, LogLevelConfig severity2 = LogLevelConfig.Everything) { if (severity2 == LogLevelConfig.None) { return false; } if (severity == LogLevelConfig.Everything) { return severity2 == LogLevelConfig.Everything; } return true; } public void Log(string text = "", LogLevel level = 16, LogLevelConfig severity = LogLevelConfig.Important) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) _ = FearOverhauledMod.ConfigValues.logLevel; bool flag = false; if (!flag) { flag = LogLevelAllow(severity, FearOverhauledMod.ConfigValues.logLevel); } if (flag) { string text2 = $"[{modName} v{modVersion}] - {text}"; MLS.Log(level, (object)text2); } } } [BepInPlugin("thej01.lc.FearOverhauled", "Fear Overhauled", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class FearOverhauledMod : BaseUnityPlugin { public static class ConfigValues { public static bool doSpeed; public static bool doSprintTime; public static bool doClimbSpeed; public static bool doAdrenaline; public static Lang.AvailableLang lang; public static Logger.LogLevelConfig logLevel; } public static class ConfigBinds { public static ConfigEntry<bool> doSpeed; public static ConfigEntry<bool> doSprintTime; public static ConfigEntry<bool> doClimbSpeed; public static ConfigEntry<bool> doAdrenaline; public static ConfigEntry<Lang.AvailableLang> lang; public static ConfigEntry<Logger.LogLevelConfig> logLevel; } public static class Sounds { public static AudioClip[] panicAttackWarning = HUDManager.Instance.warningSFX; public static AudioClip panicAttackRecovery = HUDManager.Instance.reachedQuotaSFX; } public static class VanillaValues { public static float speed = 4.6f; public static float sprintTime = 11f; public static float climbSpeed = 3f; public static float limpMultiplier = 0.2f; public static float staminaRegen = 0f; public static bool dontLimp = false; } public interface IFearProperties { float fearNeeded { get; } float speed { get; } float sprintTime { get; } float staminaRegen { get; } float climbSpeed { get; } bool dontLimp { get; } } public class StressedProperties : IFearProperties { public float fearNeeded { get; } = 0.01f; public float speed { get; } = 0.25f; public float sprintTime { get; } = 1f; public float staminaRegen { get; } = -0.005f; public float climbSpeed { get; } = 1f; public bool dontLimp { get; } = false; } public class ScaredProperties : IFearProperties { public float fearNeeded { get; } = 0.25f; public float speed { get; } = 0.6f; public float sprintTime { get; } = 2f; public float staminaRegen { get; } = -0.01f; public float climbSpeed { get; } = 2f; public bool dontLimp { get; } = false; } public class HorrifiedProperties : IFearProperties { public float fearNeeded { get; } = 0.5f; public float speed { get; } = 0.9f; public float sprintTime { get; } = 4f; public float staminaRegen { get; } = -0.025f; public float climbSpeed { get; } = 3f; public bool dontLimp { get; } = true; } public class PanicAttackProperties : IFearProperties { public float fearNeeded { get; } = 0.85f; public float speed { get; } = 1.1f; public float sprintTime { get; } = 6f; public float staminaRegen { get; } = -0.0425f; public float climbSpeed { get; } = 4f; public bool dontLimp { get; } = true; } public static class Lang { public enum AvailableLang { En, De, Rus } public interface ILangProperties { string panicAttackWarningMSG { get; } string panicAttackRecoveryMSG { get; } } public class EN : ILangProperties { public string panicAttackWarningMSG { get; } = "WARNING: High heartbeat detected. Find a place to rest ASAP."; public string panicAttackRecoveryMSG { get; } = "INFO: Heartrate slowing down to normal levels."; } public class DE : ILangProperties { public string panicAttackWarningMSG { get; } = "WARNUNG: Hoher Herzschlag wurde festgestellt. Suchen Sie sich jetzt einen Platz zum Ausruhen."; public string panicAttackRecoveryMSG { get; } = "INFO: Die Herzfrequenz kehrt zur normalen Geschwindigkeit zurück."; } public class RUS : ILangProperties { public string panicAttackWarningMSG { get; } = "ПРЕДУПРЕЖДЕНИЕ: Обнаружено учащенное сердцебиение. Выздоравливайте скорее."; public string panicAttackRecoveryMSG { get; } = "Информация: Пульс возвращается к нормальной скорости."; } public static AvailableLang curLang; public static ILangProperties GetLangClassFromEnum(AvailableLang langEnum = AvailableLang.En) { return langEnum switch { AvailableLang.De => new DE(), AvailableLang.Rus => new RUS(), _ => new EN(), }; } } private const string modGUID = "thej01.lc.FearOverhauled"; private const string modName = "Fear Overhauled"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("thej01.lc.FearOverhauled"); private static FearOverhauledMod Instance; public static Logger fearLogger = new Logger(); public void InitConfigValues(Logger fearLogger) { fearLogger.Log("Initialising config values...", (LogLevel)16); ConfigValues.doSpeed = ConfigBinds.doSpeed.Value; ConfigValues.doSprintTime = ConfigBinds.doSprintTime.Value; ConfigValues.doClimbSpeed = ConfigBinds.doClimbSpeed.Value; ConfigValues.doAdrenaline = ConfigBinds.doAdrenaline.Value; ConfigValues.lang = ConfigBinds.lang.Value; ConfigValues.logLevel = ConfigBinds.logLevel.Value; fearLogger.Log("Config values initialised.", (LogLevel)16); } public void InitAllConfigBinds(Logger fearLogger) { //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown fearLogger.Log("Initialising config binds...", (LogLevel)8); string text = ""; ConfigBinds.doSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Speed changes", true, "Determines if your speed will increase while scared"); text = $"doSpeed initialised. (Value: {ConfigBinds.doSpeed.Value})"; fearLogger.Log(text, (LogLevel)8); ConfigBinds.doSprintTime = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Stamina changes", true, "Determines if your stamina will increase while scared"); text = $"doSprintTime initialised. (Value: {ConfigBinds.doSprintTime.Value})"; fearLogger.Log(text, (LogLevel)8); ConfigBinds.doClimbSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Climb speed changes", true, "Determines if your climb speed will increase while scared"); text = $"doClimbSpeed initialised. (Value: {ConfigBinds.doClimbSpeed.Value})"; fearLogger.Log(text, (LogLevel)8); ConfigBinds.doAdrenaline = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Adrenaline", true, "Determines if you won't limp while scared"); text = $"doAdrenaline initialised. (Value: {ConfigBinds.doAdrenaline.Value})"; fearLogger.Log(text, (LogLevel)8); fearLogger.Log("Initialising LethalConfig items...", (LogLevel)16); ConfigBinds.lang = ((BaseUnityPlugin)this).Config.Bind<Lang.AvailableLang>("Misc", "Language", Lang.AvailableLang.En, "Doesn't affect config"); EnumDropDownConfigItem<Lang.AvailableLang> val = new EnumDropDownConfigItem<Lang.AvailableLang>(ConfigBinds.lang, new EnumDropDownOptions { RequiresRestart = false }); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val); ConfigBinds.logLevel = ((BaseUnityPlugin)this).Config.Bind<Logger.LogLevelConfig>("Misc", "Log Level", Logger.LogLevelConfig.Important, "Console logging level"); EnumDropDownConfigItem<Logger.LogLevelConfig> val2 = new EnumDropDownConfigItem<Logger.LogLevelConfig>(ConfigBinds.logLevel, new EnumDropDownOptions { RequiresRestart = false }); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2); fearLogger.Log("LethalConfig items initialised.", (LogLevel)8); fearLogger.Log("Config binds initialised.", (LogLevel)8); } public void InitConfig(Logger fearLogger) { fearLogger.Log("Initialising config...", (LogLevel)8); InitAllConfigBinds(fearLogger); InitConfigValues(fearLogger); fearLogger.Log("Config initialised.", (LogLevel)8); } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } fearLogger.Init("thej01.lc.FearOverhauled"); fearLogger.modName = "Fear Overhauled"; fearLogger.modVersion = "1.0.0"; fearLogger.Log("fearLogger Initialised!", (LogLevel)16, Logger.LogLevelConfig.Everything); InitConfig(fearLogger); fearLogger.Log("Patching FearOverhauledMod...", (LogLevel)16, Logger.LogLevelConfig.Everything); harmony.PatchAll(typeof(FearOverhauledMod)); fearLogger.Log("Patched FearOverhauledMod.", (LogLevel)16, Logger.LogLevelConfig.Everything); fearLogger.Log("Patching PlayerControllerBPatch...", (LogLevel)16, Logger.LogLevelConfig.Everything); harmony.PatchAll(typeof(PlayerControllerBPatch)); fearLogger.Log("Patched PlayerControllerBPatch.", (LogLevel)16, Logger.LogLevelConfig.Everything); fearLogger.Log("Patching RoundManagerPatch...", (LogLevel)16, Logger.LogLevelConfig.Everything); harmony.PatchAll(typeof(RoundManagerPatch)); fearLogger.Log("Patched RoundManagerPatch.", (LogLevel)16, Logger.LogLevelConfig.Everything); } public static IFearProperties GetPropertyClassFromName(string property = "") { return property switch { "scared" => new ScaredProperties(), "horrified" => new HorrifiedProperties(), "panicAttack" => new PanicAttackProperties(), _ => new StressedProperties(), }; } public static string GetFearString(float fear = 0f, float minFear = 0f) { PanicAttackProperties panicAttackProperties = new PanicAttackProperties(); float fearNeeded = panicAttackProperties.fearNeeded; if (fear >= fearNeeded || minFear >= fearNeeded) { return "panicAttack"; } HorrifiedProperties horrifiedProperties = new HorrifiedProperties(); fearNeeded = horrifiedProperties.fearNeeded; if (fear >= fearNeeded || minFear >= fearNeeded) { return "horrified"; } ScaredProperties scaredProperties = new ScaredProperties(); fearNeeded = scaredProperties.fearNeeded; if (fear >= fearNeeded || minFear >= fearNeeded) { return "scared"; } StressedProperties stressedProperties = new StressedProperties(); fearNeeded = stressedProperties.fearNeeded; if (fear >= fearNeeded || minFear >= fearNeeded) { return "stressed"; } return "calm"; } } } namespace FearOverhauled.Patches { [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatch { [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPrefix] private static void PostStart() { FearOverhauledMod fearOverhauledMod = new FearOverhauledMod(); fearOverhauledMod.InitConfig(FearOverhauledMod.fearLogger); } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { private static string fearState = "calm"; private static float logTimer = 0f; private static float messageTimer = 0f; private static bool playedWarningSound = false; private static bool showAfterPanicAttackMessage = false; [HarmonyPatch("Update")] [HarmonyPostfix] private static void PostUpdate(ref StartOfRound ___playersManager, ref float ___movementSpeed, ref float ___sprintTime, ref float ___climbSpeed, ref float ___sprintMeter, ref bool ___isSprinting, ref Animator ___playerBodyAnimator, ref float ___limpMultiplier, ref bool ___isPlayerDead) { if (___playersManager.fearLevel < 0f) { ___playersManager.fearLevel = 0f; } float fearLevel = ___playersManager.fearLevel; float num = 0f; bool flag = false; FearOverhauledMod.StressedProperties stressedProperties = new FearOverhauledMod.StressedProperties(); if (fearLevel >= stressedProperties.fearNeeded) { FearOverhauledMod.IFearProperties propertyClassFromName = FearOverhauledMod.GetPropertyClassFromName(fearState); fearState = FearOverhauledMod.GetFearString(fearLevel, propertyClassFromName.fearNeeded); propertyClassFromName = FearOverhauledMod.GetPropertyClassFromName(fearState); if (fearState != "calm") { if (FearOverhauledMod.ConfigValues.doSpeed) { ___movementSpeed = FearOverhauledMod.VanillaValues.speed + propertyClassFromName.speed; } if (FearOverhauledMod.ConfigValues.doSprintTime) { ___sprintTime = FearOverhauledMod.VanillaValues.sprintTime + propertyClassFromName.sprintTime; } if (FearOverhauledMod.ConfigValues.doClimbSpeed) { ___climbSpeed = FearOverhauledMod.VanillaValues.climbSpeed + propertyClassFromName.climbSpeed; } if (FearOverhauledMod.ConfigValues.doAdrenaline) { flag = propertyClassFromName.dontLimp; } num = FearOverhauledMod.VanillaValues.staminaRegen + propertyClassFromName.staminaRegen; } } else { if (fearState == "panicAttack") { showAfterPanicAttackMessage = true; playedWarningSound = false; messageTimer = 0f; } if (!CheckIfStatsAreVanilla(___movementSpeed, ___sprintTime, ___climbSpeed, num, flag, ___limpMultiplier)) { if (FearOverhauledMod.ConfigValues.doSpeed) { ___movementSpeed = FearOverhauledMod.VanillaValues.speed; } if (FearOverhauledMod.ConfigValues.doSprintTime) { ___sprintTime = FearOverhauledMod.VanillaValues.sprintTime; } if (FearOverhauledMod.ConfigValues.doClimbSpeed) { ___climbSpeed = FearOverhauledMod.VanillaValues.climbSpeed; } if (FearOverhauledMod.ConfigValues.doAdrenaline) { ___limpMultiplier = FearOverhauledMod.VanillaValues.limpMultiplier; flag = FearOverhauledMod.VanillaValues.dontLimp; } num = FearOverhauledMod.VanillaValues.staminaRegen; } fearState = "calm"; } if (!___isSprinting) { ___sprintMeter += num * Time.deltaTime; } if (flag) { ___playerBodyAnimator.SetBool("Limp", false); ___limpMultiplier = 1f; } if (!___isPlayerDead) { if (fearState == "panicAttack") { showAfterPanicAttackMessage = false; if (!playedWarningSound) { RoundManager.PlayRandomClip(HUDManager.Instance.UIAudio, FearOverhauledMod.Sounds.panicAttackWarning, false, 1f, 0, 1000); playedWarningSound = true; messageTimer = 0f; } if (messageTimer <= 30f) { FearOverhauledMod.Lang.ILangProperties langClassFromEnum = FearOverhauledMod.Lang.GetLangClassFromEnum(FearOverhauledMod.ConfigValues.lang); HUDManager.Instance.DisplayStatusEffect(langClassFromEnum.panicAttackWarningMSG); } } if (showAfterPanicAttackMessage) { if (!playedWarningSound) { HUDManager.Instance.UIAudio.PlayOneShot(FearOverhauledMod.Sounds.panicAttackRecovery); playedWarningSound = true; messageTimer = 0f; } if (messageTimer <= 30f) { FearOverhauledMod.Lang.ILangProperties langClassFromEnum2 = FearOverhauledMod.Lang.GetLangClassFromEnum(FearOverhauledMod.ConfigValues.lang); HUDManager.Instance.DisplayStatusEffect(langClassFromEnum2.panicAttackRecoveryMSG); } else { playedWarningSound = false; showAfterPanicAttackMessage = false; } } } else { messageTimer = 999f; showAfterPanicAttackMessage = false; } messageTimer += Time.deltaTime; logTimer += Time.deltaTime; if (logTimer > 5f) { logTimer = 0f; string text = $"Current Fear State: {fearState} (Cur Fear {fearLevel})"; FearOverhauledMod.fearLogger.Log(text, (LogLevel)16, Logger.LogLevelConfig.Everything); text = $"Current Speed: {___movementSpeed})"; FearOverhauledMod.fearLogger.Log(text, (LogLevel)16, Logger.LogLevelConfig.Everything); text = $"Current Sprint Time: {___sprintTime})"; FearOverhauledMod.fearLogger.Log(text, (LogLevel)16, Logger.LogLevelConfig.Everything); text = $"Current ClimbSpeed: {___climbSpeed})"; FearOverhauledMod.fearLogger.Log(text, (LogLevel)16, Logger.LogLevelConfig.Everything); text = $"Current StaminaRegen: {num})"; FearOverhauledMod.fearLogger.Log(text, (LogLevel)16, Logger.LogLevelConfig.Everything); text = $"Current dontLimp: {flag}"; FearOverhauledMod.fearLogger.Log(text, (LogLevel)16, Logger.LogLevelConfig.Everything); } } private static bool CheckIfStatsAreVanilla(float movementSpeed, float sprintTime, float climbSpeed, float staminaRegen, bool dontLimp, float limpMultiplier) { if (movementSpeed != FearOverhauledMod.VanillaValues.speed && FearOverhauledMod.ConfigValues.doSpeed) { return false; } if (sprintTime != FearOverhauledMod.VanillaValues.sprintTime && FearOverhauledMod.ConfigValues.doSprintTime) { return false; } if (climbSpeed != FearOverhauledMod.VanillaValues.climbSpeed && FearOverhauledMod.ConfigValues.doClimbSpeed) { return false; } if (limpMultiplier != FearOverhauledMod.VanillaValues.limpMultiplier && FearOverhauledMod.ConfigValues.doAdrenaline) { return false; } if (dontLimp != FearOverhauledMod.VanillaValues.dontLimp && FearOverhauledMod.ConfigValues.doAdrenaline) { return false; } if (staminaRegen != FearOverhauledMod.VanillaValues.staminaRegen) { return false; } return true; } } }