fix: 修复迁移后的基础UI显示问题

This commit is contained in:
cancerai committed 2026-10-25 16:03:05 +08:00
1 parent 18017f819a
commit a93e06f60c
68 files changed
+2293 -8404

No files matched your search

+8 -2
View File
@@ -59,7 +59,12 @@ class Entity implements EntityView, CamZoneLike {
double speed = 2.4;
int timer = 0;
String kind = 'ball';
String? doorId;
// 与 web 原版一致:doorId 既可来自 data.doors[].id(常为 String),
// 也可在无匹配门时回退到实体序号 idx(int)。JS 弱类型下二者都能用 === 比较;
// 移植到 Dart 后若声明为 String?,回退分支把 int 赋给 String? 会抛
// "type 'int' is not a subtype of type 'String?'"。故用 Object? 容纳两种类型,
// == 比较(world.dart)对 String/String、int/int 走值相等,语义与 web 一致。
Object? doorId;
int pair = 0;
dynamic to;
int cool = 0;
@@ -252,7 +257,8 @@ class Level implements LevelLike {
}
if (type == 'warp') {
final cfg = (idx < warpSrc.length ? warpSrc[idx] : {}) as Map? ?? {};
final door = (data['doors'] as List?)?.cast<Map>()
final doors = (data['doors'] as List?)?.cast<Map>() ?? const <Map>[];
final door = doors
.firstWhere((d) => d['tx'] == tx && d['ty'] == ty, orElse: () => <String, dynamic>{});
e.doorId = (door != null && door.isNotEmpty) ? door['id'] : idx;
e.pair = cfg['pair'] ?? (idx % 2 == 0 ? idx + 1 : idx - 1);