55 lines
3.3 KiB
GDScript
55 lines
3.3 KiB
GDScript
|
|
extends SceneTree
|
||
|
|
const E = preload("res://world/owniverse/math/exact.gd")
|
||
|
|
const Extra = preload("res://data/owniverse_extra_param_loader.gd")
|
||
|
|
const Parameters = preload("res://world/owniverse/world_parameters.gd")
|
||
|
|
var checks: int = 0
|
||
|
|
var failures: int = 0
|
||
|
|
func _initialize(): call_deferred("run")
|
||
|
|
func check(ok: bool, label: String):
|
||
|
|
checks += 1
|
||
|
|
if not ok:
|
||
|
|
failures += 1
|
||
|
|
push_error(label)
|
||
|
|
func run():
|
||
|
|
var global = root.get_node("Global")
|
||
|
|
check(E.eq(global.ExtraParams, Extra.get_data()), "Global table equals loader data")
|
||
|
|
check(E.eq(global.ExtraParams.E, E.of("1e27")), "Energy parsed as exact integer")
|
||
|
|
check(E.eq(global.ExtraParams.DA, 65536), "Export column is used, not formatted display column")
|
||
|
|
var saved: Dictionary = global.ExtraParams.duplicate()
|
||
|
|
global.ExtraParams.E = E.of("1e40")
|
||
|
|
var world = load("res://world/owniverse/owniverse.gd").new()
|
||
|
|
world.catalog.load_definitions(global.OwniverseEntities)
|
||
|
|
check(E.eq(world.state.energy, E.of("1e40")), "New world uses configured energy")
|
||
|
|
var initial: Dictionary = world.environment.stellar_environment(world.state)
|
||
|
|
global.ExtraParams.DA = E.multiply(saved.DA, 4)
|
||
|
|
check(E.near(world.environment.stellar_environment(world.state).density, E.multiply(initial.density, 2)), "Base mass changes density")
|
||
|
|
global.ExtraParams.DA = saved.DA
|
||
|
|
global.ExtraParams.NPC = E.multiply(saved.NPC, 2)
|
||
|
|
check(E.near(world.environment.stellar_environment(world.state).density, E.multiply(initial.density, 2)), "NPC changes density")
|
||
|
|
global.ExtraParams.NPC = saved.NPC
|
||
|
|
world.state.amount.S = E.of("1e24")
|
||
|
|
world.state.amount.LGF = 1
|
||
|
|
var old_density = world.environment.stellar_environment(world.state).density
|
||
|
|
global.ExtraParams.VoidSize = E.multiply(saved.VoidSize, 100)
|
||
|
|
check(E.lt(world.environment.stellar_environment(world.state).density, old_density), "Void volume uses configured size")
|
||
|
|
global.ExtraParams.bigcrunch1 = E.of("0.5")
|
||
|
|
global.ExtraParams.bigcrunch2 = E.of("0.6")
|
||
|
|
global.ExtraParams.bigcrunch3 = E.of("0.7")
|
||
|
|
check(Parameters.density_display(E.of("0.6")).mode == "DensityCrunch", "Configured crunch start")
|
||
|
|
check(E.near(Parameters.density_display(E.of("0.6")).position, E.of("0.5")), "Crunch indicator uses configured interval")
|
||
|
|
check(Parameters.density_warning_color(E.of("0.6")) == Color.html("20b0dfbf"), "Configured middle crunch warning")
|
||
|
|
global.ExtraParams.bigrip1 = E.of("0.01")
|
||
|
|
global.ExtraParams.bigrip2 = E.of("0.001")
|
||
|
|
global.ExtraParams.bigrip3 = E.of("0.0001")
|
||
|
|
check(Parameters.density_display(E.of("0.001")).mode == "DensityRip", "Configured rip start")
|
||
|
|
check(E.near(Parameters.density_display(E.of("0.001")).position, E.of("0.5")), "Rip indicator uses configured interval")
|
||
|
|
check(Parameters.density_warning_color(E.of("0.001")) == Color.html("df2020bf"), "Configured middle rip warning")
|
||
|
|
world.state.world_parameters.Bur = 19
|
||
|
|
global.ExtraParams.combustibility_bonus = 1
|
||
|
|
check(E.eq(Parameters.production(world.state, world.catalog.entities.RD), Parameters.effective(world.state, "Bur")), "Configured combustion exponent")
|
||
|
|
global.ExtraParams.merge(saved, true)
|
||
|
|
for entity in world.catalog.entities.values(): entity.free()
|
||
|
|
world.free()
|
||
|
|
print("Extra params: %d checks, %d failures" % [checks, failures])
|
||
|
|
quit(1 if failures else 0)
|