From e91a4a7ed0a55e9406623d1649cc432369bc0834 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Mon, 21 Sep 2026 10:58:30 +0800 Subject: feat(desktop): 民居正面完整化与图集足迹 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增屋脊/檐口/木构粉墙/格窗/木门五个地块图块,可进屋民居以门为锚点绘制四宽三高完整立面(黛瓦正脊、檐口层次、木构白墙、格窗与木门);新增 planFootprint 供生成阻挡判定,村民不会刷在建筑图块上。 --- src/LivingVillage.Desktop.Tests/DesktopTests.fs | 2 +- src/LivingVillage.Desktop.Tests/PrototypeTests.fs | 14 ++++++ .../Assets/jiangnan-world.png | Bin 1098 -> 1483 bytes src/LivingVillage.Desktop/VillageArt.fs | 47 +++++++++++++++++---- 4 files changed, 54 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/LivingVillage.Desktop.Tests/DesktopTests.fs b/src/LivingVillage.Desktop.Tests/DesktopTests.fs index 526d1af..e9713e5 100644 --- a/src/LivingVillage.Desktop.Tests/DesktopTests.fs +++ b/src/LivingVillage.Desktop.Tests/DesktopTests.fs @@ -102,7 +102,7 @@ type DesktopTests () = let renderPlan = VillageArt.sampleRenderPlan () let blockedTiles = (renderPlan.Grounds |> List.map (fun (tile, _) -> VillageArt.worldTile renderPlan tile)) - @ (renderPlan.Props |> List.map (fun prop -> VillageArt.worldTile renderPlan prop.Position)) + @ VillageArt.planFootprint renderPlan |> List.map (fun tile -> tile.X, tile.Y) |> Set.ofList let sceneTileOf (position: Vec2) : TilePosition = diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs index a403223..06b3250 100644 --- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs +++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs @@ -290,6 +290,20 @@ type PrototypeTests () = Assert.IsTrue(first.Props |> List.exists (fun prop -> prop.Kind = VillageArt.Bridge)) Assert.AreEqual(4, first.Interior.Elements.Length) + [] + member _.HouseFacadeCoversRoofEaveAndWalledDoorRow () = + let plan = VillageArt.sampleRenderPlan () + let footprint = VillageArt.planFootprint plan |> Set.ofList + let door = scene.Homes |> List.head |> fun home -> VillageArt.worldTile plan home.Door + + // The enterable home must present a full facade: ridge, eave, and a walled row with the door. + for dx in -2 .. 1 do + Assert.IsTrue(footprint.Contains({ X = door.X + dx; Y = door.Y - 2 } : TilePosition), sprintf "missing ridge tile dx=%d" dx) + Assert.IsTrue(footprint.Contains({ X = door.X + dx; Y = door.Y - 1 } : TilePosition), sprintf "missing eave tile dx=%d" dx) + Assert.IsTrue(footprint.Contains({ X = door.X + dx; Y = door.Y } : TilePosition), sprintf "missing wall tile dx=%d" dx) + // 12 house tiles + 2 bridge + 3 bamboo + 2 garden. + Assert.AreEqual(19, footprint.Count) + [] member _.FacingUsesTheActualMovementOrTargetVector () = Assert.AreEqual(VillageArt.EastFacing, VillageArt.directionFromVector { X = 1.0f; Y = 0.1f }) diff --git a/src/LivingVillage.Desktop/Assets/jiangnan-world.png b/src/LivingVillage.Desktop/Assets/jiangnan-world.png index 75dc906..766405f 100644 Binary files a/src/LivingVillage.Desktop/Assets/jiangnan-world.png and b/src/LivingVillage.Desktop/Assets/jiangnan-world.png differ diff --git a/src/LivingVillage.Desktop/VillageArt.fs b/src/LivingVillage.Desktop/VillageArt.fs index 03cd22e..5883a97 100644 --- a/src/LivingVillage.Desktop/VillageArt.fs +++ b/src/LivingVillage.Desktop/VillageArt.fs @@ -97,6 +97,11 @@ module VillageArt = | BridgeSprite | BambooSprite | GardenSprite + | RoofRidgeSprite + | RoofEaveSprite + | WallWoodSprite + | WallWindowSprite + | DoorSprite type private XnaColor = Microsoft.Xna.Framework.Color type private XnaRectangle = Microsoft.Xna.Framework.Rectangle @@ -158,7 +163,7 @@ module VillageArt = ground StonePath 6 6 ground StonePath 6 7 ] Props = - [ renderProp House 6 4 + [ renderProp House 6 5 renderProp Bridge 10 5 renderProp BambooGrove 3 2 renderProp VegetablePatch 8 7 ] @@ -173,6 +178,23 @@ module VillageArt = { X = plan.Origin.X + localPosition.X Y = plan.Origin.Y + localPosition.Y } + /// Every tile a prop paints over, in world coordinates. Used by draw ordering and by + /// spawn-overlap assertions so villagers never start inside a painted prop. + let planFootprint (plan: JiangnanRenderPlan) : TilePosition list = + let many positions = positions |> List.map (worldTile plan) + plan.Props + |> List.collect (fun prop -> + let x, y = prop.Position.X, prop.Position.Y + match prop.Kind with + | House -> + [ for dx in -2 .. 1 do + for dy in -2 .. 0 do + yield position (x + dx) (y + dy) ] + | Bridge -> [ position x y; position x (y + 1) ] + | BambooGrove -> [ position x y; position x (y + 1); position (x + 1) y ] + | VegetablePatch -> [ position x y; position (x + 1) y ]) + |> many + let private positiveModulo divisor value = let remainder = value % divisor if remainder < 0 then remainder + divisor else remainder @@ -249,7 +271,8 @@ module VillageArt = let characterAtlasRelativePath = "Assets/jiangnan-characters.png" let interiorAtlasRelativePath = "Assets/jiangnan-interior.png" - let worldAtlasWidth = Sim.tilePixels * 8 + let worldTileCount = 13 + let worldAtlasWidth = Sim.tilePixels * worldTileCount let worldAtlasHeight = Sim.tilePixels let characterAtlasWidth = 32 * 4 * 4 * 2 let characterAtlasHeight = 48 @@ -285,6 +308,11 @@ module VillageArt = | BridgeSprite -> 5 | BambooSprite -> 6 | GardenSprite -> 7 + | RoofRidgeSprite -> 8 + | RoofEaveSprite -> 9 + | WallWoodSprite -> 10 + | WallWindowSprite -> 11 + | DoorSprite -> 12 XnaRectangle(index * Sim.tilePixels, 0, Sim.tilePixels, Sim.tilePixels) let private tilePosition x y : TilePosition = @@ -342,12 +370,15 @@ module VillageArt = | StonePath -> StonePathSprite draw position sprite - let drawHouse localPosition = - let position = worldTile plan localPosition - for dx in -1 .. 1 do - draw (offsetTile position dx 0) RoofSprite - draw (offsetTile position dx 1) WallSprite - draw (offsetTile position 0 1) BridgeSprite + let drawHouse doorTile = + let position = worldTile plan doorTile + for dx in -2 .. 1 do + draw (offsetTile position dx -2) RoofRidgeSprite + draw (offsetTile position dx -1) RoofEaveSprite + draw (offsetTile position -2 0) WallWoodSprite + draw (offsetTile position -1 0) WallWindowSprite + draw (offsetTile position 0 0) DoorSprite + draw (offsetTile position 1 0) WallWoodSprite let drawBridge localPosition = let position = worldTile plan localPosition -- cgit v1.2.3