feat(tools): Outcrop and BoulderField primitives with forced rock material
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
aae9bcd301
commit
6dd2e86f91
2 files changed
+135
-1
No files matched your search
@@ -8,7 +8,7 @@ const SiteTerrainData = preload("res://game/domain/sites/site_terrain_data.gd")
|
||||
|
||||
const ZONE1_TERRAIN_PATH := "res://content/sites/zone1_vigilant_terrain.res"
|
||||
|
||||
const TEST_COUNT := 26
|
||||
const TEST_COUNT := 36
|
||||
|
||||
var _failures: Array[String] = []
|
||||
|
||||
@@ -20,6 +20,8 @@ func _init() -> void:
|
||||
_test_zone1_artefact_is_stable()
|
||||
_test_canyon()
|
||||
_test_escarpment()
|
||||
_test_outcrop()
|
||||
_test_boulder_field()
|
||||
|
||||
if _failures.is_empty():
|
||||
print("Site baker unit tests: %d passed, 0 failed." % TEST_COUNT)
|
||||
@@ -144,6 +146,34 @@ func _test_escarpment() -> void:
|
||||
_expect(is_equal_approx(cliff.elevation_delta(0.0, 12.0), -15.0), "escarpment keeps falling at slope_beyond")
|
||||
|
||||
|
||||
func _test_outcrop() -> void:
|
||||
var mesa := SiteTerrainBaker.Outcrop.new(Vector2.ZERO, 10.0, 10.0, 6.0, 4.0, 0, 0.0, true)
|
||||
_expect(is_equal_approx(mesa.elevation_delta(0.0, 0.0), 6.0), "outcrop top is flat at height_m")
|
||||
_expect(is_equal_approx(mesa.elevation_delta(0.0, 8.0), 3.0), "outcrop flank is half way down in the middle of the wall")
|
||||
_expect(is_equal_approx(mesa.elevation_delta(0.0, 25.0), 0.0), "outcrop is zero past its outline")
|
||||
_expect(mesa.material_at(0.0, 0.0) == SonarMaterial.Value.ROCK, "rock_top makes the flat summit rock")
|
||||
_expect(mesa.material_at(0.0, 25.0) == SiteTerrainBaker.NO_MATERIAL, "outcrop leaves the surroundings to the slope rule")
|
||||
var sand_top := SiteTerrainBaker.Outcrop.new(Vector2.ZERO, 10.0, 10.0, 6.0, 4.0, 0, 0.0, false)
|
||||
_expect(sand_top.material_at(0.0, 0.0) == SiteTerrainBaker.NO_MATERIAL, "without rock_top the summit follows the slope rule")
|
||||
var pit := SiteTerrainBaker.Outcrop.new(Vector2.ZERO, 10.0, 20.0, -5.0, 3.0, 0, 0.0, false)
|
||||
_expect(is_equal_approx(pit.elevation_delta(0.0, 0.0), -5.0), "negative height digs a flat-bottomed pit")
|
||||
|
||||
|
||||
func _test_boulder_field() -> void:
|
||||
var first := SiteTerrainBaker.BoulderField.new(Vector2(50.0, -50.0), 30.0, 11, 20, 2.0, 4.0, 0.8)
|
||||
var second := SiteTerrainBaker.BoulderField.new(Vector2(50.0, -50.0), 30.0, 11, 20, 2.0, 4.0, 0.8)
|
||||
_expect(first.boulders() == second.boulders(), "same seed scatters the same boulders")
|
||||
var all_inside := true
|
||||
for boulder in first.boulders():
|
||||
all_inside = all_inside and Vector2(boulder.x, boulder.y).distance_to(Vector2(50.0, -50.0)) <= 30.0
|
||||
_expect(all_inside and first.boulders().size() == 20, "boulders stay inside the field disc")
|
||||
var top := first.boulders()[0]
|
||||
_expect(first.elevation_delta(top.x, top.y) >= top.z * 0.8 - 0.001, "a boulder centre is at least its own height")
|
||||
_expect(first.material_at(top.x, top.y) == SonarMaterial.Value.ROCK and first.material_at(200.0, 200.0) == SiteTerrainBaker.NO_MATERIAL, "boulders are rock, the sand around is not forced")
|
||||
var stacked := SiteTerrainBaker.BoulderField.new(Vector2.ZERO, 0.0, 3, 5, 2.0, 4.0, 1.0)
|
||||
_expect(stacked.elevation_delta(0.0, 0.0) <= 4.0 + 0.001, "overlapping boulders combine by maximum, not by sum")
|
||||
|
||||
|
||||
func _test_zone1_artefact_is_stable() -> void:
|
||||
var versioned := load(ZONE1_TERRAIN_PATH) as SiteTerrainData
|
||||
_expect(versioned != null, "versioned zone 1 terrain loads")
|
||||
|
||||
Reference in new issue
Block a user