From c932969539b00a42937f0aa5ed1e10b4e94932a3 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Mon, 21 Sep 2026 08:37:29 +0800 Subject: feat(desktop): 增加可选昼光自动演示启动 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [变更性质] - 本提交新增可选的 Desktop 启动行为,不改变默认启动行为。 [新增功能] - 设置 LV_AUTOPLAY_DAYLIGHT=1 时,初始世界和 StartNewGame 从黎明 tick 开始。 - 未设置该变量时继续从 tick 0 的夜晚状态开始。 [实现方案] - 在 WorldBootstrap 中集中计算昼光起始 tick 和同步时间。 - 在 Game 中复用同一世界工厂,并增加黎明与默认状态回归测试。 [影响范围] - 仅影响 Desktop 运行时代码和测试;Kernel 保持不变。 - 环境变量为显式 opt-in,不影响现有自动演示和普通启动路径。 --- src/LivingVillage.Desktop.Tests/DesktopTests.fs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/LivingVillage.Desktop.Tests') diff --git a/src/LivingVillage.Desktop.Tests/DesktopTests.fs b/src/LivingVillage.Desktop.Tests/DesktopTests.fs index 20cbbe9..667ab69 100644 --- a/src/LivingVillage.Desktop.Tests/DesktopTests.fs +++ b/src/LivingVillage.Desktop.Tests/DesktopTests.fs @@ -124,3 +124,18 @@ type DesktopTests () = Assert.IsTrue(day.WorldTint.R > day.WorldTint.G) Assert.IsTrue(day.WorldTint.G > day.WorldTint.B) + + [] + member _.DaylightAutoplayBootstrapStartsAtDawnAndPreservesDefaultStart () = + let dawnTick = 6L * Sim.ticksPerDay / 24L + let daylightWorld = WorldBootstrap.initialWorldForDaylight true 42UL Sim.npcCount + let defaultWorld = WorldBootstrap.initialWorldForDaylight false 42UL Sim.npcCount + let daylightProfile = M6Presentation.profileAtTick daylightWorld.Tick + let defaultProfile = M6Presentation.profileAtTick defaultWorld.Tick + + Assert.AreEqual(dawnTick, daylightWorld.Tick) + Assert.IsTrue(abs (daylightWorld.Time - float dawnTick * Sim.dtSeconds) < 1e-9) + Assert.AreEqual(Day, daylightProfile.Mode) + Assert.AreEqual(0L, defaultWorld.Tick) + Assert.AreEqual(0.0, defaultWorld.Time) + Assert.AreEqual(Night, defaultProfile.Mode) -- cgit v1.2.3