@@ -30,6 +30,14 @@ LAYER_DEFAULT = 1073741824
|
||||
LAYER_UI_2D = 33554432 # 编辑器 2D 视图可见(对齐 SpriteSplash.prefab)
|
||||
|
||||
CELL = 100
|
||||
|
||||
# themes-database.json id → textures/ 子目录(与 ThemeDatabase.getThemeTextureFolder 一致)
|
||||
THEME_TEXTURE_FOLDER: dict[str, str] = {
|
||||
"redarmy": "redArmy",
|
||||
"redArmy": "redArmy",
|
||||
}
|
||||
|
||||
|
||||
def resolve_level_map_data_type() -> str:
|
||||
"""从 Creator 编译产物读取 LevelMapData 的 __type__(_RF.push 第二参数)。"""
|
||||
chunk = Path("temp/programming/packer-driver/targets/preview/chunks/bb/bbf6a3729c922dc4638933a67da37eeb23e90aee.js")
|
||||
@@ -74,19 +82,27 @@ def theme_from_cfg(cfg: dict, override: str) -> str:
|
||||
return "silu"
|
||||
|
||||
|
||||
def texture_folder_for_theme(theme: str) -> str:
|
||||
return THEME_TEXTURE_FOLDER.get(theme, theme)
|
||||
|
||||
|
||||
def ground_sprite_path(theme: str, tile_name: str) -> str:
|
||||
key = tile_name if tile_name in ("Baseblock", "JumpBlock") else "Baseblock"
|
||||
return f"textures/{theme}/{key}"
|
||||
# Ground 仅地砖
|
||||
key = "JumpBlock" if tile_name == "JumpBlock" else "Baseblock"
|
||||
return f"textures/{texture_folder_for_theme(theme)}/{key}"
|
||||
|
||||
|
||||
def border_sprite_path(theme: str, tile_val) -> str:
|
||||
# Border 仅墙砖/墙饰;地砖名回退 WallBlock
|
||||
if tile_val is True or tile_val is None:
|
||||
name = "WallBlock"
|
||||
elif isinstance(tile_val, str):
|
||||
name = tile_val
|
||||
name = tile_val.strip() or "WallBlock"
|
||||
if name in ("Baseblock", "JumpBlock"):
|
||||
name = "WallBlock"
|
||||
else:
|
||||
name = "WallBlock"
|
||||
return f"textures/{theme}/{name}"
|
||||
return f"textures/{texture_folder_for_theme(theme)}/{name}"
|
||||
|
||||
|
||||
def read_sprite_size(project: Path, texture_path: str) -> tuple[int, int]:
|
||||
@@ -390,12 +406,12 @@ def build_prefab(level_id: int, cfg: dict, project: Path, theme: str = "") -> li
|
||||
val = border[key]
|
||||
if val is True or val is None:
|
||||
bname = "WallBlock"
|
||||
elif isinstance(val, str):
|
||||
bname = val
|
||||
elif isinstance(val, str) and val.strip() and val.strip() not in ("Baseblock", "JumpBlock"):
|
||||
bname = val.strip()
|
||||
else:
|
||||
bname = "WallBlock"
|
||||
spr_wall = read_sprite_uuid(project, border_sprite_path(theme, border[key]))
|
||||
wall_path = border_sprite_path(theme, border[key])
|
||||
wall_path = border_sprite_path(theme, bname)
|
||||
spr_wall = read_sprite_uuid(project, wall_path)
|
||||
border_tiles.append(
|
||||
b.tile(f"b_{x}_{y}", -1, x, y, spr_wall, bname, read_sprite_size(project, wall_path))
|
||||
)
|
||||
@@ -404,7 +420,8 @@ def build_prefab(level_id: int, cfg: dict, project: Path, theme: str = "") -> li
|
||||
for key in sorted(ground.keys()):
|
||||
xs, ys = key.split(",")
|
||||
x, y = int(xs), int(ys)
|
||||
tile_name = ground[key]
|
||||
raw = ground[key]
|
||||
tile_name = "JumpBlock" if raw == "JumpBlock" else "Baseblock"
|
||||
gpath = ground_sprite_path(theme, tile_name)
|
||||
spr = read_sprite_uuid(project, gpath)
|
||||
ground_tiles.append(
|
||||
@@ -455,6 +472,7 @@ def main():
|
||||
ap.add_argument("--out-dir", required=True)
|
||||
ap.add_argument("--limit", type=int, default=0)
|
||||
ap.add_argument("--level-id", type=int, default=0, help="只烘焙指定关卡,0=全部")
|
||||
ap.add_argument("--min-level-id", type=int, default=0, help="只烘焙 levelID >= 此值的关卡")
|
||||
ap.add_argument("--max-level-id", type=int, default=0, help="只烘焙 levelID <= 此值的关卡")
|
||||
ap.add_argument("--rebuild-index", action="store_true", help="仅重建 tools/level-prefab-index.json(不烘焙 prefab)")
|
||||
ap.add_argument("--theme", default="", help="贴图主题 silu/sanxing/snow/…,空则从关卡 theme 字段读取")
|
||||
@@ -467,7 +485,7 @@ def main():
|
||||
|
||||
levels = db["levels"]
|
||||
ids = sorted(int(k) for k in levels.keys())
|
||||
if args.rebuild_index and args.level_id == 0 and args.max_level_id == 0 and args.limit == 0:
|
||||
if args.rebuild_index and args.level_id == 0 and args.min_level_id == 0 and args.max_level_id == 0 and args.limit == 0:
|
||||
index = rebuild_index_from_disk(out)
|
||||
index_path = write_prefab_index(project, out, index)
|
||||
uuid_path = write_prefab_uuid_index(project, out)
|
||||
@@ -476,8 +494,10 @@ def main():
|
||||
|
||||
if args.level_id > 0:
|
||||
ids = [args.level_id] if str(args.level_id) in levels else []
|
||||
elif args.max_level_id > 0:
|
||||
ids = [i for i in ids if i <= args.max_level_id]
|
||||
elif args.min_level_id > 0 or args.max_level_id > 0:
|
||||
lo = args.min_level_id if args.min_level_id > 0 else min(ids) if ids else 0
|
||||
hi = args.max_level_id if args.max_level_id > 0 else max(ids) if ids else 0
|
||||
ids = [i for i in ids if lo <= i <= hi]
|
||||
elif args.limit > 0:
|
||||
ids = ids[: args.limit]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user