diff --git a/AGENTS.md b/AGENTS.md index 311042dd..cb19f63c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -104,6 +104,10 @@ All generated or modified code MUST include clear and meaningful comments where - Keep `using` directives at the top of the file and sort them consistently. - Separate logical blocks with blank lines when it improves readability. - Prefer one primary type per file unless the surrounding project already uses a different local pattern. +- Unless there is a clear and documented reason to keep a file large, keep a single source file under roughly 800-1000 + lines. +- If a file grows beyond that range, contributors MUST stop and check whether responsibilities should be split before + continuing; treating oversized files as the default is considered a design smell. - Keep line length readable. Around 120 characters is the preferred upper bound. ### C# Conventions diff --git a/GFramework.Game/Config/YamlConfigSchemaValidator.cs b/GFramework.Game/Config/YamlConfigSchemaValidator.cs index d8c09f9f..f7dc74c4 100644 --- a/GFramework.Game/Config/YamlConfigSchemaValidator.cs +++ b/GFramework.Game/Config/YamlConfigSchemaValidator.cs @@ -1745,8 +1745,9 @@ internal static class YamlConfigSchemaValidator /// /// 判断数值是否满足 multipleOf。 - /// 双精度浮点比较会保留一个与商值量级相关的微小容差, - /// 以避免运行时与 JS 工具侧在 0.1 / 0.01 这类十进制步进上出现伪失败。 + /// 双精度浮点比较会保留一个与步进量级相关的微小容差, + /// 以避免运行时与 JS 工具侧在 0.1 / 0.01 这类十进制步进上出现伪失败, + /// 同时避免值越大就无限放宽合法余数范围。 /// /// 当前值。 /// 步进约束。 @@ -1755,8 +1756,8 @@ internal static class YamlConfigSchemaValidator { var quotient = value / divisor; var nearestInteger = Math.Round(quotient); - var tolerance = 1e-9 * Math.Max(1d, Math.Abs(quotient)); - return Math.Abs(quotient - nearestInteger) <= tolerance; + var tolerance = 1e-9 * Math.Max(1d, Math.Abs(divisor)); + return Math.Abs(value - (nearestInteger * divisor)) <= tolerance; } ///