62 lines
2.6 KiB
GDScript
62 lines
2.6 KiB
GDScript
# environment_test —— 真实 .msenv -> Godot 运行时断言。
|
|
# 验证参考端的 Filter / Character light / cloud fields are parsed and that
|
|
# an existing cloud texture is attached to the appropriate sky material.
|
|
extends SceneTree
|
|
|
|
var _fail := 0
|
|
|
|
func _ck(ok: bool, message: String) -> void:
|
|
if not ok:
|
|
_fail += 1
|
|
printerr("FAIL: " + message)
|
|
|
|
func _init() -> void:
|
|
if not ClassDB.class_exists("Metin2World"):
|
|
printerr("FAIL: Metin2World extension is not registered")
|
|
quit(1)
|
|
return
|
|
var world: Node = ClassDB.instantiate("Metin2World")
|
|
world.set("auto_load", false)
|
|
world.set("assets_root", AssetRoot.path())
|
|
world.set("map_path", "OutdoorA1/metin2_map_a1")
|
|
world.set("focus_tile", Vector2i(0, 0))
|
|
world.set("load_radius_tiles", 0)
|
|
world.set("splat_enabled", false)
|
|
world.set("water_enabled", false)
|
|
get_root().add_child(world)
|
|
_ck(bool(world.call("load_map")), "A1 map loads with .msenv")
|
|
var rep: Dictionary = world.call("get_load_report")
|
|
_ck(bool(rep.get("env_ok", false)), ".msenv env_ok")
|
|
var env_node := world.get_node_or_null("WorldEnv") as WorldEnvironment
|
|
_ck(env_node != null and env_node.environment != null, "WorldEnv has Environment")
|
|
var background_light := world.get_node_or_null("Sun") as DirectionalLight3D
|
|
var character_light := world.get_node_or_null("CharacterLight") as DirectionalLight3D
|
|
_ck(background_light != null and character_light != null, "background and character lights exist")
|
|
if background_light != null and character_light != null:
|
|
_ck(background_light.light_cull_mask == 1, "background light only sees layer 1")
|
|
_ck(character_light.light_cull_mask == 2, "character light only sees layer 2")
|
|
if env_node != null:
|
|
_ck(bool(env_node.get_meta("msenv_filter_enabled", false)) == false,
|
|
"A1 filter flag preserved")
|
|
_ck(is_equal_approx(float(env_node.get_meta("msenv_wind_strength", -1.0)), 0.2),
|
|
"reference wind strength default preserved")
|
|
_ck(is_equal_approx(float(env_node.get_meta("msenv_wind_random", -1.0)), 0.0),
|
|
"reference wind random default preserved")
|
|
_ck(env_node.has_meta("msenv_cloud_scale") and env_node.has_meta("msenv_cloud_speed"),
|
|
"cloud scale/speed metadata preserved")
|
|
var sky := env_node.environment.sky
|
|
_ck(sky != null, "WorldEnv has sky")
|
|
if sky != null:
|
|
var mat := sky.get_material() as ProceduralSkyMaterial
|
|
_ck(mat != null, "sky uses ProceduralSkyMaterial")
|
|
if mat != null:
|
|
_ck(mat.sky_cover != null, "real A1 cloud texture attached as sky cover")
|
|
world.queue_free()
|
|
await process_frame
|
|
if _fail == 0:
|
|
print("PASS: environment_test (.msenv parser + runtime sky cover)")
|
|
quit(0)
|
|
else:
|
|
printerr("%d check(s) failed" % _fail)
|
|
quit(1)
|