35 lines
1.1 KiB
GDScript
35 lines
1.1 KiB
GDScript
extends SceneTree
|
|
|
|
const BUILDING_DEFINITIONS = preload("res://BuildingDefinitions.gd")
|
|
|
|
|
|
func _initialize() -> void:
|
|
var scene: PackedScene = load("res://Building.tscn")
|
|
for definition in BUILDING_DEFINITIONS.all():
|
|
if definition.placement_mode != "space":
|
|
continue
|
|
var building: Node2D = scene.instantiate()
|
|
building.definition_id = definition.definition_id
|
|
building._ready()
|
|
if building.definition == null \
|
|
or building.definition.definition_id != definition.definition_id \
|
|
or building.visual == null:
|
|
_fail("%s did not compose its definition and visual (resolved=%s visual=%s)" % [
|
|
definition.definition_id,
|
|
"null" if building.definition == null else building.definition.definition_id,
|
|
building.visual,
|
|
])
|
|
return
|
|
var provider: Node = building.visual.get_node_or_null("ActionProvider")
|
|
if provider == null or not provider.actions.has("transfer"):
|
|
_fail("%s has no composed action provider" % definition.definition_id)
|
|
return
|
|
building.free()
|
|
|
|
print("TEST_BUILDING_COMPOSITION: PASS")
|
|
quit(0)
|
|
|
|
|
|
func _fail(message: String) -> void:
|
|
print("TEST_BUILDING_COMPOSITION: FAIL (%s)" % message)
|
|
quit(1)
|