diff options
Diffstat (limited to 'src/LivingVillage.Desktop/Game.fs')
| -rw-r--r-- | src/LivingVillage.Desktop/Game.fs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop/Game.fs b/src/LivingVillage.Desktop/Game.fs index 8309867..bcc4094 100644 --- a/src/LivingVillage.Desktop/Game.fs +++ b/src/LivingVillage.Desktop/Game.fs @@ -215,6 +215,8 @@ type LivingVillageGame() as this = let mutable avatarMoving = false let unlockFps = Environment.GetEnvironmentVariable("LV_UNLOCK_FPS") = "1" let perfSummaryMode = Environment.GetEnvironmentVariable("LV_PERF_SUMMARY") = "1" + // P24 证据钩子:每秒打印屏幕内可见 NPC 数,证明大世界村民确实被渲染。 + let npcVisibleLog = Environment.GetEnvironmentVariable("LV_NPC_VISIBLE_LOG") = "1" let mutable fpsSamples: float list = [] let mutable fpsFrames = 0 let mutable fpsSeconds = 0.0 @@ -751,6 +753,18 @@ type LivingVillageGame() as this = if perfSummaryMode then fpsSamples <- fps :: fpsSamples printfn $"fps={fps:F1} tick={world.Tick} pos=({world.Avatar.Pos.X:F0},{world.Avatar.Pos.Y:F0})" + if npcVisibleLog then + let viewport = this.GraphicsDevice.Viewport + let margin = float32 Sim.tilePixels + let visible = + world.Npcs + |> Array.filter (fun npc -> + let sx = npc.Pos.X - camera.X + let sy = npc.Pos.Y - camera.Y + sx >= -margin && sx <= float32 viewport.Width + margin + && sy >= -margin && sy <= float32 viewport.Height + margin) + |> Array.length + printfn $"visible-npcs={visible} of {world.Npcs.Length}" prevKb <- kb override this.EndRun() = |
