using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FishNet.Object; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RandomCreatureSize")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("随机生物尺寸:海鸥/鱼类/螃蟹/Boss 外观随机缩放,s 即重量(影响售价/存档/联机一致)")] [assembly: AssemblyFileVersion("1.1.3.0")] [assembly: AssemblyInformationalVersion("1.1.3")] [assembly: AssemblyProduct("RandomCreatureSize")] [assembly: AssemblyTitle("RandomCreatureSize")] [assembly: AssemblyVersion("1.1.3.0")] namespace RandomCreatureSize; internal static class SizeLogic { private static readonly FieldInfo _skipRandomizedWeightField = AccessTools.Field(typeof(Creature), "_skipRandomizedWeight"); public static bool IsBoss(Creature c) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if ((Object)(object)c != (Object)null) { return (int)c.BossType > 0; } return false; } private static bool SkipsRandomizedWeight(Creature c) { try { if (_skipRandomizedWeightField == null) { return false; } object value = _skipRandomizedWeightField.GetValue(c); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } public static bool ShouldScale(Creature c) { try { if ((Object)(object)c == (Object)null || !Plugin.Enabled.Value) { return false; } if (SkipsRandomizedWeight(c)) { return false; } if (IsBoss(c) && !Plugin.ScaleBosses.Value) { return false; } if (c is Bird) { return Plugin.ScaleBirds.Value; } if (c is Fish) { return Plugin.ScaleFish.Value; } return Plugin.ScaleOthers.Value; } catch (Exception ex) { Plugin.LogWarn("ShouldScale 异常: " + ex.Message); return false; } } public static float RollSize(bool boss) { float num = (boss ? Plugin.BossMinScale.Value : Plugin.MinScale.Value); float num2 = (boss ? Plugin.BossMaxScale.Value : Plugin.MaxScale.Value); if (num2 < num) { float num3 = num; num = num2; num2 = num3; } if (num <= 0f) { num = 0.01f; } float num4 = BiasUnit(Random.value); if (Plugin.LogUniform.Value) { return num * Mathf.Pow(num2 / num, num4); } return Mathf.Lerp(num, num2, num4); } private static float BiasUnit(float u) { float num = Mathf.Clamp01(Plugin.ExtremeBias.Value); if (num <= 0f) { return u; } float num2 = 2f * u - 1f; float num3 = (num2 * num2 * num2 + 1f) * 0.5f; return Mathf.Lerp(u, num3, num); } public static void ApplyFromWeight(Creature c) { if (!((Object)(object)c == (Object)null)) { float num = ((Item)c).RandomizedWeight; if (num <= 0f || float.IsNaN(num)) { num = 1f; } Apply(c, num); } } public static void Apply(Creature c, float s) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = AxisFactors(((NetworkBehaviour)c).ObjectId); ((Component)c).transform.localScale = new Vector3(s * val.x, s * val.y, s * val.z); } public static Vector3 AxisFactors(int objectId) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.JitterEnabled.Value) { return Vector3.one; } float num = Mathf.Clamp01(Plugin.JitterPercent.Value); if (num <= 0f) { return Vector3.one; } return new Vector3(1f + (DetUnit(objectId * 31 + 1) * 2f - 1f) * num, 1f + (DetUnit(objectId * 31 + 2) * 2f - 1f) * num, 1f + (DetUnit(objectId * 31 + 3) * 2f - 1f) * num); } private static float DetUnit(int seed) { int num = seed ^ (seed << 13); int num2 = num ^ (num >>> 17); return (float)(uint)((num2 ^ (num2 << 5)) & 0x3FFFFFFF) / 1.0737418E+09f; } public static float SpeedFactor(Creature c) { try { if ((Object)(object)c == (Object)null || !Plugin.SpeedEnabled.Value) { return 1f; } float randomizedWeight = ((Item)c).RandomizedWeight; if (randomizedWeight <= 1f || float.IsNaN(randomizedWeight)) { return 1f; } float num = Mathf.Max(0f, Plugin.SpeedPow.Value); return Mathf.Max(Mathf.Pow(randomizedWeight, 0f - num), Mathf.Clamp(Plugin.SpeedMinFactor.Value, 0.01f, 1f)); } catch (Exception ex) { Plugin.LogWarn("SpeedFactor 异常: " + ex.Message); return 1f; } } public static void DampHorizontalVelocity(Creature c) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c == (Object)null || c.IsDead) { return; } RigidbodySync rigidbodySync = ((Item)c).RigidbodySync; if ((Object)(object)rigidbodySync == (Object)null || !rigidbodySync.IsSimulatedLocal) { return; } float num = SpeedFactor(c); if (!(num >= 1f)) { Rigidbody rig = ((Item)c).Rig; if (!((Object)(object)rig == (Object)null) && !rig.isKinematic) { Vector3 linearVelocity = rig.linearVelocity; linearVelocity.x *= num; linearVelocity.z *= num; rig.linearVelocity = linearVelocity; } } } public static void ServerRollAndApply(Creature c) { if (!((Object)(object)c == (Object)null) && ShouldScale(c)) { if (!SaveRestore.Restoring.Contains(c)) { ((Item)c)._syncedRandomWeight.Value = RollSize(IsBoss(c)); } Apply(c, Mathf.Max(((Item)c).RandomizedWeight, 0.01f)); if (c._hp.Value > 0) { float num = Mathf.Max(((Item)c).RandomizedWeight, 0.01f); c._hp.Value = Mathf.Max(1, Mathf.RoundToInt((float)c._hp.Value * num)); } } } } internal static class SaveRestore { public static readonly HashSet Restoring = new HashSet(); } [HarmonyPatch(typeof(Creature), "OnStartServer")] internal static class Patch_Creature_OnStartServer { private static void Postfix(Creature __instance) { try { SizeLogic.ServerRollAndApply(__instance); } catch (Exception ex) { Plugin.LogWarn("OnStartServer 补丁异常: " + ex.Message); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class Patch_Creature_MaxHp { private static void Postfix(Creature __instance, ref int __result) { try { if (!((Object)(object)__instance == (Object)null) && __result > 0 && SizeLogic.ShouldScale(__instance)) { float randomizedWeight = ((Item)__instance).RandomizedWeight; if (!(randomizedWeight <= 0f) && !float.IsNaN(randomizedWeight)) { __result = Mathf.Max(1, Mathf.RoundToInt((float)__result * randomizedWeight)); } } } catch (Exception ex) { Plugin.LogWarn("MaxHp 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(AttackingFish), "OnStartServer")] internal static class Patch_AttackingFish_OnStartServer { private static void Postfix(Creature __instance) { try { SizeLogic.ServerRollAndApply(__instance); } catch (Exception ex) { Plugin.LogWarn("AttackingFish.OnStartServer 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(Piranha), "OnStartServer")] internal static class Patch_Piranha_OnStartServer { private static void Postfix(Creature __instance) { try { SizeLogic.ServerRollAndApply(__instance); } catch (Exception ex) { Plugin.LogWarn("Piranha.OnStartServer 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(Pufferfish), "OnStartServer")] internal static class Patch_Pufferfish_OnStartServer { private static void Postfix(Creature __instance) { try { SizeLogic.ServerRollAndApply(__instance); } catch (Exception ex) { Plugin.LogWarn("Pufferfish.OnStartServer 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(Spidercrab), "OnStartServer")] internal static class Patch_Spidercrab_OnStartServer { private static void Postfix(Creature __instance) { try { SizeLogic.ServerRollAndApply(__instance); } catch (Exception ex) { Plugin.LogWarn("Spidercrab.OnStartServer 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(Creature), "LoadFromSave")] internal static class Patch_Creature_LoadFromSave { private static void Prefix(Creature __instance) { try { SaveRestore.Restoring.Add(__instance); } catch { } } private static void Postfix(Creature __instance) { try { if (SizeLogic.ShouldScale(__instance)) { SizeLogic.Apply(__instance, Mathf.Max(((Item)__instance).RandomizedWeight, 0.01f)); } } catch (Exception ex) { Plugin.LogWarn("LoadFromSave 补丁异常: " + ex.Message); } finally { try { SaveRestore.Restoring.Remove(__instance); } catch { } } } } [HarmonyPatch(typeof(Creature), "OnStartClient")] internal static class Patch_Creature_OnStartClient { private static void Postfix(Creature __instance) { try { if (!SizeLogic.ShouldScale(__instance)) { return; } SizeLogic.ApplyFromWeight(__instance); ((Item)__instance)._syncedRandomWeight.OnChange += delegate { try { if (SizeLogic.ShouldScale(__instance)) { SizeLogic.ApplyFromWeight(__instance); } } catch (Exception ex2) { Plugin.LogWarn("重量同步回调异常: " + ex2.Message); } }; } catch (Exception ex) { Plugin.LogWarn("OnStartClient 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(Item), "PickUp")] internal static class Patch_Item_PickUp { private static void Postfix(Item __instance) { try { if (!((Object)(object)__instance == (Object)null)) { Creature creature = __instance.Creature; if (!((Object)(object)creature == (Object)null) && SizeLogic.ShouldScale(creature)) { SizeLogic.ApplyFromWeight(creature); } } } catch (Exception ex) { Plugin.LogWarn("PickUp 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(Item), "SpawnFromInventory")] internal static class Patch_Item_SpawnFromInventory { private static void Postfix(Item __instance) { try { if (!((Object)(object)__instance == (Object)null)) { Creature creature = __instance.Creature; if (!((Object)(object)creature == (Object)null) && SizeLogic.ShouldScale(creature)) { SizeLogic.ApplyFromWeight(creature); } } } catch (Exception ex) { Plugin.LogWarn("SpawnFromInventory 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(InventorySlot), "SetItem")] internal static class Patch_InventorySlot_SetItem { private static readonly FieldInfo _filterField = AccessTools.Field(typeof(InventorySlot), "_filter"); private static void Postfix(InventorySlot __instance, Item item) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)item == (Object)null) { return; } Creature creature = item.Creature; if ((Object)(object)creature == (Object)null || !SizeLogic.ShouldScale(creature) || _filterField == null) { return; } object? value = _filterField.GetValue(__instance); MeshFilter val = (MeshFilter)((value is MeshFilter) ? value : null); if (!((Object)(object)val == (Object)null)) { float randomizedWeight = item.RandomizedWeight; if (!(randomizedWeight <= 0f) && !float.IsNaN(randomizedWeight)) { ((Component)val).transform.localScale = Vector3.one * item.InventoryMeshScale * randomizedWeight; } } } catch (Exception ex) { Plugin.LogWarn("InventorySlot 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(Fish), "FixedUpdate")] internal static class Patch_Fish_FixedUpdate { private static void Postfix(Fish __instance) { try { if (!(__instance is RunningFish) && !(__instance is Pufferfish) && !(__instance is BowheadWhale)) { SizeLogic.DampHorizontalVelocity((Creature)(object)__instance); } } catch (Exception ex) { Plugin.LogWarn("Fish.FixedUpdate 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(RunningFish), "FixedUpdate")] internal static class Patch_RunningFish_FixedUpdate { private static void Postfix(RunningFish __instance) { try { SizeLogic.DampHorizontalVelocity((Creature)(object)__instance); } catch (Exception ex) { Plugin.LogWarn("RunningFish.FixedUpdate 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(Pufferfish), "FixedUpdate")] internal static class Patch_Pufferfish_FixedUpdate { private static void Postfix(Pufferfish __instance) { try { SizeLogic.DampHorizontalVelocity((Creature)(object)__instance); } catch (Exception ex) { Plugin.LogWarn("Pufferfish.FixedUpdate 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(BowheadWhale), "FixedUpdate")] internal static class Patch_BowheadWhale_FixedUpdate { private static void Postfix(BowheadWhale __instance) { try { SizeLogic.DampHorizontalVelocity((Creature)(object)__instance); } catch (Exception ex) { Plugin.LogWarn("BowheadWhale.FixedUpdate 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(Crab), "FixedUpdate")] internal static class Patch_Crab_FixedUpdate { private static void Postfix(Crab __instance) { try { if (!(__instance is Spidercrab)) { SizeLogic.DampHorizontalVelocity((Creature)(object)__instance); } } catch (Exception ex) { Plugin.LogWarn("Crab.FixedUpdate 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(Spidercrab), "FixedUpdate")] internal static class Patch_Spidercrab_FixedUpdate { private static void Postfix(Spidercrab __instance) { try { SizeLogic.DampHorizontalVelocity((Creature)(object)__instance); } catch (Exception ex) { Plugin.LogWarn("Spidercrab.FixedUpdate 补丁异常: " + ex.Message); } } } [HarmonyPatch(typeof(BirdManager), "SimulateBird")] internal static class Patch_BirdManager_SimulateBird { private static readonly string[] _speedFields = new string[7] { "_defaultFlySpeed", "_horizontalSpeed", "_verticalSpeed", "_attackingFoodSpeed", "_attackingHorizontalSpeed", "_closeToFoodSpeed", "_closeToFoodHorizontalSpeed" }; private static FieldInfo[] _fields; private static float[] _originals; private static void Prefix(BirdManager __instance, Bird bird) { try { float num = SizeLogic.SpeedFactor((Creature)(object)bird); if (num >= 1f) { return; } _fields = new FieldInfo[_speedFields.Length]; _originals = new float[_speedFields.Length]; for (int i = 0; i < _speedFields.Length; i++) { _fields[i] = AccessTools.Field(typeof(BirdManager), _speedFields[i]); if (!(_fields[i] == null)) { _originals[i] = (float)_fields[i].GetValue(__instance); _fields[i].SetValue(__instance, _originals[i] * num); } } } catch (Exception ex) { Plugin.LogWarn("SimulateBird Prefix 异常: " + ex.Message); Restore(__instance); } } private static void Postfix(BirdManager __instance) { Restore(__instance); } private static void Restore(BirdManager __instance) { try { if (_fields == null || _originals == null) { return; } for (int i = 0; i < _fields.Length; i++) { if (!(_fields[i] == null)) { try { _fields[i].SetValue(__instance, _originals[i]); } catch { } } } _fields = null; _originals = null; } catch { } } } [HarmonyPatch(typeof(Albatross), "Move")] internal static class Patch_Albatross_Move { private static readonly string[] _speedFields = new string[7] { "_defaultFlySpeed", "_horizontalSpeed", "_verticalSpeed", "_attackingTargetSpeed", "_attackingHorizontalSpeed", "_closeToTargetSpeed", "_closeToTargetHorizontalSpeed" }; private static FieldInfo[] _fields; private static float[] _originals; private static void Prefix(Albatross __instance) { try { float num = SizeLogic.SpeedFactor((Creature)(object)__instance); if (num >= 1f) { return; } _fields = new FieldInfo[_speedFields.Length]; _originals = new float[_speedFields.Length]; for (int i = 0; i < _speedFields.Length; i++) { _fields[i] = AccessTools.Field(typeof(Albatross), _speedFields[i]); if (!(_fields[i] == null)) { _originals[i] = (float)_fields[i].GetValue(__instance); _fields[i].SetValue(__instance, _originals[i] * num); } } } catch (Exception ex) { Plugin.LogWarn("Albatross.Move Prefix 异常: " + ex.Message); Restore(__instance); } } private static void Postfix(Albatross __instance) { Restore(__instance); } private static void Restore(Albatross __instance) { try { if (_fields == null || _originals == null) { return; } for (int i = 0; i < _fields.Length; i++) { if (!(_fields[i] == null)) { try { _fields[i].SetValue(__instance, _originals[i]); } catch { } } } _fields = null; _originals = null; } catch { } } } [BepInPlugin("top.yw.randomcreaturesize", "RandomCreatureSize", "1.1.3")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry Enabled; internal static ConfigEntry ScaleBirds; internal static ConfigEntry ScaleFish; internal static ConfigEntry ScaleOthers; internal static ConfigEntry ScaleBosses; internal static ConfigEntry MinScale; internal static ConfigEntry MaxScale; internal static ConfigEntry BossMinScale; internal static ConfigEntry BossMaxScale; internal static ConfigEntry LogUniform; internal static ConfigEntry JitterEnabled; internal static ConfigEntry JitterPercent; internal static ConfigEntry ExtremeBias; internal static ConfigEntry SpeedEnabled; internal static ConfigEntry SpeedPow; internal static ConfigEntry SpeedMinFactor; internal static void LogInfo(string msg) { try { Log.LogInfo((object)msg); } catch { } } internal static void LogWarn(string msg) { try { Log.LogWarning((object)msg); } catch { } } private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; InitConfig(); Harmony val = new Harmony("top.yw.randomcreaturesize"); int num = 0; int num2 = 0; Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0) { try { new PatchClassProcessor(val, type).Patch(); num++; } catch (Exception ex) { num2++; LogWarn("补丁应用失败:" + type.Name + " => " + ex.GetType().Name + ": " + ex.Message); } } } LogInfo("Harmony 补丁应用完成(成功 " + num + " 失败 " + num2 + ")"); LogInfo("随机生物尺寸模组已加载!(cfg: " + Paths.ConfigPath + ")"); } private void InitConfig() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Expected O, but got Unknown //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "总开关(Master switch;关闭后所有生物保持原版尺寸与原版重量随机)"); ScaleBirds = ((BaseUnityPlugin)this).Config.Bind("Category", "ScaleBirds", true, "海鸥随机尺寸(Seagulls)"); ScaleFish = ((BaseUnityPlugin)this).Config.Bind("Category", "ScaleFish", true, "鱼类随机尺寸(Fish,含钓上来的鱼/陆跑鱼/攻击鱼)"); ScaleOthers = ((BaseUnityPlugin)this).Config.Bind("Category", "ScaleOthers", true, "其他生物随机尺寸(Other creatures:螃蟹/蜘蛛蟹/信天翁/诱饵生物等)"); ScaleBosses = ((BaseUnityPlugin)this).Config.Bind("Category", "ScaleBosses", true, "Boss 随机尺寸(Bosses,使用独立倍率范围;关闭后 Boss 完全原版)"); MinScale = ((BaseUnityPlugin)this).Config.Bind("Size", "MinScale", 0.1f, new ConfigDescription("普通生物最小尺寸倍率(Min multiplier, 默认 0.1)", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 100f), Array.Empty())); MaxScale = ((BaseUnityPlugin)this).Config.Bind("Size", "MaxScale", 10f, new ConfigDescription("普通生物最大尺寸倍率(Max multiplier, 默认 10)", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 100f), Array.Empty())); BossMinScale = ((BaseUnityPlugin)this).Config.Bind("Size", "BossMinScale", 0.5f, new ConfigDescription("Boss 最小尺寸倍率(Boss min multiplier, 默认 0.5)", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 100f), Array.Empty())); BossMaxScale = ((BaseUnityPlugin)this).Config.Bind("Size", "BossMaxScale", 2f, new ConfigDescription("Boss 最大尺寸倍率(Boss max multiplier, 默认 2)", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 100f), Array.Empty())); LogUniform = ((BaseUnityPlugin)this).Config.Bind("Size", "LogUniform", true, "对数均匀分布(推荐):0.1/1/10 概率均衡;关闭 = 均匀分布(false = uniform)"); JitterEnabled = ((BaseUnityPlugin)this).Config.Bind("Size", "JitterEnabled", true, "分轴抖动:长/宽/高在尺寸附近各自随机(Per-axis jitter;关闭 = 纯等比缩放)"); JitterPercent = ((BaseUnityPlugin)this).Config.Bind("Size", "JitterPercent", 0.3f, new ConfigDescription("分轴抖动幅度(Jitter amount, 默认 0.3 = ±30%)", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); ExtremeBias = ((BaseUnityPlugin)this).Config.Bind("Size", "ExtremeBias", 0.3f, new ConfigDescription("随机偏极端程度:让明显大/小体型出现更频繁(0 = 对数均匀,1 = 全偏极值;默认 0.3)", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); SpeedEnabled = ((BaseUnityPlugin)this).Config.Bind("Size", "SpeedEnabled", true, "尺寸越大移动越慢(Bigger creatures move slower;s≤1 速度不变)"); SpeedPow = ((BaseUnityPlugin)this).Config.Bind("Size", "SpeedPow", 0.5f, new ConfigDescription("速度衰减指数:速度 = 1/尺寸^指数(Speed exponent, 默认 0.5)", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); SpeedMinFactor = ((BaseUnityPlugin)this).Config.Bind("Size", "SpeedMinFactor", 0.4f, new ConfigDescription("速度下限(Speed floor, 默认 0.4 = 最多减少 60% 速度;速度最低为原来的 40%)", (AcceptableValueBase)(object)new AcceptableValueRange(0.4f, 1f), Array.Empty())); } }