summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj1
-rw-r--r--src/LivingVillage.Desktop.Tests/P73LightingTierTests.fs67
-rw-r--r--src/LivingVillage.Desktop.Tests/PrototypeTests.fs2
-rw-r--r--src/LivingVillage.Desktop/Assets/cjk-glyph-atlas.pngbin90591 -> 90485 bytes
-rw-r--r--src/LivingVillage.Desktop/Assets/cjk-glyphs.txt2
-rw-r--r--src/LivingVillage.Desktop/CjkGlyphAtlas.fs2
-rw-r--r--src/LivingVillage.Desktop/Game.fs77
-rw-r--r--src/LivingVillage.Desktop/M6Presentation.fs70
8 files changed, 206 insertions, 15 deletions
diff --git a/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj b/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj
index 432cd03..11a1b90 100644
--- a/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj
+++ b/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj
@@ -44,6 +44,7 @@
<Compile Include="P69CopyAuditTests.fs" />
<Compile Include="P71ApiDocsTests.fs" />
<Compile Include="P72CharacterWalkTests.fs" />
+ <Compile Include="P73LightingTierTests.fs" />
<Compile Include="SampleTests.fs" />
</ItemGroup>
diff --git a/src/LivingVillage.Desktop.Tests/P73LightingTierTests.fs b/src/LivingVillage.Desktop.Tests/P73LightingTierTests.fs
new file mode 100644
index 0000000..e5baf0a
--- /dev/null
+++ b/src/LivingVillage.Desktop.Tests/P73LightingTierTests.fs
@@ -0,0 +1,67 @@
+namespace LivingVillage.Desktop.Tests
+
+open Microsoft.VisualStudio.TestTools.UnitTesting
+open Microsoft.Xna.Framework
+open LivingVillage.Desktop
+open LivingVillage.Kernel
+open LivingVillage.Kernel.Sim
+
+/// P73 回归:四时段光照档参数表完整性 + 与既有连续光照/时段标签一致。
+[<TestClass>]
+type P73LightingTierTests () =
+
+ let ticksPerHour = Sim.ticksPerDay / 24L
+ let atHour hour = int64 hour * ticksPerHour
+
+ [<TestMethod>]
+ member _.PeriodTableCoversFourDistinctTiers () =
+ let periods = [ M6Presentation.Morning; M6Presentation.Noon; M6Presentation.Dusk; M6Presentation.Night ]
+ let stated =
+ periods
+ |> List.map (fun p ->
+ let l = M6Presentation.periodLighting p
+ (p, l.AmbientTint.R, l.AmbientTint.G, l.AmbientTint.B, l.Veil.R, l.Veil.G, l.Veil.B, l.VeilAlpha, l.LanternGlow))
+ // 四档两两不同(色调/覆盖色/alpha/灯光至少一项相异)。
+ Assert.AreEqual<int>(4, stated |> List.map (fun (_, r, g, b, vr, vg, vb, a, glow) -> (r, g, b, vr, vg, vb, a, glow)) |> List.distinct |> List.length)
+ // 名称表覆盖全四档。
+ let names = periods |> List.map M6Presentation.lightingPeriodName
+ Assert.AreEqual<int>(4, names |> List.distinct |> List.length)
+ Assert.IsTrue(names |> List.forall (fun n -> n <> ""))
+
+ [<TestMethod>]
+ member _.NoonTierIsIdentityAndNightLightsLanterns () =
+ let noon = M6Presentation.periodLighting M6Presentation.Noon
+ Assert.AreEqual<int>(255, int noon.AmbientTint.R)
+ Assert.AreEqual<int>(255, int noon.AmbientTint.G)
+ Assert.AreEqual<int>(255, int noon.AmbientTint.B)
+ Assert.AreEqual<int>(0, noon.VeilAlpha)
+ Assert.AreEqual<float32>(0.0f, noon.LanternGlow)
+
+ let night = M6Presentation.periodLighting M6Presentation.Night
+ Assert.AreEqual<float32>(1.0f, night.LanternGlow)
+ let dusk = M6Presentation.periodLighting M6Presentation.Dusk
+ Assert.IsTrue(dusk.LanternGlow >= 0.3f, "黄昏须开始点亮路灯/灯笼")
+
+ // 实际灯光强度:夜晚点亮,正午熄灭。
+ Assert.IsTrue(M6Presentation.effectiveLanternGlow (atHour 22) >= 1.0f)
+ Assert.AreEqual<float32>(0.0f, M6Presentation.effectiveLanternGlow (atHour 12))
+
+ [<TestMethod>]
+ member _.PeriodAtTickMatchesRequestedHoursAndExistingLabels () =
+ Assert.AreEqual<M6Presentation.M6Period>(M6Presentation.Morning, M6Presentation.periodAtTick (atHour 6))
+ Assert.AreEqual<M6Presentation.M6Period>(M6Presentation.Noon, M6Presentation.periodAtTick (atHour 12))
+ Assert.AreEqual<M6Presentation.M6Period>(M6Presentation.Dusk, M6Presentation.periodAtTick (atHour 18))
+ Assert.AreEqual<M6Presentation.M6Period>(M6Presentation.Night, M6Presentation.periodAtTick (atHour 22))
+ // 边界与既有 timePeriodLabel 完全一致:清晨↔清晨、正午↔白天、黄昏↔黄昏、夜晚↔夜晚。
+ let expectedLabel period =
+ match period with
+ | M6Presentation.Morning -> "清晨"
+ | M6Presentation.Noon -> "白天"
+ | M6Presentation.Dusk -> "黄昏"
+ | M6Presentation.Night -> "夜晚"
+ for hour in 0 .. 23 do
+ let label = M6Presentation.timePeriodLabel (atHour hour)
+ Assert.AreEqual<string>(expectedLabel (M6Presentation.periodAtTick (atHour hour)), label)
+ // 乘法色调:白色恒等。
+ let day = M6Presentation.profileAtTick (atHour 12)
+ Assert.AreEqual<Color>(day.WorldTint, M6Presentation.multiplyTint day.WorldTint (M6Presentation.periodLighting M6Presentation.Noon).AmbientTint)
diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
index 68e5b93..5da55f1 100644
--- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
+++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
@@ -1100,7 +1100,7 @@ type PrototypeTests () =
[<TestMethod>]
member _.CjkGlyphAtlasHasAStableCharacterTableAndGeometry () =
- Assert.AreEqual<int>(343, characters.Length)
+ Assert.AreEqual<int>(345, characters.Length)
CollectionAssert.AreEqual(characters, characters |> Array.sort)
Assert.AreEqual<int>(characters.Length, characters |> Array.distinct |> Array.length)
Assert.AreEqual<int>(16, columns)
diff --git a/src/LivingVillage.Desktop/Assets/cjk-glyph-atlas.png b/src/LivingVillage.Desktop/Assets/cjk-glyph-atlas.png
index 6d422e7..75c3577 100644
--- a/src/LivingVillage.Desktop/Assets/cjk-glyph-atlas.png
+++ b/src/LivingVillage.Desktop/Assets/cjk-glyph-atlas.png
Binary files differ
diff --git a/src/LivingVillage.Desktop/Assets/cjk-glyphs.txt b/src/LivingVillage.Desktop/Assets/cjk-glyphs.txt
index 7532222..c4724b7 100644
--- a/src/LivingVillage.Desktop/Assets/cjk-glyphs.txt
+++ b/src/LivingVillage.Desktop/Assets/cjk-glyphs.txt
@@ -63,6 +63,7 @@
匀
包
北
+午
单
卖
南
@@ -200,6 +201,7 @@
档
桥
歉
+正
段
民
水
diff --git a/src/LivingVillage.Desktop/CjkGlyphAtlas.fs b/src/LivingVillage.Desktop/CjkGlyphAtlas.fs
index a295f10..c8b7986 100644
--- a/src/LivingVillage.Desktop/CjkGlyphAtlas.fs
+++ b/src/LivingVillage.Desktop/CjkGlyphAtlas.fs
@@ -11,7 +11,7 @@ module CjkGlyphAtlas =
// Keep this table sorted and stable so the generated PNG has a reproducible layout.
let private characterTable =
- "×→一上不与业东两中为主乐乡书买了争事于互些交人今从以件价任众会传位体作使保信倍停先入关内册再农冬准几出分切到前剧力功务动助匀包北单卖南卷原去友取受口只可各同和品回围圃土在地坏块墙备夏多夜大天夫失头好始子存完定家察对将小尚就层居屋工差己已巴巷币布帮常平年庄库应庙度开式当录待得心必态怒总恼情愁意戏成或户打找报拒择指挑捕据接提播操收改效敌数文料新方无日旧时明昏易春是晓晚晨景暂更最有未村束板林果柴标格档桥歉段民水求江没法涨淡清渔游热照物状玩理瓦生用田留白的盐目看真石确社离秋移稳空竹笑第米粮精系紧纭纷线结给绝继绪续置翻耕聊职背能自范茶获菜落衅行西观认讨议记讲论设访试话询说请读谅谈败货贩资走足路跳车转轴过近返还进迫退送选速道邻郎都里量金鉴钱门闭问闯闲间闻附雨零需面页项须食饥饿香鱼黄黛,:"
+ "×→一上不与业东两中为主乐乡书买了争事于互些交人今从以件价任众会传位体作使保信倍停先入关内册再农冬准几出分切到前剧力功务动助匀包北午单卖南卷原去友取受口只可各同和品回围圃土在地坏块墙备夏多夜大天夫失头好始子存完定家察对将小尚就层居屋工差己已巴巷币布帮常平年庄库应庙度开式当录待得心必态怒总恼情愁意戏成或户打找报拒择指挑捕据接提播操收改效敌数文料新方无日旧时明昏易春是晓晚晨景暂更最有未村束板林果柴标格档桥歉正段民水求江没法涨淡清渔游热照物状玩理瓦生用田留白的盐目看真石确社离秋移稳空竹笑第米粮精系紧纭纷线结给绝继绪续置翻耕聊职背能自范茶获菜落衅行西观认讨议记讲论设访试话询说请读谅谈败货贩资走足路跳车转轴过近返还进迫退送选速道邻郎都里量金鉴钱门闭问闯闲间闻附雨零需面页项须食饥饿香鱼黄黛,:"
let characters = characterTable.ToCharArray()
let rowCount = (characters.Length + columns - 1) / columns
diff --git a/src/LivingVillage.Desktop/Game.fs b/src/LivingVillage.Desktop/Game.fs
index 6252117..3d04ca7 100644
--- a/src/LivingVillage.Desktop/Game.fs
+++ b/src/LivingVillage.Desktop/Game.fs
@@ -388,6 +388,10 @@ type LivingVillageGame() as this =
let mutable p47Step = 0
let mutable p47PendingName = ""
let mutable p47Pending = false
+ // P73 证据钩子:LV_P73_SHOT=1 时在同一生成器世界的桥头光源处,按
+ // 6/12/18/22 时各拍一帧(同机位),四张真实帧用于四时段光照档差异核验。
+ let p73ShotMode = Environment.GetEnvironmentVariable("LV_P73_SHOT") = "1"
+ let mutable p73Step = 0
// P52 证据钩子:LV_P52_SHOT=1 时选职业开局 → 走到 NPC 旁用真实 Interact 开对话 →
// 真实 BuyFromTarget / SellToTarget 各一次,拍「对话入口 / 买入后 / 卖出后」三帧;
// 每笔交易打印钱与背包数量前后值,供 analyze 脚本算 delta。
@@ -1474,7 +1478,39 @@ type LivingVillageGame() as this =
let placeCameraOn (tileX: int) (tileY: int) =
world <- { world with Avatar = { world.Avatar with Pos = { X = float32 (tileX * Sim.tilePixels); Y = float32 (tileY * Sim.tilePixels) } } }
this.CenterCamera()
- if not p47Pending then
+ if p73ShotMode then
+ // 同一桥头光源机位的四时段巡拍;tick 只经 setHour 改变,保证画面差异只来自光照档。
+ let hours = [ ("p73-morning", 6.0); ("p73-noon", 12.0); ("p73-dusk", 18.0); ("p73-night", 22.0) ]
+ if p73Step < hours.Length then
+ match riverscapeMap with
+ | Some map ->
+ let pick =
+ SceneDetail.lightSources map
+ |> List.sortByDescending (fun (x, y, _) -> SceneDetail.reflectionLength map x y)
+ |> List.tryHead
+ let spot = match pick with Some (x, y, _) -> x, y | None -> map.Core.MinX, map.Core.MinY
+ let name, hour = hours.[p73Step]
+ setHour hour
+ placeCameraOn (fst spot) (snd spot)
+ p47PendingName <- name
+ let tint = (M6Presentation.profileAtTick world.Tick).WorldTint
+ printfn
+ "p73-shot=%s hour=%.1f tick=%d period=%s blend=%.3f lantern=%.2f tint=%d,%d,%d veil=%d"
+ name hour world.Tick
+ (M6Presentation.lightingPeriodName (M6Presentation.periodAtTick world.Tick))
+ (M6Presentation.lightingBlend world.Tick)
+ (M6Presentation.effectiveLanternGlow world.Tick)
+ (int tint.R) (int tint.G) (int tint.B)
+ (M6Presentation.periodLightingAtTick world.Tick).VeilAlpha
+ p47Pending <- true
+ | None ->
+ printfn "p73-shot=error no-riverscape-map"
+ this.Exit()
+ else
+ printfn "p73-shot=done"
+ this.Exit()
+ ()
+ elif not p47Pending then
match riverscapeMap with
| None -> this.Exit()
| Some map ->
@@ -1582,9 +1618,14 @@ type LivingVillageGame() as this =
p47Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p47PendingName)
- printfn "p47-shot=%s tick=%d pos=(%.0f,%.0f) camera=(%.0f,%.0f)"
- p47PendingName world.Tick world.Avatar.Pos.X world.Avatar.Pos.Y camera.X camera.Y
- p47Step <- p47Step + 1
+ if p73ShotMode then
+ printfn "p73-frame=%s tick=%d pos=(%.0f,%.0f) camera=(%.0f,%.0f)"
+ p47PendingName world.Tick world.Avatar.Pos.X world.Avatar.Pos.Y camera.X camera.Y
+ p73Step <- p73Step + 1
+ else
+ printfn "p47-shot=%s tick=%d pos=(%.0f,%.0f) camera=(%.0f,%.0f)"
+ p47PendingName world.Tick world.Avatar.Pos.X world.Avatar.Pos.Y camera.X camera.Y
+ p47Step <- p47Step + 1
/// P52 证据:选职业开局 → 真实 Interact 开对话 → 真实 BuyFromTarget / SellToTarget 各一次。
member private this.PrepareP52Shot () =
@@ -2386,7 +2427,7 @@ type LivingVillageGame() as this =
elif p57ShotMode then
if menu.Page = MainMenu then
this.PrepareP57Shot()
- elif p47ShotMode then
+ elif p47ShotMode || p73ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
@@ -2864,7 +2905,7 @@ type LivingVillageGame() as this =
this.CaptureP46Shot()
if p57ShotMode then
this.CaptureP57Shot()
- if p47ShotMode && menu.Page = Playing then
+ if (p47ShotMode || p73ShotMode) && menu.Page = Playing then
this.CaptureP47Shot()
if p52ShotMode && menu.Page = Playing then
this.CaptureP52Shot()
@@ -3126,6 +3167,10 @@ type LivingVillageGame() as this =
member private this.DrawWorldView() =
let profile = M6Presentation.profileAtTick world.Tick
+ // P73:时段档并入世界色调与灯光强度;正午档为恒等,不影响既有正午观感。
+ let period = M6Presentation.periodLightingAtTick world.Tick
+ let worldTint = M6Presentation.multiplyTint profile.WorldTint period.AmbientTint
+ let lanternGlow = M6Presentation.effectiveLanternGlow world.Tick
let viewport = this.GraphicsDevice.Viewport
this.GraphicsDevice.Clear(profile.Background)
spriteBatch.Begin()
@@ -3145,14 +3190,14 @@ type LivingVillageGame() as this =
renderPlan
riverscapeMap
world.Tick
- profile.WorldTint
+ worldTint
// Warm lantern / window glows strengthen as night falls (pure function of tick phase).
// Concentric premultiplied circles follow a quadratic radial falloff (radius 3-4 tiles),
// so the core stays a soft warm disc instead of saturating to a white block and no glow
// is painted where there is no light entity. 生成器世界用桥头灯笼 + 民居门窗。
- if profile.LanternGlow > 0.3f then
- let glow = profile.LanternGlow
+ if lanternGlow > 0.3f then
+ let glow = lanternGlow
let peakAlpha = int (140.0f * glow)
let tileX x = x * Sim.tilePixels - int camera.X
let tileY y = y * Sim.tilePixels - int camera.Y
@@ -3180,9 +3225,9 @@ type LivingVillageGame() as this =
spriteBatch.Draw(pixel, rect, color)
| _ -> ()
- match riverscapeMap, profile.LanternGlow > 0.3f with
+ match riverscapeMap, lanternGlow > 0.3f with
| Some map, true ->
- VillageArt.drawCc0BoatOverlay spriteBatch artTextures camera map profile.WorldTint
+ VillageArt.drawCc0BoatOverlay spriteBatch artTextures camera map worldTint
| _ -> ()
// P47 场景细节:河道倒影 + 岸边芦苇加密度 + 漂浮元素 + 近景楼层层错落。
@@ -3202,12 +3247,12 @@ type LivingVillageGame() as this =
VillageArt.drawGroundShadow spriteBatch pixel camera world.Avatar.Pos
let avatarSpec = VillageArt.avatarSpriteSpec avatarFacing avatarMoving world.Tick
- VillageArt.drawCharacter spriteBatch artTextures camera world.Avatar.Pos avatarSpec profile.WorldTint
+ VillageArt.drawCharacter spriteBatch artTextures camera world.Avatar.Pos avatarSpec worldTint
for npc in world.Npcs do
VillageArt.drawGroundShadow spriteBatch pixel camera npc.Pos
let spec = VillageArt.npcSpriteSpecAtTarget npc.Id npc.Pos npc.Mind.Target world.Tick
- VillageArt.drawCharacter spriteBatch artTextures camera npc.Pos spec profile.WorldTint
+ VillageArt.drawCharacter spriteBatch artTextures camera npc.Pos spec worldTint
// Golden-hour wash: the multiplicative WorldTint can only darken, so a warm
// premultiplied veil is layered over the whole scene. Because rgb is premultiplied
@@ -3224,6 +3269,12 @@ type LivingVillageGame() as this =
if moonAlpha > 0 then
let mr, mg, mb = M6Presentation.moonlightRgb
spriteBatch.Draw(pixel, Rectangle(0, 0, viewport.Width, viewport.Height), VillageArt.premultiply mr mg mb moonAlpha)
+
+ // P73:时段档加性覆盖色,最后叠上,保证 6/12/18/22 四时段色调肉眼可辨;
+ // 正午 alpha=0 故为恒等,清晨偏冷、黄昏暖橙、夜晚冷蓝。
+ if period.VeilAlpha > 0 then
+ let v = period.Veil
+ spriteBatch.Draw(pixel, Rectangle(0, 0, viewport.Width, viewport.Height), VillageArt.premultiply (int v.R) (int v.G) (int v.B) period.VeilAlpha)
spriteBatch.End()
// Contextual floating prompt over the unique target; same CJK atlas font path as the HUD.
diff --git a/src/LivingVillage.Desktop/M6Presentation.fs b/src/LivingVillage.Desktop/M6Presentation.fs
index 825847a..4e88bd9 100644
--- a/src/LivingVillage.Desktop/M6Presentation.fs
+++ b/src/LivingVillage.Desktop/M6Presentation.fs
@@ -159,3 +159,73 @@ module M6Presentation =
elif hour < 17 then "白天"
elif hour < 21 then "黄昏"
else "夜晚"
+
+ // ------------------------------------------------------------------
+ // P73:四时段光照档(清晨/正午/黄昏/夜晚)。
+ // 既有的 blend/warmth 是连续曲线;这里在其上叠加一层「时段档」——
+ // 每个时段一份乘性环境色调 + 加性覆盖色 + 灯光强度,保证 6/12/18/22 时
+ // 四张真实帧肉眼可辨,尤其填补 17:00–19:15 原本与正午无差的黄昏空档。
+ // 正午档为恒等(白 tint / alpha 0 / 灯光 0),因此不改变既有正午观感。
+ // ------------------------------------------------------------------
+
+ type M6Period =
+ | Morning
+ | Noon
+ | Dusk
+ | Night
+
+ type M6PeriodLighting =
+ { AmbientTint: Color
+ Veil: Color
+ VeilAlpha: int
+ LanternGlow: float32 }
+
+ /// 时段档参数表(纯数据)。调用方按 periodAtTick 取值。
+ let periodLighting (period: M6Period) : M6PeriodLighting =
+ match period with
+ | Morning ->
+ { AmbientTint = Color(238, 246, 255)
+ Veil = Color(255, 222, 160)
+ VeilAlpha = 20
+ LanternGlow = 0.0f }
+ | Noon ->
+ { AmbientTint = Color(255, 255, 255)
+ Veil = Color(255, 255, 255)
+ VeilAlpha = 0
+ LanternGlow = 0.0f }
+ | Dusk ->
+ { AmbientTint = Color(255, 231, 200)
+ Veil = Color(255, 140, 58)
+ VeilAlpha = 52
+ LanternGlow = 0.6f }
+ | Night ->
+ { AmbientTint = Color(150, 176, 216)
+ Veil = Color(70, 110, 190)
+ VeilAlpha = 26
+ LanternGlow = 1.0f }
+
+ /// 时段枚举名(证据日志用,纯函数;与 timePeriodLabel 边界一致)。
+ let lightingPeriodName = function
+ | Morning -> "清晨"
+ | Noon -> "正午"
+ | Dusk -> "黄昏"
+ | Night -> "夜晚"
+
+ /// tick → 四时段档。边界与 timePeriodLabel 完全一致:<5 夜晚、<8 清晨、<17 正午、<21 黄昏、否则夜晚。
+ let periodAtTick (tick: int64) : M6Period =
+ let hour = hourOf tick
+ if hour < 5 then Night
+ elif hour < 8 then Morning
+ elif hour < 17 then Noon
+ elif hour < 21 then Dusk
+ else Night
+
+ let periodLightingAtTick (tick: int64) : M6PeriodLighting = periodAtTick tick |> periodLighting
+
+ /// 两乘性色调逐通道相乘(255 为恒等)。用于把时段环境色调并入世界 tint。
+ let multiplyTint (a: Color) (b: Color) : Color =
+ Color(int a.R * int b.R / 255, int a.G * int b.G / 255, int a.B * int b.B / 255, 255)
+
+ /// 实际灯光强度:连续曲线与时段档取较大者(黄昏档让灯笼从 18:00 起点亮)。
+ let effectiveLanternGlow (tick: int64) : float32 =
+ max (lightingAtTick tick).LanternGlow (periodLightingAtTick tick).LanternGlow