summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/LivingVillage.Desktop/Game.fs14
-rw-r--r--src/LivingVillage.Desktop/VillageArt.fs21
2 files changed, 28 insertions, 7 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() =
diff --git a/src/LivingVillage.Desktop/VillageArt.fs b/src/LivingVillage.Desktop/VillageArt.fs
index 3ad5b19..12c17ba 100644
--- a/src/LivingVillage.Desktop/VillageArt.fs
+++ b/src/LivingVillage.Desktop/VillageArt.fs
@@ -616,13 +616,20 @@ module VillageArt =
for (x, y) in map.Bridges do
spriteBatch.Draw(textures.TileAtlas, XnaRectangle(tileX x, tileY y, cell, cell), bridgeSource, XnaColor.White)
for building in map.Buildings do
- for row in building.Top .. building.Top + building.Height - 1 do
- // 白墙朝向道路一行(门所在行),其余为黑瓦屋顶,两侧河岸朝向一致。
- let color =
- if row = building.DoorY then XnaColor(236, 232, 220)
- else XnaColor(48, 52, 60)
- fillRect spriteBatch pixel color (tileX building.Left) (tileY row) (building.Width * cell) (cell)
- fillRect spriteBatch pixel (XnaColor(96, 60, 42)) (tileX building.DoorX) (tileY building.DoorY) cell cell
+ let left = building.Left
+ let right = building.Left + building.Width - 1
+ // P24:改用 256x192 同款民宅部件——黛瓦(脊/檐)+ 木墙/窗 + 门。
+ for row in building.Top .. building.DoorY - 1 do
+ let roofSprite = if row = building.Top then RoofRidgeSprite else RoofEaveSprite
+ let source = tileSourceRectangle roofSprite
+ for x in left .. right do
+ spriteBatch.Draw(textures.TileAtlas, XnaRectangle(tileX x, tileY row, cell, cell), source, XnaColor.White)
+ for x in left .. right do
+ let wallSprite =
+ if x = building.DoorX then DoorSprite
+ elif (x - left) % 2 = 0 then WallWindowSprite
+ else WallWoodSprite
+ spriteBatch.Draw(textures.TileAtlas, XnaRectangle(tileX x, tileY building.DoorY, cell, cell), tileSourceRectangle wallSprite, XnaColor.White)
/// 桥头灯笼瓦片:每座桥每列的最上/最下一格(桥两端),用于挂灯笼与夜间暖光。
let bridgeLanternTiles (map: MapGen.Result) : (int * int) list =