using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")] [assembly: AssemblyVersion("0.0.0.0")] namespace LevelAtFeet; [BepInPlugin("com.matviy.levelatfeet", "LevelAtFeet", "2.4.4")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "com.matviy.levelatfeet"; public const string PluginName = "LevelAtFeet"; public const string PluginVersion = "2.4.4"; internal static ManualLogSource Log; internal static ConfigEntry Enabled; internal static ConfigEntry MaxStepPerClick; internal static ConfigEntry ClearRocksInRadius; internal static ConfigEntry RemoveVanillaHeightCap; internal static ConfigEntry MaxHeightDelta; internal static ConfigEntry RadiusScrollEnabled; internal static ConfigEntry RadiusScrollKey; internal static ConfigEntry RadiusScrollStep; internal static ConfigEntry RadiusScrollMin; internal static ConfigEntry RadiusScrollMax; private void Awake() { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown //IL_021c: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "LevelToPlayerHeight", true, "Якщо true - 'Вирівняти землю' завжди рівняє до висоти, на якій стоїть гравець, і завжди спрацьовує (навіть біля каменів/скель). Вимкни (false), щоб повернути ванільну поведінку."); MaxStepPerClick = ((BaseUnityPlugin)this).Config.Bind("General", "MaxStepPerClick", 1f, "Максимальна зміна висоти (в метрах) за один клік. За замовчуванням = 1 - великі перепади вирівнюються поступово, за кілька кліків. Збільш це число (напр. до 1000), якщо натомість хочеш, щоб будь-який перепад рівнявся повністю за один клік. (Примітка: якщо конфіг-файл вже існує з іншим значенням, збережене в ньому число має пріоритет над цим за замовчуванням - постав своє число прямо у файлі, якщо треба.)"); ClearRocksInRadius = ((BaseUnityPlugin)this).Config.Bind("General", "ClearRocksInRadius", true, "Якщо true - разом з вирівнюванням землі 'Вирівняти землю' також знищує кам'яні/рудні об'єкти (MineRock і MineRock5 - валуни, брили руди тощо) і дрібне 'сміття' на кшталт пеньків чи завалів (Destructible) в радіусі дії інструмента, наче їх зачистили інструментом. Дроп ресурсів з них випадає як завжди. НЕ прибирає звичайні (незруйновувані за задумом гри) скельні масиви/гори без жодного з цих компонентів - таке не можна 'видобути' жодним інструментом навіть у ванільній грі. Вимкни (false), щоб такі об'єкти й надалі треба було довбати киркою вручну."); RemoveVanillaHeightCap = ((BaseUnityPlugin)this).Config.Bind("General", "RemoveVanillaHeightCap", true, "Гра має вбудований ліміт: висоту будь-якої точки рельєфу можна змінити не більше ніж на ±8м від її ОРИГІНАЛЬНОЇ (згенерованої світом) висоти - назавжди, скільки б разів ти не клікав 'Вирівняти' чи 'Насипати землю'. Саме через це деякі глибокі ями чи високі кам'яні гори неможливо довести до кінця жодним інструментом рельєфу, і доводиться вручну підсипати чи докопувати з боків. Якщо true - цей ліміт замінюється на значення з MaxHeightDeltaLimit нижче (за замовчуванням дуже велике - фактично без обмежень). Потребує перезапуску гри, щоб зміна значення набула сили. Вимкни (false), щоб залишити ванільний ліміт ±8м."); MaxHeightDelta = ((BaseUnityPlugin)this).Config.Bind("General", "MaxHeightDeltaLimit", 10000f, "Новий ліміт (в метрах) сумарної зміни висоти рельєфу, якщо RemoveVanillaHeightCap = true. За замовчуванням дуже велике число - фактично без обмежень."); RadiusScrollEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "RadiusScrollEnabled", true, "Якщо true - радіус дії інструментів рельєфу (Вирівняти/Насипати/Згладити землю) можна змінювати клавішами ] (збільшити) і [ (зменшити), тримаючи натиснутою клавішу з RadiusScrollKey нижче. Колесико миші більше в цьому не бере участі - воно завжди керує лише зумом камери, як завжди. Вимкни (false), щоб повернути ванільний фіксований радіус."); RadiusScrollKey = ((BaseUnityPlugin)this).Config.Bind("General", "RadiusScrollKey", (KeyCode)306, "Клавіша-модифікатор, яку треба тримати разом з [ / ], щоб змінити радіус інструмента. За замовчуванням Left Ctrl - ОКРЕМА від ігрових keybind'ів (не 'AltPlace'), бо 'AltPlace' сама гра вже використовує для власної спецповедінки саме для інструментів рельєфу (m_allowAltGroundPlacement - міняє спосіб прицілювання), яка заважала цій фічі. Можна поставити будь-яку іншу клавішу прямо тут, у файлі конфігу (напр. LeftAlt, LeftShift, CapsLock тощо) - Shift тут ні на що не заважає, бо ця фіча не залежить від колесика миші."); RadiusScrollStep = ((BaseUnityPlugin)this).Config.Bind("General", "RadiusScrollStep", 0.5f, "На скільки метрів змінюється радіус інструмента за одне натискання [ або ]."); RadiusScrollMin = ((BaseUnityPlugin)this).Config.Bind("General", "RadiusScrollMin", 1f, new ConfigDescription("Мінімальний радіус (в метрах), до якого можна зменшити.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 10f), Array.Empty())); RadiusScrollMax = ((BaseUnityPlugin)this).Config.Bind("General", "RadiusScrollMax", 10f, new ConfigDescription("Максимальний радіус (в метрах), до якого можна збільшити. Жорстко обмежено діапазоном 1-10 - навіть старе значення 20 зі старого конфігу буде автоматично підтягнуте до 10.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 10f), Array.Empty())); Harmony val = new Harmony("com.matviy.levelatfeet"); TryPatch(val, typeof(TerrainComp_LevelTerrain_Patch), "level-target fix (TerrainComp.LevelTerrain)"); TryPatch(val, typeof(TerrainComp_SmoothTerrain_LevelPatch), "level-target fix (TerrainComp.SmoothTerrain - the REAL 'Вирівняти землю' method)"); TryPatch(val, typeof(Player_UpdatePlacementGhost_Patch), "placement-block fix (Player.UpdatePlacementGhost)"); TryPatch(val, typeof(TerrainComp_ClearRocks_Patch), "rock-clearing fix (MineRock destroy in radius)"); TryPatch(val, typeof(TerrainComp_RaiseTerrain_RemoveCap_Patch), "height-cap fix (TerrainComp.RaiseTerrain)"); TryPatch(val, typeof(TerrainComp_PaintCleared_Patch), "resize fix (TerrainComp.PaintCleared - grass clearing)"); Log.LogInfo((object)$"[LevelAtFeet] RadiusScrollEnabled={RadiusScrollEnabled.Value}, RadiusScrollKey loaded as: '{RadiusScrollKey.Value}'"); Log.LogInfo((object)"LevelAtFeet 2.4.4 loaded."); } private static void TryPatch(Harmony harmony, Type patchClass, string label) { try { harmony.CreateClassProcessor(patchClass).Patch(); Log.LogInfo((object)("[LevelAtFeet] OK: " + label)); } catch (Exception arg) { Log.LogError((object)$"[LevelAtFeet] FAILED: {label}\n{arg}"); } } } [HarmonyPatch(typeof(TerrainComp), "LevelTerrain")] public static class TerrainComp_LevelTerrain_Patch { private static void Prefix(ref Vector3 worldPos, ref float radius) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (Plugin.RadiusScrollEnabled.Value) { radius = Mathf.Clamp(radius + RadiusScrollUtil.CurrentOffset, Plugin.RadiusScrollMin.Value, Plugin.RadiusScrollMax.Value); } if (Plugin.Enabled.Value && !((Object)(object)Player.m_localPlayer == (Object)null)) { float y = ((Component)Player.m_localPlayer).transform.position.y; float value = Plugin.MaxStepPerClick.Value; float num = default(float); if (Heightmap.GetHeight(worldPos, ref num)) { float num2 = Mathf.Clamp(y - num, 0f - value, value); worldPos.y = num + num2; } else { worldPos.y = y; } } } private static IEnumerable Transpiler(IEnumerable instructions) { return HeightCapUtil.RaiseClampBounds(instructions, 8f); } } [HarmonyPatch(typeof(TerrainComp), "SmoothTerrain")] public static class TerrainComp_SmoothTerrain_LevelPatch { private const float FlattenPower = 1000f; private static void Prefix(ref Vector3 worldPos, ref float radius, ref float power) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (Plugin.RadiusScrollEnabled.Value) { radius = Mathf.Clamp(radius + RadiusScrollUtil.CurrentOffset, Plugin.RadiusScrollMin.Value, Plugin.RadiusScrollMax.Value); } if (!Plugin.Enabled.Value || (Object)(object)Player.m_localPlayer == (Object)null) { power = 1000f; return; } float y = ((Component)Player.m_localPlayer).transform.position.y; float value = Plugin.MaxStepPerClick.Value; float num = default(float); if (Heightmap.GetHeight(worldPos, ref num)) { float num2 = Mathf.Clamp(y - num, 0f - value, value); worldPos.y = num + num2; } else { worldPos.y = y; } power = 1000f; } private static IEnumerable Transpiler(IEnumerable instructions) { return HeightCapUtil.RaiseClampBounds(instructions, 1f); } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] public static class Player_UpdatePlacementGhost_Patch { private static readonly FieldInfo GhostField = AccessTools.Field(typeof(Player), "m_placementGhost"); private static readonly FieldInfo StatusField = AccessTools.Field(typeof(Player), "m_placementStatus"); private static void Postfix(Player __instance) { if (GhostField == null || StatusField == null) { RadiusScrollUtil.ResetTracking(); return; } if (!Plugin.Enabled.Value) { RadiusScrollUtil.ResetTracking(); return; } object? value = GhostField.GetValue(__instance); GameObject val = (GameObject)((value is GameObject) ? value : null); if (val == null || (Object)(object)val == (Object)null) { RadiusScrollUtil.ResetTracking(); return; } Piece component = val.GetComponent(); if ((Object)(object)component == (Object)null || !component.m_groundPiece) { RadiusScrollUtil.ResetTracking(); return; } StatusField.SetValue(__instance, (object)(PlacementStatus)0); RadiusScrollUtil.HandleScroll(val); } } internal static class RadiusScrollUtil { private static GameObject s_ghost; private static float s_offset; private static float s_baseLevel; private static float s_baseRaise; private static float s_baseSmooth; private static float s_basePaint; private const int IndicatorSegments = 64; private static GameObject s_indicatorObj; private static LineRenderer s_indicatorLine; private static float s_lastMessageChangeTime = float.NegativeInfinity; private static bool s_messageFadedOut = true; private const float MessageFadeDelay = 2f; private const float MessageFadeDuration = 1f; internal static float CurrentOffset => s_offset; internal static void ResetTracking() { s_ghost = null; s_offset = 0f; HideIndicator(); } private static void EnsureIndicator() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)s_indicatorObj != (Object)null)) { s_indicatorObj = new GameObject("LevelAtFeet_RadiusIndicator"); Object.DontDestroyOnLoad((Object)(object)s_indicatorObj); s_indicatorLine = s_indicatorObj.AddComponent(); s_indicatorLine.loop = true; s_indicatorLine.useWorldSpace = true; s_indicatorLine.positionCount = 64; s_indicatorLine.widthMultiplier = 0.06f; ((Renderer)s_indicatorLine).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)s_indicatorLine).receiveShadows = false; ((Renderer)s_indicatorLine).material = new Material(Shader.Find("Sprites/Default")); Color val = default(Color); ((Color)(ref val))..ctor(1f, 0.85f, 0.15f, 0.95f); s_indicatorLine.startColor = val; s_indicatorLine.endColor = val; } } private static void UpdateIndicator(Vector3 center, float radius) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) EnsureIndicator(); s_indicatorObj.SetActive(true); for (int i = 0; i < 64; i++) { float num = (float)Math.PI * 2f * (float)i / 64f; Vector3 val = center + new Vector3(Mathf.Cos(num) * radius, 0.05f, Mathf.Sin(num) * radius); s_indicatorLine.SetPosition(i, val); } } private static void HideIndicator() { if ((Object)(object)s_indicatorObj != (Object)null) { s_indicatorObj.SetActive(false); } } private static void ShowRadiusMessage(float shown) { string text = $"Радіус інструмента: {shown:0.0} м"; MessageHud instance = MessageHud.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_messageText != (Object)null) { instance.m_messageText.text = text; ((Graphic)instance.m_messageText).CrossFadeAlpha(1f, 0f, true); } else if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)1, text, 0, (Sprite)null, false); } s_lastMessageChangeTime = Time.time; s_messageFadedOut = false; } private static void UpdateMessageFade() { if (!s_messageFadedOut && !(Time.time - s_lastMessageChangeTime < 2f)) { MessageHud instance = MessageHud.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_messageText != (Object)null) { ((Graphic)instance.m_messageText).CrossFadeAlpha(0f, 1f, true); } s_messageFadedOut = true; } } internal static void HandleScroll(GameObject ghost) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.RadiusScrollEnabled.Value) { return; } TerrainOp componentInChildren = ghost.GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null || componentInChildren.m_settings == null) { return; } Settings settings = componentInChildren.m_settings; if ((Object)(object)ghost != (Object)(object)s_ghost) { s_ghost = ghost; s_offset = 0f; s_baseLevel = settings.m_levelRadius; s_baseRaise = settings.m_raiseRadius; s_baseSmooth = settings.m_smoothRadius; s_basePaint = settings.m_paintRadius; ApplyOffset(settings); } UpdateIndicator(ghost.transform.position, GetDisplayRadius(settings)); UpdateMessageFade(); if (Input.GetKey(Plugin.RadiusScrollKey.Value)) { float num = 0f; if (Input.GetKeyDown((KeyCode)93)) { num = Plugin.RadiusScrollStep.Value; } else if (Input.GetKeyDown((KeyCode)91)) { num = 0f - Plugin.RadiusScrollStep.Value; } if (!Mathf.Approximately(num, 0f)) { s_offset += num; ApplyOffset(settings); ShowRadiusMessage(GetDisplayRadius(settings)); } } } private static float RepresentativeBase(Settings settings) { if (settings.m_level || settings.m_raise || settings.m_smooth) { float num = 0f; if (settings.m_level) { num = Mathf.Max(num, s_baseLevel); } if (settings.m_raise) { num = Mathf.Max(num, s_baseRaise); } if (settings.m_smooth) { num = Mathf.Max(num, s_baseSmooth); } return num; } if (settings.m_paintCleared) { return s_basePaint; } return Mathf.Max(Mathf.Max(s_baseLevel, s_baseRaise), Mathf.Max(s_baseSmooth, s_basePaint)); } private static float GetDisplayRadius(Settings settings) { if (settings.m_level || settings.m_raise || settings.m_smooth) { float num = 0f; if (settings.m_level) { num = Mathf.Max(num, settings.m_levelRadius); } if (settings.m_raise) { num = Mathf.Max(num, settings.m_raiseRadius); } if (settings.m_smooth) { num = Mathf.Max(num, settings.m_smoothRadius); } return num; } return settings.GetRadius(); } private static void ApplyOffset(Settings settings) { float value = Plugin.RadiusScrollMin.Value; float value2 = Plugin.RadiusScrollMax.Value; float num = RepresentativeBase(settings); s_offset = Mathf.Clamp(s_offset, value - num, value2 - num); settings.m_levelRadius = Mathf.Clamp(s_baseLevel + s_offset, value, value2); settings.m_raiseRadius = Mathf.Clamp(s_baseRaise + s_offset, value, value2); settings.m_smoothRadius = Mathf.Clamp(s_baseSmooth + s_offset, value, value2); settings.m_paintRadius = Mathf.Clamp(s_basePaint + s_offset, value, value2); } } [HarmonyPatch(typeof(TerrainComp), "LevelTerrain")] public static class TerrainComp_ClearRocks_Patch { private static readonly FieldInfo HitAreasField = AccessTools.Field(typeof(MineRock), "m_hitAreas"); private static void Postfix(Vector3 worldPos, float radius) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled.Value || !Plugin.ClearRocksInRadius.Value || (Object)(object)Player.m_localPlayer == (Object)null) { return; } Collider[] array = Physics.OverlapSphere(worldPos, radius); if (array == null || array.Length == 0) { return; } HashSet hashSet = new HashSet(); HashSet hashSet2 = new HashSet(); Collider[] array2 = array; foreach (Collider val in array2) { if ((Object)(object)val == (Object)null) { continue; } MineRock componentInParent = ((Component)val).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { hashSet.Add(componentInParent); continue; } Destructible componentInParent2 = ((Component)val).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null) { hashSet2.Add(componentInParent2); } } if (HitAreasField != null) { foreach (MineRock item in hashSet) { DestroyRock(item); } } foreach (Destructible item2 in hashSet2) { item2.Damage(BuildOverkillHit()); } } private static void DestroyRock(MineRock rock) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!(HitAreasField.GetValue(rock) is Collider[] array) || array == null) { return; } Collider[] array2 = array; foreach (Collider val in array2) { if (!((Object)(object)val == (Object)null)) { HitData val2 = BuildOverkillHit(); Bounds bounds = val.bounds; val2.m_point = ((Bounds)(ref bounds)).center; val2.m_hitCollider = val; rock.Damage(val2); } } } private static HitData BuildOverkillHit() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown HitData val = new HitData { m_damage = { m_damage = 9999f }, m_damage = { m_blunt = 9999f }, m_damage = { m_slash = 9999f }, m_damage = { m_pierce = 9999f }, m_damage = { m_chop = 9999f }, m_damage = { m_pickaxe = 9999f }, m_damage = { m_fire = 9999f }, m_damage = { m_frost = 9999f }, m_damage = { m_lightning = 9999f }, m_damage = { m_poison = 9999f }, m_damage = { m_spirit = 9999f }, m_toolTier = 100, m_point = ((Component)Player.m_localPlayer).transform.position, m_dir = Vector3.down }; val.SetAttacker((Character)(object)Player.m_localPlayer); return val; } } internal static class HeightCapUtil { internal static IEnumerable RaiseClampBounds(IEnumerable instructions, float expectedBound) { List list = new List(instructions); if (!Plugin.RemoveVanillaHeightCap.Value) { return list; } float value = Plugin.MaxHeightDelta.Value; for (int i = 0; i < list.Count - 1; i++) { if (list[i].opcode == OpCodes.Ldc_R4 && list[i].operand is float num && Mathf.Approximately(num, 0f - expectedBound) && list[i + 1].opcode == OpCodes.Ldc_R4 && list[i + 1].operand is float num2 && Mathf.Approximately(num2, expectedBound)) { list[i].operand = 0f - value; list[i + 1].operand = value; } } return list; } } [HarmonyPatch(typeof(TerrainComp), "RaiseTerrain")] public static class TerrainComp_RaiseTerrain_RemoveCap_Patch { private static void Prefix(ref float radius) { if (Plugin.RadiusScrollEnabled.Value) { radius = Mathf.Clamp(radius + RadiusScrollUtil.CurrentOffset, Plugin.RadiusScrollMin.Value, Plugin.RadiusScrollMax.Value); } } private static IEnumerable Transpiler(IEnumerable instructions) { return HeightCapUtil.RaiseClampBounds(instructions, 8f); } } [HarmonyPatch(typeof(TerrainComp), "PaintCleared")] public static class TerrainComp_PaintCleared_Patch { private static void Prefix(Settings settings) { if (Plugin.RadiusScrollEnabled.Value && settings != null) { float value = Plugin.RadiusScrollMin.Value; float value2 = Plugin.RadiusScrollMax.Value; float currentOffset = RadiusScrollUtil.CurrentOffset; float num = (settings.m_level ? settings.m_levelRadius : (settings.m_raise ? settings.m_raiseRadius : ((!settings.m_smooth) ? settings.m_paintRadius : settings.m_smoothRadius))); settings.m_paintRadius = Mathf.Clamp(num + currentOffset, value, value2); } } }