using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; 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 Microsoft.CodeAnalysis; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 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) { return severity2 != LogLevelConfig.None && (severity != LogLevelConfig.Everything || severity2 == LogLevelConfig.Everything); } public void Log(string text = "", LogLevel level = (LogLevel)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.1.2")] [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 bool doFreePanicAttackJumps; public static Lang.AvailableLang lang; public static Logger.LogLevelConfig logLevel; } public static class ConfigBinds { public static ConfigEntry doSpeed; public static ConfigEntry doSprintTime; public static ConfigEntry doClimbSpeed; public static ConfigEntry doAdrenaline; public static ConfigEntry doFreePanicAttackJumps; public static ConfigEntry lang; public static ConfigEntry logLevel; } 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) { if (1 == 0) { } ILangProperties result = langEnum switch { AvailableLang.De => new DE(), AvailableLang.Rus => new RUS(), _ => new EN(), }; if (1 == 0) { } return result; } } private const string modGUID = "thej01.lc.FearOverhauled"; private const string modName = "Fear Overhauled"; private const string modVersion = "1.1.2"; 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.doFreePanicAttackJumps = ConfigBinds.doFreePanicAttackJumps.Value; ConfigValues.lang = ConfigBinds.lang.Value; ConfigValues.logLevel = ConfigBinds.logLevel.Value; fearLogger.Log("Config values initialised.", (LogLevel)16); } public void InitAllConfigBinds(Logger fearLogger) { //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown fearLogger.Log("Initialising config binds...", (LogLevel)8); ConfigBinds.doSpeed = ((BaseUnityPlugin)this).Config.Bind("General", "Speed changes", true, "Determines if your speed will increase while scared"); string text = $"doSpeed initialised. (Value: {ConfigBinds.doSpeed.Value})"; fearLogger.Log(text, (LogLevel)8); ConfigBinds.doSprintTime = ((BaseUnityPlugin)this).Config.Bind("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("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("General", "Adrenaline", true, "Determines if you won't limp while scared"); text = $"doAdrenaline initialised. (Value: {ConfigBinds.doAdrenaline.Value})"; fearLogger.Log(text, (LogLevel)8); ConfigBinds.doFreePanicAttackJumps = ((BaseUnityPlugin)this).Config.Bind("General", "No stamina loss from jumping", false, "If true, prevents stamina loss from jumping whilst having a panic attack"); fearLogger.Log("Initialising LethalConfig items...", (LogLevel)16); ConfigBinds.lang = ((BaseUnityPlugin)this).Config.Bind("Misc", "Language", Lang.AvailableLang.En, "Doesn't affect config"); EnumDropDownConfigItem val = new EnumDropDownConfigItem(ConfigBinds.lang, new EnumDropDownOptions { RequiresRestart = false }); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val); ConfigBinds.logLevel = ((BaseUnityPlugin)this).Config.Bind("Misc", "Log Level", Logger.LogLevelConfig.Important, "Console logging level"); EnumDropDownConfigItem val2 = new EnumDropDownConfigItem(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.1.2"; 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 = "") { if (1 == 0) { } IFearProperties result = property switch { "scared" => new ScaredProperties(), "horrified" => new HorrifiedProperties(), "panicAttack" => new PanicAttackProperties(), _ => new StressedProperties(), }; if (1 == 0) { } return result; } 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; return (fear >= fearNeeded || minFear >= fearNeeded) ? "stressed" : "calm"; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "FearOverhauled"; public const string PLUGIN_NAME = "FearOverhauled"; public const string PLUGIN_VERSION = "1.1.2"; } } namespace FearOverhauled.Patches { [HarmonyPatch(typeof(PlayerControllerB))] internal static 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("Jump_performed")] [HarmonyPrefix] private static void PreJump(ref float ___sprintMeter, out float __state) { __state = ___sprintMeter; } [HarmonyPatch("Jump_performed")] [HarmonyPostfix] private static void PostJump(ref float ___sprintMeter, float __state) { if (FearOverhauledMod.ConfigValues.doFreePanicAttackJumps && fearState == "panicAttack") { ___sprintMeter = __state; } } [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) { 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) { 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; } return (limpMultiplier == FearOverhauledMod.VanillaValues.limpMultiplier || !FearOverhauledMod.ConfigValues.doAdrenaline) && (dontLimp == FearOverhauledMod.VanillaValues.dontLimp || !FearOverhauledMod.ConfigValues.doAdrenaline) && staminaRegen == FearOverhauledMod.VanillaValues.staminaRegen; } } internal static class RoundManagerPatch { [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPrefix] private static void PostStart() { FearOverhauledMod fearOverhauledMod = new FearOverhauledMod(); fearOverhauledMod.InitConfig(FearOverhauledMod.fearLogger); } } }