Improve pixel map unit silhouettes

This commit is contained in:
2026-06-19 16:01:01 +09:00
parent 806b375313
commit 19af1359d1
2 changed files with 246 additions and 51 deletions

View File

@@ -381,6 +381,15 @@ func _check_pixel_unit_helpers(failures: Array[String]) -> void:
var scene = BattleSceneScript.new()
for method_name in [
"_draw_pixel_unit_sprite",
"_pixel_unit_sprite_profile",
"_unit_idle_bob",
"_unit_idle_step",
"_draw_pixel_shield",
"_draw_pixel_spear",
"_draw_pixel_bow",
"_draw_pixel_banner",
"_draw_pixel_staff",
"_draw_pixel_heavy_blade",
"_draw_pixel_infantry",
"_draw_pixel_archer",
"_draw_pixel_cavalry",
@@ -389,4 +398,49 @@ func _check_pixel_unit_helpers(failures: Array[String]) -> void:
]:
if not scene.has_method(method_name):
failures.append("missing pixel-map unit helper: %s" % method_name)
_check_pixel_unit_profiles(scene, failures)
scene.free()
func _check_pixel_unit_profiles(scene, failures: Array[String]) -> void:
var profiles := {
"infantry": scene._pixel_unit_sprite_profile({"class_id": "infantry"}),
"ranged": scene._pixel_unit_sprite_profile({"class_id": "archer"}),
"cavalry": scene._pixel_unit_sprite_profile({"class_id": "cavalry"}),
"tactic": scene._pixel_unit_sprite_profile({"class_id": "strategist"}),
"heavy": scene._pixel_unit_sprite_profile({"class_id": "bandit"})
}
for family in profiles.keys():
var profile: Dictionary = profiles[family]
if str(profile.get("family", "")) != str(family):
failures.append("pixel unit profile should map %s class to %s family: %s" % [family, family, str(profile)])
if absf(float(profile.get("pixel", 0.0)) - 3.0) > 0.001:
failures.append("pixel unit profile should use a stable 3px grid for %s" % family)
if float(profile.get("min_x", -1.0)) < 0.0 or float(profile.get("max_x", 99.0)) > 16.0:
failures.append("pixel unit profile should stay inside tile width for %s: %s" % [family, str(profile)])
var bottom_px := 5.0 + 1.0 + float(profile.get("max_y", 99.0)) * float(profile.get("pixel", 3.0))
if bottom_px >= 56.0:
failures.append("pixel unit profile should stay above HP bar for %s: %.1f" % [family, bottom_px])
if float((profiles["cavalry"] as Dictionary).get("max_x", 0.0)) <= float((profiles["infantry"] as Dictionary).get("max_x", 0.0)):
failures.append("cavalry pixel profile should read wider than infantry")
if float((profiles["heavy"] as Dictionary).get("max_x", 0.0)) <= float((profiles["infantry"] as Dictionary).get("max_x", 0.0)):
failures.append("heavy pixel profile should read wider than infantry")
if float((profiles["tactic"] as Dictionary).get("max_y", 0.0)) <= float((profiles["infantry"] as Dictionary).get("max_y", 0.0)):
failures.append("tactic pixel profile should read taller or more robed than infantry")
var seen_weapons := {}
var seen_idles := {}
for family in profiles.keys():
var profile: Dictionary = profiles[family]
var weapon := str(profile.get("weapon", ""))
var idle := str(profile.get("idle", ""))
if weapon.is_empty() or seen_weapons.has(weapon):
failures.append("pixel unit profile should expose a distinct weapon silhouette for %s" % family)
seen_weapons[weapon] = true
if idle.is_empty() or seen_idles.has(idle):
failures.append("pixel unit profile should expose a distinct idle profile for %s" % family)
seen_idles[idle] = true
if str((profiles["ranged"] as Dictionary).get("weapon", "")) != "bow":
failures.append("ranged pixel profile should keep an explicit bow silhouette")
if str((profiles["infantry"] as Dictionary).get("weapon", "")) != "shield_spear":
failures.append("infantry pixel profile should keep shield and spear silhouette")