1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
|
namespace LivingVillage.Desktop
open System
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Graphics
open Microsoft.Xna.Framework.Input
open LivingVillage.Kernel
open LivingVillage.Kernel.Sim
open LivingVillage.Desktop.ChineseText
open LivingVillage.Desktop.VillagePresentation
module PixelText =
let private glyphs =
[ 'A', [| "01110"; "10001"; "10001"; "11111"; "10001"; "10001"; "10001" |]
'B', [| "11110"; "10001"; "10001"; "11110"; "10001"; "10001"; "11110" |]
'C', [| "01111"; "10000"; "10000"; "10000"; "10000"; "10000"; "01111" |]
'D', [| "11110"; "10001"; "10001"; "10001"; "10001"; "10001"; "11110" |]
'E', [| "11111"; "10000"; "10000"; "11110"; "10000"; "10000"; "11111" |]
'F', [| "11111"; "10000"; "10000"; "11110"; "10000"; "10000"; "10000" |]
'G', [| "01111"; "10000"; "10000"; "10111"; "10001"; "10001"; "01111" |]
'H', [| "10001"; "10001"; "10001"; "11111"; "10001"; "10001"; "10001" |]
'I', [| "11111"; "00100"; "00100"; "00100"; "00100"; "00100"; "11111" |]
'J', [| "00111"; "00010"; "00010"; "00010"; "00010"; "10010"; "01100" |]
'K', [| "10001"; "10010"; "10100"; "11000"; "10100"; "10010"; "10001" |]
'L', [| "10000"; "10000"; "10000"; "10000"; "10000"; "10000"; "11111" |]
'M', [| "10001"; "11011"; "10101"; "10101"; "10001"; "10001"; "10001" |]
'N', [| "10001"; "11001"; "10101"; "10011"; "10001"; "10001"; "10001" |]
'O', [| "01110"; "10001"; "10001"; "10001"; "10001"; "10001"; "01110" |]
'P', [| "11110"; "10001"; "10001"; "11110"; "10000"; "10000"; "10000" |]
'Q', [| "01110"; "10001"; "10001"; "10001"; "10101"; "10010"; "01101" |]
'R', [| "11110"; "10001"; "10001"; "11110"; "10100"; "10010"; "10001" |]
'S', [| "01111"; "10000"; "10000"; "01110"; "00001"; "00001"; "11110" |]
'T', [| "11111"; "00100"; "00100"; "00100"; "00100"; "00100"; "00100" |]
'U', [| "10001"; "10001"; "10001"; "10001"; "10001"; "10001"; "01110" |]
'V', [| "10001"; "10001"; "10001"; "10001"; "10001"; "01010"; "00100" |]
'W', [| "10001"; "10001"; "10001"; "10101"; "10101"; "11011"; "10001" |]
'X', [| "10001"; "10001"; "01010"; "00100"; "01010"; "10001"; "10001" |]
'Y', [| "10001"; "10001"; "01010"; "00100"; "00100"; "00100"; "00100" |]
'Z', [| "11111"; "00001"; "00010"; "00100"; "01000"; "10000"; "11111" |]
'0', [| "01110"; "10001"; "10011"; "10101"; "11001"; "10001"; "01110" |]
'1', [| "00100"; "01100"; "00100"; "00100"; "00100"; "00100"; "01110" |]
'2', [| "01110"; "10001"; "00001"; "00010"; "00100"; "01000"; "11111" |]
'3', [| "11110"; "00001"; "00001"; "01110"; "00001"; "00001"; "11110" |]
'4', [| "00010"; "00110"; "01010"; "10010"; "11111"; "00010"; "00010" |]
'5', [| "11111"; "10000"; "10000"; "11110"; "00001"; "00001"; "11110" |]
'6', [| "01110"; "10000"; "10000"; "11110"; "10001"; "10001"; "01110" |]
'7', [| "11111"; "00001"; "00010"; "00100"; "01000"; "01000"; "01000" |]
'8', [| "01110"; "10001"; "10001"; "01110"; "10001"; "10001"; "01110" |]
'9', [| "01110"; "10001"; "10001"; "01111"; "00001"; "00001"; "01110" |]
('-', [| "00000"; "00000"; "00000"; "11111"; "00000"; "00000"; "00000" |])
('.', [| "00000"; "00000"; "00000"; "00000"; "00000"; "00110"; "00110" |])
('=', [| "00000"; "11111"; "00000"; "00000"; "11111"; "00000"; "00000" |])
(':', [| "00000"; "00110"; "00110"; "00000"; "00110"; "00110"; "00000" |])
(';', [| "00000"; "00110"; "00110"; "00000"; "00110"; "00100"; "01000" |])
('/', [| "00001"; "00010"; "00010"; "00100"; "01000"; "01000"; "10000" |])
('>', [| "10000"; "01000"; "00100"; "00010"; "00100"; "01000"; "10000" |])
('?', [| "01110"; "10001"; "00001"; "00010"; "00100"; "00000"; "00100" |]) ]
|> Map.ofList
let isRenderable (text: string) : bool =
not (isNull text)
&& text
|> Seq.forall (fun character ->
character = ' '
|| Map.containsKey (Char.ToUpperInvariant character) glyphs
|| CjkGlyphAtlas.contains character)
let draw (spriteBatch: SpriteBatch) (pixel: Texture2D) (cjkAtlas: Texture2D) (x: int) (y: int) (scale: int) (color: Color) (text: string) =
let mutable cursor = x
for character in text.ToUpperInvariant() do
if character = ' ' then
cursor <- cursor + (4 * scale)
elif CjkGlyphAtlas.sourceRectangle character |> Option.isSome then
let source = CjkGlyphAtlas.sourceRectangle character |> Option.get
let glyphPixels = 8 * scale
spriteBatch.Draw(
cjkAtlas,
Rectangle(cursor, y, glyphPixels, glyphPixels),
Nullable<Rectangle>(source),
color)
cursor <- cursor + glyphPixels
else
match glyphs |> Map.tryFind character with
| Some rows ->
for row in 0 .. rows.Length - 1 do
for column in 0 .. rows.[row].Length - 1 do
if rows.[row].[column] = '1' then
spriteBatch.Draw(pixel, Rectangle(cursor + column * scale, y + row * scale, scale, scale), color)
cursor <- cursor + (6 * scale)
| None ->
// Unsupported characters are intentionally blank, never a fake glyph.
cursor <- cursor + (6 * scale)
type LivingVillageGame() as this =
inherit Game()
let autoplay = (Environment.GetEnvironmentVariable("LV_AUTOPLAY") = "1") || (Environment.GetEnvironmentVariable("LV_MAP_TOUR") = "1")
let autoplayFlow = Environment.GetEnvironmentVariable("LV_AUTOPLAY_FLOW") = "1"
// P36 证据钩子:复用 sample 脚本的走位/互动序列,但按状态抓 4 帧关键帧
// (靠近→提示出现→对话层打开且世界交互被隔离→关闭离开提示消失)后退出。
let p36ShotMode = Environment.GetEnvironmentVariable("LV_P36_SHOT") = "1"
// P72 evidence hook: with sample recording on, log each saved frame's per-NPC walk
// frame so the PNGs can be correlated with the deterministic 6-frame cycle.
let p72Log = Environment.GetEnvironmentVariable("LV_P72_LOG") = "1"
let sampleMode = Environment.GetEnvironmentVariable("LV_AUTOPLAY_SAMPLE") = "1" || p36ShotMode
let menuShotMode = Environment.GetEnvironmentVariable("LV_AUTOPLAY_MENU_SHOT") = "1"
let daylightAutoplay = Environment.GetEnvironmentVariable("LV_AUTOPLAY_DAYLIGHT") = "1"
let automated = autoplay || autoplayFlow
let modeName =
if sampleMode then "sample"
elif autoplayFlow then "autoplay-flow"
elif autoplay then "autoplay"
else "keyboard"
let configuredStepsPerFrame =
match Environment.GetEnvironmentVariable("LV_STEPS_PER_FRAME") with
| null | "" -> 1
| s ->
match Int32.TryParse s with
| true, n when n > 0 -> n
| _ -> 1
let initialSimulationControl, initialLegacyStepsPerFrame =
SimulationControl.initialForConfiguredSteps configuredStepsPerFrame
let startSimulationControl =
if sampleMode then SimulationControl.setSpeed TwoX initialSimulationControl else initialSimulationControl
let savePath =
match Environment.GetEnvironmentVariable("LV_SAVE_PATH") with
| null | "" -> "living-village.save"
| path -> path
let graphics = new GraphicsDeviceManager(this)
let mutable spriteBatch = Unchecked.defaultof<SpriteBatch>
let mutable artTextures = Unchecked.defaultof<VillageArt.ArtTextures>
let mutable cjkAtlas = Unchecked.defaultof<Texture2D>
let mutable pixel = Unchecked.defaultof<Texture2D>
let renderPlan = VillageArt.sampleRenderPlan ()
let legacyMapMode = Environment.GetEnvironmentVariable("LV_LEGACY_MAP") = "1"
let mapScale =
match Environment.GetEnvironmentVariable("LV_MAP_SCALE") with
| null | "" -> 1
| v -> match Int32.TryParse v with (true, value) -> max 1 value | _ -> 1
let mapTourMode = Environment.GetEnvironmentVariable("LV_MAP_TOUR") = "1"
// P20 第三步:默认可玩世界走 256x192 生成器(核心可达区站位);LV_LEGACY_MAP=1 回退 64x48。
// 证据用 sample 流程(LV_AUTOPLAY_SAMPLE)保持旧 64x48 以确保既有录像可复现,除非显式请求巡游。
let riverscapeTourRequested = Environment.GetEnvironmentVariable("LV_RIVERSCAPE_TOUR") = "1"
let riverscapeActive = not legacyMapMode && not mapTourMode && mapScale <= 1 && (not sampleMode || riverscapeTourRequested)
// P23 取证钩子:可把生成器世界扩到 512x384(默认仍是 256x192,不改默认值)。
let riverscapeWidth =
match Environment.GetEnvironmentVariable("LV_RIVERSCAPE_WIDTH") with
| null | "" -> 256
| v -> match Int32.TryParse v with (true, value) when value > 0 -> value | _ -> 256
let riverscapeHeight =
match Environment.GetEnvironmentVariable("LV_RIVERSCAPE_HEIGHT") with
| null | "" -> 192
| v -> match Int32.TryParse v with (true, value) when value > 0 -> value | _ -> 192
let riverscapeMap : MapGen.Result option =
if riverscapeActive then
Sim.configureBounds riverscapeWidth riverscapeHeight
Some (MapGen.generateWithSize riverscapeWidth riverscapeHeight 42UL)
else
None
let riverscapeTourMode = riverscapeTourRequested && riverscapeActive
// P21 性能核对:>0 时巡游循环到该秒数再退出(默认 0 = 跑完一遍路点)。
let riverscapeTourSeconds =
match Environment.GetEnvironmentVariable("LV_RIVERSCAPE_SECONDS") with
| null | "" -> 0.0
| v ->
match Double.TryParse(v, Globalization.NumberStyles.Float, Globalization.CultureInfo.InvariantCulture) with
| true, seconds when seconds > 0.0 -> seconds
| _ -> 0.0
let riverscapeTourWatch = System.Diagnostics.Stopwatch()
let mutable riverscapeTourWatchStarted = false
// P25 证据钩子:村民巡游。NPC 行动目标固定在 Sim 的四个活动点(厨房/家/集市/工位),
// 让 avatar 在这些点之间环游,保证记录帧多数时刻屏内有 >=8 名村民。
let riverscapeVillageTour = Environment.GetEnvironmentVariable("LV_RIVERSCAPE_VILLAGE_TOUR") = "1"
let villageTourWaypoints () : (int * int) list =
let tileOf (p: Vec2) = (int p.X / Sim.tilePixels, int p.Y / Sim.tilePixels)
let plaza = tileOf Sim.plazaPoint
let kitchen = tileOf Sim.kitchenPoint
let home = tileOf Sim.homePoint
let worksite = tileOf Sim.worksitePoint
[ plaza; home; worksite; kitchen; plaza ]
/// 巡游路点:第一座桥的整列(含两端外沿)+ 民居门 + 核心中心,用于桥面行走取证。
/// LV_RIVERSCAPE_VILLAGE_TOUR=1 时改为村民活动点环游(P25 村民可见性取证)。
let riverscapeTourWaypoints () : (int * int) list =
match riverscapeMap with
| None -> []
| Some map when riverscapeVillageTour ->
villageTourWaypoints ()
|> List.filter (fun (x, y) -> x >= 0 && x < map.Width && y >= 0 && y < map.Height)
|> List.distinct
| Some map ->
let bridgeStops =
map.Bridges
|> List.groupBy fst
|> List.sortBy fst
|> List.truncate 1
|> List.collect (fun (x, entries) ->
let ys = entries |> List.map snd |> List.sort
[ (x, List.min ys - 2) ] @ [ for y in ys -> (x, y) ] @ [ (x, List.max ys + 2) ])
let doors = map.Buildings |> List.map (fun building -> (building.DoorX, building.DoorY))
let core = ((map.Core.MinX + map.Core.MaxX) / 2, (map.Core.MinY + map.Core.MaxY) / 2)
(bridgeStops @ doors @ [ core ])
|> List.filter (fun (x, y) -> x >= 0 && x < map.Width && y >= 0 && y < map.Height)
|> List.distinct
// Evidence hook: pin the starting wall-clock hour (e.g. 20.75 for 黄昏), desktop-only.
let startHourOverride =
match Environment.GetEnvironmentVariable("LV_AUTOPLAY_START_HOUR") with
| null | "" -> None
| value ->
match Double.TryParse(value, Globalization.NumberStyles.Float, Globalization.CultureInfo.InvariantCulture) with
| true, hour -> Some hour
| _ -> None
// Single source of truth for the starting tick so the sample/autoplay path (which
// re-creates the world via StartNewGame) honours the evidence hour too.
let evidenceStartTick () =
M6Presentation.resolveStartTick startHourOverride daylightAutoplay
let withStartTick (world: World) : World =
let tick = evidenceStartTick ()
{ world with Tick = tick; Time = float tick * Sim.dtSeconds }
let initialWorldForMode (occupation: Occupation.State option) : World =
match riverscapeMap with
| Some map ->
let core = map.Core
WorldBootstrap.initialWorldWithPlacement
daylightAutoplay
42UL
Sim.npcCount
((core.MinX + core.MaxX) / 2, (core.MinY + core.MaxY) / 2)
map.Spawns
occupation
| None -> WorldBootstrap.initialWorldWithOccupation daylightAutoplay 42UL Sim.npcCount occupation
let createInitialWorld () =
initialWorldForMode None |> withStartTick
let mutable world = createInitialWorld ()
let mutable camera = Vector2.Zero
let mutable avatarFacing = VillageArt.SouthFacing
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
// P22:让 sample/legacy 世界也能长时间采样帧率(>0 时跑完一轮脚本后回到开头继续)。
let perfSoakSeconds =
match Environment.GetEnvironmentVariable("LV_PERF_SOAK_SECONDS") with
| null | "" -> 0.0
| v ->
match Double.TryParse(v, Globalization.NumberStyles.Float, Globalization.CultureInfo.InvariantCulture) with
| true, seconds when seconds > 0.0 -> seconds
| _ -> 0.0
let perfSoakWatch = System.Diagnostics.Stopwatch()
let mutable perfSoakStarted = false
// P70 基准:LV_FRAME_LOG=1 时逐帧打印真实帧间隔(墙钟 ms,含 Update+Draw)与线程分配增量,
// 供 scripts/bench-p70.sh + analyze-p70.py 计算平均/最大帧间隔、掉帧与每帧分配。
// 仅新增日志,不改变渲染/更新逻辑;配合 LV_PERF_SOAK_SECONDS + LV_AUTOPLAY_SAMPLE 循环 N 秒。
let frameLogEnabled = Environment.GetEnvironmentVariable("LV_FRAME_LOG") = "1"
let frameLogWatch = System.Diagnostics.Stopwatch()
let mutable frameLogIndex = 0L
let mutable frameLogAllocStart = 0L
let mutable frameLogLastTick = 0L
let mutable prevKb = Unchecked.defaultof<KeyboardState>
let mutable relationView = false
let mutable relationSnapshot: float32[,] option = None
let mutable m5View = M5Interaction.initial
// P54:记录上一帧玩家所在瓦片,用于折叠「到达瓦片」环境信号(仅在跨越瓦片时触发)。
let mutable lastAvatarTile : (int * int) option = None
let mutable simulationControl = startSimulationControl
let mutable legacyStepsPerFrame = (if sampleMode then None else initialLegacyStepsPerFrame)
let mutable menu = MenuState.create startSimulationControl false
let mutable splashActive = true
let mutable splashFrame = 0L
let mutable menuEntranceFrame = 0L
let mutable menuShotFrame = 0L
// P31 证据钩子:LV_STORY_SHOT=1 时以指定职业开局、经真实对话管线推进剧情线后
// 打开任务面板截图,拍完即退出。LV_STORY_OCCUPATION=farmer|fisher|peddler|scholar,
// LV_STORY_STAGE=0..3(默认 2),输出到 LV_RECORD_DIR/p31-story-<职业>-stage<N>.png。
let storyShotMode = Environment.GetEnvironmentVariable("LV_STORY_SHOT") = "1"
let storyShotKind =
match Environment.GetEnvironmentVariable("LV_STORY_OCCUPATION") with
| "fisher" -> Occupation.Fisher
| "peddler" -> Occupation.Peddler
| "scholar" -> Occupation.Scholar
| _ -> Occupation.Farmer
let storyShotStage =
match Environment.GetEnvironmentVariable("LV_STORY_STAGE") with
| null | "" -> 2
| v -> match Int32.TryParse v with (true, value) -> max 0 (min 3 value) | _ -> 2
let mutable storyShotPrepared = false
let mutable storyShotFrame = 0L
let mutable storyShotSaved = false
// P37 证据钩子:LV_P37_SHOT=1 时从主菜单进入职业选择页截图,选定职业开局后打开任务面板
// 截 HUD/任务列表,然后退出。LV_P37_OCCUPATION=farmer|fisher|peddler|scholar(默认渔夫)。
let p37ShotMode = Environment.GetEnvironmentVariable("LV_P37_SHOT") = "1"
let p37Occupation =
match Environment.GetEnvironmentVariable("LV_P37_OCCUPATION") with
| "farmer" -> Occupation.Farmer
| "peddler" -> Occupation.Peddler
| "scholar" -> Occupation.Scholar
| _ -> Occupation.Fisher
let mutable p37Step = 0
let mutable p37Hold = 0
let mutable p37Captured = false
// P39 证据钩子:LV_P39_SHOT=1 时在真实 256x192 生成器世界里,把相机分别对准
// 「桥+乌篷船+芦苇」与「主路石灯笼+菜摊」,拍昼/夜整帧后退出。位置来自
// VillageArt 的确定性摆放纯函数,含真实 tint/光晕,非 mockup。
let p39ShotMode = Environment.GetEnvironmentVariable("LV_P39_SHOT") = "1"
let mutable p39Step = 0
let mutable p39PendingName = ""
let mutable p39Pending = false
// P40 证据钩子:LV_P40_SHOT=1 时在真实 256x192 生成器世界里拍
// p40-day / p40-night / p40-boat-closeup(相机贴近乌篷船,便于 2x 特写)。
let p40ShotMode = Environment.GetEnvironmentVariable("LV_P40_SHOT") = "1"
let mutable p40Step = 0
let mutable p40PendingName = ""
let mutable p40Pending = false
// P42 证据钩子:LV_P42_SHOT=1 时拍启动环境动效两帧 + 菜单动效一帧后退出;
// 全程走正常启动/菜单流程(不改 duration/结构/输入),仅按帧表落盘。
let p42ShotMode = Environment.GetEnvironmentVariable("LV_P42_SHOT") = "1"
let mutable p42SplashEarlyDone = false
let mutable p42SplashLateDone = false
// P74 证据钩子:LV_P74_SHOT=1 时在 60Hz 固定步进下按 splash 帧表拍开场过渡序列,拍完退出。
let p74ShotMode = Environment.GetEnvironmentVariable("LV_P74_SHOT") = "1"
let p74Frames = [ 8L; 30L; 60L; 100L; 140L ]
let mutable p74Saved = Set.empty<int64>
// P43 证据钩子:LV_P43_SHOT=1 时在真实世界里拍昼/夜两张 HUD 整帧(日历钟卡 + 体力条 + 10 格 hotbar)。
let p43ShotMode = Environment.GetEnvironmentVariable("LV_P43_SHOT") = "1"
let mutable p43Step = 0
let mutable p43PendingName = ""
let mutable p43Pending = false
// P44 证据钩子:LV_P44_SHOT=1 时在真实世界里开一场 NPC 对话弹层,拍默认页/翻页后/关闭恢复三帧。
let p44ShotMode = Environment.GetEnvironmentVariable("LV_P44_SHOT") = "1"
let mutable p44Step = 0
let mutable p44PendingName = ""
let mutable p44Pending = false
// P61 证据钩子(G1 字形补齐):拍「右上日历(春夏秋冬·第N天)/ 对话页脚(第N/3页 + V 卖出 背包物品×1)」
// 两帧,证明新补 16 字在真实游戏 UI 中完整可辨。
let p61ShotMode = Environment.GetEnvironmentVariable("LV_P61_SHOT") = "1"
let mutable p61Step = 0
let mutable p61PendingName = ""
let mutable p61Pending = false
// P62 证据钩子(G2):在可玩样板地图里拍「村庄全貌俯瞰」与「民居内景」两帧。
// 内景走真实 MoveTo + PushM5 Interact(同 SampleScript),非合成相机。
let p62ShotMode = Environment.GetEnvironmentVariable("LV_P62_SHOT") = "1"
let mutable p62Step = 0
let mutable p62PendingName = ""
let mutable p62Pending = false
let mutable p62MoveFrames = 0
// P64 证据钩子(A3 成熟度):俯瞰/桥近景/内景三帧,内景走真实 MoveTo + Interact。
let p64ShotMode = Environment.GetEnvironmentVariable("LV_P64_SHOT") = "1"
let mutable p64Step = 0
let mutable p64PendingName = ""
let mutable p64Pending = false
let mutable p64MoveFrames = 0
// P65 证据钩子(职业切片五):货郎真实开局 → 与村民真实闲聊写入既有 World.Rumors →
// 真实 Interact 打开对话菜单(拍菜单帧)→ 选「提议交易」询价,拍带中文行情短答的帧。
let p65ShotMode = Environment.GetEnvironmentVariable("LV_P65_SHOT") = "1"
let mutable p65Step = 0
let mutable p65PendingName = ""
let mutable p65Pending = false
// P67 证据钩子(职业每日任务 UI 目标展示):农夫真实开局 → 找到当日「帮工」任务 →
// 拍带目标帧(帮工:… → 村民 N)与同模板无目标帧(帮工:…,文案与旧版逐字节一致)各一帧。
let p67ShotMode = Environment.GetEnvironmentVariable("LV_P67_SHOT") = "1"
let mutable p67Step = 0
let mutable p67PendingName = ""
let mutable p67Pending = false
// P45 证据钩子:LV_P45_SHOT=1 时拍角色 idle / 行走朝下 / 行走朝右 三帧(真实游戏截图)。
let p45ShotMode = Environment.GetEnvironmentVariable("LV_P45_SHOT") = "1"
let mutable p45Step = 0
let mutable p45PendingName = ""
let mutable p45Pending = false
// P46 证据钩子:LV_P46_SHOT=1 时拍 splash 涟漪中帧 + 云影两帧 + 菜单灯笼呼吸两相位,
// 全程走正常启动/菜单流程,仅按帧表落盘。
let p46ShotMode = Environment.GetEnvironmentVariable("LV_P46_SHOT") = "1"
let mutable p46PendingName = ""
let mutable p46Pending = false
let mutable p46SplashRippleDone = false
let mutable p46CloudEarlyDone = false
let mutable p46CloudLateDone = false
let mutable p46MenuADone = false
let mutable p46MenuBDone = false
// P57 证据钩子:LV_P57_SHOT=1 时对同一 splash/menu 帧各拍「高光层关 / 开」两帧
// (像素差即第二层高光贡献),并打印逐列主水带亮度/高光 alpha/相位供 analyze 计算。
// p57HighlightDisabled 仅供取证时开关高光层,缺省 false(正常渲染始终开启)。
let p57ShotMode = Environment.GetEnvironmentVariable("LV_P57_SHOT") = "1"
let mutable p57HighlightDisabled = false
let mutable p57Step = 0
let mutable p57PendingName = ""
let mutable p57Pending = false
// P47 证据钩子:LV_P47_SHOT=1 时在真实生成器世界里拍「白天河道 / 夜晚河道 / 近景」三帧。
let p47ShotMode = Environment.GetEnvironmentVariable("LV_P47_SHOT") = "1"
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
// P78 证据钩子:LV_P78_SHOT=1 时在同一机位拍「白天 / 夜晚」两帧,机位同时纳入桥头灯柱、
// 河面与一户带炊烟的民居,用于核验夜帧水面光斑/桥头窄光晕/炊烟与白天零回归。
let p78ShotMode = Environment.GetEnvironmentVariable("LV_P78_SHOT") = "1"
let mutable p78Step = 0
// P52 证据钩子:LV_P52_SHOT=1 时选职业开局 → 走到 NPC 旁用真实 Interact 开对话 →
// 真实 BuyFromTarget / SellToTarget 各一次,拍「对话入口 / 买入后 / 卖出后」三帧;
// 每笔交易打印钱与背包数量前后值,供 analyze 脚本算 delta。
// LV_P52_OCCUPATION=farmer|fisher|peddler|scholar(默认 peddler)。
let p52ShotMode = Environment.GetEnvironmentVariable("LV_P52_SHOT") = "1"
let p52Occupation =
match Environment.GetEnvironmentVariable("LV_P52_OCCUPATION") with
| "farmer" -> Occupation.Farmer
| "fisher" -> Occupation.Fisher
| "scholar" -> Occupation.Scholar
| _ -> Occupation.Peddler
let mutable p52Step = 0
let mutable p52PendingName = ""
let mutable p52Pending = false
// P53 证据钩子:LV_P53_REC=1 时在真实世界里录制「远处 → 靠近提示出现 → 互动开对话 →
// 关闭+离开 → 提示消失」帧序列,逐帧打印面板/提示/目标/提示矩形,供 analyze 脚本 verdict。
// 提示层为瞬时叠加,不新开面板。
let p53RecordMode = Environment.GetEnvironmentVariable("LV_P53_REC") = "1"
let mutable p53Step = 0
let mutable p53PendingName = ""
let mutable p53Pending = false
// P54 证据钩子:LV_P54_SHOT=1 时以农夫真实开局,走「任务面板(待接受) → 接受 →
// 环境到达 + 对话 + 卖出三条真实信号」全流程,拍「待接受 / 进行中 / 完成」帧;
// 每步打印任务模板与状态,供 analyze 脚本核验 Offered→Active→Done 只由真实信号驱动。
// LV_P54_OCCUPATION=farmer|fisher|peddler|scholar(默认 farmer)。
let p54ShotMode = Environment.GetEnvironmentVariable("LV_P54_SHOT") = "1"
let p54Occupation =
match Environment.GetEnvironmentVariable("LV_P54_OCCUPATION") with
| "fisher" -> Occupation.Fisher
| "peddler" -> Occupation.Peddler
| "scholar" -> Occupation.Scholar
| _ -> Occupation.Farmer
let mutable p54Step = 0
let mutable p54PendingName = ""
let mutable p54Pending = false
// P55 证据钩子:LV_P55_SHOT=1 时以农夫真实开局,跳到第 3 日(当日任务=送粮),
// 走「面板(待接受) → 接受 → 真实卖出 Food(送粮完成,设计口径 +食物×1)→ 面板(已完成)」,
// 打印 streak/背包/反馈,供 analyze 脚本核验报酬入账与连续天数。
let p55ShotMode = Environment.GetEnvironmentVariable("LV_P55_SHOT") = "1"
let mutable p55Step = 0
let mutable p55PendingName = ""
let mutable p55Pending = false
let mutable autoplayFrames = 0
let mutable flowStep = 0
let mutable flowHold = 0
let mutable sampleState = SampleScript.initial
let mutable p36Captured = Array.zeroCreate<bool> 4
let mutable hudClock = 0L
let mutable hudStatus = ""
let mutable hudStatusAt = 0L
// P43:hotbar 选中格(0..9),仅由游戏内 1-0 键或证据脚本写入,非伪造状态。
let mutable hotbarSelected = 0
// P44:对话/文字弹层模型与内容指纹(内容变化时重建,翻页状态保持不变)。
let mutable dialogOverlay: DialogOverlay.Model option = None
let mutable dialogOverlayKey = ""
let mutable pauseHelpControl: SimulationControl option = None
let recordMode = Environment.GetEnvironmentVariable("LV_AUTOPLAY_RECORD") = "1"
let recordDirectory =
match Environment.GetEnvironmentVariable("LV_RECORD_DIR") with
| null | "" -> "/tmp/lv-p5-prompt"
| v -> v
let recordEvery = int (
match Environment.GetEnvironmentVariable("LV_RECORD_EVERY") with
| null | "" -> 25
| v -> match Int32.TryParse v with (true, value) -> max 1 value | _ -> 25)
let mutable recordIndex = 0
let recordName =
match Environment.GetEnvironmentVariable("LV_RECORD_NAME") with
| null | "" -> "rec-frame-"
| v -> v
let mutable tourWaypoints =
[ (1, 1); (255, 191); (509, 381); (256, 60); (256, 300); (80, 200); (430, 300) ]
let mutable tourIndex = 0
let mutable tourFrame = 0
// P20 证据钩子:LV_MAPGEN_SHOT=1 时用参数化生成器出整图 + 视口裁剪帧,拍完即退出。
let mapGenShotMode = Environment.GetEnvironmentVariable("LV_MAPGEN_SHOT") = "1"
let mapGenWidth =
match Environment.GetEnvironmentVariable("LV_MAPGEN_WIDTH") with
| null | "" -> 256
| v -> match Int32.TryParse v with (true, value) when value > 0 -> value | _ -> 256
let mapGenHeight =
match Environment.GetEnvironmentVariable("LV_MAPGEN_HEIGHT") with
| null | "" -> 192
| v -> match Int32.TryParse v with (true, value) when value > 0 -> value | _ -> 192
let mapGenSeed =
match Environment.GetEnvironmentVariable("LV_MAPGEN_SEED") with
| null | "" -> 4242UL
| v -> match UInt64.TryParse v with (true, value) -> value | _ -> 4242UL
// P28 证据钩子:额外把整图按指定像素目标渲染一次(用于 1 tile≈2px 的缩放可读性取证)。
let mapGenFitWidth =
match Environment.GetEnvironmentVariable("LV_MAPGEN_FIT_WIDTH") with
| null | "" -> 0
| v -> match Int32.TryParse v with (true, value) when value > 0 -> value | _ -> 0
let mapGenFitHeight =
match Environment.GetEnvironmentVariable("LV_MAPGEN_FIT_HEIGHT") with
| null | "" -> 0
| v -> match Int32.TryParse v with (true, value) when value > 0 -> value | _ -> 0
// P28 夜景取证:LV_MAPGEN_NIGHT=1 时整图按 23:30 的真实 tint + 月光 veil 渲染。
let mapGenNight = Environment.GetEnvironmentVariable("LV_MAPGEN_NIGHT") = "1"
// P30 证据钩子:LV_MAPGEN_P30_SHOT=1 时按 P30 规格出图(整图 day/night + 田块局部 + 路网弯曲局部)。
let mapGenP30Shot = Environment.GetEnvironmentVariable("LV_MAPGEN_P30_SHOT") = "1"
let mapGenNightTick = if mapGenNight then M6Presentation.resolveStartTick (Some 23.5) false else 0L
let mutable mapGenResult = Unchecked.defaultof<MapGen.Result>
let mutable mapGenGenMs = 0.0
do
if mapScale > 1 then
Sim.configureBounds (64 * mapScale) (48 * mapScale)
ProceduralMap.activate (uint64 4242)
if mapGenShotMode then
let stopwatch = System.Diagnostics.Stopwatch.StartNew()
mapGenResult <- MapGen.generateWithSize mapGenWidth mapGenHeight mapGenSeed
stopwatch.Stop()
mapGenGenMs <- stopwatch.Elapsed.TotalMilliseconds
printfn
"mapgen-gen size=%dx%d seed=%d gen_ms=%.2f tiles=%d reachable_ok=%b reachable_tiles=%d spawns=%d"
mapGenResult.Width
mapGenResult.Height
(int mapGenResult.Seed)
mapGenGenMs
mapGenResult.Tiles.Length
mapGenResult.ReachabilityOk
mapGenResult.ReachableTiles
mapGenResult.Spawns.Length
if mapTourMode then
tourWaypoints <-
[ (1, 1); (Sim.mapWidthTiles / 2, Sim.mapHeightTiles / 2); (Sim.mapWidthTiles - 3, Sim.mapHeightTiles - 3)
(Sim.mapWidthTiles / 2, 60); (Sim.mapWidthTiles / 2, Sim.mapHeightTiles - 60)
(80, 200); (430, 300) ]
if riverscapeTourMode then
tourWaypoints <- riverscapeTourWaypoints ()
graphics.PreferredBackBufferWidth <- 1280
graphics.PreferredBackBufferHeight <- 720
graphics.SynchronizeWithVerticalRetrace <- true
this.IsFixedTimeStep <- true
this.TargetElapsedTime <- TimeSpan.FromTicks(TimeSpan.TicksPerSecond / 60L)
if unlockFps then
// P21 性能核对:放开 vsync/固定步长,测真实的渲染帧率上限。
this.IsFixedTimeStep <- false
graphics.SynchronizeWithVerticalRetrace <- false
this.Window.Title <- ChineseText.copy.SceneTitle
printfn
"world-mode=%s bounds=%dx%d"
(if riverscapeActive then "riverscape" elif mapScale > 1 then "map-scale" else "legacy-64x48")
Sim.mapWidthTiles
Sim.mapHeightTiles
printfn $"mode={modeName} seed=42"
printfn "controls=WASD move E interact 1-6 choose Q observe Tab needs C chronicle L relations P pause F1/F2/F3 speed F6 save F7 load Esc close/exit"
member private this.CenterCamera() =
let viewport = this.GraphicsDevice.Viewport
let vw = float32 viewport.Width
let vh = float32 viewport.Height
let worldW = float32 (Sim.mapWidthTiles * Sim.tilePixels)
let worldH = float32 (Sim.mapHeightTiles * Sim.tilePixels)
let half = float32 Sim.tilePixels / 2.0f
let x = MathHelper.Clamp(world.Avatar.Pos.X + half - vw / 2.0f, 0.0f, max 0.0f (worldW - vw))
let y = MathHelper.Clamp(world.Avatar.Pos.Y + half - vh / 2.0f, 0.0f, max 0.0f (worldH - vh))
camera <- Vector2(x, y)
member private this.CenterCameraOnTile (tileX: int) (tileY: int) =
let viewport = this.GraphicsDevice.Viewport
let vw = float32 viewport.Width
let vh = float32 viewport.Height
let worldW = float32 (Sim.mapWidthTiles * Sim.tilePixels)
let worldH = float32 (Sim.mapHeightTiles * Sim.tilePixels)
let half = float32 Sim.tilePixels / 2.0f
let x = MathHelper.Clamp(float32 (tileX * Sim.tilePixels) + half - vw / 2.0f, 0.0f, max 0.0f (worldW - vw))
let y = MathHelper.Clamp(float32 (tileY * Sim.tilePixels) + half - vh / 2.0f, 0.0f, max 0.0f (worldH - vh))
camera <- Vector2(x, y)
member private this.ResetWorldView() =
relationView <- false
relationSnapshot <- None
avatarFacing <- VillageArt.SouthFacing
avatarMoving <- false
m5View <- M5Interaction.refreshPrompt world M5Interaction.initial
this.CenterCamera()
member private this.StartNewGame (occupation: Occupation.Kind option) =
let startTick = evidenceStartTick ()
let baseState =
occupation
|> Option.map (fun kind -> WorldBootstrap.occupationStateFor 42UL kind startTick)
world <-
initialWorldForMode baseState
|> withStartTick
// P66:用真实世界的可达候选集合给当日任务定点(世界只依赖 profile,故只需建一次)。
let state =
match occupation with
| Some kind -> Some(WorldBootstrap.occupationStateForWorld 42UL kind startTick world)
| None -> None
// §3 身份条目:带职业开局即写入年鉴,形成个人传记线
match state with
| Some occupationState ->
world <- WorldBootstrap.appendIdentityAnnal occupationState world
| None -> ()
this.ResetWorldView()
m5View <- { m5View with Task = state }
menu <- menu |> MenuState.setCurrentWorld true |> MenuState.enterGame
let occupationName = occupation |> Option.map Occupation.nameOf |> Option.defaultValue "none"
printfn $"new-game=ok seed=42 npcs={Sim.npcCount} occupation={occupationName} tick={world.Tick}"
member private this.SaveWorld (prefix: string) : bool =
try
WorldSave.saveToFileWith m5View.Task savePath world
m5View <- { m5View with Status = "save succeeded"; StatusTick = Some world.Tick }
printfn $"{prefix}=ok path={savePath} tick={world.Tick}"
true
with
| ex ->
m5View <- { m5View with Status = "save failed"; StatusTick = Some world.Tick }
printfn $"{prefix}=error path={savePath} message={ex.Message}"
false
member private this.LoadWorld (prefix: string) : Result<int64, string> =
match WorldSave.loadFromFileWith savePath with
| Ok (nextWorld, occupation) ->
world <- nextWorld
this.ResetWorldView()
m5View <- { m5View with Task = occupation }
printfn $"{prefix}=ok path={savePath} tick={world.Tick}"
Ok world.Tick
| Error failure ->
printfn $"{prefix}=error path={savePath} message={failure}"
Error failure
member private this.OpenMainMenu() =
relationView <- false
relationSnapshot <- None
m5View <- M5Interaction.initial
menu <- menu |> MenuState.setCurrentWorld true |> MenuState.openMain
printfn $"menu=open tick={world.Tick}"
member private this.ApplyMenuCommand (command: MenuCommand) =
match command with
| NoCommand -> ()
| ContinueGame ->
menu <- menu |> MenuState.setCurrentWorld true |> MenuState.enterGame
printfn $"continue=ok tick={world.Tick}"
| StartNewGame ->
menu <- MenuState.openOccupationSelect menu
printfn "menu=occupation-select"
| StartNewGameWith occupation -> this.StartNewGame occupation
| LoadGame ->
match this.LoadWorld "load" with
| Ok _ ->
menu <- menu |> MenuState.setCurrentWorld true |> MenuState.enterGame
| Error failure ->
menu <- menu |> MenuState.showLoadError failure
| ApplySettings nextControl ->
simulationControl <- nextControl
legacyStepsPerFrame <- None
menu <- menu |> MenuState.setSettings nextControl
printfn $"simulation={M6Presentation.clockLabel simulationControl}"
| ExitGame ->
printfn "menu=exit"
this.Exit()
member private this.DispatchMenuInput (input: MenuInput) =
let nextMenu, command = MenuState.update input menu
menu <- nextMenu
this.ApplyMenuCommand command
member private this.UpdateMenu (pressed: Keys -> bool) =
let pressedAny (keys: Keys list) = keys |> List.exists pressed
let input =
if pressedAny [ Keys.Up; Keys.W ] then Some Up
elif pressedAny [ Keys.Down; Keys.S ] then Some Down
elif pressed Keys.Enter then Some Confirm
elif pressed Keys.Escape then Some Back
else None
match input with
| Some nextInput -> this.DispatchMenuInput nextInput
| None when (autoplay || sampleMode) && not autoplayFlow
&& (menu.Page = MainMenu || menu.Page = OccupationSelect)
&& not menu.HasCurrentWorld ->
autoplayFrames <- autoplayFrames + 1
if autoplayFrames >= 15 then
this.DispatchMenuInput Confirm
| None -> ()
member private this.RunSampleMode () =
if perfSoakSeconds > 0.0 && not perfSoakStarted then
perfSoakStarted <- true
perfSoakWatch.Start()
let stageBefore = sampleState.Stage
let positionBefore = world.Avatar.Pos
let nextWorld, nextView, nextState = SampleScript.runFrame world m5View sampleState
if nextWorld.Avatar.Pos <> positionBefore then
avatarFacing <- VillageArt.facingAfterMovement positionBefore nextWorld.Avatar.Pos avatarFacing
avatarMoving <- nextWorld.Avatar.Pos <> positionBefore
world <- nextWorld
m5View <- nextView
sampleState <- nextState
this.CenterCamera()
if nextState.Stage <> stageBefore then
printfn $"sample stage={nextState.Stage} tick={nextWorld.Tick} pos=({nextWorld.Avatar.Pos.X:F0},{nextWorld.Avatar.Pos.Y:F0})"
if nextState.Stage = SampleScript.SampleComplete then
if perfSoakSeconds > 0.0 && perfSoakWatch.Elapsed.TotalSeconds < perfSoakSeconds then
sampleState <- SampleScript.initial
else
printfn (if nextState.TimedOut then "sample result=timeout" else "sample result=ok")
this.Exit()
/// P36 证据:在 sample 序列的自然状态下抓 4 帧,证明「情境提示」契约:
/// 1 靠近目标(进入 ApproachNpc)2 提示出现 3 对话层打开(浮动提示消失=世界交互被隔离)
/// 4 关闭并走远后提示消失。每帧打印 panel/prompt/home 对照点,第 4 帧后退出。
member private this.CaptureP36PromptShot () =
if p36ShotMode then
let save (index: int) (label: string) =
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/p36-prompt-approach-%d.png" recordDirectory index)
printfn
"p36-shot=%s index=%d tick=%d pos=(%.0f,%.0f) panel=%s prompt=%s home=%A"
label
index
world.Tick
world.Avatar.Pos.X
world.Avatar.Pos.Y
(M5Interaction.panelName m5View)
(m5View.Prompt |> Option.defaultValue "<none>")
m5View.HomeMode
let stage = sampleState.Stage
// 第 4 帧必须已真正走远(超出所有村民的交谈范围)且提示消失,才能证明「离开即消失」。
let leaveMargin = Sim.chatRangePx + 24.0f
let outsideEveryRange =
world.Npcs
|> Array.forall (fun npc ->
let dx = npc.Pos.X - world.Avatar.Pos.X
let dy = npc.Pos.Y - world.Avatar.Pos.Y
dx * dx + dy * dy > leaveMargin * leaveMargin)
if not p36Captured.[0] && stage = SampleScript.ApproachNpc then
p36Captured.[0] <- true
save 1 "approach"
elif not p36Captured.[1] && stage = SampleScript.ApproachNpc && m5View.Prompt.IsSome then
p36Captured.[1] <- true
save 2 "prompt"
elif not p36Captured.[2] && m5View.Panel = DialoguePanel && m5View.Menu.IsSome then
p36Captured.[2] <- true
save 3 "dialogue-isolated"
elif not p36Captured.[3] && stage = SampleScript.WalkAway && m5View.Prompt.IsNone && outsideEveryRange then
p36Captured.[3] <- true
save 4 "left"
printfn "p36-shot=done tick=%d" world.Tick
this.Exit()
/// P16-FIX:菜单截图模式。停在开始界面,按确定性帧表向下切到「读档」,帧表见 MenuShotScript。
member private this.RunMenuShot () =
menuShotFrame <- menuShotFrame + 1L
if menuShotFrame = MenuShotScript.downFrame then
this.DispatchMenuInput Down
/// P37 证据:主菜单 →「选择职业」页截图 → 选定职业开局 → 打开任务面板截 HUD/任务列表 → 退出。
member private this.RunP37Shot () =
let save (name: string) =
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory name)
printfn "p37-shot=%s tick=%d page=%A selected=%d task=%s"
name
world.Tick
menu.Page
menu.Selected
(M5Interaction.panelLines world m5View |> List.tryHead |> Option.defaultValue "<none>")
let targetIndex =
MenuState.occupationOptions |> List.findIndex (fun option -> option = Some p37Occupation)
match p37Step with
| 0 when menu.Page = MainMenu ->
this.DispatchMenuInput Confirm
p37Step <- 1
| 1 when menu.Page = OccupationSelect ->
if menu.Selected <> targetIndex then
this.DispatchMenuInput Down
else
save "p37-occupation-select"
this.DispatchMenuInput Confirm
p37Step <- 2
| 2 when menu.Page = Playing ->
p37Hold <- p37Hold + 1
if p37Hold = 1 then
let _, taskView = M5Interaction.apply ShowTaskPanel world m5View
m5View <- taskView
elif p37Hold >= 90 then
if not p37Captured then
p37Captured <- true
save (sprintf "p37-%s-start" (Occupation.saveToken p37Occupation))
this.Exit()
| _ -> ()
/// P39 证据:真实生成器世界里对准 P39 中式元素拍昼/夜整帧。
/// 相机对准「桥+船+苇」与「主路石灯笼+菜摊」两处,输出 1280x720 真实帧
/// (含 M6Presentation 的昼/夜 tint、golden/moonlight veil 与 lantern glow)。
/// 由于软件渲染下 Update 可能一帧内跑多次,截图统一在 `Draw` 末尾落盘(见
/// `CaptureP39Shot`),确保落盘的是「新状态已经画进后台缓冲」的那一帧。
member private this.PrepareP39Shot () =
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()
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
let dayHour = 12.0
let nightHour = 23.5
if not p39Pending then
match riverscapeMap with
| None -> this.Exit()
| Some map ->
let boat = VillageArt.cc0BoatTile map
// 取「离船最近的桥」的中点取景,保证桥/船/苇落在同一帧同一河段。
let bridgeTarget =
match boat with
| Some (boatX, boatY) ->
let nearest =
map.Bridges
|> List.minBy (fun (bx, by) -> abs (bx - boatX) + abs (by - boatY))
((fst nearest + boatX) / 2, (snd nearest + boatY) / 2)
| None ->
match map.Bridges |> List.sortBy (fun (x, y) -> (x, y)) |> List.tryHead with
| Some (bx, by) -> (bx, by)
| None -> (map.Core.MinX, map.Core.MinY)
let lanternTarget =
match VillageArt.cc0LanternTiles map 12 with
| (lx, ly) :: _ -> (lx, ly)
| [] -> bridgeTarget
match p39Step with
| 0 ->
setHour dayHour
placeCameraOn (fst bridgeTarget) (snd bridgeTarget)
p39PendingName <- "p39-day"
p39Pending <- true
| 1 ->
setHour nightHour
placeCameraOn (fst bridgeTarget) (snd bridgeTarget)
p39PendingName <- "p39-night"
p39Pending <- true
| 2 ->
setHour nightHour
placeCameraOn (fst lanternTarget) (snd lanternTarget)
p39PendingName <- "p39-lantern-night"
p39Pending <- true
| _ ->
printfn "p39-shot=done"
this.Exit()
/// P39 证据:在 `Draw` 末尾把刚画好的后台缓冲落盘(软件渲染下 Update 可能一帧多跑,
/// 只有 Draw 之后的缓冲区才是当前状态的真实帧)。
member private this.CaptureP39Shot () =
if p39Pending then
p39Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p39PendingName)
printfn "p39-shot=%s tick=%d pos=(%.0f,%.0f) camera=(%.0f,%.0f)"
p39PendingName world.Tick world.Avatar.Pos.X world.Avatar.Pos.Y camera.X camera.Y
p39Step <- p39Step + 1
/// P40 证据:真实生成器世界里拍昼 / 夜整帧与乌篷船近景。位置取自确定性摆放纯函数,
/// 含真实 tint 与 P14 光晕;相机贴近船体便于 2x NEAREST 特写。
member private this.PrepareP40Shot () =
let placeAvatarOnLand (tileX: int) (tileY: int) =
world <- { world with Avatar = { world.Avatar with Pos = { X = float32 (tileX * Sim.tilePixels); Y = float32 (tileY * Sim.tilePixels) } } }
let placeCameraOn (tileX: int) (tileY: int) =
placeAvatarOnLand tileX tileY
this.CenterCamera()
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
let dayHour = 12.0
let nightHour = 23.5
if not p40Pending then
match riverscapeMap with
| None -> this.Exit()
| Some map ->
let boat =
match VillageArt.cc0BoatTile map with
| Some (bx, by) -> (bx, by)
| None ->
match map.Bridges |> List.sortBy (fun (x, y) -> (x, y)) |> List.tryHead with
| Some (bx, by) -> (bx, by)
| None -> (map.Core.MinX, map.Core.MinY)
match p40Step with
| 0 ->
setHour dayHour
placeAvatarOnLand 232 51
this.CenterCameraOnTile (fst boat) (snd boat)
p40PendingName <- "p40-day"
p40Pending <- true
| 1 ->
setHour nightHour
placeAvatarOnLand 232 51
this.CenterCameraOnTile (fst boat) (snd boat)
p40PendingName <- "p40-night"
p40Pending <- true
| 2 ->
setHour dayHour
placeAvatarOnLand 240 51
this.CenterCameraOnTile (fst boat + 1) (snd boat)
p40PendingName <- "p40-boat"
p40Pending <- true
| _ ->
printfn "p40-shot=done"
this.Exit()
/// P40 证据:与 P39 相同,在 `Draw` 末尾落盘当前后台缓冲。
member private this.CaptureP40Shot () =
if p40Pending then
p40Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p40PendingName)
printfn "p40-shot=%s tick=%d pos=(%.0f,%.0f) camera=(%.0f,%.0f)"
p40PendingName world.Tick world.Avatar.Pos.X world.Avatar.Pos.Y camera.X camera.Y
p40Step <- p40Step + 1
/// P43 证据:真实世界里拍昼 / 夜两张 HUD 整帧(右上日历钟卡 + 体力条形 + 底部 10 格 hotbar)。
member private this.PrepareP43Shot () =
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
if not p43Pending then
match p43Step with
| 0 ->
setHour 12.0
hotbarSelected <- (HudLayout.selectSlotForDigit 1 |> Option.defaultValue 0)
this.CenterCamera()
p43PendingName <- "p43-hud-day"
p43Pending <- true
| 1 ->
setHour 23.5
hotbarSelected <- (HudLayout.selectSlotForDigit 5 |> Option.defaultValue 0)
this.CenterCamera()
p43PendingName <- "p43-hud-night"
p43Pending <- true
| _ ->
printfn "p43-shot=done"
this.Exit()
/// P43 证据:在 `Draw` 末尾落盘,并打印实测布局矩形与真实状态(供 p43-analysis.txt)。
member private this.CaptureP43Shot () =
if p43Pending then
p43Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p43PendingName)
let viewport = this.GraphicsDevice.Viewport
let reading = HudLayout.calendarReading world.Tick
let cal = HudLayout.calendarCardRect viewport.Width reading
let bar = HudLayout.hotbarBarRect viewport.Width viewport.Height
let slot = HudLayout.hotbarSlotRect viewport.Width viewport.Height 0
printfn
"p43-shot=%s tick=%d calendar=%d,%d,%d,%d hotbar=%d,%d,%d,%d slot0=%d,%d,%d,%d selected=%d energy=%.0f day=%d season=%s period=%s clock=%s"
p43PendingName world.Tick cal.X cal.Y cal.Width cal.Height bar.X bar.Y bar.Width bar.Height
slot.X slot.Y slot.Width slot.Height hotbarSelected world.Avatar.Mind.Needs.Energy
reading.DayNumber reading.Season reading.Period reading.Clock
p43Step <- p43Step + 1
/// P44 证据:真实世界里把角色放到 NPC 旁、用真实 Interact 命令开对话弹层,
/// 依次拍「默认页 / 翻页后 / Esc 关闭后恢复」三帧。
member private this.PrepareP44Shot () =
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
if not p44Pending then
match p44Step with
| 0 ->
setHour 12.0
let npc = world.Npcs.[0]
world <- { world with Avatar = { world.Avatar with Pos = npc.Pos } }
let nextWorld, nextView = M5Interaction.apply M5Command.Interact world m5View
world <- nextWorld
m5View <- nextView
this.CenterCamera()
p44PendingName <- "p44-dialog-a"
p44Pending <- true
| 1 ->
match dialogOverlay with
| Some model ->
match DialogOverlay.nextPage model with
| Some next -> dialogOverlay <- Some next
| None -> ()
| None -> ()
p44PendingName <- "p44-dialog-b"
p44Pending <- true
| 2 ->
let nextWorld, nextView = M5Interaction.apply M5Command.ClosePanel world m5View
world <- nextWorld
m5View <- nextView
p44PendingName <- "p44-dialog-c"
p44Pending <- true
| _ ->
printfn "p44-shot=done"
this.Exit()
/// P44 证据:在 `Draw` 末尾落盘,并打印弹层实测 rect / 行数 / 页码;关闭帧打印 overlay=gone。
member private this.CaptureP44Shot () =
if p44Pending then
p44Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p44PendingName)
let viewport = this.GraphicsDevice.Viewport
match dialogOverlay with
| Some model ->
let layout = DialogOverlay.rect viewport.Width viewport.Height model
let current = DialogOverlay.view model
printfn
"p44-shot=%s panel=%s rect=%d,%d,%d,%d page=%d/%d lines=%d avatar=%b"
p44PendingName
(M5Interaction.panelName m5View)
layout.X
layout.Y
layout.Width
layout.Height
current.PageNumber
current.PageCount
current.Lines.Length
model.ShowAvatar
| None ->
printfn
"p44-shot=%s panel=%s overlay=gone prompt=%s"
p44PendingName
(M5Interaction.panelName m5View)
(m5View.Prompt |> Option.defaultValue "<none>")
p44Step <- p44Step + 1
/// P61 证据(G1):真实世界里拍「右上日历」与「对话页脚/背包文案」两帧。
member private this.PrepareP61Shot () =
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
if not p61Pending then
match p61Step with
| 0 ->
setHour 12.0
let npc = world.Npcs.[0]
world <- { world with Avatar = { world.Avatar with Pos = npc.Pos } }
this.CenterCamera()
p61PendingName <- "p61-calendar"
p61Pending <- true
| 1 ->
let nextWorld, nextView = M5Interaction.apply M5Command.Interact world m5View
world <- nextWorld
m5View <- nextView
this.CenterCamera()
p61PendingName <- "p61-dialog-footer"
p61Pending <- true
| _ ->
printfn "p61-shot=done"
this.Exit()
/// P61 证据:落盘并打印日历读数(春夏秋冬·第N天)与面板名,供 analyze 核验。
member private this.CaptureP61Shot () =
if p61Pending then
p61Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p61PendingName)
let reading = HudLayout.calendarReading world.Tick
printfn
"p61-shot=%s tick=%d calendar=%s panel=%s"
p61PendingName world.Tick (HudLayout.calendarLine1 reading) (M5Interaction.panelName m5View)
p61Step <- p61Step + 1
/// P62 证据(G2):可玩样板地图内的「村庄全貌俯瞰」+「真实进门的内景」。
member private this.PrepareP62Shot () =
let tileCenter (t: TilePosition) : Vec2 =
{ X = float32 (t.X * Sim.tilePixels + Sim.tilePixels / 2)
Y = float32 (t.Y * Sim.tilePixels + Sim.tilePixels / 2) }
let home = VillagePresentation.scene.Homes |> List.head
let doorCenter = tileCenter (worldTileForSceneTile home.Door)
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
if not p62Pending then
match p62Step with
| 0 ->
setHour 12.0
// 俯瞰点:样板村落西侧上空,相机随角色居中,村舍/石桥/岸线/菜圃/竹林全部入画。
let vantage = tileCenter (worldTileForSceneTile { X = 6; Y = 3 })
world <- { world with Avatar = { world.Avatar with Pos = vantage } }
this.CenterCamera()
p62PendingName <- "p62-overview"
p62Pending <- true
| 1 ->
// 真实走入:沿真实 Sim.step 向门口移动,抵达后用真实 Interact 进门。
let dx = doorCenter.X - world.Avatar.Pos.X
let dy = doorCenter.Y - world.Avatar.Pos.Y
if dx * dx + dy * dy <= 12.0f * 12.0f then
let nextWorld, nextView = M5Interaction.apply M5Command.Interact world m5View
world <- nextWorld
m5View <- nextView
match m5View.HomeMode with
| Inside _ ->
p62PendingName <- "p62-interior"
p62Pending <- true
| Outside ->
p62MoveFrames <- p62MoveFrames + 1
else
let length = sqrt (dx * dx + dy * dy)
let input =
if length > 0.001f then { MoveX = dx / length; MoveY = dy / length }
else { MoveX = 0.0f; MoveY = 0.0f }
world <- Sim.step { Input = input } world
p62MoveFrames <- p62MoveFrames + 1
if p62MoveFrames > 900 then
printfn "p62-shot=move-timeout frames=%d home=%A" p62MoveFrames m5View.HomeMode
this.Exit()
| _ ->
printfn "p62-shot=done"
this.Exit()
/// P62 证据:落盘并打印相机/角色/内景模式,供 analyze 核验非空帧与真实进门。
member private this.CaptureP62Shot () =
if p62Pending then
p62Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p62PendingName)
printfn
"p62-shot=%s tick=%d avatar=(%.0f,%.0f) camera=(%.0f,%.0f) home=%A"
p62PendingName world.Tick world.Avatar.Pos.X world.Avatar.Pos.Y camera.X camera.Y m5View.HomeMode
p62Step <- p62Step + 1
/// P64 证据(A3 成熟度):样板区俯瞰 / 桥近景 / 内景三帧。
/// 内景沿用 P62 的真实 MoveTo + Interact 进门路径;桥为既有位置,只增强可读性。
member private this.PrepareP64Shot () =
let tileCenter (t: TilePosition) : Vec2 =
{ X = float32 (t.X * Sim.tilePixels + Sim.tilePixels / 2)
Y = float32 (t.Y * Sim.tilePixels + Sim.tilePixels / 2) }
let sceneCenter localX localY =
tileCenter (worldTileForSceneTile { X = localX; Y = localY })
let home = VillagePresentation.scene.Homes |> List.head
let doorCenter = sceneCenter home.Door.X home.Door.Y
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
if not p64Pending then
match p64Step with
| 0 ->
setHour 12.0
// 俯瞰:整村居中,上半部补种与桥、民居同框。
world <- { world with Avatar = { world.Avatar with Pos = sceneCenter 6 3 } }
this.CenterCamera()
let plan = VillageArt.sampleRenderPlan ()
let upper =
plan.Props
|> List.filter (fun prop -> prop.Kind <> VillageArt.House && prop.Position.Y >= 0 && prop.Position.Y <= 6)
let upperKinds = upper |> List.map (fun prop -> prop.Kind) |> List.distinct |> List.length
let bridgeProps = plan.Props |> List.filter (fun prop -> prop.Kind = VillageArt.Bridge) |> List.length
let abutments = VillageArt.sampleBridgeAbutmentTiles plan |> List.length
printfn
"p64-plan upper_band_props=%d upper_band_kinds=%d bridge_props=%d bridge_foot_tiles=3 bridge_abutments=%d interior_elements=%d"
upper.Length
upperKinds
bridgeProps
abutments
plan.Interior.Elements.Length
p64PendingName <- "p64-overview"
p64Pending <- true
| 1 ->
setHour 12.0
// 桥近景:角色立于桥北岸,相机居中,桥面栏杆/护岸石入画。
world <- { world with Avatar = { world.Avatar with Pos = sceneCenter 6 10 } }
this.CenterCamera()
p64PendingName <- "p64-bridge"
p64Pending <- true
| 2 ->
// 真实走入:沿真实 Sim.step 向门口移动,抵达后真实 Interact 进门。
let dx = doorCenter.X - world.Avatar.Pos.X
let dy = doorCenter.Y - world.Avatar.Pos.Y
if dx * dx + dy * dy <= 12.0f * 12.0f then
let nextWorld, nextView = M5Interaction.apply M5Command.Interact world m5View
world <- nextWorld
m5View <- nextView
match m5View.HomeMode with
| Inside _ ->
p64PendingName <- "p64-interior"
p64Pending <- true
| Outside ->
p64MoveFrames <- p64MoveFrames + 1
else
let length = sqrt (dx * dx + dy * dy)
let input =
if length > 0.001f then { MoveX = dx / length; MoveY = dy / length }
else { MoveX = 0.0f; MoveY = 0.0f }
world <- Sim.step { Input = input } world
p64MoveFrames <- p64MoveFrames + 1
if p64MoveFrames > 900 then
printfn "p64-shot=move-timeout frames=%d home=%A" p64MoveFrames m5View.HomeMode
this.Exit()
| _ ->
printfn "p64-shot=done"
this.Exit()
/// P64 证据:落盘并打印帧名/相机/内景模式,供 analyze 核验。
member private this.CaptureP64Shot () =
if p64Pending then
p64Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p64PendingName)
printfn
"p64-shot=%s tick=%d avatar=(%.0f,%.0f) camera=(%.0f,%.0f) home=%A"
p64PendingName world.Tick world.Avatar.Pos.X world.Avatar.Pos.Y camera.X camera.Y m5View.HomeMode
p64Step <- p64Step + 1
/// P65 证据:货郎真实开局 → 闲聊写入既有谣言池 → 真实 Interact 开菜单 → 提议交易询价。
member private this.PrepareP65Shot () =
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
let ask (command: M5Command) =
let nextWorld, nextView = M5Interaction.apply command world m5View
world <- nextWorld
m5View <- nextView
let placeAtNpc () =
let npc = world.Npcs.[0]
world <- { world with Avatar = { world.Avatar with Pos = npc.Pos } }
if not p65Pending then
match p65Step with
| 0 ->
setHour 12.0
placeAtNpc ()
ask M5Command.Interact
this.CenterCamera()
p65PendingName <- "p65-menu"
p65Pending <- true
| 1 ->
// 真实闲聊一次:把玩家对话写入既有 World.Rumors(最新在前),供询价读取。
ask M5Command.Intent1
placeAtNpc ()
ask M5Command.Interact
// 非货郎回归:同世界跑农夫 Interact + Intent3,应仍得旧 dialogue 文案(无 inquiry|)。
let farmerView =
{ M5Interaction.initial with
Task = Some(Occupation.stateOf Occupation.Farmer)
Seed = m5View.Seed }
let farmerWorld, farmerOpen = M5Interaction.apply M5Command.Interact world farmerView
let _, farmerAnswered = M5Interaction.apply M5Command.Intent3 farmerWorld farmerOpen
printfn "p65-regression status=%s" farmerAnswered.Status
// 同一世界两次查询:证明同输入逐字符串一致(禁随机)。
let answer1 = Occupation.marketInquiryText (Some Occupation.Peddler) Sim.OfferTrade world
let answer2 = Occupation.marketInquiryText (Some Occupation.Peddler) Sim.OfferTrade world
printfn
"p65-inquiry rumors=%d fresh=%d hit=%b text1=%s text2=%s equal=%b"
world.Rumors.Length
(Occupation.freshReliableRumors world |> List.length)
(Occupation.inquiryRumor world |> Option.isSome)
(answer1 |> Option.defaultValue "<none>")
(answer2 |> Option.defaultValue "<none>")
(answer1 = answer2)
p65Step <- p65Step + 1
| 2 ->
ask M5Command.Intent3
p65PendingName <- "p65-answer"
p65Pending <- true
| _ ->
printfn "p65-shot=done"
this.Exit()
/// P65 证据:落盘并打印帧名/面板/状态,供 analyze 核验「货郎 status=inquiry|...」。
member private this.CaptureP65Shot () =
if p65Pending then
p65Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p65PendingName)
printfn
"p65-shot=%s panel=%s avatar=(%.0f,%.0f) status=%s"
p65PendingName
(M5Interaction.panelName m5View)
world.Avatar.Pos.X
world.Avatar.Pos.Y
m5View.Status
p65Step <- p65Step + 1
/// P67 证据:任务面板的目标展示(带目标 / 无目标各一帧),走真实每日任务纯函数生成的 DailyTask。
member private this.PrepareP67Shot () =
let noonOfDay (day: int64) : int64 =
day * Sim.ticksPerDay + M6Presentation.resolveStartTick (Some 12.0) false
let targets = WorldBootstrap.reachableTargets world
let dayTask (day: int64) (targeted: bool) =
if targeted then
Occupation.dailyTaskOfWith targets 42UL (Occupation.occupationSeedOf Occupation.Farmer) day Occupation.Farmer
else
Occupation.dailyTaskOf 42UL (Occupation.occupationSeedOf Occupation.Farmer) day Occupation.Farmer
// 找一天当日任务为「帮工」(有目标语义),使两帧同模板可直接对照。
let mutable helpDay = 0L
let mutable found = false
for day in 0L .. 120L do
if not found then
match dayTask day true with
| Some task when task.TemplateId = Occupation.HelpWork -> helpDay <- day; found <- true
| _ -> ()
let setToday (task: Occupation.DailyTask) =
match m5View.Task with
| Some state -> m5View <- { m5View with Task = Some { state with Today = Some task } }
| None -> ()
let ask (command: M5Command) =
let nextWorld, nextView = M5Interaction.apply command world m5View
world <- nextWorld
m5View <- nextView
if not p67Pending then
match p67Step with
| 0 ->
let tick = noonOfDay helpDay
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
match dayTask helpDay true with
| Some task -> setToday task
| None -> ()
ask M5Command.ShowTaskPanel
this.CenterCamera()
p67PendingName <- "p67-target"
p67Pending <- true
| 1 ->
match dayTask helpDay false with
| Some task -> setToday task
| None -> ()
p67PendingName <- "p67-wildcard"
p67Pending <- true
| _ ->
printfn "p67-shot=done"
this.Exit()
/// P67 证据:落盘并打印帧名/面板/模板/目标/整行文案/缺字槽位,供 analyze 核验。
member private this.CaptureP67Shot () =
if p67Pending then
p67Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p67PendingName)
let lines = M5Interaction.panelLines world m5View
let missingSlots =
lines
|> List.sumBy (fun line ->
line
|> Seq.filter (fun c -> c <> ' ' && not (PixelText.isRenderable (string c)))
|> Seq.length)
let templateText, targetText, lineText =
match m5View.Task |> Option.bind (fun state -> state.Today) with
| None -> "none", "<none>", "<none>"
| Some task ->
Occupation.taskNameOf task.TemplateId,
(TaskRuntime.targetText task |> Option.defaultValue "<none>"),
(TaskRuntime.taskLine task "进行中")
printfn
"p67-shot=%s panel=%s template=%s target=%s line=%s missing_glyph_slots=%d"
p67PendingName
(M5Interaction.panelName m5View)
templateText
targetText
lineText
missingSlots
p67Step <- p67Step + 1
member private this.PrepareP45Shot () =
let baseTick = M6Presentation.resolveStartTick (Some 12.0) false
let setTick (tick: int64) =
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
if not p45Pending then
match p45Step with
| 0 ->
setTick baseTick
world <-
{ world with
Avatar = { world.Avatar with Pos = { X = float32 (100 * Sim.tilePixels); Y = float32 (100 * Sim.tilePixels) } } }
avatarFacing <- VillageArt.SouthFacing
avatarMoving <- false
this.CenterCamera()
p45PendingName <- "p45-char-a"
p45Pending <- true
| 1 ->
setTick (baseTick + 4L)
avatarFacing <- VillageArt.SouthFacing
avatarMoving <- true
this.CenterCamera()
p45PendingName <- "p45-char-b"
p45Pending <- true
| 2 ->
setTick (baseTick + 8L)
avatarFacing <- VillageArt.EastFacing
avatarMoving <- true
this.CenterCamera()
p45PendingName <- "p45-char-c"
p45Pending <- true
| _ ->
printfn "p45-shot=done"
this.Exit()
/// P45 证据:在 `Draw` 末尾落盘,并打印角色目标矩形 / 朝向 / 帧,供裁剪与帧差分析。
member private this.CaptureP45Shot () =
if p45Pending then
p45Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p45PendingName)
let dest = VillageArt.characterDestination world.Avatar.Pos camera
let spec = VillageArt.avatarSpriteSpec avatarFacing avatarMoving world.Tick
printfn
"p45-shot=%s tick=%d facing=%s moving=%b dest=%d,%d,%d,%d frame=%s"
p45PendingName
world.Tick
(sprintf "%A" avatarFacing)
avatarMoving
dest.X
dest.Y
dest.Width
dest.Height
(sprintf "%A" spec.Frame)
p45Step <- p45Step + 1
/// P46 证据:Draw 末尾落盘。splash 阶段按帧阈值拍涟漪/云影,菜单阶段拍灯笼两相位。
member private this.CaptureP46Shot () =
let save (name: string) =
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory name)
printfn "p46-shot=%s splashFrame=%d menuEntranceFrame=%d" name splashFrame menuEntranceFrame
if splashActive then
if not p46SplashRippleDone && splashFrame >= P46ShotScript.splashRippleFrame then
p46SplashRippleDone <- true
save P46ShotScript.splashRippleName
elif not p46CloudEarlyDone && splashFrame >= P46ShotScript.cloudEarlyFrame then
p46CloudEarlyDone <- true
save P46ShotScript.cloudEarlyName
elif not p46CloudLateDone && splashFrame >= P46ShotScript.cloudLateFrame then
p46CloudLateDone <- true
save P46ShotScript.cloudLateName
elif p46Pending then
p46Pending <- false
if p46PendingName = P46ShotScript.menuPeakName then p46MenuADone <- true
else p46MenuBDone <- true
save p46PendingName
/// P57 取证:把当前水面帧的逐列主水带亮度/高光 alpha/两层相位打印成逗号数组。
member private this.LogP57Columns (name: string) =
let frame = if splashActive then splashFrame else menuEntranceFrame
let columns = [ 0 .. 39 ]
let fmt (values: float32 list) =
values |> List.map (fun v -> sprintf "%.4f" v) |> String.concat ","
let main = columns |> List.map (fun c -> MenuAmbience.waterColumnBrightness frame c 0)
let hl = columns |> List.map (fun c -> float32 (MenuAmbience.highlightAlpha MenuAmbience.highlightDayLight frame c 0))
let mainPhase = columns |> List.map (fun c -> MenuAmbience.waterPhase frame c 0)
let hlPhase = columns |> List.map (fun c -> MenuAmbience.highlightPhase frame c 0)
printfn "p57-status=%s pendingName=%s disabled=%b frame=%d main=%s hl=%s mainphase=%s hlphase=%s"
name (if String.IsNullOrEmpty p57PendingName then "-" else p57PendingName) p57HighlightDisabled frame
(fmt main) (fmt hl) (fmt mainPhase) (fmt hlPhase)
/// P57 证据:Splash 阶段按帧表拍「高光层关 / 开」两帧。
member private this.PrepareP57Splash () =
if not p57Pending then
match p57Step with
| 0 ->
p57HighlightDisabled <- true
p57PendingName <- P57ShotScript.splashBaseName
p57Pending <- true
| 1 ->
p57HighlightDisabled <- false
p57PendingName <- P57ShotScript.splashHighlightName
p57Pending <- true
| _ -> ()
/// P57 证据:菜单阶段拍「高光层关 / 开」两帧后收尾。
member private this.PrepareP57Shot () =
if p57Step >= 4 then
printfn "p57-shot=done"
this.Exit()
elif not p57Pending then
match p57Step with
| 2 ->
menuEntranceFrame <- P57ShotScript.menuFrame
p57HighlightDisabled <- true
p57PendingName <- P57ShotScript.menuBaseName
p57Pending <- true
| 3 ->
menuEntranceFrame <- P57ShotScript.menuFrame
p57HighlightDisabled <- false
p57PendingName <- P57ShotScript.menuHighlightName
p57Pending <- true
| _ -> ()
/// P57 证据:Draw 末尾落盘并打印逐列数字。
member private this.CaptureP57Shot () =
if p57Pending then
p57Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p57PendingName)
this.LogP57Columns p57PendingName
p57Step <- p57Step + 1
/// P47 证据:真实生成器世界里拍「白天河道 / 夜晚河道 / 近景」三帧,含 P47 场景细节。
member private this.PrepareP47Shot () =
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
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 p78ShotMode then
// 机位:倒影最长的桥头灯柱 → 其最近一户民居的中点;同机位先拍正午(白天对照),
// 再拍 22 时(夜帧),两帧差异只来自光照与夜帧加成层。
match riverscapeMap with
| Some map ->
let bridgePick =
SceneDetail.bridgeLanternTiles map
|> List.sortByDescending (fun (x, y) -> SceneDetail.reflectionLength map x y)
|> List.tryHead
match bridgePick with
| None ->
printfn "p78-shot=error no-bridge-lantern"
this.Exit()
| Some (bx, by) ->
let nearestHouse =
(map.Buildings @ map.Farmhouses)
|> List.sortBy (fun b -> abs (b.DoorX - bx) + abs (b.DoorY - by))
|> List.tryHead
let camTileX, camTileY =
match nearestHouse with
| Some b -> (bx + b.DoorX) / 2, (by + b.DoorY) / 2
| None -> bx, by
let waterBounds () =
let vw = this.GraphicsDevice.Viewport.Width
let vh = this.GraphicsDevice.Viewport.Height
let visible =
[ for y in 0 .. map.Height - 1 do
for x in 0 .. map.Width - 1 do
if SceneDetail.isWaterSurface map x y then
let sx = x * Sim.tilePixels - int camera.X
let sy = y * Sim.tilePixels - int camera.Y
if sx + Sim.tilePixels > 0 && sx < vw && sy + Sim.tilePixels > 0 && sy < vh then
yield (sx, sy) ]
match visible with
| [] -> (0, 0, 0, 0)
| _ ->
let xs = visible |> List.map fst
let ys = visible |> List.map snd
let x0, y0 = List.min xs, List.min ys
let x1 = List.max xs + Sim.tilePixels
let y1 = List.max ys + Sim.tilePixels
(x0, y0, x1 - x0, y1 - y0)
let smokeScreen =
match nearestHouse with
| Some b -> (b.DoorX * Sim.tilePixels - int camera.X, (b.DoorY - 3) * Sim.tilePixels - int camera.Y)
| None -> (-1, -1)
let vw = this.GraphicsDevice.Viewport.Width
let vh = this.GraphicsDevice.Viewport.Height
let screenX (x: int) = x * Sim.tilePixels - int camera.X
let screenY (y: int) = y * Sim.tilePixels - int camera.Y
let visibleTile (x: int) (y: int) =
screenX x >= 0 && screenX x + Sim.tilePixels <= vw && screenY y >= 0 && screenY y + Sim.tilePixels <= vh
let glintTiles = SceneDetail.waterGlintTiles map
let glintPick = glintTiles |> List.tryPick (fun (x, y) -> if visibleTile x y then Some(x, y) else None)
let glintCtl =
glintPick
|> Option.bind (fun (gx, gy) ->
[ (gx + 1, gy); (gx + 2, gy); (gx - 1, gy) ]
|> List.tryFind (fun (cx, cy) -> SceneDetail.isWaterSurface map cx cy && not (List.contains (cx, cy) glintTiles)))
let bridgeScreen = SceneDetail.bridgeLanternTiles map |> List.tryFind (fun (x, y) -> visibleTile x y)
let regionFmt (x, y) = sprintf "%d,%d" (screenX x) (screenY y)
let regionLine (tag: string) =
printfn
"p78-regions %s glint_src=%s glint_ctl=%s bridge_src=%s"
tag
(match glintPick with Some p -> regionFmt p | None -> "-1,-1")
(match glintCtl with Some p -> regionFmt p | None -> "-1,-1")
(match bridgeScreen with Some p -> regionFmt p | None -> "-1,-1")
if p78Step = 0 then
setHour 12.0
placeCameraOn camTileX camTileY
p47PendingName <- "p78-day"
p47Pending <- true
let wx, wy, ww, wh = waterBounds ()
printfn
"p78-shot=day hour=12.0 tick=%d lantern=%.2f water=%d,%d,%d,%d glints=%d smoke=%d bridge_halo=%d"
world.Tick
(M6Presentation.effectiveLanternGlow world.Tick)
wx wy ww wh
(List.length (SceneDetail.waterGlintTiles map))
(List.length (SceneDetail.smokeSourceTiles map))
(List.length (SceneDetail.bridgeLanternTiles map))
regionLine "day"
elif p78Step = 1 then
// 保持同一机位,只把时刻改到夜晚。
setHour 22.0
p47PendingName <- "p78-night"
p47Pending <- true
let wx, wy, ww, wh = waterBounds ()
printfn
"p78-shot=night hour=22.0 tick=%d lantern=%.2f water=%d,%d,%d,%d smoke_src=%d,%d smoke_alpha=%d smoke_cell=%d glint_alpha=%d"
world.Tick
(M6Presentation.effectiveLanternGlow world.Tick)
wx wy ww wh
(fst smokeScreen) (snd smokeScreen)
(SceneDetail.smokeAlphaAt (M6Presentation.effectiveLanternGlow world.Tick))
(SceneDetail.smokeCellSize (M6Presentation.effectiveLanternGlow world.Tick))
(SceneDetail.waterGlintAlpha
(M6Presentation.effectiveLanternGlow world.Tick)
(SceneDetail.waterGlintPhase world.Tick camTileX camTileY))
regionLine "night"
else
printfn "p78-shot=done"
this.Exit()
| None ->
printfn "p78-shot=error no-riverscape-map"
this.Exit()
elif 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 ->
let riverside =
// 取倒影长度最长、优先桥头/红灯笼的光源,相机对准其光源格,倒影落在正下方。
let ranked =
SceneDetail.lightSources map
|> List.map (fun (x, y, kind) ->
let length = SceneDetail.reflectionLength map x y
let kindRank =
match kind with
| SceneDetail.RedLantern -> 2
| SceneDetail.BridgeLantern -> 1
| SceneDetail.RoadLantern -> 0
x, y, kind, length, kindRank)
let deep = ranked |> List.filter (fun (_, _, _, length, _) -> length >= 3)
let pick =
(if List.isEmpty deep then ranked else deep)
|> List.sortByDescending (fun (_, _, _, length, kindRank) -> kindRank, length)
|> List.tryHead
match pick with
| Some (x, y, _, _, _) -> (x, y)
| None ->
match SceneDetail.reflectionStreaks map with
| (rx, ry, _, _) :: _ -> (rx, ry - 1)
| [] -> (map.Core.MinX, map.Core.MinY)
let closeup =
// 近景:优先倒影更长、且离漂浮元素更近的光源,保证近景同时有倒影与漂浮元素。
let waterSources =
SceneDetail.lightSources map
|> List.filter (fun (x, y, _) -> SceneDetail.reflectionLength map x y >= 1)
let floatTiles = SceneDetail.floatingProps map |> List.map (fun (x, y, _) -> x, y)
let distToFloat (sx: int) (sy: int) =
if List.isEmpty floatTiles then 0
else floatTiles |> List.map (fun (fx, fy) -> abs (fx - sx) + abs (fy - sy)) |> List.min
match waterSources with
| [] -> riverside
| _ ->
waterSources
|> List.map (fun (x, y, _) -> x, y, SceneDetail.reflectionLength map x y, distToFloat x y)
|> List.sortBy (fun (_, _, length, distance) -> -length, distance)
|> List.head
|> fun (x, y, _, _) -> (x, y)
let reportVisibleReflections (shotName: string) =
let vw = this.GraphicsDevice.Viewport.Width
let vh = this.GraphicsDevice.Viewport.Height
for (lx, ly, kind) in SceneDetail.lightSources map do
for (rx, ry, alpha, _) in SceneDetail.reflectionStreakFor map lx ly kind do
let ssx = lx * Sim.tilePixels - int camera.X
let ssy = ly * Sim.tilePixels - int camera.Y
let rsx = rx * Sim.tilePixels - int camera.X
let rsy = ry * Sim.tilePixels - int camera.Y
// 空白对照:同排最近的非倒影水面格。
let control =
[ (2, 0); (-2, 0); (4, 0); (-4, 0); (0, 1); (0, -1) ]
|> List.map (fun (ox, oy) -> rx + ox, ry + oy)
|> List.tryFind (fun (cx, cy) -> SceneDetail.isWaterSurface map cx cy)
if ssx >= 0 && ssx + Sim.tilePixels <= vw && ssy >= 0 && ssy + Sim.tilePixels <= vh
&& rsy + Sim.tilePixels <= vh then
match control with
| Some (cx, cy) ->
printfn
"p47-reflection %s src=%d,%d dst=%d,%d ctrl=%d,%d alpha=%d"
shotName ssx ssy rsx rsy (cx * Sim.tilePixels - int camera.X) (cy * Sim.tilePixels - int camera.Y) alpha
| None ->
printfn "p47-reflection %s src=%d,%d dst=%d,%d ctrl=-1,-1 alpha=%d" shotName ssx ssy rsx rsy alpha
for (rx, ry, rw) in SceneDetail.foregroundRooftops vw vh world.Tick do
if rx + rw > 0 && rx < vw then
printfn "p47-roof %s x=%d y=%d w=%d" shotName rx ry rw
printfn
"p47-elements reeds=%d floats=%d reflections=%d sources=%d maxstreak=%d"
(List.length (SceneDetail.bankReedTiles map))
(List.length (SceneDetail.floatingProps map))
(List.length (SceneDetail.reflectionStreaks map))
(List.length (SceneDetail.lightSources map))
(SceneDetail.lightSources map
|> List.map (fun (x, y, _) -> SceneDetail.reflectionLength map x y)
|> List.fold max 0)
match p47Step with
| 0 ->
setHour 12.0
placeCameraOn (fst riverside) (snd riverside)
p47PendingName <- "p47-day"
reportVisibleReflections "p47-day"
p47Pending <- true
| 1 ->
setHour 23.5
placeCameraOn (fst riverside) (snd riverside)
p47PendingName <- "p47-night"
reportVisibleReflections "p47-night"
p47Pending <- true
| 2 ->
setHour 12.0
placeCameraOn (fst closeup) (snd closeup)
p47PendingName <- "p47-close"
reportVisibleReflections "p47-close"
p47Pending <- true
| _ ->
printfn "p47-shot=done"
this.Exit()
/// P47 证据:在 `Draw` 末尾落盘当前后台缓冲。
member private this.CaptureP47Shot () =
if p47Pending then
p47Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p47PendingName)
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
elif p78ShotMode then
printfn "p78-frame=%s tick=%d camera=(%.0f,%.0f)"
p47PendingName world.Tick camera.X camera.Y
p78Step <- p78Step + 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 () =
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
let bagText () =
match m5View.Task with
| None -> "-"
| Some state ->
state.Backpack
|> List.map (fun (item, quantity) -> sprintf "%A=%d" item quantity)
|> String.concat ";"
if not p52Pending then
match p52Step with
| 0 ->
setHour 12.0
let npc = world.Npcs.[0]
world <- { world with Avatar = { world.Avatar with Pos = npc.Pos } }
let nextWorld, nextView = M5Interaction.apply M5Command.Interact world m5View
world <- nextWorld
m5View <- nextView
this.CenterCamera()
p52PendingName <- "p52-dialog"
p52Pending <- true
| 1 ->
let moneyBefore = world.Avatar.Mind.Needs.Money
let bagBefore = bagText ()
let nextWorld, nextView = M5Interaction.apply M5Command.BuyFromTarget world m5View
world <- nextWorld
m5View <- nextView
printfn "p52-trade buy npc=%A money_before=%.2f money_after=%.2f bag_before=[%s] bag_after=[%s] status=%s"
world.Npcs.[0].Id moneyBefore world.Avatar.Mind.Needs.Money bagBefore (bagText ()) m5View.Status
p52PendingName <- "p52-buy"
p52Pending <- true
| 2 ->
let reopenedWorld, reopenedView = M5Interaction.apply M5Command.Interact world m5View
world <- reopenedWorld
m5View <- reopenedView
let moneyBefore = world.Avatar.Mind.Needs.Money
let bagBefore = bagText ()
let nextWorld, nextView = M5Interaction.apply M5Command.SellToTarget world m5View
world <- nextWorld
m5View <- nextView
printfn "p52-trade sell npc=%A money_before=%.2f money_after=%.2f bag_before=[%s] bag_after=[%s] status=%s"
world.Npcs.[0].Id moneyBefore world.Avatar.Mind.Needs.Money bagBefore (bagText ()) m5View.Status
p52PendingName <- "p52-sell"
p52Pending <- true
| _ ->
printfn "p52-shot=done"
this.Exit()
/// P52 证据:在 `Draw` 末尾落盘每帧,并打印面板/反馈/背包快照。
member private this.CaptureP52Shot () =
if p52Pending then
p52Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p52PendingName)
let bag =
match m5View.Task with
| None -> "-"
| Some state ->
state.Backpack
|> List.map (fun (item, quantity) -> sprintf "%A=%d" item quantity)
|> String.concat ";"
printfn "p52-shot=%s panel=%s status=%s bag=[%s]"
p52PendingName
(M5Interaction.panelName m5View)
m5View.Status
bag
p52Step <- p52Step + 1
/// P54 证据:农夫真实开局 → 任务面板(待接受) → 接受 → 环境到达 + 对话 + 买/卖
/// 四条真实信号,验证 Offered→Active→Done 只由真实事件驱动。
member private this.PrepareP54Shot () =
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
let ask (command: M5Command) =
let nextWorld, nextView = M5Interaction.apply command world m5View
world <- nextWorld
m5View <- nextView
if not p54Pending then
match p54Step with
| 0 ->
setHour 12.0
let npc = world.Npcs.[0]
world <- { world with Avatar = { world.Avatar with Pos = npc.Pos } }
ask M5Command.ShowTaskPanel
this.CenterCamera()
p54PendingName <- "p54-task-offered"
p54Pending <- true
| 1 ->
ask M5Command.AcceptTask
p54PendingName <- "p54-task-active"
p54Pending <- true
| 2 ->
ask M5Command.ClosePanel
// 模拟跨入当前瓦片:以相邻瓦片为基线喂「到达瓦片」环境信号(真实折叠函数)。
let tile = (int (world.Avatar.Pos.X / float32 Sim.tilePixels), int (world.Avatar.Pos.Y / float32 Sim.tilePixels))
match m5View.Task with
| Some state ->
let previousTile = (fst tile + 1, snd tile)
let signals = TaskRuntime.environmentSignals false false (Some previousTile) tile
let advanced, message = TaskRuntime.foldSignals signals state
m5View <- { m5View with Task = Some advanced; Status = (match message with Some m -> "task|" + m | None -> m5View.Status) }
| None -> ()
this.CenterCamera()
p54PendingName <- "p54-arrive"
p54Pending <- true
| 3 ->
ask M5Command.Interact
ask M5Command.Intent1
p54PendingName <- "p54-dialogue"
p54Pending <- true
| 4 ->
ask M5Command.Interact
ask M5Command.BuyFromTarget
p54PendingName <- "p54-buy"
p54Pending <- true
| 5 ->
ask M5Command.Interact
ask M5Command.SellToTarget
p54PendingName <- "p54-sell"
p54Pending <- true
| 6 ->
ask M5Command.ShowTaskPanel
p54PendingName <- "p54-task-done"
p54Pending <- true
| _ ->
printfn "p54-shot=done"
this.Exit()
/// P54 证据:在 `Draw` 末尾落盘并打印任务模板/状态/反馈/背包。
member private this.CaptureP54Shot () =
if p54Pending then
p54Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p54PendingName)
let stateName (state: Occupation.TaskState) =
match state with
| Occupation.Offered -> "offered"
| Occupation.Active -> "active"
| Occupation.Done -> "done"
| Occupation.Failed -> "failed"
let taskText =
match m5View.Task with
| None -> "occupation=none template=none state=none"
| Some state ->
match state.Today with
| None -> "occupation=yes template=none state=none"
| Some task ->
sprintf "occupation=yes template=%s state=%s"
(Occupation.taskNameOf task.TemplateId) (stateName task.State)
let bag =
match m5View.Task with
| None -> "-"
| Some state ->
state.Backpack
|> List.map (fun (item, quantity) -> sprintf "%A=%d" item quantity)
|> String.concat ";"
printfn "p54-shot=%s %s panel=%s status=%s bag=[%s]"
p54PendingName taskText (M5Interaction.panelName m5View) m5View.Status bag
p54Step <- p54Step + 1
/// P55 证据:跳到第 3 日(送粮)→ 面板(待接受) → 接受 → 真实卖出 Food(完成 +食物×1)。
member private this.PrepareP55Shot () =
let setDay3Noon () =
let tick = 3L * Sim.ticksPerDay + M6Presentation.resolveStartTick (Some 12.0) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
let ask (command: M5Command) =
let nextWorld, nextView = M5Interaction.apply command world m5View
world <- nextWorld
m5View <- nextView
if not p55Pending then
match p55Step with
| 0 ->
setDay3Noon ()
// 用真实跨日刷新把当日任务推进到第 3 日(seed 42/农夫 = 送粮)。
match m5View.Task with
| Some state -> m5View <- { m5View with Task = Some(WorldBootstrap.refreshOccupationTodayWorld 42UL state world.Tick world) }
| None -> ()
let npc = world.Npcs.[0]
world <- { world with Avatar = { world.Avatar with Pos = npc.Pos } }
ask M5Command.ShowTaskPanel
this.CenterCamera()
p55PendingName <- "p55-task-offered"
p55Pending <- true
| 1 ->
ask M5Command.AcceptTask
p55PendingName <- "p55-task-active"
p55Pending <- true
| 2 ->
ask M5Command.ClosePanel
ask M5Command.Interact
ask M5Command.SellToTarget
p55PendingName <- "p55-reward"
p55Pending <- true
| 3 ->
ask M5Command.ShowTaskPanel
p55PendingName <- "p55-task-done"
p55Pending <- true
| _ ->
printfn "p55-shot=done"
this.Exit()
/// P55 证据:落盘并打印模板/状态/streak/背包/反馈。
member private this.CaptureP55Shot () =
if p55Pending then
p55Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p55PendingName)
let stateText (state: Occupation.TaskState) =
match state with
| Occupation.Offered -> "offered"
| Occupation.Active -> "active"
| Occupation.Done -> "done"
| Occupation.Failed -> "failed"
let templateText, taskState, streak =
match m5View.Task with
| None -> "none", "none", 0
| Some state ->
(match state.Today with
| Some task -> Occupation.taskNameOf task.TemplateId, stateText task.State, state.Streak
| None -> "none", "none", state.Streak)
let bag =
match m5View.Task with
| None -> "-"
| Some state ->
state.Backpack
|> List.map (fun (item, quantity) -> sprintf "%A=%d" item quantity)
|> String.concat ";"
printfn "p55-shot=%s template=%s state=%s streak=%d panel=%s status=%s bag=[%s]"
p55PendingName templateText taskState streak (M5Interaction.panelName m5View) m5View.Status bag
p55Step <- p55Step + 1
/// P53 证据:真实录制提示出现/消失序列(远处 → 靠近 → 互动 → 关闭+离开)。
member private this.PrepareP53Recording () =
let setHour (hour: float) =
let tick = M6Presentation.resolveStartTick (Some hour) false
world <- { world with Tick = tick; Time = float tick * Sim.dtSeconds }
let placeAwayFromNpc () =
let npc = world.Npcs.[0]
world <- { world with Avatar = { world.Avatar with Pos = { X = npc.Pos.X + 240.0f; Y = npc.Pos.Y } } }
if not p53Pending then
match p53Step with
| 0 ->
setHour 12.0
// 只保留 0 号村民作候选,其余移远,隔离出唯一的提示对象(真实 resolver 不改)。
let npcs = Array.copy world.Npcs
for index in 1 .. npcs.Length - 1 do
npcs.[index] <- { npcs.[index] with Pos = { X = 4000.0f; Y = 4000.0f } }
world <- { world with Npcs = npcs }
placeAwayFromNpc ()
m5View <- M5Interaction.refreshPrompt world m5View
this.CenterCamera()
p53PendingName <- "p53-far"
p53Pending <- true
| 1 ->
let npc = world.Npcs.[0]
world <- { world with Avatar = { world.Avatar with Pos = npc.Pos } }
m5View <- M5Interaction.refreshPrompt world m5View
this.CenterCamera()
p53PendingName <- "p53-prompt"
p53Pending <- true
| 2 ->
let nextWorld, nextView = M5Interaction.apply M5Command.Interact world m5View
world <- nextWorld
m5View <- nextView
p53PendingName <- "p53-dialog"
p53Pending <- true
| 3 ->
let closedWorld, closedView = M5Interaction.apply M5Command.ClosePanel world m5View
world <- closedWorld
m5View <- closedView
placeAwayFromNpc ()
m5View <- M5Interaction.refreshPrompt world m5View
this.CenterCamera()
p53PendingName <- "p53-gone"
p53Pending <- true
| _ ->
printfn "p53-rec=done"
this.Exit()
/// P53 证据:在 `Draw` 末尾落盘每帧,并打印面板/提示/目标/提示矩形。
member private this.CaptureP53Recording () =
if p53Pending then
p53Pending <- false
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory p53PendingName)
let targetText =
match InteractionResolver.resolve world m5View.HomeMode with
| Some target -> sprintf "%A" target.Action
| None -> "none"
let rectText =
match m5View.Prompt, m5View.PromptTargetPos with
| Some text, Some position ->
let viewport = this.GraphicsDevice.Viewport
let rect =
FloatingPrompt.layout viewport.Width viewport.Height position.X position.Y camera.X camera.Y 2 text
sprintf "%d,%d,%d,%d" rect.X rect.Y rect.Width rect.Height
| _ -> "none"
printfn "p53-rec=%s panel=%s prompt=%s target=%s rect=%s"
p53PendingName
(M5Interaction.panelName m5View)
(m5View.Prompt |> Option.defaultValue "none")
targetText
rectText
p53Step <- p53Step + 1
/// P46 证据:菜单阶段按帧表把 menuEntranceFrame 钉到灯笼呼吸的波峰/波谷,拍两相位。
member private this.PrepareP46Shot () =
if p46MenuADone && p46MenuBDone then
printfn "p46-shot=done"
this.Exit()
elif not p46MenuADone then
// 每帧钉住目标帧,抵消 Update 末尾的自增,保证 Draw 看到精确相位。
menuEntranceFrame <- P46ShotScript.menuPeakFrame
if not p46Pending then
p46PendingName <- P46ShotScript.menuPeakName
p46Pending <- true
elif not p46MenuBDone then
menuEntranceFrame <- P46ShotScript.menuTroughFrame
if not p46Pending then
p46PendingName <- P46ShotScript.menuTroughName
p46Pending <- true
/// P20 第三步取证:真走位巡游(Sim.step 驱动)沿桥/路/民居门移动,用于桥面行走帧与昼夜录制。
member private this.RunRiverscapeTour () =
if not riverscapeTourWatchStarted then
riverscapeTourWatchStarted <- true
riverscapeTourWatch.Start()
let target = tourWaypoints.[tourIndex % tourWaypoints.Length]
let targetPos : Vec2 =
{ X = float32 (fst target * Sim.tilePixels + Sim.tilePixels / 2)
Y = float32 (snd target * Sim.tilePixels + Sim.tilePixels / 2) }
let dx = targetPos.X - world.Avatar.Pos.X
let dy = targetPos.Y - world.Avatar.Pos.Y
let distance = sqrt (dx * dx + dy * dy)
if distance < 3.0f then
tourIndex <- tourIndex + 1
if tourIndex >= tourWaypoints.Length then
if riverscapeTourSeconds > 0.0 && riverscapeTourWatch.Elapsed.TotalSeconds < riverscapeTourSeconds then
tourIndex <- 0
else
printfn "riverscape tour=complete frames=%d elapsed_s=%.1f" recordIndex riverscapeTourWatch.Elapsed.TotalSeconds
this.Exit()
else
let inv = 1.0f / distance
let input = { Input = { MoveX = dx * inv; MoveY = dy * inv } }
let before = world.Avatar.Pos
world <- Sim.step input world
avatarFacing <- VillageArt.facingAfterMovement before world.Avatar.Pos avatarFacing
avatarMoving <- distance > 4.0f
m5View <- M5Interaction.refreshPrompt world m5View
this.CenterCamera()
tourFrame <- tourFrame + 1
member private this.RunMapTour () =
let (tileX, tileY) = tourWaypoints.[tourIndex % tourWaypoints.Length]
let position : Vec2 =
{ X = float32 (tileX * Sim.tilePixels + Sim.tilePixels / 2)
Y = float32 (tileY * Sim.tilePixels + Sim.tilePixels / 2) }
world <- { world with Avatar = { world.Avatar with Pos = position } }
// give NPCs active ticks so the town stays alive between waypoints
for _ in 0 .. 7 do
world <- Sim.step { Input = { MoveX = 0.0f; MoveY = 0.0f } } world
avatarFacing <- VillageArt.SouthFacing
avatarMoving <- false
m5View <- M5Interaction.refreshPrompt world m5View
this.CenterCamera()
tourFrame <- tourFrame + 1
if tourFrame >= 45 then
tourFrame <- 0
tourIndex <- tourIndex + 1
if tourIndex >= tourWaypoints.Length then
printfn "map tour=complete frames={recordIndex}"
this.Exit()
else
printfn $"map tour={tourIndex} at tile=({tileX},{tileY})"
member private this.UpdatePlaying (gameTime: GameTime) (kb: KeyboardState) (pressed: Keys -> bool) (pressedAny: Keys list -> bool) =
if riverscapeTourMode then
this.RunRiverscapeTour()
elif mapTourMode then
this.RunMapTour()
elif sampleMode then
this.RunSampleMode()
else
this.UpdatePlayingManual gameTime kb pressed pressedAny
member private this.UpdatePlayingManual (gameTime: GameTime) (kb: KeyboardState) (pressed: Keys -> bool) (pressedAny: Keys list -> bool) =
let mutable loadFailed = false
let mutable leftGame = false
let lPressed = pressed Keys.L
let escapePressed = pressed Keys.Escape
if pressed Keys.P then
if m5View.Panel = WorldPanel then
let helpState, pausedControl = MenuState.enterPauseHelp simulationControl menu
menu <- helpState
pauseHelpControl <- Some simulationControl
simulationControl <- pausedControl
printfn $"help=pause-open simulation={M6Presentation.clockLabel simulationControl}"
if pressed Keys.F1 then
simulationControl <- SimulationControl.setSpeed OneX simulationControl
legacyStepsPerFrame <- None
menu <- MenuState.setSettings simulationControl menu
printfn $"simulation={M6Presentation.clockLabel simulationControl}"
if pressed Keys.F2 then
simulationControl <- SimulationControl.setSpeed TwoX simulationControl
legacyStepsPerFrame <- None
menu <- MenuState.setSettings simulationControl menu
printfn $"simulation={M6Presentation.clockLabel simulationControl}"
if pressed Keys.F3 then
simulationControl <- SimulationControl.setSpeed FiveX simulationControl
legacyStepsPerFrame <- None
menu <- MenuState.setSettings simulationControl menu
printfn $"simulation={M6Presentation.clockLabel simulationControl}"
if pressed Keys.F6 then
this.SaveWorld "save" |> ignore
if pressed Keys.F7 then
match this.LoadWorld "load" with
| Ok _ -> menu <- MenuState.setCurrentWorld true menu
| Error failure ->
menu <- menu |> MenuState.setCurrentWorld true |> MenuState.showLoadError failure
loadFailed <- true
if not loadFailed && escapePressed then
if m5View.Panel <> WorldPanel then
let nextWorld, nextView = M5Interaction.apply ClosePanel world m5View
world <- nextWorld
m5View <- nextView
printfn $"m5 panel={M5Interaction.panelName m5View} status={m5View.Status} tick={world.Tick}"
elif relationView then
relationView <- false
relationSnapshot <- None
printfn $"relation view=off tick={world.Tick}"
else
this.OpenMainMenu()
leftGame <- true
if not loadFailed && not leftGame then
if lPressed && M5Interaction.worldInputAllowed m5View then
relationView <- not relationView
if relationView then relationSnapshot <- Some(Sim.relationMatrix world)
let state = if relationView then "on" else "off"
printfn $"relation view={state} tick={world.Tick}"
// P44:弹层开启时用 空格/回车/E 翻页(下一页);最后一页再翻为 no-op,不崩。
let overlayOpen = dialogOverlay.IsSome
if overlayOpen && (pressed Keys.Space || pressed Keys.Enter || pressed Keys.E) then
match DialogOverlay.nextPage dialogOverlay.Value with
| Some next -> dialogOverlay <- Some next
| None -> ()
let m5Command =
if overlayOpen then
// P44:弹层开启只允许对话选项 1-6 + P52 买卖键;E/Q/Tab/C/T 等世界交互键全部屏蔽,不穿透。
if m5View.Panel = DialoguePanel && pressedAny [ Keys.D1; Keys.NumPad1 ] then Some Intent1
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D2; Keys.NumPad2 ] then Some Intent2
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D3; Keys.NumPad3 ] then Some Intent3
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D4; Keys.NumPad4 ] then Some Intent4
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D5; Keys.NumPad5 ] then Some Intent5
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D6; Keys.NumPad6 ] then Some Intent6
elif m5View.Panel = DialoguePanel && pressed Keys.B then Some BuyFromTarget
elif m5View.Panel = DialoguePanel && pressed Keys.V then Some SellToTarget
else None
else
if M5Interaction.worldInputAllowed m5View && pressed Keys.E then Some Interact
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D1; Keys.NumPad1 ] then Some Intent1
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D2; Keys.NumPad2 ] then Some Intent2
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D3; Keys.NumPad3 ] then Some Intent3
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D4; Keys.NumPad4 ] then Some Intent4
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D5; Keys.NumPad5 ] then Some Intent5
elif m5View.Panel = DialoguePanel && pressedAny [ Keys.D6; Keys.NumPad6 ] then Some Intent6
elif m5View.Panel = DialoguePanel && pressed Keys.B then Some BuyFromTarget
elif m5View.Panel = DialoguePanel && pressed Keys.V then Some SellToTarget
elif pressed Keys.Q then Some Observe
elif pressed Keys.Tab then Some ToggleNeeds
elif pressed Keys.C then Some ShowChronicle
elif pressed Keys.T then Some ShowTaskPanel
elif m5View.Panel = TaskPanel && pressedAny [ Keys.Enter; Keys.Space ] then Some AcceptTask
else None
match m5Command with
| Some command ->
let nextWorld, nextView = M5Interaction.apply command world m5View
world <- nextWorld
m5View <- nextView
printfn $"m5 panel={M5Interaction.panelName m5View} status={m5View.Status} tick={world.Tick}"
| None -> ()
let panelOpen = m5View.Panel <> WorldPanel
// P43:游戏内按 1-0 直接选中 hotbar 槽位;仅当世界输入允许(无面板/对话)时生效,
// Esc 打开的菜单走 UpdateMenu 分支、根本不进这里,输入不穿透。
if HudLayout.hotbarInputAllowed (menu.Page = Playing) (M5Interaction.worldInputAllowed m5View) then
let digitKeys =
[ 1, Keys.D1; 2, Keys.D2; 3, Keys.D3; 4, Keys.D4; 5, Keys.D5
6, Keys.D6; 7, Keys.D7; 8, Keys.D8; 9, Keys.D9; 0, Keys.D0 ]
for (digit, key) in digitKeys do
if pressed key then
match HudLayout.selectSlotForDigit digit with
| Some slot -> hotbarSelected <- slot
| None -> ()
if not relationView && not panelOpen then
let input =
if automated then
let t = float32 world.Tick
{ MoveX = MathF.Sin(t / 60.0f) * 0.8f
MoveY = MathF.Cos(t / 90.0f) * 0.6f }
else
{ MoveX =
(if kb.IsKeyDown(Keys.D) then 1.0f
elif kb.IsKeyDown(Keys.A) then -1.0f
else 0.0f)
MoveY =
(if kb.IsKeyDown(Keys.S) then 1.0f
elif kb.IsKeyDown(Keys.W) then -1.0f
else 0.0f) }
let ts = { Input = input }
let stepCount = SimulationControl.stepsPerFrameWithLegacy legacyStepsPerFrame simulationControl
if stepCount > 0 then
let mutable moved = false
for _ in 1 .. stepCount do
let previousPosition = world.Avatar.Pos
world <- Sim.step ts world
avatarFacing <- VillageArt.facingAfterMovement previousPosition world.Avatar.Pos avatarFacing
moved <- moved || world.Avatar.Pos <> previousPosition
avatarMoving <- moved
else
avatarMoving <- false
this.CenterCamera()
match m5View.Task with
| Some state ->
let refreshed = WorldBootstrap.refreshOccupationTodayWorld 42UL state world.Tick world
if refreshed <> state then
m5View <- { m5View with Task = Some refreshed }
| None -> ()
// P54:把真实世界环境折叠成任务信号 —— 跨瓦片触发「到达瓦片」;
// 夜里站在水边触发「夜在水边」。全部走 Kernel 纯函数,不按日历计数。
match m5View.Task with
| Some state ->
let tileX = int (world.Avatar.Pos.X / float32 Sim.tilePixels)
let tileY = int (world.Avatar.Pos.Y / float32 Sim.tilePixels)
let isNight = (M6Presentation.profileAtTick world.Tick).Mode = Night
let nearWater =
match riverscapeMap with
| Some map ->
[ 1, 0; -1, 0; 0, 1; 0, -1 ]
|> List.exists (fun (dx, dy) -> SceneDetail.isWater map (tileX + dx) (tileY + dy))
| None -> false
let signals = TaskRuntime.environmentSignals isNight nearWater lastAvatarTile (tileX, tileY)
lastAvatarTile <- Some(tileX, tileY)
let advanced, message = TaskRuntime.foldSignals signals state
if advanced <> state then
m5View <-
{ m5View with
Task = Some advanced
Status = (match message with Some text -> "task|" + text | None -> m5View.Status)
StatusTick = (match message with Some _ -> Some world.Tick | None -> m5View.StatusTick) }
| None -> ()
m5View <- M5Interaction.refreshPrompt world m5View
member private this.RunAutoplayFlow() =
let moveDown count =
for _ in 1 .. count do
this.DispatchMenuInput Down
match flowStep with
| 0 ->
printfn "flow=main-menu"
flowStep <- 50
| 50 when menu.Page = MainMenu ->
flowHold <- flowHold + 1
if flowHold >= 60 then
flowHold <- 0
this.DispatchMenuInput Confirm
printfn "flow=new-game"
flowStep <- 1
| 50 ->
printfn "flow=new-game"
flowStep <- 1
| 1 when menu.Page = OccupationSelect ->
this.DispatchMenuInput Confirm
printfn "flow=occupation=none"
| 1 when menu.Page = Playing ->
this.OpenMainMenu()
printfn "flow=return-menu"
flowStep <- 2
| 2 when menu.Page = MainMenu ->
moveDown 1
this.DispatchMenuInput Confirm
printfn "flow=load"
flowStep <- 3
| 3 ->
this.DispatchMenuInput Back
printfn "flow=back"
flowStep <- 4
| 4 when menu.Page = MainMenu ->
this.SaveWorld "flow=save" |> ignore
flowStep <- 5
| 5 when menu.Page = MainMenu ->
moveDown 1
this.DispatchMenuInput Confirm
printfn "flow=load-again"
flowStep <- 6
| 6 ->
this.OpenMainMenu()
printfn "flow=exit"
this.Exit()
flowStep <- 7
| _ -> ()
override this.Initialize() =
base.Initialize()
prevKb <- Keyboard.GetState()
override _.LoadContent() =
spriteBatch <- new SpriteBatch(this.GraphicsDevice)
artTextures <- VillageArt.loadTextures this.GraphicsDevice
cjkAtlas <- CjkGlyphAtlas.load this.GraphicsDevice
pixel <- new Texture2D(this.GraphicsDevice, 1, 1)
pixel.SetData([| Color.White |])
override _.UnloadContent() =
if not (isNull artTextures.TileAtlas) then artTextures.TileAtlas.Dispose()
if not (isNull artTextures.CharacterAtlas) then artTextures.CharacterAtlas.Dispose()
if not (isNull artTextures.InteriorAtlas) then artTextures.InteriorAtlas.Dispose()
if not (isNull cjkAtlas) then cjkAtlas.Dispose()
if not (isNull pixel) then pixel.Dispose()
if not (isNull spriteBatch) then spriteBatch.Dispose()
/// P31 证据:以真实开局函数建世界,用真实对话管线(bias + onDialogue)推进剧情线,
/// 再打开任务面板——与玩家操作走同一套 Kernel 纯函数,仅脚本化输入。
member private this.RunStoryShotSetup () =
let seed = 42UL
let kind = storyShotKind
let stage = storyShotStage
let lineStartDay = Occupation.Story.startDayOf seed kind + int64 (max 0 (stage - 1))
let startTick = lineStartDay * Sim.ticksPerDay + 12L * Sim.ticksPerDay / 24L
let state = WorldBootstrap.occupationStateFor seed kind startTick
let world0 = WorldBootstrap.initialWorldWithOccupation false seed Sim.npcCount (Some state)
// P66:证据路径同样按真实世界候选定点当日任务(world0 只依赖 profile)。
let task0 = WorldBootstrap.occupationStateForWorld seed kind startTick world0
let world1 = { world0 with Tick = startTick; Time = float startTick * Sim.dtSeconds }
let world2 =
Sim.appendAnnal
{ Tick = startTick; Kind = StoryAnnal; Summary = Occupation.Story.identitySummaryOf kind }
world1
let mutable w = world2
let mutable task = task0
for i in 0 .. stage - 1 do
let npc = w.Npcs.[i % w.Npcs.Length]
let wNear = { w with Avatar = { w.Avatar with Pos = npc.Pos } }
let respond = Occupation.biasResponse (Some kind)
match Sim.chooseDialogueWith respond npc.Id SmallTalk wNear with
| DialogueSucceeded (_, next) ->
let nextState, summary = Occupation.Story.onDialogue seed task next
w <-
match summary with
| Some text -> Sim.appendAnnal { Tick = next.Tick; Kind = StoryAnnal; Summary = text } next
| None -> next
task <- nextState
| DialogueRejected (failure, _) -> printfn "story-shot dialogue rejected: %A" failure
world <- w
m5View <- { M5Interaction.initial with Task = Some task; Seed = seed }
let _, view = M5Interaction.apply ShowTaskPanel world m5View
m5View <- view
menu <- menu |> MenuState.setCurrentWorld true |> MenuState.enterGame
printfn "story-shot=prepared occupation=%s stage=%d tick=%d annals=%d"
(Occupation.saveToken kind) stage world.Tick world.Annals.Length
override this.Update(gameTime: GameTime) =
if frameLogEnabled && not splashActive then
let allocatedNow = System.GC.GetAllocatedBytesForCurrentThread()
if frameLogIndex = 0L then
frameLogWatch.Start()
frameLogAllocStart <- allocatedNow
else
let frameMs = frameLogWatch.Elapsed.TotalMilliseconds
let allocKb = float (allocatedNow - frameLogAllocStart) / 1024.0
printfn
"p70-frame index=%d ms=%.3f alloc_kb=%.1f tick=%d panel=%s"
frameLogIndex frameMs allocKb world.Tick (M5Interaction.panelName m5View)
frameLogWatch.Restart()
frameLogAllocStart <- allocatedNow
frameLogIndex <- frameLogIndex + 1L
let kb = Keyboard.GetState()
let pressed (key: Keys) = kb.IsKeyDown(key) && not (prevKb.IsKeyDown(key))
let pressedAny (keys: Keys list) = keys |> List.exists pressed
if splashActive then
splashFrame <- splashFrame + 1L
if p46ShotMode && splashFrame >= 10L then
// P46 取证:等画面绘制稳定后,把 splashFrame 钉到下一个未取证的目标帧,
// 令 Draw 看到精确帧号(前若干帧 backbuffer 未铺满,故需 warm-up 门槛)。
let target =
if not p46SplashRippleDone then Some P46ShotScript.splashRippleFrame
elif not p46CloudEarlyDone then Some P46ShotScript.cloudEarlyFrame
elif not p46CloudLateDone then Some P46ShotScript.cloudLateFrame
else None
match target with
| Some t -> splashFrame <- t
| None -> ()
if p57ShotMode && splashFrame >= 10L && p57Step < 2 then
splashFrame <- P57ShotScript.splashFrame
this.PrepareP57Splash()
let skip = LaunchScreen.skipRequested (pressed Keys.Escape) (pressed Keys.Space)
if skip || LaunchScreen.isComplete splashFrame then
splashActive <- false
menuEntranceFrame <- 0L
printfn (if skip then "splash=skip frame=%d" else "splash=done frame=%d") splashFrame
else
if storyShotMode && not storyShotPrepared then
storyShotPrepared <- true
this.RunStoryShotSetup()
elif autoplayFlow then
this.RunAutoplayFlow()
elif p39ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
// 证据模式选「暂不选择」(首项)直接开局。
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP39Shot()
elif p40ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP40Shot()
elif p37ShotMode then
this.RunP37Shot()
elif p43ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP43Shot()
elif p44ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP44Shot()
elif p61ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP61Shot()
elif p62ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP62Shot()
elif p64ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP64Shot()
elif p65ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
let targetIndex =
MenuState.occupationOptions |> List.findIndex (fun option -> option = Some Occupation.Peddler)
if menu.Selected <> targetIndex then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP65Shot()
elif p67ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP67Shot()
elif p45ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP45Shot()
elif p46ShotMode then
if menu.Page = MainMenu then
this.PrepareP46Shot()
elif p57ShotMode then
if menu.Page = MainMenu then
this.PrepareP57Shot()
elif p47ShotMode || p73ShotMode || p78ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP47Shot()
elif p52ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
let targetIndex =
MenuState.occupationOptions |> List.findIndex (fun option -> option = Some p52Occupation)
if menu.Selected <> targetIndex then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP52Shot()
elif p53RecordMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
if menu.Selected <> 0 then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP53Recording()
elif p54ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
let targetIndex =
MenuState.occupationOptions |> List.findIndex (fun option -> option = Some p54Occupation)
if menu.Selected <> targetIndex then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP54Shot()
elif p55ShotMode then
if menu.Page = MainMenu then
this.DispatchMenuInput Confirm
elif menu.Page = OccupationSelect then
let targetIndex =
MenuState.occupationOptions |> List.findIndex (fun option -> option = Some Occupation.Farmer)
if menu.Selected <> targetIndex then this.DispatchMenuInput Down
else this.DispatchMenuInput Confirm
elif menu.Page = Playing then
this.PrepareP55Shot()
elif menu.Page = Playing then
this.UpdatePlaying gameTime kb pressed pressedAny
elif menuShotMode then
this.RunMenuShot()
else
this.UpdateMenu pressed
if menu.Page <> Playing then
menuEntranceFrame <- menuEntranceFrame + 1L
// P57 取证:钉住菜单水面帧,令「高光层关/开」两帧渲染同一帧号(差即高光层)。
if p57ShotMode && menu.Page = MainMenu && p57Step <= 3 then
menuEntranceFrame <- P57ShotScript.menuFrame + 1L
match pauseHelpControl with
| Some original when menu.Page = Playing ->
let _, restoredControl = MenuState.exitPauseHelp original menu
simulationControl <- restoredControl
pauseHelpControl <- None
printfn $"help=pause-close simulation={M6Presentation.clockLabel simulationControl}"
| _ -> ()
if menu.Page = Playing then
this.SyncDialogOverlay()
hudClock <- hudClock + 1L
if m5View.Status <> hudStatus then
hudStatus <- m5View.Status
hudStatusAt <- hudClock
fpsFrames <- fpsFrames + 1
fpsSeconds <- fpsSeconds + gameTime.ElapsedGameTime.TotalSeconds
if fpsSeconds >= 1.0 then
let fps = float fpsFrames / fpsSeconds
fpsFrames <- 0
fpsSeconds <- 0.0
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() =
if perfSummaryMode then
match PerformanceSummary.summarize 5 (List.rev fpsSamples) with
| Some summary ->
printfn
"perf-summary samples=%d warmup_dropped=5 mean_fps=%.2f min_fps=%.2f max_fps=%.2f"
summary.Count
summary.Mean
summary.Min
summary.Max
| None -> printfn "perf-summary samples=%d (insufficient, all warmup)" fpsSamples.Length
base.EndRun()
member private this.DrawLine (a: Vector2) (b: Vector2) (thickness: float32) (color: Color) =
let d = b - a
let len = d.Length()
if len > 1.0f then
let angle = MathF.Atan2(d.Y, d.X)
spriteBatch.Draw(pixel, a, System.Nullable(), color, angle, Vector2.Zero, Vector2(len, thickness), SpriteEffects.None, 0.0f)
member private this.DrawRelationView() =
let profile = M6Presentation.profileAtTick world.Tick
this.GraphicsDevice.Clear(profile.Background)
let viewport = this.GraphicsDevice.Viewport
let vw = float32 viewport.Width
let vh = float32 viewport.Height
let mapW = float32 (Sim.mapWidthTiles * Sim.tilePixels)
let mapH = float32 (Sim.mapHeightTiles * Sim.tilePixels)
let margin = 48.0f
let scale = min ((vw - 2.0f * margin) / mapW) ((vh - 2.0f * margin) / mapH)
let ox = (vw - mapW * scale) / 2.0f
let oy = (vh - mapH * scale) / 2.0f
let toScreen (p: Vec2) : Vector2 = Vector2(ox + p.X * scale, oy + p.Y * scale)
spriteBatch.Begin()
match relationSnapshot with
| Some m ->
let n = Array2D.length1 m
for i in 0 .. n - 1 do
for j in i + 1 .. n - 1 do
let r = m.[i, j]
if abs r > Sim.relationThreshold then
let a = toScreen world.Npcs.[i].Pos
let b = toScreen world.Npcs.[j].Pos
let color = if r > 0.0f then Color.LimeGreen else Color.IndianRed
let thickness = Sim.clamp (1.5f + 3.0f * abs r) 1.5f 12.0f
this.DrawLine a b thickness color
for npc in world.Npcs do
let p = toScreen npc.Pos
spriteBatch.Draw(pixel, Rectangle(int p.X - 5, int p.Y - 5, 10, 10), Color.Cyan)
| None -> ()
spriteBatch.End()
/// 将当前后台缓冲存为 PNG(取证用;record 与菜单截图共用)。
member private this.SaveBackBuffer (path: string) =
let width = this.GraphicsDevice.PresentationParameters.BackBufferWidth
let height = this.GraphicsDevice.PresentationParameters.BackBufferHeight
let buffer = Array.zeroCreate<Color> (width * height)
this.GraphicsDevice.GetBackBufferData<Color>(buffer)
use texture = new Texture2D(this.GraphicsDevice, width, height)
texture.SetData(buffer)
use stream = System.IO.File.Create(path)
texture.SaveAsPng(stream, width, height)
/// P16-FIX:按 MenuShotScript 帧表落菜单/启动画面截图,拍完即退出。
member private this.CaptureMenuShot () =
let save name =
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory name)
if splashActive then
if splashFrame = MenuShotScript.splashMidFrame then
save MenuShotScript.splashMidName
elif menuShotFrame = MenuShotScript.initialFrame then
save MenuShotScript.initialName
elif menuShotFrame = MenuShotScript.loadFrame then
save MenuShotScript.loadName
elif menuShotFrame = MenuShotScript.exitFrame then
printfn "menu-shot=done frames=%d" menuShotFrame
this.Exit()
/// P42 证据:启动环境动效两帧 + 菜单动效一帧,拍完即退出。
member private this.CaptureP42Shot () =
let save (name: string) =
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory name)
printfn "p42-shot=%s frame=%d" name (if splashActive then splashFrame else menuEntranceFrame)
if splashActive then
if not p42SplashEarlyDone && splashFrame >= P42ShotScript.splashEarlyFrame then
p42SplashEarlyDone <- true
save P42ShotScript.splashEarlyName
if not p42SplashLateDone && splashFrame >= P42ShotScript.splashLateFrame then
p42SplashLateDone <- true
save P42ShotScript.splashLateName
elif menu.Page <> Playing && menuEntranceFrame >= P42ShotScript.menuFrame then
save P42ShotScript.menuName
printfn "p42-shot=done"
this.Exit()
/// P74 证据:splash 帧表逐帧落盘(证明开场过渡在变),拍完即退出。
member private this.CaptureP74Shot () =
if splashActive then
match p74Frames |> List.tryFind (fun f -> not (Set.contains f p74Saved) && splashFrame >= f) with
| Some frame ->
p74Saved <- Set.add frame p74Saved
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(sprintf "%s/p74-splash-%03d.png" recordDirectory frame)
printfn "p74-shot=p74-splash-%03d inkStrength=%.3f" frame (InkReveal.inkStrength splashFrame)
| None -> ()
if p74Saved.Count >= p74Frames.Length then
printfn "p74-shot=done"
this.Exit()
/// P20 证据:把一次 MapGen 绘制渲染到指定尺寸离屏 target,返回绘制瓦片数与纹理。
/// P28:可传入世界 tint 与可选 veil tick(夜景取证用)。
member private this.RenderMapGen (targetWidth: int) (targetHeight: int) (camX: int) (camY: int) (drawFitted: bool) (tint: Color) (veilTick: int64 option) : int * Texture2D =
use target = new RenderTarget2D(this.GraphicsDevice, targetWidth, targetHeight)
this.GraphicsDevice.SetRenderTarget target
this.GraphicsDevice.Clear(Color(18, 26, 20))
spriteBatch.Begin()
// P29:夜景取证帧与真实渲染同一套灯光衰减——按 veil tick 的 LanternGlow 叠加柔和径向光晕。
let glowScale =
match veilTick with
| Some tick -> (M6Presentation.profileAtTick tick).LanternGlow
| None -> 0.0f
let drawn =
if drawFitted then
VillageArt.drawMapFitted spriteBatch artTextures pixel targetWidth targetHeight mapGenResult tint glowScale
else
VillageArt.drawMapViewport spriteBatch artTextures pixel (Vector2(float32 camX, float32 camY)) targetWidth targetHeight mapGenResult 0L tint glowScale
// 与 DrawWorldView 同一套纯函数 veil,保证取证夜景=真实渲染夜景。
match veilTick with
| Some tick ->
let golden = M6Presentation.goldenVeilAlpha tick
if golden > 0 then
spriteBatch.Draw(pixel, Rectangle(0, 0, targetWidth, targetHeight), VillageArt.premultiply 255 150 70 golden)
let moon = M6Presentation.moonlightVeilAlpha tick
if moon > 0 then
let mr, mg, mb = M6Presentation.moonlightRgb
spriteBatch.Draw(pixel, Rectangle(0, 0, targetWidth, targetHeight), VillageArt.premultiply mr mg mb moon)
| None -> ()
spriteBatch.End()
this.GraphicsDevice.SetRenderTarget null
let data = Array.zeroCreate<Color> (targetWidth * targetHeight)
target.GetData<Color>(data)
let texture = new Texture2D(this.GraphicsDevice, targetWidth, targetHeight)
texture.SetData(data)
(drawn, texture)
/// P20 证据:整图放大渲染(每瓦片 6px)+ 1:1 视口裁剪帧各存一张,打印计数后退出。
member private this.DrawMapGenShot () =
System.IO.Directory.CreateDirectory recordDirectory |> ignore
let viewport = this.GraphicsDevice.Viewport
let mapCell = 6
let mapTint = if mapGenNight then (M6Presentation.profileAtTick mapGenNightTick).WorldTint else Color.White
let mapVeil = if mapGenNight then Some mapGenNightTick else None
let fittedDrawn, fittedTexture = this.RenderMapGen (mapGenResult.Width * mapCell) (mapGenResult.Height * mapCell) 0 0 true mapTint mapVeil
use _fitted = fittedTexture
use stream = System.IO.File.Create(sprintf "%s/p20b-map-%dx%d-seed%d.png" recordDirectory mapGenResult.Width mapGenResult.Height (int mapGenResult.Seed))
fittedTexture.SaveAsPng(stream, fittedTexture.Width, fittedTexture.Height)
printfn "mapgen-fitted drawn=%d png=%dx%d night=%b" fittedDrawn fittedTexture.Width fittedTexture.Height mapGenNight
// P28:整图按指定像素目标再渲染一次(真实帧)。1024x768 -> 512x384 图恰为 2px/tile,
// 用于证明两民居变体在「整图 1 tile≈2px」缩放下肉眼可分。
if mapGenFitWidth > 0 && mapGenFitHeight > 0 then
let fitDrawn, fitTexture = this.RenderMapGen mapGenFitWidth mapGenFitHeight 0 0 true mapTint mapVeil
use _fit = fitTexture
use fitStream = System.IO.File.Create(sprintf "%s/p28-fit-%dx%d-seed%d.png" recordDirectory mapGenFitWidth mapGenFitHeight (int mapGenResult.Seed))
fitTexture.SaveAsPng(fitStream, mapGenFitWidth, mapGenFitHeight)
printfn "mapgen-fit drawn=%d png=%dx%d night=%b" fitDrawn mapGenFitWidth mapGenFitHeight mapGenNight
let clampRange maximum value = max 0 (min (max 0 maximum) value)
let camX = clampRange (mapGenResult.Width * Sim.tilePixels - viewport.Width) ((mapGenResult.Width * Sim.tilePixels - viewport.Width) / 2)
let camY = clampRange (mapGenResult.Height * Sim.tilePixels - viewport.Height) ((mapGenResult.Height * Sim.tilePixels - viewport.Height) / 2)
let culledDrawn, culledTexture = this.RenderMapGen viewport.Width viewport.Height camX camY false Color.White None
use _culled = culledTexture
use culledStream = System.IO.File.Create(sprintf "%s/p20b-culled-%dx%d-seed%d.png" recordDirectory mapGenResult.Width mapGenResult.Height (int mapGenResult.Seed))
culledTexture.SaveAsPng(culledStream, viewport.Width, viewport.Height)
let total = mapGenResult.Width * mapGenResult.Height
let visible = MapGen.visibleTileCount mapGenResult.Width mapGenResult.Height camX camY viewport.Width viewport.Height
printfn "mapgen-cull drawn=%d visible=%d total=%d culled=%.1f%%" culledDrawn visible total (100.0 * (1.0 - float culledDrawn / float total))
match mapGenResult.Bridges with
| (bx, by) :: _ ->
let detailCamX = clampRange (mapGenResult.Width * Sim.tilePixels - viewport.Width) (bx * Sim.tilePixels - viewport.Width / 2)
let detailCamY = clampRange (mapGenResult.Height * Sim.tilePixels - viewport.Height) (by * Sim.tilePixels - viewport.Height / 2)
let detailDrawn, detailTexture = this.RenderMapGen viewport.Width viewport.Height detailCamX detailCamY false Color.White None
use _detail = detailTexture
use detailStream = System.IO.File.Create(sprintf "%s/p20b-detail-%dx%d-seed%d.png" recordDirectory mapGenResult.Width mapGenResult.Height (int mapGenResult.Seed))
detailTexture.SaveAsPng(detailStream, detailTexture.Width, detailTexture.Height)
printfn "mapgen-detail drawn=%d bridge=(%d,%d) camera=(%d,%d)" detailDrawn bx by detailCamX detailCamY
| [] -> ()
let smallWatch = System.Diagnostics.Stopwatch.StartNew()
let smallMap = MapGen.generateWithSize 64 48 (uint64 4242)
smallWatch.Stop()
printfn "mapgen-gen-legacy size=%dx%d gen_ms=%.2f tiles=%d reachable_ok=%b" smallMap.Width smallMap.Height smallWatch.Elapsed.TotalMilliseconds smallMap.Tiles.Length smallMap.ReachabilityOk
let frameWatch = System.Diagnostics.Stopwatch.StartNew()
use frameTarget = new RenderTarget2D(this.GraphicsDevice, viewport.Width, viewport.Height)
this.GraphicsDevice.SetRenderTarget frameTarget
for _ in 1 .. 30 do
spriteBatch.Begin()
VillageArt.drawMapViewport spriteBatch artTextures pixel (Vector2(float32 camX, float32 camY)) viewport.Width viewport.Height mapGenResult 0L Color.White 0.0f |> ignore
spriteBatch.End()
this.GraphicsDevice.SetRenderTarget null
frameWatch.Stop()
let perFrameMs = frameWatch.Elapsed.TotalMilliseconds / 30.0
printfn "mapgen-frame avg_ms=%.2f implied_fps=%.1f iterations=30" perFrameMs (1000.0 / perFrameMs)
printfn "mapgen-shot=done"
this.Exit()
/// P30 证据:把地图任意 tile 矩形以 cell px/tile 真实离屏渲染,含 tint 与可选 veil/夜光。
member private this.RenderMapRegion (tileX0: int) (tileY0: int) (tilesW: int) (tilesH: int) (cell: int) (tint: Color) (veilTick: int64 option) : int * Texture2D =
let targetWidth = max 1 (tilesW * cell)
let targetHeight = max 1 (tilesH * cell)
use target = new RenderTarget2D(this.GraphicsDevice, targetWidth, targetHeight)
this.GraphicsDevice.SetRenderTarget target
this.GraphicsDevice.Clear(Color(18, 26, 20))
spriteBatch.Begin()
let glowScale =
match veilTick with
| Some tick -> (M6Presentation.profileAtTick tick).LanternGlow
| None -> 0.0f
let drawn =
VillageArt.drawMapRegion spriteBatch artTextures pixel tileX0 tileY0 tilesW tilesH cell mapGenResult tint glowScale
match veilTick with
| Some tick ->
let golden = M6Presentation.goldenVeilAlpha tick
if golden > 0 then
spriteBatch.Draw(pixel, Rectangle(0, 0, targetWidth, targetHeight), VillageArt.premultiply 255 150 70 golden)
let moon = M6Presentation.moonlightVeilAlpha tick
if moon > 0 then
let mr, mg, mb = M6Presentation.moonlightRgb
spriteBatch.Draw(pixel, Rectangle(0, 0, targetWidth, targetHeight), VillageArt.premultiply mr mg mb moon)
| None -> ()
spriteBatch.End()
this.GraphicsDevice.SetRenderTarget null
let data = Array.zeroCreate<Color> (targetWidth * targetHeight)
target.GetData<Color>(data)
let texture = new Texture2D(this.GraphicsDevice, targetWidth, targetHeight)
texture.SetData(data)
(drawn, texture)
/// P30 田块局部取景:以「窗口内田块最密」的散落农舍为中心(含田块/树丛/院落),
/// 优先完整落入画面的农舍;否则退化为首个田块。确定性纯函数。
member private this.P30FieldRegion () : int * int =
let w = mapGenResult.Width
let h = mapGenResult.Height
let regionW = 128
let regionH = 64
let clampX x = max 0 (min (max 0 (w - regionW)) x)
let clampY y = max 0 (min (max 0 (h - regionH)) y)
let isField code = code = int MapGen.GroundTile.PaddyField || code = int MapGen.GroundTile.VegetablePlot
let countFields (cx: int) (cy: int) =
let x0 = max 0 (cx - regionW / 2)
let x1 = min (w - 1) (cx + regionW / 2)
let y0 = max 0 (cy - regionH / 2)
let y1 = min (h - 1) (cy + regionH / 2)
let mutable n = 0
for y in y0 .. y1 do
for x in x0 .. x1 do
if isField mapGenResult.Tiles.[y * w + x] then n <- n + 1
n
let interior =
mapGenResult.Farmhouses
|> List.filter (fun b -> b.Top >= 16 && b.Top <= h - 80 && b.Left >= regionW / 2 && b.Left <= w - regionW / 2)
let candidates = if interior.IsEmpty then mapGenResult.Farmhouses else interior
match candidates |> List.sortBy (fun b -> (-(countFields (b.Left + b.Width / 2) (b.Top + 1)), b.Top, b.Left)) |> List.tryHead with
| Some b -> (clampX (b.Left + b.Width / 2 - regionW / 2), clampY (b.Top - regionH / 2))
| None ->
let mutable found = None
let mutable y = 0
while found.IsNone && y < h do
let mutable x = 0
while found.IsNone && x < w do
let code = mapGenResult.Tiles.[y * w + x]
if isField code then found <- Some(x, y)
x <- x + 1
y <- y + 1
match found with
| Some (x, y) -> (clampX (x - regionW / 2), clampY (y - regionH / 2))
| None -> (clampX (w / 2 - regionW / 2), clampY (h / 2 - regionH / 2))
/// P30 路网弯曲局部取景:以主路中段某个弯折列为横向中心,纵向对准主路中心线。
member private this.P30RoadRegion () : int * int =
let w = mapGenResult.Width
let h = mapGenResult.Height
let regionW = 128
let regionH = 64
let clampX x = max 0 (min (max 0 (w - regionW)) x)
let clampY y = max 0 (min (max 0 (h - regionH)) y)
let center = mapGenResult.MainRoadCenter
let roadY = if w > 0 then center.[w / 2] else h / 2
let bendX =
[ for x in 1 .. w - 2 do
if abs (center.[x] - center.[x - 1]) > 0 then yield x ]
|> List.tryFind (fun x -> x > w / 4 && x < (3 * w) / 4)
|> Option.defaultValue (w / 2)
(clampX (bendX - regionW / 2), clampY (roadY - regionH / 2))
/// P30 证据出图:整图 3072x2304(6px/tile)day/night + 田块局部 512x256(4px/tile)
/// + 路网弯曲局部 512x256(4px/tile)。全部真实离屏渲染,拍完即退出。
member private this.DrawP30Shot () =
System.IO.Directory.CreateDirectory recordDirectory |> ignore
let save (name: string) (texture: Texture2D) =
use stream = System.IO.File.Create(sprintf "%s/%s.png" recordDirectory name)
texture.SaveAsPng(stream, texture.Width, texture.Height)
let nightTick = M6Presentation.resolveStartTick (Some 23.5) false
let nightTint = (M6Presentation.profileAtTick nightTick).WorldTint
let fullW = mapGenResult.Width * 6
let fullH = mapGenResult.Height * 6
let _, dayTexture = this.RenderMapGen fullW fullH 0 0 true Color.White None
use _day = dayTexture
save (sprintf "p30-map-%dx%d-seed%d-day" mapGenResult.Width mapGenResult.Height (int mapGenResult.Seed)) dayTexture
let _, nightTexture = this.RenderMapGen fullW fullH 0 0 true nightTint (Some nightTick)
use _night = nightTexture
save (sprintf "p30-map-%dx%d-seed%d-night" mapGenResult.Width mapGenResult.Height (int mapGenResult.Seed)) nightTexture
let fx, fy = this.P30FieldRegion ()
let _, fieldDay = this.RenderMapRegion fx fy 128 64 4 Color.White None
use _fieldDay = fieldDay
save "p30-field-cluster-4x-day" fieldDay
let _, fieldNight = this.RenderMapRegion fx fy 128 64 4 nightTint (Some nightTick)
use _fieldNight = fieldNight
save "p30-field-cluster-4x-night" fieldNight
let rx, ry = this.P30RoadRegion ()
let _, roadDay = this.RenderMapRegion rx ry 128 64 4 Color.White None
use _roadDay = roadDay
save "p30-roadserp-4x-day" roadDay
printfn "p30-shot=done map=%dx%d field_region=(%d,%d) road_region=(%d,%d) night=%b" mapGenResult.Width mapGenResult.Height fx fy rx ry mapGenNight
this.Exit()
override this.Draw(gameTime: GameTime) =
if mapGenShotMode then
if mapGenP30Shot then
this.DrawP30Shot()
else
this.DrawMapGenShot()
else
if splashActive then
this.DrawSplash()
elif menu.Page <> Playing then
this.DrawMenu()
elif relationView then
this.DrawRelationView()
this.DrawM5Overlay()
else
this.DrawWorldView()
if recordMode && sampleMode then
recordIndex <- recordIndex + 1
if recordIndex % recordEvery = 0 then
System.IO.Directory.CreateDirectory recordDirectory |> ignore
let name = sprintf "%s/%s%04d.png" recordDirectory recordName recordIndex
this.SaveBackBuffer(name)
if p72Log then
printfn "p72-frame %s tick=%d" name world.Tick
for npc in world.Npcs do
let spec = VillageArt.npcSpriteSpecAtTarget npc.Id npc.Pos npc.Mind.Target world.Tick
printfn " npc=%A pos=(%.1f,%.1f) frame=%A moving=%b" npc.Id npc.Pos.X npc.Pos.Y spec.Frame (npc.Mind.Target <> npc.Pos)
if menuShotMode then
this.CaptureMenuShot()
if p42ShotMode then
this.CaptureP42Shot()
if p74ShotMode then
this.CaptureP74Shot()
if storyShotMode && storyShotPrepared then
storyShotFrame <- storyShotFrame + 1L
if not storyShotSaved && storyShotFrame = 20L then
storyShotSaved <- true
System.IO.Directory.CreateDirectory recordDirectory |> ignore
this.SaveBackBuffer(
sprintf "%s/p31-story-%s-stage%d.png"
recordDirectory
(Occupation.saveToken storyShotKind)
storyShotStage)
printfn "story-shot=saved occupation=%s stage=%d" (Occupation.saveToken storyShotKind) storyShotStage
this.Exit()
if p36ShotMode && menu.Page = Playing && not relationView then
this.CaptureP36PromptShot()
if p39ShotMode && menu.Page = Playing then
this.CaptureP39Shot()
if p40ShotMode && menu.Page = Playing then
this.CaptureP40Shot()
if p43ShotMode && menu.Page = Playing then
this.CaptureP43Shot()
if p44ShotMode && menu.Page = Playing then
this.CaptureP44Shot()
if p61ShotMode && menu.Page = Playing then
this.CaptureP61Shot()
if p62ShotMode && menu.Page = Playing then
this.CaptureP62Shot()
if p64ShotMode && menu.Page = Playing then
this.CaptureP64Shot()
if p65ShotMode && menu.Page = Playing then
this.CaptureP65Shot()
if p67ShotMode && menu.Page = Playing then
this.CaptureP67Shot()
if p45ShotMode && menu.Page = Playing then
this.CaptureP45Shot()
if p46ShotMode then
this.CaptureP46Shot()
if p57ShotMode then
this.CaptureP57Shot()
if (p47ShotMode || p73ShotMode || p78ShotMode) && menu.Page = Playing then
this.CaptureP47Shot()
if p52ShotMode && menu.Page = Playing then
this.CaptureP52Shot()
if p53RecordMode && menu.Page = Playing then
this.CaptureP53Recording()
if p54ShotMode && menu.Page = Playing then
this.CaptureP54Shot()
if p55ShotMode && menu.Page = Playing then
this.CaptureP55Shot()
/// 启动画面:分层天色 + 屋脊/水面剪影 + 标题淡入上浮 + 跳过提示,全部为帧计数纯函数。
member private this.DrawSplash() =
let viewport = this.GraphicsDevice.Viewport
let width = viewport.Width
let height = viewport.Height
let layout = TitleScreen.layout width height
let reveal = LaunchScreen.revealProgress splashFrame
let veil = LaunchScreen.veilAlpha splashFrame
let alpha (value: int) = int (float32 value * reveal)
spriteBatch.Begin()
// 分层天色:沿用标题画面色带,绝不整屏纯色或大黑块。
let bandCount = List.length layout.SkyBands
let bandHeight = height / bandCount
List.iteri (fun index (band: TitleScreen.ColorRgb) ->
let y0 = index * bandHeight
let y1 = if index = bandCount - 1 then height else y0 + bandHeight
spriteBatch.Draw(pixel, Rectangle(0, y0, width, y1 - y0), Color(band.R, band.G, band.B))) layout.SkyBands
// ③ 屋脊上方的双层视差云影:纯水平位移(随帧缓慢漂移),低 alpha 预乘柔光,
// 只用椭圆行落成,绝不留大黑块/实心色块。
for layer in 0 .. MenuAmbience.cloudLayerCount - 1 do
let cloudColor = VillageArt.premultiply 214 228 236 (MenuAmbience.cloudLayerAlpha layer)
for (cx, cy, rx, ry) in MenuAmbience.cloudPuffs layer splashFrame width do
for (runX, runY, runW) in VillageArt.ellipseRuns cx cy rx ry do
spriteBatch.Draw(pixel, Rectangle(runX, runY, runW, 1), cloudColor)
// 屋脊剪影随暗幕退场而上浮就位。
let drop = int (28.0f * veil)
for x in 0 .. Sim.tilePixels .. width - 1 do
spriteBatch.Draw(artTextures.TileAtlas, Rectangle(x, layout.RidgeY + drop, Sim.tilePixels, Sim.tilePixels), VillageArt.atlasTileRectangle (fst TitleScreen.roofSlots), Color.White)
spriteBatch.Draw(artTextures.TileAtlas, Rectangle(x, layout.EaveY + drop, Sim.tilePixels, Sim.tilePixels), VillageArt.atlasTileRectangle (snd TitleScreen.roofSlots), Color.White)
// 水面色带反射天色,随显现度提高而淡出;P42 叠加逐格涟漪(相位随帧/列/行)。
let waterAlpha = int (255.0f * (1.0f - reveal))
let waterColor = Color(150, 170, 178, waterAlpha)
for (rowIndex, row) in List.indexed layout.WaterRows do
for x in 0 .. Sim.tilePixels .. width - 1 do
spriteBatch.Draw(artTextures.TileAtlas, Rectangle(x, row, Sim.tilePixels, Sim.tilePixels), VillageArt.atlasTileRectangle TitleScreen.waterSlot, waterColor)
for x in 0 .. Sim.tilePixels .. width - 1 do
let column = x / Sim.tilePixels
let brightness = MenuAmbience.waterColumnBrightness splashFrame column rowIndex
let crestColor =
Color(
min 255 (int (150.0f * brightness)),
min 255 (int (170.0f * brightness)),
min 255 (int (178.0f * brightness)),
waterAlpha)
let lift = MenuAmbience.waterColumnLift splashFrame column rowIndex
spriteBatch.Draw(artTextures.TileAtlas, Rectangle(x, row + lift, Sim.tilePixels, Sim.tilePixels), VillageArt.atlasTileRectangle TitleScreen.waterSlot, crestColor)
if MenuAmbience.waterColumnCrest splashFrame column rowIndex then
spriteBatch.Draw(pixel, Rectangle(x, row + lift, Sim.tilePixels, 3), Color(225, 240, 245, waterAlpha))
// P57 第二层高光波光:同列相位错开、更亮更窄的细高光条(昼/夜由 light 衰减)。
if not p57HighlightDisabled && MenuAmbience.highlightVisible splashFrame column rowIndex then
let hr, hg, hb = MenuAmbience.highlightRgb
let ha =
MenuAmbience.highlightAlpha MenuAmbience.highlightDayLight splashFrame column rowIndex
* waterAlpha / 255
let barX = x + (Sim.tilePixels - MenuAmbience.highlightBarWidth) / 2
spriteBatch.Draw(
pixel,
Rectangle(barX, row + lift + MenuAmbience.highlightRowDelta, MenuAmbience.highlightBarWidth, MenuAmbience.highlightThickness),
Color(hr, hg, hb, ha))
// P42 屋檐灯笼呼吸光晕:复用 P14 预乘 alpha 径向路径,随帧与灯序号呼吸。
let lanternColor, _ = TitleScreen.lanternColors
for (lanternIndex, (lx, ly)) in List.indexed layout.Lanterns do
let breath = MenuAmbience.lanternBreathAlpha splashFrame lanternIndex
for (rect, color) in VillageArt.lanternGlowLayers lx ly 28 6 252 216 148 breath do
spriteBatch.Draw(pixel, rect, color)
spriteBatch.Draw(pixel, Rectangle(lx - 3, ly - 5, 8, 10), Color(lanternColor.R, lanternColor.G, lanternColor.B))
spriteBatch.Draw(pixel, Rectangle(lx - 1, ly - 7, 4, 2), Color(90, 60, 40))
spriteBatch.Draw(pixel, Rectangle(lx - 2, ly + 5, 6, 2), Color(90, 60, 40))
// P74 水墨式渐显:柔和墨滴从画布各处晕开、随帧消散,露出后方天色/水面/屋脊。
// 单滴 alpha < 255 且用预乘椭圆行落成,绝无实心黑块;绘在标题之下、场景之上。
let inkR, inkG, inkB = InkReveal.inkRgb
for dab in InkReveal.dabs splashFrame width height do
if dab.Alpha > 0 then
let inkColor = VillageArt.premultiply inkR inkG inkB dab.Alpha
for (runX, runY, runW) in VillageArt.ellipseRuns dab.X dab.Y dab.Rx dab.Ry do
spriteBatch.Draw(pixel, Rectangle(runX, runY, runW, 1), inkColor)
// 标题:淡入 + 上浮,先画深色投影再画亮面。
let titleRise = int (24.0f * (1.0f - reveal))
PixelText.draw spriteBatch pixel cjkAtlas (layout.TitleX + 4) (layout.TitleY + titleRise + 4) layout.TitleScale (Color(12, 20, 28, alpha 255)) LaunchScreen.title
PixelText.draw spriteBatch pixel cjkAtlas layout.TitleX (layout.TitleY + titleRise) layout.TitleScale (Color(235, 246, 232, alpha 255)) LaunchScreen.title
// 英文副标题保持同一 CJK/点阵字体路径。
let subtitleScale = 2
let subtitleWidth = FloatingPrompt.measureWidth LaunchScreen.subtitle subtitleScale
PixelText.draw spriteBatch pixel cjkAtlas ((width - subtitleWidth) / 2) (layout.TitleY + 78) subtitleScale (Color(180, 210, 214, alpha 255)) LaunchScreen.subtitle
// 跳过提示:轻微呼吸闪烁,落在底部独立窄条上(非整屏黑块)。
let blink = if (splashFrame / 20L) % 2L = 0L then 220 else 130
let hintScale = 2
let hintWidth = FloatingPrompt.measureWidth LaunchScreen.skipHint hintScale
let hintX = (width - hintWidth) / 2
let hintY = height - 56
spriteBatch.Draw(pixel, Rectangle(hintX - 10, hintY - 8, hintWidth + 20, 8 * hintScale + 16), Color(10, 16, 24, int (170.0f * (0.5f + 0.5f * reveal))))
spriteBatch.Draw(pixel, Rectangle(hintX - 10, hintY - 8, hintWidth + 20, 2), Color(92, 180, 190, alpha 220))
PixelText.draw spriteBatch pixel cjkAtlas hintX hintY hintScale (Color(220, 235, 225, alpha blink)) LaunchScreen.skipHint
spriteBatch.End()
member private this.DrawMenu() =
let viewport = this.GraphicsDevice.Viewport
let width = viewport.Width
let height = viewport.Height
let layout = TitleScreen.layout width height
let panelWidth = layout.PanelWidth
let panelX = layout.PanelX
let panelY = layout.PanelY
let contentRows =
match menu.Page with
| MainMenu -> MenuState.items menu |> List.length
| OccupationSelect -> MenuState.occupationOptions.Length
| Settings -> MenuState.settings.Length
| Controls -> MenuState.controlRows.Length
| LoadError -> 4
| Playing -> 0
let rowHeight = if menu.Page = Controls then 25 else layout.MenuLineHeight
let panelY =
if menu.Page = Controls then layout.ControlsPanelY else layout.PanelY
let panelHeight =
min (height - panelY - 16)
(max layout.PanelHeight (120 + contentRows * rowHeight + 48))
let innerX = layout.MenuX
let textScale = 2
let lineHeight = layout.MenuLineHeight
let selectedColor = Color(245, 222, 120)
let textColor = Color(210, 226, 220)
let mutedColor = Color(140, 170, 170)
let drawText (x: int) (y: int) (color: Color) (text: string) =
PixelText.draw spriteBatch pixel cjkAtlas x y textScale color text
let drawSelection (index: int) (label: string) (y: int) =
let selected = index = menu.Selected
let cursor, labelRect = TitleScreen.selectionRects layout index
if selected then
PixelText.draw spriteBatch pixel cjkAtlas cursor.X cursor.Y textScale selectedColor ">"
else
PixelText.draw spriteBatch pixel cjkAtlas cursor.X cursor.Y textScale mutedColor " "
PixelText.draw spriteBatch pixel cjkAtlas labelRect.X labelRect.Y textScale (if selected then selectedColor else textColor) label
spriteBatch.Begin()
// Layered dusk gradient: sky bands darken toward the horizon, never a flat block.
let bandCount = List.length layout.SkyBands
let bandHeight = height / bandCount
List.iteri (fun index (band: TitleScreen.ColorRgb) ->
let y0 = index * bandHeight
let y1 = if index = bandCount - 1 then height else y0 + bandHeight
spriteBatch.Draw(pixel, Rectangle(0, y0, width, y1 - y0), Color(band.R, band.G, band.B))) layout.SkyBands
// Deterministic 2s entrance: skyline settles from above as the progress unwinds.
let entrance = TitleScreen.entranceProgress menuEntranceFrame
let skylineDrop = int (36.0f * entrance)
List.iteri (fun column slot ->
let x = column * Sim.tilePixels
let source = VillageArt.atlasTileRectangle slot
if slot = fst TitleScreen.roofSlots then
spriteBatch.Draw(artTextures.TileAtlas, Rectangle(x, layout.RidgeY + skylineDrop, Sim.tilePixels, Sim.tilePixels), source, Color.White)
spriteBatch.Draw(artTextures.TileAtlas, Rectangle(x, layout.EaveY + skylineDrop, Sim.tilePixels, Sim.tilePixels), VillageArt.atlasTileRectangle (snd TitleScreen.roofSlots), Color.White))
layout.RoofTileSlots
// Water band drawn from the atlas water tile; P42 adds per-tile ripple.
let waterAlpha = int (255.0f * (1.0f - entrance))
let waterColor = Color(150, 170, 178, waterAlpha)
for (rowIndex, row) in List.indexed layout.WaterRows do
for x in 0 .. Sim.tilePixels .. width - 1 do
spriteBatch.Draw(artTextures.TileAtlas, Rectangle(x, row, Sim.tilePixels, Sim.tilePixels), VillageArt.atlasTileRectangle TitleScreen.waterSlot, waterColor)
for x in 0 .. Sim.tilePixels .. width - 1 do
let column = x / Sim.tilePixels
let brightness = MenuAmbience.waterColumnBrightness menuEntranceFrame column rowIndex
let crestColor =
Color(
min 255 (int (150.0f * brightness)),
min 255 (int (170.0f * brightness)),
min 255 (int (178.0f * brightness)),
waterAlpha)
let lift = MenuAmbience.waterColumnLift menuEntranceFrame column rowIndex
spriteBatch.Draw(artTextures.TileAtlas, Rectangle(x, row + lift, Sim.tilePixels, Sim.tilePixels), VillageArt.atlasTileRectangle TitleScreen.waterSlot, crestColor)
if MenuAmbience.waterColumnCrest menuEntranceFrame column rowIndex then
spriteBatch.Draw(pixel, Rectangle(x, row + lift, Sim.tilePixels, 3), Color(225, 240, 245, waterAlpha))
// P57 第二层高光波光(menu)。
if not p57HighlightDisabled && MenuAmbience.highlightVisible menuEntranceFrame column rowIndex then
let hr, hg, hb = MenuAmbience.highlightRgb
let ha =
MenuAmbience.highlightAlpha MenuAmbience.highlightDayLight menuEntranceFrame column rowIndex
* waterAlpha / 255
let barX = x + (Sim.tilePixels - MenuAmbience.highlightBarWidth) / 2
spriteBatch.Draw(
pixel,
Rectangle(barX, row + lift + MenuAmbience.highlightRowDelta, MenuAmbience.highlightBarWidth, MenuAmbience.highlightThickness),
Color(hr, hg, hb, ha))
// P42 bank lanterns breathe through the shared P14 premultiplied-alpha radial path.
let lanternColor, _ = TitleScreen.lanternColors
for (lanternIndex, (lx, ly)) in List.indexed layout.Lanterns do
let breath = MenuAmbience.lanternBreathAlpha menuEntranceFrame lanternIndex
for (rect, color) in VillageArt.lanternGlowLayers lx ly 28 6 252 216 148 breath do
spriteBatch.Draw(pixel, rect, color)
spriteBatch.Draw(pixel, Rectangle(lx - 3, ly - 5, 8, 10), Color(lanternColor.R, lanternColor.G, lanternColor.B))
spriteBatch.Draw(pixel, Rectangle(lx - 1, ly - 7, 4, 2), Color(90, 60, 40))
spriteBatch.Draw(pixel, Rectangle(lx - 2, ly + 5, 6, 2), Color(90, 60, 40))
// Title rises into place as the entrance progress unwinds.
let titleLift = int (24.0f * entrance)
PixelText.draw spriteBatch pixel cjkAtlas (layout.TitleX + 4) (layout.TitleY + titleLift + 4) layout.TitleScale (Color(12, 20, 28)) layout.TitleText
PixelText.draw spriteBatch pixel cjkAtlas layout.TitleX (layout.TitleY + titleLift) layout.TitleScale (Color(235, 246, 232)) layout.TitleText
// Menu panel floats over the lower half; translucent so the scene layers stay visible.
spriteBatch.Draw(pixel, Rectangle(panelX, panelY, panelWidth, panelHeight), Color(11, 19, 27, 200))
spriteBatch.Draw(pixel, Rectangle(panelX, panelY, panelWidth, 4), Color(92, 180, 190))
let contentY = panelY + 60
let headingY = panelY + 20
match menu.Page with
| MainMenu ->
drawText innerX headingY mutedColor (ChineseText.menuHeading MainMenuHeading)
MenuState.items menu
|> List.iteri (fun index item -> drawSelection index (MenuState.itemLabel item) (contentY + index * lineHeight))
drawText innerX (panelY + panelHeight - 40) mutedColor "UP DOWN 选择 ENTER 确认"
| OccupationSelect ->
drawText innerX headingY mutedColor "选择职业"
MenuState.occupationOptions
|> List.iteri (fun index occupation ->
drawSelection index (MenuState.occupationLabel occupation) (contentY + index * lineHeight))
// P-d:选中职业时提示其轻剧情线(仅最小展示,复用既有选择页机制)。
(match MenuState.selectedOccupation menu with
| Some kind ->
drawText
innerX
(contentY + MenuState.occupationOptions.Length * lineHeight)
mutedColor
(sprintf "剧情线:%s" (Occupation.Story.lineNameOf kind))
| None -> ())
drawText innerX (panelY + panelHeight - 40) mutedColor "UP DOWN 选择 ENTER 确认 ESC 返回"
| Settings ->
drawText innerX headingY mutedColor (ChineseText.menuHeading SettingsHeading)
MenuState.settings
|> List.iteri (fun index setting -> drawSelection index (MenuState.settingsLabel setting) (contentY + index * lineHeight))
drawText innerX (panelY + panelHeight - 72) mutedColor (sprintf "当前 %s" (M6Presentation.clockLabel menu.Settings))
drawText innerX (panelY + panelHeight - 40) mutedColor "ENTER 应用 ESC 返回"
| Controls ->
drawText innerX headingY mutedColor (ChineseText.menuHeading ControlsHeading)
MenuState.controlRows
|> List.iteri (fun index row ->
let keyRect, actionRect = TitleScreen.controlRowRects layout index
PixelText.draw spriteBatch pixel cjkAtlas keyRect.X keyRect.Y textScale textColor row.Keys
PixelText.draw spriteBatch pixel cjkAtlas actionRect.X actionRect.Y textScale textColor row.Action)
drawText innerX (panelY + panelHeight - 40) mutedColor "ESC 返回"
| LoadError ->
drawText innerX headingY (Color(240, 130, 120)) "读取失败"
let message = menu.Error |> Option.defaultValue "暂无存档"
let visible = if message.Length > 24 then message.Substring(0, 24) else message
drawText innerX contentY textColor visible
drawText innerX (contentY + lineHeight * 2) mutedColor "ENTER ESC 返回"
| Playing -> ()
spriteBatch.End()
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()
match m5View.HomeMode with
| Inside _ ->
VillageArt.drawInterior spriteBatch pixel artTextures viewport.Width viewport.Height renderPlan.Interior profile.WorldTint
let interiorAvatarSpec = VillageArt.avatarSpriteSpec avatarFacing avatarMoving world.Tick
VillageArt.drawInteriorCharacter spriteBatch artTextures viewport.Width viewport.Height world.Avatar.Pos interiorAvatarSpec profile.WorldTint
| Outside ->
VillageArt.drawWorld
spriteBatch
artTextures
pixel
camera
viewport.Width
viewport.Height
renderPlan
riverscapeMap
world.Tick
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 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
match riverscapeMap with
| Some _ ->
// P79:生成器世界的夜光改到 veil 之后的去叠层(`SceneDetailRender.drawNightHalos`),
// 每光源 ≤2 层、层间暗隙、半径 4→3 tile,不再在此铺一大团叠加光。
()
| None ->
for prop in renderPlan.Props do
match prop.Kind with
| VillageArt.RenderPropKind.RiverLantern ->
let position = VillageArt.worldTile renderPlan prop.Position
let centerX = tileX position.X + Sim.tilePixels / 2
let centerY = tileY position.Y + Sim.tilePixels / 2
for (rect, color) in VillageArt.lanternGlowLayers centerX centerY (3 * Sim.tilePixels) 8 255 214 150 peakAlpha do
spriteBatch.Draw(pixel, rect, color)
| _ -> ()
match riverscapeMap, lanternGlow > 0.3f with
| Some map, true ->
VillageArt.drawCc0BoatOverlay spriteBatch artTextures camera map worldTint
| _ -> ()
// P47 场景细节:河道倒影 + 岸边芦苇加密度 + 漂浮元素 + 近景楼层层错落 + P78 炊烟。
// 画在夜光/船之后,保证倒影不被灯笼呼吸光晕盖掉、仍可辨认。
match riverscapeMap with
| Some map ->
SceneDetailRender.draw
spriteBatch
artTextures
pixel
camera
viewport.Width
viewport.Height
map
world.Tick
lanternGlow
| None -> ()
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 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 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
// by its own low alpha it adds warm light without ever saturating to white; alpha
// is a pure tick function, so noon/midnight get none and dawn/dusk peak warm.
let veilAlpha = M6Presentation.goldenVeilAlpha world.Tick
if veilAlpha > 0 then
spriteBatch.Draw(pixel, Rectangle(0, 0, viewport.Width, viewport.Height), VillageArt.premultiply 255 150 70 veilAlpha)
// Cool moonlight wash on top of the night scene: a premultiplied blue veil whose
// alpha is a pure tick function (zero by day, suppressed through dusk/dawn warmth).
// Like the golden veil it adds light and can never saturate to white.
let moonAlpha = M6Presentation.moonlightVeilAlpha world.Tick
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)
// P78/P79:夜帧加成层(水面逐格微光斑 + 桥头灯柱窄光晕 + 去叠灯群光晕 + 炊烟增强)。
// 画在全部 veil 之后,故不被夜色乘暗、暗部层次仍可读;白天 lanternGlow=0,本层为空、白天帧零回归。
match riverscapeMap with
| Some map when lanternGlow > 0.0f ->
SceneDetailRender.drawNight spriteBatch artTextures pixel camera map world.Tick lanternGlow
| _ -> ()
spriteBatch.End()
// Contextual floating prompt over the unique target; same CJK atlas font path as the HUD.
if m5View.Panel = M5Panel.WorldPanel && menu.Page = Playing then
match m5View.Prompt, m5View.PromptTargetPos with
| Some text, Some targetPos ->
let scale = 2
let layout = FloatingPrompt.layoutWrapped viewport.Width viewport.Height targetPos.X targetPos.Y camera.X camera.Y scale text
let promptPalette = HudLayout.palette (M6Presentation.profileAtTick world.Tick).Mode
spriteBatch.Begin()
// P77:与顶/底条同语言的药丸——半透明底 + 1px 描边 + 发丝高光,非大黑块。
spriteBatch.Draw(pixel, Rectangle(layout.X - 6, layout.Y - 5, layout.Width + 12, layout.Height + 8), promptPalette.SegmentBackdrop)
spriteBatch.Draw(pixel, Rectangle(layout.X - 6, layout.Y - 5, layout.Width + 12, 1), promptPalette.Outline)
spriteBatch.Draw(pixel, Rectangle(layout.X - 6, layout.Y + 3, layout.Width + 12, 1), promptPalette.Accent)
spriteBatch.Draw(pixel, Rectangle(layout.X - 6, layout.Y - 5, 1, layout.Height + 8), promptPalette.Outline)
spriteBatch.Draw(pixel, Rectangle(layout.X + layout.Width + 5, layout.Y - 5, 1, layout.Height + 8), promptPalette.Outline)
layout.Lines
|> List.iteri (fun index line ->
let lineY = layout.Y + index * (8 * scale + 4)
for (dx, dy) in HudLayout.textOutlineOffsets do
PixelText.draw spriteBatch pixel cjkAtlas (layout.X + dx) (lineY + dy) scale promptPalette.Outline line
PixelText.draw spriteBatch pixel cjkAtlas layout.X lineY scale promptPalette.Value line)
spriteBatch.End()
| _ -> ()
this.DrawM5Overlay()
/// P44:按当前面板同步对话弹层模型;内容不变时保留翻页状态,离开 DialoguePanel 即关闭。
member private this.SyncDialogOverlay () =
if m5View.Panel = DialoguePanel then
let lines = M5Interaction.panelLines world m5View
let key = String.concat "\n" lines
match dialogOverlay with
| Some _ when dialogOverlayKey = key -> ()
| _ ->
dialogOverlayKey <- key
let title = match lines with t :: _ -> t | [] -> "对话"
let body = match lines with _ :: rest -> rest | [] -> []
dialogOverlay <- Some(DialogOverlay.create title body (this.GraphicsDevice.Viewport.Width) true)
else
dialogOverlay <- None
dialogOverlayKey <- ""
/// P44:绘制完整背景框 + 原点点阵头像 + 自动换行文字 + 分页标记。
member private this.DrawDialogOverlay (model: DialogOverlay.Model) =
let viewport = this.GraphicsDevice.Viewport
let profile = M6Presentation.profileAtTick world.Tick
let palette = HudLayout.palette profile.Mode
let layout = DialogOverlay.rect viewport.Width viewport.Height model
let current = DialogOverlay.view model
let lx = layout.X
let ly = layout.Y
spriteBatch.Begin()
// P76:对话面板改与顶部/底部条同语言——半透明底 + 1px 描边 + 发丝强调线,避免大黑块。
spriteBatch.Draw(pixel, Rectangle(lx, ly, layout.Width, layout.Height / 2), Color(46, 60, 70, 200))
spriteBatch.Draw(
pixel,
Rectangle(lx, ly + layout.Height / 2, layout.Width, layout.Height - layout.Height / 2),
Color(30, 42, 52, 210))
spriteBatch.Draw(pixel, Rectangle(lx, ly, layout.Width, 1), palette.Accent)
spriteBatch.Draw(pixel, Rectangle(lx, ly + layout.Height - 1, layout.Width, 1), palette.Outline)
spriteBatch.Draw(pixel, Rectangle(lx, ly, 1, layout.Height), palette.Outline)
spriteBatch.Draw(pixel, Rectangle(lx + layout.Width - 1, ly, 1, layout.Height), palette.Outline)
// 头像:原创 8x16 点阵 @ scale 4 = 32x64,加内框。
if model.ShowAvatar then
let avatar = DialogOverlay.avatarRect layout
spriteBatch.Draw(pixel, Rectangle(avatar.X - 4, avatar.Y - 4, avatar.Width + 8, avatar.Height + 8), palette.SegmentBackdrop)
spriteBatch.Draw(pixel, Rectangle(avatar.X - 4, avatar.Y - 4, avatar.Width + 8, 2), palette.Accent)
spriteBatch.Draw(pixel, Rectangle(avatar.X - 4, avatar.Y + avatar.Height + 2, avatar.Width + 8, 2), palette.Outline)
this.DrawPattern
DialogOverlay.avatarPattern
avatar.X
avatar.Y
DialogOverlay.avatarScale
palette.Value
let textX = DialogOverlay.textOriginX layout model.ShowAvatar
let titleY = ly + DialogOverlay.paddingY
for (dx, dy) in HudLayout.textOutlineOffsets do
PixelText.draw spriteBatch pixel cjkAtlas (textX + dx) (titleY + dy) DialogOverlay.textScale palette.Outline model.Title
PixelText.draw spriteBatch pixel cjkAtlas textX titleY DialogOverlay.textScale palette.Accent model.Title
let bodyY = DialogOverlay.textOriginY layout
current.Lines
|> List.iteri (fun index line ->
let y = bodyY + index * DialogOverlay.lineHeight
for (dx, dy) in HudLayout.textOutlineOffsets do
PixelText.draw spriteBatch pixel cjkAtlas (textX + dx) (y + dy) DialogOverlay.textScale palette.Outline line
PixelText.draw spriteBatch pixel cjkAtlas textX y DialogOverlay.textScale palette.Value line)
// 分页标记:页码 + 翻页/关闭提示;有下一页时显示箭头。
let marker =
sprintf "第 %d/%d 页 空格 翻页 ESC 关闭" current.PageNumber current.PageCount
let markerWidth = FloatingPrompt.measureWidth marker DialogOverlay.textScale
let markerX = lx + layout.Width - DialogOverlay.paddingX - markerWidth
let markerY = ly + layout.Height - DialogOverlay.pageMarkerHeight
PixelText.draw spriteBatch pixel cjkAtlas markerX markerY DialogOverlay.textScale palette.Label marker
if current.HasNext then
PixelText.draw spriteBatch pixel cjkAtlas (markerX - 18) markerY DialogOverlay.textScale palette.Accent ">"
spriteBatch.End()
member private this.DrawM5Overlay() =
this.DrawHudBar()
this.DrawCalendarCard()
this.DrawHotbar()
match dialogOverlay with
| Some model -> this.DrawDialogOverlay model
| None ->
if m5View.Panel = WorldPanel then
this.DrawTransientStatus()
else
this.DrawPanel()
/// 顶部窄信息条:时段/时间/倍速/体力/钱币,半透明渐变 + 强调线,绝非大黑块。
member private this.DrawHudBar() =
let profile = M6Presentation.profileAtTick world.Tick
let palette = HudLayout.palette profile.Mode
let placed = HudLayout.layout (HudLayout.segments world simulationControl)
let barHeight = HudLayout.barHeight
let textY = (barHeight - 8 * HudLayout.textScale) / 2
spriteBatch.Begin()
// P75:去掉整宽深色渐变带(palette 的 BarTop/BarBottom alpha=0),信息只靠各段的
// 半透明药丸承载——紧凑的图标+数值并排、留白充足,HUD 区域黑块面积大幅下降。
// 图标用 pixel 贴图按 7x7 点阵绘制(无外部素材),先描边后填充,保证昼夜可读。
let drawIcon (iconX: int) (iconY: int) (color: Color) (icon: HudLayout.HudIcon) =
HudLayout.iconRows icon
|> List.iteri (fun row bits ->
bits
|> Seq.iteri (fun column bit ->
if bit = '1' then
spriteBatch.Draw(
pixel,
Rectangle(
iconX + column * HudLayout.iconScale,
iconY + row * HudLayout.iconScale,
HudLayout.iconScale,
HudLayout.iconScale),
color)))
let iconY = (barHeight - HudLayout.iconHeight) / 2
for (x, width, segment) in placed do
spriteBatch.Draw(pixel, HudLayout.segmentBackdrop x width, palette.SegmentBackdrop)
spriteBatch.Draw(pixel, HudLayout.pillHairline x width, palette.Accent)
let textX = HudLayout.textOrigin x
let labelAdvanced = FloatingPrompt.measureWidth (segment.Label + " ") HudLayout.textScale
let isEnergy = segment.Icon = HudLayout.EnergyIcon
for (dx, dy) in HudLayout.textOutlineOffsets do
drawIcon (x + dx) (iconY + dy) palette.Outline segment.Icon
PixelText.draw spriteBatch pixel cjkAtlas (textX + dx) (textY + dy) HudLayout.textScale palette.Outline segment.Label
if not isEnergy then
PixelText.draw spriteBatch pixel cjkAtlas (textX + labelAdvanced + dx) (textY + dy) HudLayout.textScale palette.Outline segment.Value
drawIcon x iconY palette.Value segment.Icon
PixelText.draw spriteBatch pixel cjkAtlas textX textY HudLayout.textScale palette.Label segment.Label
if isEnergy then
// P43:体力改图形化条形,填充比例 = 真实 Needs.Energy / 100(0..100),非伪造。
let valueX = textX + labelAdvanced
let valueWidth = max 12 (FloatingPrompt.measureWidth segment.Value HudLayout.textScale)
let barY = (barHeight - HudLayout.energyBarHeight) / 2
let track = HudLayout.energyBarTrack valueX barY valueWidth
spriteBatch.Draw(pixel, track, palette.Outline)
spriteBatch.Draw(
pixel,
Rectangle(track.X + 1, track.Y + 1, max 1 (track.Width - 2), track.Height - 2),
palette.SegmentBackdrop)
let fill =
HudLayout.energyBarFillRect
(track.X + 1)
(track.Y + 1)
(max 1 (track.Width - 2))
world.Avatar.Mind.Needs.Energy
if fill.Width > 0 then
let barColor =
match profile.Mode with
| Day -> Color(212, 168, 96)
| Night -> Color(120, 168, 196)
spriteBatch.Draw(pixel, fill, barColor)
else
PixelText.draw spriteBatch pixel cjkAtlas (textX + labelAdvanced) textY HudLayout.textScale palette.Value segment.Value
spriteBatch.End()
/// 按 7x7 点阵行用像素贴图绘制图标(无外部素材);调用方须已 Begin。
member private this.DrawPattern (rows: string list) (iconX: int) (iconY: int) (scale: int) (color: Color) =
rows
|> List.iteri (fun row bits ->
bits
|> Seq.iteri (fun column bit ->
if bit = '1' then
spriteBatch.Draw(pixel, Rectangle(iconX + column * scale, iconY + row * scale, scale, scale), color)))
/// P43:右上角日历钟卡(季节/第 N 天/时段/时钟),半透明深色底 + 细边框,绝不越界。
member private this.DrawCalendarCard() =
let viewport = this.GraphicsDevice.Viewport
let profile = M6Presentation.profileAtTick world.Tick
let palette = HudLayout.palette profile.Mode
let reading = HudLayout.calendarReading world.Tick
let rect = HudLayout.calendarCardRect viewport.Width reading
let line1 = HudLayout.calendarLine1 reading
let line2 = HudLayout.calendarLine2 reading
spriteBatch.Begin()
// P77:与顶/底条同语言的药丸——半透明底 + 1px 描边 + 发丝高光,卡片微缩。
spriteBatch.Draw(pixel, rect, palette.SegmentBackdrop)
spriteBatch.Draw(pixel, Rectangle(rect.X, rect.Y, rect.Width, 1), palette.Accent)
spriteBatch.Draw(pixel, Rectangle(rect.X, rect.Bottom - 1, rect.Width, 1), palette.Outline)
spriteBatch.Draw(pixel, Rectangle(rect.X, rect.Y, 1, rect.Height), palette.Outline)
spriteBatch.Draw(pixel, Rectangle(rect.Right - 1, rect.Y, 1, rect.Height), palette.Outline)
let iconX = rect.X + HudLayout.calendarPadX
let iconY = rect.Y + (rect.Height - HudLayout.iconHeight) / 2
this.DrawPattern (HudLayout.iconRows HudLayout.calendarIcon) iconX iconY HudLayout.iconScale palette.Value
let textX = iconX + HudLayout.iconWidth + HudLayout.iconGap
let line1Y = rect.Y + HudLayout.calendarPadY
let line2Y = line1Y + 8 * HudLayout.textScale + HudLayout.calendarLineGap
for (dx, dy) in HudLayout.textOutlineOffsets do
PixelText.draw spriteBatch pixel cjkAtlas (textX + dx) (line1Y + dy) HudLayout.textScale palette.Outline line1
PixelText.draw spriteBatch pixel cjkAtlas (textX + dx) (line2Y + dy) HudLayout.textScale palette.Outline line2
PixelText.draw spriteBatch pixel cjkAtlas textX line1Y HudLayout.textScale palette.Value line1
PixelText.draw spriteBatch pixel cjkAtlas textX line2Y HudLayout.textScale palette.Accent line2
spriteBatch.End()
/// P43:底部居中 10 格 hotbar,原创点阵图标 + 选中高亮 + 键位数字;半透明底 + 细边框。
member private this.DrawHotbar() =
let viewport = this.GraphicsDevice.Viewport
let profile = M6Presentation.profileAtTick world.Tick
let palette = HudLayout.palette profile.Mode
let bar = HudLayout.hotbarBarRect viewport.Width viewport.Height
spriteBatch.Begin()
// P76:底部条改为与顶部条同语言的紧凑半透明药丸——细描边 + 1px 发丝线,不再铺大色块。
spriteBatch.Draw(pixel, bar, palette.SegmentBackdrop)
spriteBatch.Draw(pixel, Rectangle(bar.X, bar.Y, bar.Width, 1), palette.Outline)
spriteBatch.Draw(pixel, Rectangle(bar.X, bar.Bottom - 1, bar.Width, 1), palette.Outline)
spriteBatch.Draw(pixel, Rectangle(bar.X, bar.Y, 1, bar.Height), palette.Outline)
spriteBatch.Draw(pixel, Rectangle(bar.Right - 1, bar.Y, 1, bar.Height), palette.Outline)
spriteBatch.Draw(pixel, HudLayout.hotbarBarHairline bar, palette.Accent)
for index in 0 .. HudLayout.hotbarSlotCount - 1 do
let slot = HudLayout.hotbarSlotRect viewport.Width viewport.Height index
let selected = index = hotbarSelected
// 槽位药丸:半透明底(选中略亮),1px 描边 + 发丝线,不再是实心大色块。
let slotFill =
if selected then Color(48, 66, 74, 170) else palette.SegmentBackdrop
spriteBatch.Draw(pixel, slot, slotFill)
let border = if selected then palette.Accent else palette.Outline
spriteBatch.Draw(pixel, Rectangle(slot.X, slot.Y, slot.Width, 1), border)
spriteBatch.Draw(pixel, Rectangle(slot.X, slot.Bottom - 1, slot.Width, 1), border)
spriteBatch.Draw(pixel, Rectangle(slot.X, slot.Y, 1, slot.Height), border)
spriteBatch.Draw(pixel, Rectangle(slot.Right - 1, slot.Y, 1, slot.Height), border)
if selected then
spriteBatch.Draw(pixel, Rectangle(slot.X + 1, slot.Y + slot.Height - 2, max 1 (slot.Width - 2), 1), palette.Accent)
// 键位符号小片 + 图形并排(P76 信息层次)。
let keyChip = HudLayout.hotbarKeyChipRect slot
spriteBatch.Draw(pixel, keyChip, palette.Outline)
spriteBatch.Draw(pixel, Rectangle(keyChip.X + 1, keyChip.Y + 1, max 1 (keyChip.Width - 2), max 1 (keyChip.Height - 2)), Color(18, 28, 34, 220))
let label = if index = 9 then "0" else string (index + 1)
PixelText.draw spriteBatch pixel cjkAtlas (keyChip.X + 3) (keyChip.Y + 2) 1 (if selected then palette.Accent else palette.Label) label
let iconRect = HudLayout.hotbarIconRectBesideKey slot
let iconColor = if selected then palette.Accent else palette.Value
this.DrawPattern (HudLayout.hotbarIconRows index) iconRect.X iconRect.Y HudLayout.hotbarIconScale iconColor
// 图例:真实按键 + 动作名并排(取自 MenuState.controlRows,纯展示,不改任何绑定)。
let legend = HudLayout.actionLegend MenuState.controlRows
if not legend.IsEmpty then
let legendText = legend |> List.map (fun row -> sprintf "%s %s" row.Keys row.Action) |> String.concat " "
let scale = HudLayout.textScale
let textWidth = FloatingPrompt.measureWidth legendText scale
let legendHeight = 8 * scale + 12
let legendWidth = textWidth + 20
let legendX = (viewport.Width - legendWidth) / 2
let legendY = bar.Y - legendHeight - 6
spriteBatch.Draw(pixel, Rectangle(legendX, legendY, legendWidth, legendHeight), palette.SegmentBackdrop)
spriteBatch.Draw(pixel, Rectangle(legendX, legendY, legendWidth, 1), palette.Outline)
spriteBatch.Draw(pixel, Rectangle(legendX, legendY + legendHeight - 1, legendWidth, 1), palette.Outline)
spriteBatch.Draw(pixel, Rectangle(legendX, legendY, 1, legendHeight), palette.Outline)
spriteBatch.Draw(pixel, Rectangle(legendX + legendWidth - 1, legendY, 1, legendHeight), palette.Outline)
for (dx, dy) in HudLayout.textOutlineOffsets do
PixelText.draw spriteBatch pixel cjkAtlas (legendX + 10 + dx) (legendY + 6 + dy) scale palette.Outline legendText
PixelText.draw spriteBatch pixel cjkAtlas (legendX + 10) (legendY + 6) scale palette.Value legendText
spriteBatch.End()
/// 常驻情境状态:顶部条下方的小药丸,仅 WorldPanel 且瞬态未过期时出现。
member private this.DrawTransientStatus() =
let viewport = this.GraphicsDevice.Viewport
let statusView = { m5View with StatusTick = Some hudStatusAt }
match M5Interaction.transientStatusLine hudClock statusView with
| None -> ()
| Some line ->
let scale = 2
let width = FloatingPrompt.measureWidth line scale
let x = 16
let y = HudLayout.barHeight + HudLayout.accentHeight + 8
spriteBatch.Begin()
spriteBatch.Draw(pixel, Rectangle(x - 8, y - 6, width + 16, 8 * scale + 12), Color(16, 26, 32, 200))
spriteBatch.Draw(pixel, Rectangle(x - 8, y - 6, 2, 8 * scale + 12), Color(92, 180, 190))
PixelText.draw spriteBatch pixel cjkAtlas x y scale (Color(232, 242, 232)) line
spriteBatch.End()
/// 打开的面板(对话/需求/观察/年鉴/任务):底部左侧轻量渐变板,沿用既有 panelLines。
member private this.DrawPanel() =
let viewport = this.GraphicsDevice.Viewport
let textScale = 2
let lineHeight = 18
let lines = M5Interaction.panelLines world m5View
let widthGuess = min 380 (max 1 (viewport.Width - 32))
let innerWidthGuess = max 1 (widthGuess - 24)
// P76:按实测像素宽度折行(中文逐字),换行而非整行截断;不再 Substring 截断。
let wrapped = HudLayout.wrapLines innerWidthGuess textScale lines
let maxLines = max 1 ((viewport.Height - HudLayout.barHeight - 48) / lineHeight)
let visibleLines = wrapped |> List.truncate maxLines
// P77:面板几何由 HudLayout 统一给出,底边抬到 hotbar 顶上方,绝不遮挡快捷栏。
let rect = HudLayout.panelRect viewport.Width viewport.Height visibleLines.Length
let panelX = rect.X
let panelY = rect.Y
let panelWidth = rect.Width
let panelHeight = rect.Height
let innerX = panelX + HudLayout.panelPadX
spriteBatch.Begin()
// 半透明圆角感面板:细描边 + 1px 发丝线(与 P75/P76 同语言),非大色块/纯黑。
spriteBatch.Draw(pixel, Rectangle(panelX, panelY, panelWidth, panelHeight / 2), Color(38, 52, 62, 175))
spriteBatch.Draw(pixel, Rectangle(panelX, panelY + panelHeight / 2, panelWidth, panelHeight - panelHeight / 2), Color(26, 38, 48, 180))
spriteBatch.Draw(pixel, Rectangle(panelX, panelY, panelWidth, 1), Color(92, 180, 190))
spriteBatch.Draw(pixel, Rectangle(panelX, panelY, 1, panelHeight), Color(92, 180, 190, 180))
spriteBatch.Draw(pixel, Rectangle(panelX, panelY + panelHeight - 1, panelWidth, 1), Color(8, 14, 20, 200))
spriteBatch.Draw(pixel, Rectangle(panelX + panelWidth - 1, panelY, 1, panelHeight), Color(8, 14, 20, 200))
visibleLines
|> List.iteri (fun index line ->
let color = if index = 0 then Color(226, 238, 226) else Color(192, 208, 212)
for (dx, dy) in HudLayout.textOutlineOffsets do
PixelText.draw spriteBatch pixel cjkAtlas (innerX + dx) (panelY + 13 + index * lineHeight + dy) textScale (Color(6, 10, 14)) line
PixelText.draw spriteBatch pixel cjkAtlas innerX (panelY + 13 + index * lineHeight) textScale color line)
spriteBatch.End()
|