Compose buildings from definitions and capabilities
This commit is contained in:
parent
1721edd123
commit
0504b24d8d
46 changed files with 1091 additions and 878 deletions
35
tests/test_building_composition.gd
Normal file
35
tests/test_building_composition.gd
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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)
|
||||
Loading…
Reference in a new issue