diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-21 08:16:10 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-21 08:16:10 +0800 |
| commit | f64045ca6245ed853f4d8ac1bcce6f4fe13068ce (patch) | |
| tree | 8f637a981c7099aa6216c1bdebb0921c3b9b513d /src/LivingVillage.Desktop/WorldBootstrap.fs | |
| parent | dd0907573e13981035a5ff264831edb0534e3496 (diff) | |
| download | living-village-f64045ca6245ed853f4d8ac1bcce6f4fe13068ce.tar.gz | |
feat(desktop): 固化样例世界与昼光呈现
[变更性质]
- this commit adds a deterministic desktop bootstrap for the playable sample world.
[新增功能]
- this commit places the avatar away from the home doorway and separates villagers from scene footprints.
- this commit provides a warm high-contrast daylight tint and exits autoplay after SampleComplete.
[实现方案]
- this commit isolates desktop spawn policy in WorldBootstrap and routes game startup and sample tests through it.
- this commit adds regression coverage for spawn positions, spacing, determinism, and daylight tint.
[影响范围]
- this commit affects the Desktop application and Desktop tests only.
- this commit preserves Kernel behavior and does not include unrelated worktree changes.
Diffstat (limited to 'src/LivingVillage.Desktop/WorldBootstrap.fs')
| -rw-r--r-- | src/LivingVillage.Desktop/WorldBootstrap.fs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop/WorldBootstrap.fs b/src/LivingVillage.Desktop/WorldBootstrap.fs new file mode 100644 index 0000000..612931b --- /dev/null +++ b/src/LivingVillage.Desktop/WorldBootstrap.fs @@ -0,0 +1,36 @@ +namespace LivingVillage.Desktop + +open LivingVillage.Kernel +open LivingVillage.Kernel.Sim + +module WorldBootstrap = + + let private tileCenter (x: int) (y: int) : Vec2 = + { X = float32 (x * Sim.tilePixels + Sim.tilePixels / 2) + Y = float32 (y * Sim.tilePixels + Sim.tilePixels / 2) } + + let private npcSpawnTiles : (int * int) array = + [| for y in [ 14; 18; 28; 32; 36; 40 ] do + for x in [ 24; 28; 32; 36; 40 ] do + yield x, y |] + + let private avatarSpawnPosition = tileCenter 31 25 + + let initialWorld (seed: uint64) (count: int) : World = + if count < 0 || count > npcSpawnTiles.Length then + invalidArg (nameof count) "Desktop bootstrap supports at most 30 NPCs." + + let baseWorld = Sim.initialWorldN seed count + let avatar = + { baseWorld.Avatar with + Pos = avatarSpawnPosition + Mind = { baseWorld.Avatar.Mind with Target = avatarSpawnPosition } } + let npcs = + baseWorld.Npcs + |> Array.mapi (fun index npc -> + let x, y = npcSpawnTiles.[index] + { npc with Pos = tileCenter x y }) + + { baseWorld with + Avatar = avatar + Npcs = npcs } |
