Skip to content

Commit a61e85d

Browse files
authored
Give Silverhart's Warrens their ramshackle hut exteriors (#331)
* Use source-appropriate ramshackle hut shells in Silverhart Warrens * Test source-positioned Silverhart Warrens hut presentation * Add Silverhart Warrens presentation regression to Godot CI
1 parent 4963234 commit a61e85d

3 files changed

Lines changed: 96 additions & 3 deletions

File tree

‎.github/workflows/godot-validation.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ jobs:
184184
run: bash tools/ci/run_godot_checked.sh godot --headless --path . --script res://tests/test_world_prop_feature_factory.gd
185185
- name: Run modular Hollowmere authored data tests
186186
run: bash tools/ci/run_godot_checked.sh godot --headless --path . --script res://tests/test_hollowmere_data_modules.gd
187+
- name: Run Silverhart Warrens presentation tests
188+
run: bash tools/ci/run_godot_checked.sh godot --headless --path . --script res://tests/test_silverhart_warrens_presentation.gd
187189
- name: Run generic authored settlement presentation tests
188190
run: bash tools/ci/run_godot_checked.sh godot --headless --path . --script res://tests/test_authored_settlement_presenter.gd
189191
- name: Run generic interior feature factory tests

‎data/world/campaign2_settlement_layouts.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,7 +2466,7 @@
24662466
{
24672467
"id": "silverhart_warrens_shack_1",
24682468
"kind": "house",
2469-
"archetype": "cottage",
2469+
"archetype": "hut",
24702470
"center": {
24712471
"q": 2,
24722472
"r": -433
@@ -2487,7 +2487,7 @@
24872487
{
24882488
"id": "silverhart_warrens_shack_2",
24892489
"kind": "house",
2490-
"archetype": "cottage",
2490+
"archetype": "hut",
24912491
"center": {
24922492
"q": 5,
24932493
"r": -427
@@ -2508,7 +2508,7 @@
25082508
{
25092509
"id": "silverhart_warrens_shack_3",
25102510
"kind": "house",
2511-
"archetype": "cottage",
2511+
"archetype": "hut",
25122512
"center": {
25132513
"q": 11,
25142514
"r": -433
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
extends SceneTree
2+
3+
const TERRAIN_DATA = preload("res://scripts/world/campaign2_world_terrain_data.gd")
4+
const FEATURE_COMPOSER = preload("res://scripts/world/world_settlement_feature_composer.gd")
5+
6+
var failures := 0
7+
8+
func _initialize() -> void:
9+
_test_warrens_source_layout()
10+
_test_warrens_streamed_hut_presentation()
11+
if failures > 0:
12+
push_error("%d Silverhart Warrens presentation test(s) failed." % failures)
13+
quit(1)
14+
return
15+
print("Silverhart Warrens presentation tests passed.")
16+
quit(0)
17+
18+
func _test_warrens_source_layout() -> void:
19+
var data := TERRAIN_DATA.new() as Campaign2WorldTerrainData
20+
var entry := _silverhart_entry(data)
21+
_check(not entry.is_empty(), "Silverhart must resolve from the canonical settlement registry")
22+
if entry.is_empty():
23+
return
24+
var layout: Dictionary = entry.get("definition", {}).get("layout", {})
25+
var buildings: Array = layout.get("buildings", [])
26+
var expected := {
27+
"silverhart_warrens_shack_1": {"centre": Vector2i(2, -433), "door": Vector2i(2, -431), "side": "south"},
28+
"silverhart_warrens_shack_2": {"centre": Vector2i(5, -427), "door": Vector2i(5, -429), "side": "north"},
29+
"silverhart_warrens_shack_3": {"centre": Vector2i(11, -433), "door": Vector2i(11, -431), "side": "south"}
30+
}
31+
for building_id in expected:
32+
var building := _find_building(buildings, building_id)
33+
var expected_entry: Dictionary = expected[building_id]
34+
_check(not building.is_empty(), "The source Warrens should retain %s" % building_id)
35+
if building.is_empty():
36+
continue
37+
_check(String(building.get("archetype", "")) == "hut", "%s should use the ramshackle hut exterior, not a prosperous cottage" % building_id)
38+
_check(_read_hex(building.get("center")) == expected_entry.get("centre", Vector2i.ZERO), "%s should retain its source position" % building_id)
39+
_check(_read_hex(building.get("door")) == expected_entry.get("door", Vector2i.ZERO), "%s should retain its source entrance" % building_id)
40+
_check(String(building.get("door_side", "")) == expected_entry.get("side", ""), "%s should retain its source-facing door" % building_id)
41+
42+
func _test_warrens_streamed_hut_presentation() -> void:
43+
var data := TERRAIN_DATA.new() as Campaign2WorldTerrainData
44+
var entry := _silverhart_entry(data)
45+
if entry.is_empty():
46+
return
47+
var parent := Node3D.new()
48+
root.add_child(parent)
49+
var north_chunk: Dictionary = FEATURE_COMPOSER.compose_chunk(
50+
parent, entry, Vector2i(0, -456), 24, HexGrid.DEFAULT_RADIUS_M
51+
)
52+
var south_chunk: Dictionary = FEATURE_COMPOSER.compose_chunk(
53+
parent, entry, Vector2i(0, -432), 24, HexGrid.DEFAULT_RADIUS_M
54+
)
55+
_check(bool(north_chunk.get("ok", false)), "The northern Warrens shack chunk should compose")
56+
_check(bool(south_chunk.get("ok", false)), "The southern Warrens shack chunk should compose")
57+
for building_id in [
58+
"silverhart_warrens_shack_1",
59+
"silverhart_warrens_shack_2",
60+
"silverhart_warrens_shack_3"
61+
]:
62+
var building := parent.get_node_or_null(building_id)
63+
_check(building != null, "%s should render in its owning streamed chunk" % building_id)
64+
if building != null:
65+
_check(String(building.get_meta("archetype", "")) == "hut", "%s should be built using the smaller hut shell" % building_id)
66+
_check(building.get_node_or_null("RoofLeftSlope") != null, "%s should retain its roof shell" % building_id)
67+
parent.free()
68+
69+
func _silverhart_entry(data: Campaign2WorldTerrainData) -> Dictionary:
70+
for entry in data.settlement_layouts:
71+
if String(entry.get("id", "")) == "silverhart":
72+
return entry
73+
return {}
74+
75+
func _find_building(buildings: Array, building_id: String) -> Dictionary:
76+
for building in buildings:
77+
if String(building.get("id", "")) == building_id:
78+
return building
79+
return {}
80+
81+
func _read_hex(value: Variant) -> Vector2i:
82+
if value is Vector2i:
83+
return value
84+
if value is Dictionary:
85+
return Vector2i(int(value.get("q", 0)), int(value.get("r", 0)))
86+
return Vector2i.ZERO
87+
88+
func _check(condition: bool, message: String) -> void:
89+
if not condition:
90+
failures += 1
91+
push_error(message)

0 commit comments

Comments
 (0)