using System.Collections; using System.Collections.Generic; using System.Text; using HarmonyLib; using UnityEngine; namespace UltraParadise { internal static partial class Plugin { internal static void ApplyKeeps(Body b) { Limb[] ls = b.limbs; if (ls != null && (NoBleeding.Value || NoPain.Value || NoInfection.Value)) { for (int i = 0; i < ls.Length; i++) { Limb l = ls[i]; if (l == null || l.dismembered) continue; if (NoBleeding.Value) l.bleedAmount = 0f; if (NoPain.Value) l.pain = 0f; if (NoInfection.Value) { l.infectionAmount = 0f; l.infected = false; } } } if (NoBleeding.Value) { b.internalBleeding = 0f; b.hemothorax = 0f; } if (NoPain.Value) b.painShock = 0f; if (NoInfection.Value) b.septicShock = 0f; if (NoSickness.Value) { b.sicknessAmount = 0f; b.venomCurrent = 0f; } if (NoRadiation.Value) b.radiationSickness = 0f; if (UnlimitedOxygen.Value) b.bloodOxygen = 100f; if (StableTemperature.Value) b.temperature = 37f; if (UnlimitedCarry.Value) b.overEncumberance = 0f; if (InfiniteStamina.Value) b.stamina = 100f; if (NoHunger.Value && b.hunger < 100f) b.hunger = 100f; if (NoThirst.Value && b.thirst < 100f) b.thirst = 100f; if (NoTiredness.Value) b.energy = 100f; if (MoodLock.Value) { if (MoodBody != b || float.IsNaN(MoodTarget)) { MoodBody = b; MoodTarget = Mathf.Max(b.happiness, 60f); } b.happiness = MoodTarget; b.traumaAmount = 0f; } else MoodTarget = float.NaN; } internal static Body MoodBody; internal static float MoodTarget = float.NaN; internal static float MoodMax(Body b) { return 100f * (b.charType == 2 ? 1.5151515f : 1f); } internal static void SetMood(Body b, float v) { float m = MoodMax(b); v = Mathf.Clamp(v, -m, m); b.happiness = v; if (MoodLock.Value) { MoodBody = b; MoodTarget = v; } } internal static float RagdollUntil; internal static Body PausedBody; internal static string PauseReason; internal static bool PauseResumable; internal static float PausedAt; internal static bool IsPlayer(Body body) { return body != null && PlayerCamera.main != null && PlayerCamera.main.body == body; } internal static bool GodOn(Body body) { return GodMode.Value && IsPlayer(body) && !Paused(body); } internal static bool Paused(Body body) { return body != null && PausedBody != null && body == PausedBody; } internal static void Pause(Body body, string reason, bool resumable) { if (body == null) return; if (Paused(body) && !PauseResumable) return; PausedBody = body; PauseReason = reason; PauseResumable = resumable; PausedAt = Time.time; Log.LogInfo("God Mode paused: " + reason); Feed.Add("WARNING", "#ff6b6b", "God Mode PAUSED: " + reason); } internal static void TryResume() { Body b = PausedBody; if (b == null || !PauseResumable) return; if (!b.alive) { PauseResumable = false; return; } bool harming = b.harmer != null && b.harmer.harming; if (Time.time - PausedAt > 20f && b.totalBleedSpeed < 0.01f && !harming && !b.forceNoMovement) { PausedBody = null; PauseReason = null; Log.LogInfo("God Mode resumed (survived)."); Feed.Add("WARNING", "#9cff8a", "Survived - God Mode resumed"); } } internal static string DamageSummary(Body b) { List parts = new List(); if (b.brainHealth < 99.9f) parts.Add("brain -" + (100f - b.brainHealth).ToString("0.0")); if (b.bloodVolume < 99f) parts.Add("blood -" + (100f - b.bloodVolume).ToString("0.0")); if (b.internalBleeding > 0.1f) parts.Add("internal bleed"); Limb[] limbs = b.limbs; if (limbs != null) { for (int i = 0; i < limbs.Length; i++) { Limb l = limbs[i]; if (l == null || l.dismembered) continue; float lost = (100f - l.skinHealth) + (100f - l.muscleHealth); if (lost > 0.5f || l.bleedAmount > 0.1f || l.shrapnel > 0) parts.Add(l.gameObject.name + " -" + lost.ToString("0.0") + (l.bleedAmount > 0.1f ? " bleeding" : "")); } } return parts.Count == 0 ? null : string.Join(", ", parts.ToArray()); } internal static void Restore(Body b) { Stats.Restores++; b.brainHealth = 100f; if (!b.sleeping) b.consciousness = 100f; b.bloodVolume = 100f; b.bloodOxygen = 100f; if (b.bloodPressure < 100f) b.bloodPressure = 100f; else if (b.bloodPressure > 140f) b.bloodPressure = 140f; if (b.heartRate > 160f) b.heartRate = 160f; b.fibrillationProgress = 0f; b.hasPulmonaryEmbolism = false; b.strokeAmount = 0f; b.shock = Time.time < RagdollUntil ? 20f : 0f; b.painShock = 0f; b.internalBleeding = 0f; b.hemothorax = 0f; b.septicShock = 0f; b.sicknessAmount = 0f; b.radiationSickness = 0f; b.venomCurrent = 0f; b.barotrauma = 0f; b.temperature = 37f; if (b.hunger < 30f) b.hunger = 30f; if (b.thirst < 30f) b.thirst = 30f; if (b.thirst > 150f) b.thirst = 150f; Limb[] limbs = b.limbs; if (limbs == null) return; for (int i = 0; i < limbs.Length; i++) { Limb l = limbs[i]; if (l == null || l.dismembered) continue; l.skinHealth = 100f; l.muscleHealth = 100f; l.bleedAmount = 0f; l.pain = 0f; l.infectionAmount = 0f; l.infected = false; l.shrapnel = 0; } } } internal static class Stats { internal static int Restores; private static readonly Dictionary counts = new Dictionary(); internal static readonly List Order = new List(); internal static void Hit(string key) { int n; if (!counts.TryGetValue(key, out n)) Order.Add(key); counts[key] = n + 1; } internal static int Get(string key) { int n; counts.TryGetValue(key, out n); return n; } } [HarmonyPatch] internal static class FreezeEnemiesPatch { private static IEnumerable TargetMethods() { List list = new List(); Add(list, typeof(GuardScript), "Update"); Add(list, typeof(TurretScript), "Update"); Add(list, typeof(CeilingTurret), "Update"); Add(list, typeof(LaserDroneScript), "Update"); Add(list, typeof(LaserDroneScript), "FixedUpdate"); Add(list, typeof(LaserDroneScript), "OnCollisionEnter2D"); Add(list, typeof(CrystalEnemy), "Update"); Add(list, typeof(CrystalEnemy), "FixedUpdate"); Add(list, typeof(SpiderHandler), "Update"); Add(list, typeof(SpiderHandler), "FixedUpdate"); Add(list, typeof(SpiderHandler), "OnCollisionStay2D"); Add(list, typeof(SpiderHandler), "OnCollisionEnter2D"); Add(list, typeof(ElderThornbackBehaviour), "Update"); Add(list, typeof(ScrapEaterScript), "Update"); Add(list, typeof(BloodSuckerScript), "OnTriggerEnter2D"); return list; } private static void Add(List list, System.Type t, string name) { System.Reflection.MethodInfo m = AccessTools.Method(t, name); if (m != null) list.Add(m); else Plugin.Log.LogWarning("Freeze: " + t.Name + "." + name + " not found"); } private static bool Prefix(MonoBehaviour __instance) { if (!Plugin.FreezeEnemies.Value) return true; BuildingEntity be = __instance.GetComponent(); if (be != null && be.health <= 0f) return true; return false; } } internal static class OneHit { internal static bool Active; internal static bool IsEnemy(BuildingEntity e) { if (e.GetComponent() != null || e.GetComponent() != null) return false; return e.animal || e.GetComponent() != null || e.GetComponent() != null || e.GetComponent() != null || e.GetComponent() != null || e.GetComponent() != null || e.GetComponent() != null || e.GetComponent() != null || e.GetComponent() != null; } } [HarmonyPatch(typeof(Body), "Attack")] internal static class MeleeHitPatch { internal static bool Melee; private static void Prefix(Body __instance) { OneHit.Active = Plugin.IsPlayer(__instance); Melee = OneHit.Active; } private static void Postfix(Body __instance, bool __result) { if (__result && Plugin.FasterAttacks.Value && Plugin.IsPlayer(__instance)) __instance.attackCooldown /= Mathf.Max(1f, Plugin.AttackSpeedMult.Value); } private static System.Exception Finalizer(System.Exception __exception) { OneHit.Active = false; Melee = false; return __exception; } } [HarmonyPatch(typeof(WorldGeneration), "DamageBlock", new[] { typeof(Vector2Int), typeof(float), typeof(bool), typeof(bool), typeof(bool) })] internal static class InstantMinePatch { private static void Prefix(WorldGeneration __instance, Vector2Int pos, ref float dmg) { if (!MeleeHitPatch.Melee || !Plugin.InstantMine.Value || dmg <= 0f) return; BlockInfo info = __instance.GetBlockInfo(__instance.GetBlock(pos)); if (info == null || info.health <= 0f || info.health >= 1E+08f) return; if (dmg < info.health) { dmg = info.health; Stats.Hit("Instant mines"); } } } [HarmonyPatch(typeof(GunScript), "Fire")] internal static class GunHitPatch { private static bool recoilSaved; private static float savedKnock; private static float savedSpread; private static void Prefix(GunScript __instance, bool suicide) { OneHit.Active = !suicide; if (!suicide && Plugin.NoRecoil.Value) { recoilSaved = true; savedKnock = __instance.knockBack; savedSpread = __instance.verticalSpread; __instance.knockBack = 0f; __instance.verticalSpread = 0f; } } private static void Postfix(GunScript __instance, bool suicide) { if (recoilSaved) { recoilSaved = false; __instance.knockBack = savedKnock; __instance.verticalSpread = savedSpread; } if (suicide || !Plugin.UnlimitedAmmo.Value) return; if (!__instance.hasMag && __instance.feedType != GunScript.FeedType.Direct) return; if (__instance.magCapacity > 0 && __instance.roundsInMag < __instance.magCapacity) { __instance.roundsInMag = __instance.magCapacity; Stats.Hit("Ammo refills"); } } private static System.Exception Finalizer(GunScript __instance, System.Exception __exception) { OneHit.Active = false; if (recoilSaved) { recoilSaved = false; __instance.knockBack = savedKnock; __instance.verticalSpread = savedSpread; } return __exception; } } [HarmonyPatch(typeof(EndLabScript), "Update")] internal static class EscapeTimerPatch { private static readonly System.Reflection.FieldInfo TimeLeft = AccessTools.Field(typeof(EndLabScript), "timeLeft"); private static EndLabScript extended; private static void Prefix(EndLabScript __instance) { if (!Plugin.LongerEscape.Value || !__instance.doTimer || extended == __instance || TimeLeft == null) return; extended = __instance; TimeLeft.SetValue(__instance, (float)TimeLeft.GetValue(__instance) + 60f); Feed.Mod("Escape timer +60s (2 minutes before the guards)"); } } [HarmonyPatch(typeof(BuildingEntity), "health", MethodType.Setter)] internal static class OneHitKillPatch { internal static bool Bypass; private static void Prefix(BuildingEntity __instance, ref float value) { if (Bypass) return; float cur = __instance.health; if (value >= cur || cur <= 0f) return; bool player = OneHit.Active; bool stronger = Plugin.StrongerEnemies.Value; if (!player && !stronger) return; if (!(player && (Plugin.OneHitKills.Value || Plugin.MoreDamage.Value)) && !stronger) return; if (!OneHit.IsEnemy(__instance)) return; float dmg = cur - value; if (stronger) dmg *= 0.5f; if (player && Plugin.MoreDamage.Value) dmg *= Mathf.Max(1f, Plugin.DamageMult.Value); value = Mathf.Max(0f, cur - dmg); if (player && Plugin.OneHitKills.Value && value > 0f) { value = 0f; Stats.Hit("One-hit kills"); Feed.Mod("One-hit kill: " + __instance.gameObject.name.Replace("(Clone)", "").Trim()); } } } [HarmonyPatch(typeof(TraderScript), "ItemPrice")] internal static class FreeShoppingPatch { private static void Postfix(ref int __result) { if (Plugin.FreeShopping.Value) __result = 0; } } [HarmonyPatch(typeof(ConsoleScript), "CheckForCheats")] internal static class CheatCheckPatch { private static bool Prefix() { Stats.Hit("Cheat flags blocked"); Feed.Mod("Blocked the game's cheat-command flag (achievements stay on)"); return false; } } [HarmonyPatch(typeof(SaveSystem), "SaveGame")] internal static class CleanSavePatch { private static void Prefix() { if (!SteamManager.disableAchievements) return; SteamManager.disableAchievements = false; Stats.Hit("Cheat flags blocked"); Feed.Mod("Saved without the cheated mark"); } } [HarmonyPatch(typeof(SaveSystem), "TryLoadGame")] internal static class CleanLoadPatch { private static void Postfix() { if (!SteamManager.disableAchievements) return; SteamManager.disableAchievements = false; Stats.Hit("Cheat flags blocked"); Feed.Mod("Removed the cheated mark from a loaded save"); } } [HarmonyPatch(typeof(ConsoleScript), "Alert")] internal static class CheatAlertPatch { private static bool Prefix(string message) { return message == null || message.IndexOf("Achievements are disabled", System.StringComparison.OrdinalIgnoreCase) < 0; } } [HarmonyPatch(typeof(PlayerCamera), "StartSelfDestruct")] internal static class GiveUpPatch { private static void Prefix(PlayerCamera __instance) { Plugin.Pause(__instance.body, "you gave up this run", false); } } [HarmonyPatch(typeof(SelfHarmer), "Suicide")] internal static class SuicidePatch { private static void Prefix(Body ___body) { if (!Plugin.GodMode.Value || !Plugin.IsPlayer(___body)) return; Item gun; bool hasGun = ___body.FindByTagThorough("gun", out gun); Plugin.Pause(___body, "suicide attempt (" + (hasGun ? "gun" : "no gun, heavy bleeding") + ")", true); } } internal static class MoodWatch { private static int lastStage; internal static float SuicideAt(Body b) { if (Body.censorMood || b.charType == 2) return float.NegativeInfinity; return b.charType == 1 ? -95f : -90f; } internal static int Stage(Body b) { if (b == null || !b.alive || b.harmer == null || !WorldGeneration.GetRunSettingBool("lowmoodevents")) return 0; float mood = b.totalHappiness; if (mood > -50f) return 0; if (mood > -70f) return 1; if (mood > SuicideAt(b)) return 2; return b.harmer.timeWasStill > 20f ? 4 : 3; } internal static void Tick() { Body b = PlayerCamera.main != null ? PlayerCamera.main.body : null; int s = Stage(b); if (s > lastStage) { if (s == 1) Feed.Add("WARNING", "#ffd966", "Mood is getting low (" + b.totalHappiness.ToString("0") + "). Self-harm starts at -70."); else if (s == 2) Feed.Add("WARNING", "#ff9a3c", "Mood " + b.totalHappiness.ToString("0") + ": standing still will trigger self-harm (God Mode heals it)."); else if (s == 3) Feed.Add("WARNING", "#ff6b6b", "SUICIDE RISK: mood " + b.totalHappiness.ToString("0") + ". Standing still triggers an attempt and God Mode will turn OFF."); else if (s == 4) Feed.Add("WARNING", "#ff3030", "SUICIDE ATTEMPT IMMINENT - keep moving!"); } lastStage = s; } internal static void Describe(StringBuilder sb, Body b) { if (b == null) return; sb.Append("MOOD\n"); float mood = b.totalHappiness; sb.Append("Mood: ").Append(mood.ToString("0")).Append(" | low-mood events: ") .Append(WorldGeneration.GetRunSettingBool("lowmoodevents") ? "on" : "off").Append('\n'); if (Plugin.Paused(b)) sb.Append("God Mode PAUSED: ").Append(Plugin.PauseReason).Append("\n"); int s = Stage(b); if (s == 0) { sb.Append("No self-harm risk\n\n"); return; } if (s == 1) { sb.Append("Mood is low. Self-harm starts at -70.\n\n"); return; } SelfHarmer h = b.harmer; if (h.cooldownTime > 0f) sb.Append("Cooldown after last attempt: ").Append(h.cooldownTime.ToString("0")).Append("s\n"); else sb.Append("Standing still: ").Append(h.timeWasStill.ToString("0.0")).Append(" / 30s (warning sound at 20s)\n"); if (s == 2) { sb.Append("Next attempt: self-harm (not deadly, God Mode heals it).\n"); if (SuicideAt(b) > float.NegativeInfinity) sb.Append("At ").Append(SuicideAt(b).ToString("0")).Append(" it becomes a suicide attempt.\n"); } else { Item gun; bool hasGun = b.FindByTagThorough("gun", out gun); sb.Append("SUICIDE RISK. Next attempt is suicide (").Append(hasGun ? "has a gun - instant death" : "no gun - heavy bleeding") .Append("). God Mode will turn OFF and let it happen. Keep moving and raise the mood.\n"); } sb.Append('\n'); } } [HarmonyPatch(typeof(Limb), "ImpactDamage")] internal static class ImpactPatch { private static bool Prefix(Limb __instance, float force) { if (!Plugin.IsPlayer(__instance.body)) return true; if (!(Plugin.NoFallDamage.Value || Plugin.GodMode.Value || Plugin.FlyMode.Value || Plugin.Noclip.Value)) return true; if (force > __instance.body.jumpSpeed) { Stats.Hit("Impacts blocked"); Feed.Mod("Blocked impact damage on " + __instance.gameObject.name); } return false; } } [HarmonyPatch(typeof(Body), "Scream")] internal static class ScreamPatch { private static bool Prefix(Body __instance) { if (!Plugin.IsPlayer(__instance)) return true; bool fallingFast = __instance.rb != null && __instance.rb.velocity.y < -__instance.jumpSpeed * 2.25f; if (fallingFast) return true; if (Plugin.GodOn(__instance)) { Stats.Hit("Screams muted"); Feed.Mod("Muted hazard scream"); return false; } return true; } } [HarmonyPatch(typeof(Talker), "Talk", new[] { typeof(List), typeof(Limb), typeof(bool), typeof(bool) })] internal static class TalkListPatch { private static bool Prefix(Talker __instance, List lines) { return !DamageLines.ShouldMute(__instance, lines, null); } } [HarmonyPatch(typeof(Talker), "Talk", new[] { typeof(string), typeof(Limb), typeof(bool), typeof(bool) })] internal static class TalkStringPatch { private static bool Prefix(Talker __instance, string text) { return !DamageLines.ShouldMute(__instance, null, text); } } internal static class DamageLines { private static readonly string[] Keys = { "steponglass", "hitbycreature", "cargoimpale", "cargoimpale2", "cargoimpale3", "vomitblood", "pain", "bigpain", "bleeding", "bleedingheavy", "limbskin", "limbmuscle", "limbinfected", "braindamaged", "cantBreathe", "lastmoments", "sick", "verysick", "freezing", "hot", "cold", "warm", "confused" }; internal static bool ShouldMute(Talker t, List lines, string text) { if (t == null || !Plugin.GodOn(t.body)) return false; int chr = t.body.charType; for (int i = 0; i < Keys.Length; i++) { List known; try { known = Locale.GetCharacter(Keys[i], chr); } catch (System.Exception) { continue; } if (known == null || known.Count == 0 || (known.Count == 1 && known[0] == Keys[i])) continue; bool hit = (lines != null && (ReferenceEquals(lines, known) || (lines.Count > 0 && known.Contains(lines[0])))) || (text != null && known.Contains(text)); if (hit) { Stats.Hit("Damage lines muted"); Feed.Mod("Muted damage line (" + Keys[i] + ")"); return true; } } return false; } } [HarmonyPatch(typeof(WorldGeneration), "CreateExplosion")] internal static class ExplosionPatch { internal static bool Active; private static float savedHearingLoss; private static void Prefix(ExplosionParams param) { Body b = PlayerCamera.main != null ? PlayerCamera.main.body : null; Active = Plugin.GodOn(b); if (Active) savedHearingLoss = b.hearingLoss; string where = b != null ? Vector2.Distance(param.position, b.transform.position).ToString("0.0") + "m away" : ""; Feed.Add("EXPLOSION", "#ff9a3c", "Range " + param.range.ToString("0.#") + ", " + where); } private static void Postfix() { if (!Active) return; Active = false; Body b = PlayerCamera.main.body; b.hearingLoss = savedHearingLoss; if (b.shock >= 100f) { Plugin.RagdollUntil = Time.time + 1.5f; Stats.Hit("Explosions absorbed"); string dmg = Plugin.DamageSummary(b); Feed.Mod("Absorbed explosion" + (dmg != null ? ": undid " + dmg : "") + " - ragdoll 1.5s"); } Plugin.Restore(b); } private static System.Exception Finalizer(System.Exception __exception) { Active = false; return __exception; } } [HarmonyPatch(typeof(Limb), "Dismember")] internal static class DismemberPatch { private static bool Prefix(Limb __instance) { if (ExplosionPatch.Active && Plugin.IsPlayer(__instance.body)) { Stats.Hit("Limb losses blocked"); Feed.Mod("Blocked explosion dismembering " + __instance.gameObject.name); return false; } return true; } } [HarmonyPatch(typeof(Body), "Disfigure")] internal static class DisfigurePatch { private static bool Prefix(Body __instance) { if (ExplosionPatch.Active && Plugin.IsPlayer(__instance)) { Stats.Hit("Disfigures blocked"); Feed.Mod("Blocked disfigurement"); return false; } return true; } } [HarmonyPatch(typeof(Body), "RemoveEye")] internal static class RemoveEyePatch { private static bool Prefix(Body __instance) { if (ExplosionPatch.Active && Plugin.IsPlayer(__instance)) { Stats.Hit("Eye losses blocked"); Feed.Mod("Blocked eye loss"); return false; } return true; } } [HarmonyPatch(typeof(Limb), "DamageWearables")] internal static class WearablesPatch { private static bool Prefix(Limb __instance) { if (ExplosionPatch.Active && Plugin.IsPlayer(__instance.body)) { Stats.Hit("Armor hits blocked"); return false; } return true; } } [HarmonyPatch(typeof(Limb), "BreakBone")] internal static class BreakBonePatch { private static bool Prefix(Limb __instance) { if (Plugin.GodOn(__instance.body) && !__instance.broken) { Stats.Hit("Bone breaks blocked"); Feed.Mod("Blocked broken bone: " + __instance.gameObject.name); return false; } return !Plugin.GodOn(__instance.body); } } [HarmonyPatch(typeof(Limb), "Dislocate")] internal static class DislocatePatch { private static bool Prefix(Limb __instance) { if (!Plugin.GodOn(__instance.body)) return true; if (!__instance.dislocated) { Stats.Hit("Dislocations blocked"); Feed.Mod("Blocked dislocation: " + __instance.gameObject.name); } return false; } } [HarmonyPatch(typeof(Body), "Update")] internal static class BodyUpdatePatch { private static float lastLog; private static void Prefix(Body __instance) { if (!Plugin.GodOn(__instance)) return; string dmg = Plugin.DamageSummary(__instance); if (dmg != null) { Stats.Hit("Damage undone"); if (Time.unscaledTime - lastLog > 0.25f) { lastLog = Time.unscaledTime; Feed.Mod("Undid damage: " + dmg); } } Plugin.Restore(__instance); } private static void Postfix(Body __instance) { if (Plugin.GodOn(__instance)) Plugin.Restore(__instance); if (Plugin.IsPlayer(__instance)) Plugin.ApplyKeeps(__instance); } } [HarmonyPatch(typeof(Body), "HandlePeriodicChecks")] internal static class EncumbrancePatch { private static void Postfix(Body __instance) { if (Plugin.UnlimitedCarry.Value && Plugin.IsPlayer(__instance)) __instance.overEncumberance = 0f; } } internal static class Targets { internal static void Add(List list, System.Type t, string name) { System.Reflection.MethodInfo m = AccessTools.DeclaredMethod(t, name); if (m != null) list.Add(m); else Plugin.Log.LogWarning("Patch target " + t.Name + "." + name + " not found"); } } [HarmonyPatch(typeof(WorldGeneration), "GetRunSettingFloat")] internal static class RunFloatPatch { private static void Postfix(string name, ref float __result) { switch (name) { case "healingrate": if (Plugin.FasterHealing.Value) __result *= Mathf.Max(1f, Plugin.HealingMult.Value); break; case "metabolismrate": if (Plugin.FastMetabolism.Value) __result *= 2f; break; case "xpgain": if (Plugin.MoreXp.Value) __result *= Mathf.Max(1f, Plugin.XpMult.Value); break; case "baselootdensity": if (Plugin.MoreLoot.Value) __result *= Mathf.Max(1f, Plugin.LootMult.Value); if (Plugin.LootScarcity.Value) __result *= 0.4f; break; case "basetrapdensity": if (Plugin.MoreTraps.Value) __result *= 2f; break; case "enemystrength": if (Plugin.StrongerEnemies.Value) __result *= 1.75f; break; case "temperatureoffset": if (Plugin.ColdCaves.Value) __result -= 15f; break; case "itemdecayrate": if (Plugin.BrittleGear.Value) __result *= 3f; break; case "timelimit": if (Plugin.FastRadiation.Value) __result *= 0.5f; break; } } } [HarmonyPatch(typeof(WorldGeneration), "GetRunSettingInt")] internal static class RunIntPatch { private static void Postfix(string name, ref int __result) { if (name == "startingsupplies" && Plugin.HopelessStart.Value) __result = 0; } } [HarmonyPatch(typeof(WorldGeneration), "GetRunSettingBool")] internal static class RunBoolPatch { private static void Postfix(string name, ref bool __result) { if (name == "unchipped" && Plugin.UnchippedChallenge.Value) __result = true; } } [HarmonyPatch(typeof(Body), "actualMaxSpeed", MethodType.Getter)] internal static class MaxSpeedPatch { private static void Postfix(Body __instance, ref float __result) { if (Plugin.FasterMovement.Value && Plugin.IsPlayer(__instance)) __result *= Mathf.Max(1f, Plugin.MoveSpeedMult.Value); } } [HarmonyPatch(typeof(Body), "actualMoveForce", MethodType.Getter)] internal static class MoveForcePatch { private static void Postfix(Body __instance, ref float __result) { if (Plugin.FasterMovement.Value && Plugin.IsPlayer(__instance)) __result *= Mathf.Max(1f, Plugin.MoveSpeedMult.Value); } } [HarmonyPatch(typeof(Body), "actualJumpSpeed", MethodType.Getter)] internal static class JumpSpeedPatch { private static void Postfix(Body __instance, ref float __result) { if (Plugin.HigherJumps.Value && Plugin.IsPlayer(__instance)) __result *= Mathf.Max(1f, Plugin.JumpMult.Value); } } [HarmonyPatch(typeof(Body), "HandleClimbing")] internal static class ClimbPatch { private static void Postfix(Body __instance) { if (!Plugin.FasterClimbing.Value || !Plugin.IsPlayer(__instance)) return; Climbable c = __instance.currentClimbable; if (c == null || !__instance.standing) return; float extra = __instance.climbVelocity * Time.fixedDeltaTime * (Mathf.Max(1f, Plugin.ClimbSpeedMult.Value) - 1f); if (extra == 0f) return; __instance.climbableProgress = Mathf.Clamp(__instance.climbableProgress + extra, 0.01f, c.totalLength); __instance.rb.MovePosition(c.GetPositionAtDistance(__instance.climbableProgress)); } } [HarmonyPatch(typeof(Body), "Jump")] internal static class JumpPatch { private static readonly System.Reflection.FieldInfo Cooldown = AccessTools.Field(typeof(Body), "jumpCooldown"); private static readonly System.Reflection.FieldInfo SinceGrounded = AccessTools.Field(typeof(Body), "timeSinceGrounded"); private static readonly System.Reflection.FieldInfo FirstWall = AccessTools.Field(typeof(Body), "firstWallJump"); private static void Prefix(Body __instance) { if (!Plugin.IsPlayer(__instance)) return; if (Plugin.UnlimitedJumps.Value && __instance.standing && !__instance.grounded) { if (Cooldown != null) Cooldown.SetValue(__instance, 0f); if (SinceGrounded != null) SinceGrounded.SetValue(__instance, 0f); } if (Plugin.UnlimitedWallJumps.Value && FirstWall != null) FirstWall.SetValue(__instance, true); } } [HarmonyPatch(typeof(Limb), "GetArmorReduction")] internal static class FragilePatch { private static void Postfix(Limb __instance, ref float __result) { if (Plugin.FragileBody.Value && Plugin.IsPlayer(__instance.body)) __result *= 0.5f; } } [HarmonyPatch(typeof(Recipe), "TryMake")] internal static class FreeCraftPatch { private static bool Prefix(Recipe __instance) { if (!Plugin.FreeCrafting.Value) return true; Body b = PlayerCamera.main != null ? PlayerCamera.main.body : null; if (b == null) return true; __instance.result.SpawnResult(__instance.INT); Sound.Play("combine", b.transform.position); if (!__instance.hasMadeBefore) { __instance.hasMadeBefore = true; b.happiness++; b.skills.AddExp(2, 10f); } PlayerCamera.main.PlayUISound(PlayerCamera.UISoundType.Click); Stats.Hit("Free crafts"); return false; } } [HarmonyPatch(typeof(Recipe), "GetItemsForRecipe")] internal static class FreeCraftListPatch { private static void Postfix(ref List __result) { if (__result == null && Plugin.FreeCrafting.Value) __result = new List(); } } [HarmonyPatch(typeof(Recipe), "visible", MethodType.Getter)] internal static class AllRecipesPatch { private static void Postfix(ref bool __result) { if (Plugin.AllRecipes.Value) __result = true; } } [HarmonyPatch(typeof(RecipeResult), "SpawnResult")] internal static class NoCraftFailPatch { private static void Prefix(ref int recipeInt) { if (Plugin.NoCraftFail.Value) recipeInt = -1000; } } internal static class Durability { private static readonly Dictionary held = new Dictionary(); private static readonly Dictionary cache = new Dictionary(); private static float nextSweep; private static bool Protected(Item it) { if (string.IsNullOrEmpty(it.id)) return false; bool r; if (cache.TryGetValue(it.id, out r)) return r; r = Decide(it); cache[it.id] = r; return r; } private static bool Decide(Item it) { ItemInfo s; try { s = it.Stats; } catch (System.Exception) { return false; } if (s == null) return false; if (s is LiquidItemInfo || it.GetComponent() != null) return false; if (s is BatteryInfo || it.GetComponent() != null) return true; if (it.GetComponent() != null) return true; if (s.category == "container" || it.GetComponent() != null) return true; if (s.category == "tool") return true; try { if (s.HasTag("tool")) return true; } catch (System.Exception) { } return s.wearable; } internal static void Hold(Item it) { if (!Plugin.NoDegradation.Value || it == null || !Protected(it)) return; float c = it.condition; float t; if (it.battery != null && !it.battery.hasBattery) { held[it] = c; return; } if (!held.TryGetValue(it, out t) || c >= t) { held[it] = c; return; } it.condition = t; } internal static void Accept(Item it) { if (it != null && held.ContainsKey(it)) held[it] = it.condition; } internal static void Sweep() { if (Time.unscaledTime < nextSweep) return; nextSweep = Time.unscaledTime + 30f; if (!Plugin.NoDegradation.Value) { held.Clear(); return; } List dead = null; foreach (Item k in held.Keys) if (k == null) { if (dead == null) dead = new List(); dead.Add(k); } if (dead != null) for (int i = 0; i < dead.Count; i++) held.Remove(dead[i]); } } [HarmonyPatch(typeof(Item), "Update")] internal static class ItemHoldPatch { private static void Prefix(Item __instance) { Durability.Hold(__instance); } } [HarmonyPatch(typeof(RecipeItem), "UseItem")] internal static class RecipeUsePatch { private static void Postfix(RecipeItem __instance, Item item) { if (__instance != null && __instance.destroyItem) Durability.Accept(item); } } [HarmonyPatch(typeof(Body), "CombineItems")] internal static class CombinePatch { private static void Postfix(Item it1, Item it2) { Durability.Accept(it1); Durability.Accept(it2); } } [HarmonyPatch(typeof(BatteryItem), "DrainCharge")] internal static class BatteryPatch { private static bool Prefix() { return !Plugin.UnlimitedBattery.Value; } } [HarmonyPatch(typeof(WaterContainerItem), "Drain")] internal static class LiquidPatch { private static bool Prefix() { return !Plugin.UnlimitedLiquids.Value; } } [HarmonyPatch(typeof(LockpingMinigame), "MaxTurnProgress")] internal static class LockAnglePatch { private static void Postfix(ref float __result) { if (Plugin.MasterLockpick.Value) __result = 1f; } } [HarmonyPatch(typeof(LockpingMinigame), "Update")] internal static class LockSpeedPatch { private static void Prefix(LockpingMinigame __instance) { if (Plugin.MasterLockpick.Value && __instance.clickingInside && __instance.lockProgress < 0.98f) __instance.lockProgress = 0.98f; } } [HarmonyPatch(typeof(GunScript), "JamChance")] internal static class JamPatch { private static void Postfix(ref float __result) { if (Plugin.NoGunJams.Value) __result = 0f; } } [HarmonyPatch] internal static class InvisibilityPatch { private static IEnumerable TargetMethods() { List list = new List(); Targets.Add(list, typeof(TurretScript), "Update"); Targets.Add(list, typeof(CeilingTurret), "Update"); Targets.Add(list, typeof(LaserDroneScript), "FireShot"); Targets.Add(list, typeof(GuardScript), "Fire"); Targets.Add(list, typeof(CrystalEnemy), "Lunge"); Targets.Add(list, typeof(GrabberPlant), "Update"); Targets.Add(list, typeof(GrabberPlant), "FixedUpdate"); Targets.Add(list, typeof(ElderThornbackBehaviour), "Update"); return list; } private static bool Prefix() { return !Plugin.Invisibility.Value; } } [HarmonyPatch(typeof(GuardScript), "MeleeAttack")] internal static class GuardMeleePatch { private static IEnumerator Nothing() { yield break; } private static bool Prefix(ref IEnumerator __result) { if (!Plugin.Invisibility.Value) return true; __result = Nothing(); return false; } } [HarmonyPatch] internal static class SpiderBitePatch { private static IEnumerable TargetMethods() { List list = new List(); Targets.Add(list, typeof(SpiderHandler), "DamageLimb"); Targets.Add(list, typeof(SpiderHandlerTBE), "DamageLimb"); return list; } private static bool Prefix(Limb limb) { return !(Plugin.Invisibility.Value && limb != null && Plugin.IsPlayer(limb.body)); } } [HarmonyPatch(typeof(BloodSuckerScript), "BeginSucc")] internal static class BloodSuckerPatch { private static bool Prefix(Limb lm) { return !(Plugin.Invisibility.Value && lm != null && Plugin.IsPlayer(lm.body)); } } [HarmonyPatch] internal static class TrapPatch { private static IEnumerable TargetMethods() { List list = new List(); Targets.Add(list, typeof(BearTrap), "OnTriggerEnter2D"); Targets.Add(list, typeof(MineScript), "Update"); Targets.Add(list, typeof(MineScript), "OnCollisionEnter2D"); Targets.Add(list, typeof(SpikeStabberScript), "OnTriggerEnter2D"); Targets.Add(list, typeof(SpikeStabberScript), "Stab"); Targets.Add(list, typeof(SpikeStabberScript), "CheckStab"); Targets.Add(list, typeof(SoundCannon), "Update"); Targets.Add(list, typeof(FanTrap), "Update"); Targets.Add(list, typeof(FanTrap), "FixedUpdate"); Targets.Add(list, typeof(GunmineScript), "OnWillRenderObject"); Targets.Add(list, typeof(TurretScript), "Update"); Targets.Add(list, typeof(CeilingTurret), "Update"); return list; } private static bool Prefix() { return !Plugin.DisableTraps.Value; } } [HarmonyPatch(typeof(RadiationLine), "Update")] internal static class RadiationPatch { private static readonly System.Reflection.FieldInfo Gone = AccessTools.Field(typeof(RadiationLine), "timeGone"); private static bool Prefix() { return !Plugin.PauseRadiation.Value; } private static void Postfix(RadiationLine __instance) { if (Plugin.PauseRadiation.Value || !Plugin.FastRadiation.Value || !__instance.active) return; Body b = PlayerCamera.main != null ? PlayerCamera.main.body : null; if (b == null || Gone == null) return; Gone.SetValue(__instance, (float)Gone.GetValue(__instance) + Time.deltaTime * (b.conscious ? 1f : 0.2f) * 1.5f); } } [HarmonyPatch(typeof(WorldGeneration), "Update")] internal static class WorldUpdatePatch { private static float savedLayerTime; private static void Prefix(WorldGeneration __instance) { savedLayerTime = __instance.layerTimeSpent; if (Plugin.NoEarthquakes.Value) { if (__instance.earthquakeDelay < 30f) __instance.earthquakeDelay = 30f; __instance.earthquakeTime = 0f; __instance.earthquakeIntensity = 0f; } } private static void Postfix(WorldGeneration __instance) { if (Plugin.PauseRadiation.Value) __instance.layerTimeSpent = savedLayerTime; else if (Plugin.FastRadiation.Value) __instance.layerTimeSpent += Time.deltaTime; if (Actions.DownpourUntil <= Time.time || !__instance.worldExists) return; Body b = PlayerCamera.main != null ? PlayerCamera.main.body : null; if (b == null) return; __instance.fungusRainIntensity = 1f; if (__instance.rainSprite != null) __instance.rainSprite.color = Color.white; if (__instance.rainLoopSource != null) __instance.rainLoopSource.volume = 1f; if (b.wetness < 100f) b.wetness = Mathf.MoveTowards(b.wetness, 100f, Time.deltaTime); b.dirtyness = Mathf.MoveTowards(b.dirtyness, 0f, Time.deltaTime); } } internal static class Actions { internal static float DownpourUntil; private static float skipCooldown; private static Body Player() { return PlayerCamera.main != null && WorldGeneration.world != null ? PlayerCamera.main.body : null; } internal static string HealWounds() { Body b = Player(); if (b == null) return "Not in a run"; Limb[] ls = b.limbs; for (int i = 0; i < ls.Length; i++) if (ls[i] != null && !ls[i].dismembered) ls[i].Heal(); Plugin.Restore(b); b.hearingLoss = 0f; return "Healed all wounds"; } internal static string Emergency(string id) { Body b = Player(); if (b == null) return "Not in a run"; Limb[] ls = b.limbs ?? new Limb[0]; switch (id) { case "em_full": HealWounds(); ReattachLimbs(); if (b.hunger < 100f) b.hunger = 100f; if (b.thirst < 100f) b.thirst = 100f; return "Full restore: wounds, limbs, blood, food and water"; case "em_bleed": for (int i = 0; i < ls.Length; i++) if (ls[i] != null && !ls[i].dismembered) ls[i].bleedAmount = 0f; b.internalBleeding = 0f; b.hemothorax = 0f; if (b.bloodVolume < 70f) b.bloodVolume = 70f; return "Bleeding stopped"; case "em_breathe": b.bloodOxygen = 100f; b.hasPulmonaryEmbolism = false; b.hemothorax = 0f; b.barotrauma = 0f; return "Breathing fixed, oxygen full"; case "em_heart": b.fibrillationProgress = 0f; if (b.heartRate > 160f || b.heartRate < 40f) b.heartRate = 80f; if (b.bloodPressure < 100f) b.bloodPressure = 110f; b.shock = 0f; b.painShock = 0f; b.strokeAmount = 0f; if (b.brainHealth < 60f) b.brainHealth = 60f; if (!b.sleeping) b.consciousness = 100f; return "Heart and circulation stabilised"; case "em_cure": for (int i = 0; i < ls.Length; i++) if (ls[i] != null && !ls[i].dismembered) { ls[i].infectionAmount = 0f; ls[i].infected = false; } b.sicknessAmount = 0f; b.radiationSickness = 0f; b.venomCurrent = 0f; b.septicShock = 0f; return "Infection, sickness, radiation and venom cured"; case "em_body": b.temperature = 37f; if (b.hunger < 100f) b.hunger = 100f; if (b.thirst < 100f) b.thirst = 100f; else if (b.thirst > 150f) b.thirst = 120f; for (int i = 0; i < ls.Length; i++) if (ls[i] != null) ls[i].pain = 0f; return "Fed, watered, warm and pain-free"; } return null; } internal static string ReattachLimbs() { Body b = Player(); if (b == null) return "Not in a run"; int n = 0; Limb[] ls = b.limbs; for (int i = 0; i < ls.Length; i++) { Limb l = ls[i]; if (l == null || !l.dismembered || l.prostheticInfo.hasProsthetic) continue; l.Reattach(); n++; } return n == 0 ? "No missing limbs" : "Reattached " + n + " limb" + (n == 1 ? "" : "s"); } internal static string KillAllEnemies() { if (Player() == null) return "Not in a run"; int n = 0; BuildingEntity[] all = Object.FindObjectsOfType(); OneHitKillPatch.Bypass = true; try { for (int i = 0; i < all.Length; i++) { BuildingEntity e = all[i]; if (e == null || e.health <= 0f || !OneHit.IsEnemy(e)) continue; e.health = 0f; n++; } } finally { OneHitKillPatch.Bypass = false; } return "Killed " + n + " enem" + (n == 1 ? "y" : "ies"); } internal static string SpiderAmbush() { Body b = Player(); if (b == null) return "Not in a run"; WorldGeneration w = WorldGeneration.world; int n = 0; for (int tries = 0; tries < 60 && n < 4; tries++) { Vector2 pos = (Vector2)b.transform.position + Random.insideUnitCircle.normalized * Random.Range(5f, 11f); try { if (w.GetBlock(pos) != 0) continue; Utils.Create("cavetick", pos, 0f); n++; } catch (System.Exception) { } } return n == 0 ? "No room for spiders here" : n + " spiders incoming!"; } internal static string SkipLayer() { Body b = Player(); WorldGeneration w = WorldGeneration.world; if (b == null) return "Not in a run"; if (w.generatingWorld || !w.worldExists || Time.unscaledTime < skipCooldown) return "Wait for the layer to finish loading"; if (w.biomeOverride != WorldGeneration.OverrideSceneType.None) return "Can't skip layers here"; if (w.biomeDepth >= 9) return "Can't skip from this layer"; skipCooldown = Time.unscaledTime + 8f; b.forceWalk = false; if (w.savePanel != null) w.savePanel.SetActive(false); PlayerPrefs.SetInt("deepestlayer", System.Math.Max(w.biomeDepth + 1, PlayerPrefs.GetInt("deepestlayer"))); w.StartCoroutine(w.RegenerateWorld(false)); return "Skipping to the next layer"; } private static readonly System.Reflection.MethodInfo InstantiateWorldMethod = AccessTools.Method(typeof(WorldGeneration), "InstantiateWorld"); private static readonly System.Reflection.FieldInfo DoingRegenField = AccessTools.Field(typeof(WorldGeneration), "doingRegen"); internal static string PreviousLayer() { Body b = Player(); WorldGeneration w = WorldGeneration.world; if (b == null) return "Not in a run"; if (w.generatingWorld || !w.worldExists || Time.unscaledTime < skipCooldown) return "Wait for the layer to finish loading"; if (w.biomeOverride != WorldGeneration.OverrideSceneType.None) return "Can't change layers here"; if (w.biomeDepth < 1) return "You're already on the first layer"; if (InstantiateWorldMethod == null || GlobalDark.main == null) return "Couldn't go back a layer in this game version"; skipCooldown = Time.unscaledTime + 8f; b.forceWalk = false; if (w.savePanel != null) w.savePanel.SetActive(false); int target = w.biomeDepth - 1; w.StartCoroutine(GoBack(w, target)); return "Going back to layer " + (target + 1); } private static IEnumerator GoBack(WorldGeneration w, int target) { if (DoingRegenField != null) DoingRegenField.SetValue(w, true); w.canStartMercRun = false; GlobalDark.main.Darken(); while (GlobalDark.main.IsDarkening()) yield return null; w.biomeDepth = target; Feed.Mod("Going back to layer " + (target + 1)); yield return w.Clear(); if (DoingRegenField != null) DoingRegenField.SetValue(w, false); yield return (IEnumerator)InstantiateWorldMethod.Invoke(w, new object[] { true }); } internal static void Teleport(Body b, Vector2 pos) { b.transform.position = pos; if (b.rb != null) b.rb.velocity = Vector2.zero; Vector3 cp = PlayerCamera.main.transform.position; PlayerCamera.main.transform.position = new Vector3(pos.x, pos.y, cp.z); if (ConsoleScript.instance != null) ConsoleScript.instance.noClipPos = pos; } internal static string TeleportToCursor() { Body b = Player(); if (b == null || Camera.main == null) return "Not in a run"; Teleport(b, Camera.main.ScreenToWorldPoint(Input.mousePosition)); return null; } internal static string TeleportToExit() { Body b = Player(); WorldGeneration w = WorldGeneration.world; if (b == null) return "Not in a run"; if (w.generatingWorld || !w.worldExists) return "Wait for the layer to finish loading"; if (w.biomeOverride != WorldGeneration.OverrideSceneType.None || w.biomeDepth >= 9) return "No layer exit here"; Vector2 pos = new Vector2(b.transform.position.x, -(float)w.halfHeight + 2.5f); w.GenerateBlockCircle(pos, 3, 0, 1f, 1f, true); Teleport(b, pos); return "Teleported to the layer exit"; } internal static string StartEarthquake() { WorldGeneration w = WorldGeneration.world; if (Player() == null) return "Not in a run"; if (Plugin.NoEarthquakes.Value) return "Turn off No Earthquakes first"; w.earthquakeTime = Random.Range(10f, 20f); if (PlayerCamera.main.shaker != null) PlayerCamera.main.shaker.Shake(150f); return "Earthquake!"; } internal static string FungalDownpour() { if (Player() == null) return "Not in a run"; DownpourUntil = Time.time + 60f; return "Fungal downpour for 60 seconds"; } internal static string UnlockCharacters() { for (int i = 0; i < 10; i++) if (PlayerPrefs.GetInt("wonchar" + i, 0) <= 0) PlayerPrefs.SetInt("wonchar" + i, 1); PlayerPrefs.Save(); return "All characters unlocked"; } internal static string SpawnItem(string id, int amount) { Body b = Player(); if (b == null) return "Not in a run"; if (Resources.Load(id) as GameObject == null) return "Can't spawn " + id; for (int i = 0; i < amount; i++) { GameObject g = Utils.Create(id, b.transform.position, 0f); Item it = g != null ? g.GetComponent() : null; if (it != null) b.AutoPickUpItem(it); } Stats.Hit("Items spawned"); return "Spawned " + ItemName(id) + (amount > 1 ? " x" + amount : ""); } internal static string StarterKit() { if (Player() == null || ConsoleScript.instance == null) return "Not in a run"; System.Reflection.MethodInfo m = AccessTools.Method(typeof(ConsoleScript), "RunCommandString"); if (m == null) return "Starter kit isn't available"; m.Invoke(ConsoleScript.instance, new object[] { "starterkit" }); return "Starter kit spawned"; } internal static string RandomLoadout() { Body b = Player(); if (b == null || Item.GlobalItems == null) return "Not in a run"; List ids = new List(Item.GlobalItems.Keys); int n = 0; for (int tries = 0; tries < 60 && n < 6; tries++) { string id = ids[Random.Range(0, ids.Count)]; GameObject prefab = Resources.Load(id) as GameObject; if (prefab == null || prefab.GetComponent() == null) continue; SpawnItem(id, 1); n++; } return "Random loadout: " + n + " items"; } internal static string ItemName(string id) { try { string s = Locale.GetItem(id); if (!string.IsNullOrEmpty(s)) return s; } catch (System.Exception) { } return id; } internal static string AddSkill(int stat, int delta) { Body b = Player(); if (b == null || b.skills == null) return "Not in a run"; Skills s = b.skills; int v = Mathf.Clamp((stat == 0 ? s.STR : stat == 1 ? s.RES : s.INT) + delta, 0, 40); float xp = Skills.GetExperienceForLevel(v); if (stat == 0) { s.STR = v; s.expSTR = xp; } else if (stat == 1) { s.RES = v; s.expRES = xp; } else { s.INT = v; s.expINT = xp; } s.UpdateExpBoundaries(); return (stat == 0 ? "Strength " : stat == 1 ? "Resilience " : "Intelligence ") + v; } } [HarmonyPatch(typeof(Body), "FixedUpdate")] internal static class BodyFixedUpdatePatch { private static void Postfix(Body __instance) { if (Plugin.GodOn(__instance)) Plugin.Restore(__instance); if (!Plugin.IsPlayer(__instance)) return; Plugin.ApplyKeeps(__instance); Rigidbody2D rb = __instance.rb; if (rb == null || !rb.simulated) return; if (Plugin.FlyMode.Value && __instance.standing && __instance.currentClimbable == null) { rb.gravityScale = 0f; Vector2 dir = __instance.moveDir; if (Input.GetKey(KeyCode.Space)) dir.y = 1f; if (dir.sqrMagnitude > 1f) dir.Normalize(); float speed = Mathf.Max(1f, Plugin.FlySpeed.Value) * (Input.GetKey(KeyCode.LeftShift) ? 2.5f : 1f); rb.velocity = Vector2.Lerp(rb.velocity, dir * speed, 0.35f); } else if (Plugin.LowGravity.Value) { rb.gravityScale *= Mathf.Clamp(Plugin.GravityScale.Value, 0.05f, 1f); } } } }