40 lines
2.1 KiB
GDScript
40 lines
2.1 KiB
GDScript
extends Node
|
|
const GENERATOR := preload("res://scripts/planets/surface_generator.gd")
|
|
const SCENERY := preload("res://scripts/planets/surface_scenery.gd")
|
|
|
|
func _ready() -> void:
|
|
var extra_ruins := 0
|
|
for index in 64:
|
|
var profile: Dictionary = preload("res://scripts/planets/planet_profiles.gd").generate(711,index,"Test")
|
|
var data: Dictionary = GENERATOR.generate(500+index,profile)
|
|
var counts := {"warehouse":0,"village":0,"cave":0,"ruins":0,"deposit":0}
|
|
for poi in data.pois: counts[poi.kind] += 1
|
|
for poi in data.pois:
|
|
if poi.kind != "cave": continue
|
|
assert(poi.has("mountain_position"))
|
|
assert(poi.position.distance_to(poi.mountain_position) == 86)
|
|
assert(data.mountains.any(func(m): return m.get("cave_anchor",false) and m.position == poi.mountain_position))
|
|
for other in data.pois:
|
|
if other.id != poi.id: assert(other.position.distance_to(poi.position) >= 420)
|
|
assert(counts.warehouse == 1 and counts.village == 1 and counts.cave == 1 and counts.ruins in [1,2])
|
|
assert(counts.deposit == 2)
|
|
assert(data.events.size() == 1 and data.events[0].position.is_finite())
|
|
assert(data.events[0].position.length() > 300)
|
|
extra_ruins += int(counts.ruins == 2)
|
|
if index == 0:
|
|
var repeated: Dictionary = GENERATOR.generate(500,profile)
|
|
assert(repeated.pois == data.pois and repeated.events == data.events)
|
|
# Most maps have one of each, with some maps containing a second.
|
|
assert(extra_ruins > 4 and extra_ruins < 30)
|
|
# No flat ground can disable the guaranteed question-mark event.
|
|
var fallback := {"seed":987,"heights":PackedFloat32Array(),"trees":[],"rocks":[],"mountains":[],"pois":[]}
|
|
fallback.heights.resize(96*96)
|
|
fallback.heights.fill(0.0)
|
|
var rng := RandomNumberGenerator.new()
|
|
rng.seed = 987
|
|
SCENERY.generate(fallback,rng)
|
|
assert(fallback.events.size() == 1 and fallback.events[0].position.is_finite())
|
|
assert(fallback.events[0].position.length() > 400)
|
|
print("SURFACE POI COUNTS PASS: 64 maps, ruins 1..2, two deposits, warehouse/village/cave once, one guaranteed event, deterministic layout; extra ruins=",extra_ruins)
|
|
get_tree().quit()
|