Add new test file for phase 19 scenery with unique identifier

This commit is contained in:
2026-10-17 12:53:38 -04:00
parent 36032ebb1e
commit a0510e6405
74 changed files with 40948 additions and 149 deletions
+49 -2
View File
@@ -58,6 +58,14 @@ static func scan(dir_path: String = PROP_FILE.DEFAULT_DIR) -> Array[Dictionary]:
static func make_custom_entry(path: String) -> Dictionary:
return _make_custom_entry(path, false)
static func make_visual_entry(path: String) -> Dictionary:
return _make_custom_entry(path, true)
static func _make_custom_entry(path: String, allow_visual_only: bool) -> Dictionary:
var normalized_path: String = canonical_path(path)
if not is_custom_path(normalized_path): return {}
var raw: Dictionary = PROP_FILE.load(normalized_path)
@@ -70,13 +78,52 @@ static func make_custom_entry(path: String) -> Dictionary:
return {}
var shapes: Array[Dictionary] = parsed.get("shapes", [])
var hull: PackedVector2Array = PROP_VISUALS.collision_hull(shapes)
if shapes.is_empty() or hull.size() < 3:
if shapes.is_empty() or (not allow_visual_only and hull.size() < 3):
push_warning("PropLibrary: custom prop '%s' has no valid closed collision geometry." % normalized_path)
return {}
var name := String(parsed.get("prop_name", "")).strip_edges()
if name.is_empty(): name = normalized_path.get_file().get_basename()
var preset: int = int(parsed.get("material_preset", PROP_BLOCK.MaterialPreset.NONE))
return {"id": normalized_path, "path": normalized_path, "name": name, "material_preset": preset, "material_label": PROP_FILE.preset_to_string(preset).capitalize(), "is_custom": true, "payload": PROP_FILE.flatten_to_payload(shapes), "shapes": shapes, "collision_hull": hull, "anchors": parsed.get("anchors", {})}
var tags: Array[String] = parsed.get("tags", []) as Array[String]
if tags.is_empty():
tags = _legacy_tags_for_path(normalized_path)
return {"id": normalized_path, "path": normalized_path, "name": name, "material_preset": preset, "material_label": PROP_FILE.preset_to_string(preset).capitalize(), "is_custom": true, "payload": PROP_FILE.flatten_to_payload(shapes), "shapes": shapes, "collision_hull": hull, "anchors": parsed.get("anchors", {}), "tags": tags, "visual_only": hull.size() < 3}
static func scan_visual_entries(dir_path: String = PROP_FILE.DEFAULT_DIR) -> Array[Dictionary]:
var entries: Array[Dictionary] = []
if not DirAccess.dir_exists_absolute(dir_path):
return entries
var directory: DirAccess = DirAccess.open(dir_path)
if directory == null:
return entries
var paths: Array[String] = []
directory.list_dir_begin()
var file_name: String = directory.get_next()
while not file_name.is_empty():
if not directory.current_is_dir() and file_name.to_lower().ends_with(PROP_FILE.FILE_EXT):
paths.append(dir_path.path_join(file_name))
file_name = directory.get_next()
directory.list_dir_end()
paths.sort_custom(func(a: String, b: String) -> bool: return a.nocasecmp_to(b) < 0)
for path: String in paths:
var entry: Dictionary = make_visual_entry(path)
if not entry.is_empty():
entries.append(entry)
return entries
static func _legacy_tags_for_path(path: String) -> Array[String]:
var basename: String = path.get_file().get_basename().to_lower()
if basename.contains("tree") or basename.contains("plant"):
return ["nature", "objects"] if basename.contains("plant") else ["nature"]
if basename.contains("skyline") or basename.contains("storefront") or basename.contains("house"):
return ["buildings"]
if basename.contains("window") or basename.contains("fireplace") or basename.contains("clock"):
return ["walls", "objects"]
if basename.contains("bookshelf") or basename.contains("picture") or basename.contains("rug") or basename.contains("couch") or basename.contains("armchair") or basename.contains("table"):
return ["objects"]
return []
static func is_custom_path(path: String) -> bool: