Add world indicators and parameters to enhance universe simulation
- new universe creation function.
This commit is contained in:
@@ -7,6 +7,7 @@ const SAVE_PATH = "user://settings.cfg"
|
||||
|
||||
const FORMAT_VERSION: int = 2
|
||||
const SimulationTime = preload("res://world/owniverse/simulation_time.gd")
|
||||
const WorldParameters = preload("res://world/owniverse/world_parameters.gd")
|
||||
const STATE_VERSION: String = SimulationTime.STATE_VERSION
|
||||
var last_error: String = ""
|
||||
var blocked_saves: Dictionary = {}
|
||||
@@ -229,8 +230,25 @@ static func _validate_payload(data: Variant, speed_limit: int, stages: Array) ->
|
||||
"planet_remainders", "blast_remainders", "destruction_remainders", "civilization_remainders",
|
||||
"civilization_stats", "civilization_homes", "ethics", "stats",
|
||||
]
|
||||
if saved.size() != required.size():
|
||||
return "unsupported state structure"
|
||||
# Optional additions to the current format. Saves predating indicators keep
|
||||
# their quantities and receive neutral defaults from Owniverse on load.
|
||||
for field in saved:
|
||||
if field not in required and field not in ["world_parameters", "trends"]:
|
||||
return "unsupported state structure"
|
||||
if saved.has("world_parameters"):
|
||||
if not _number_map(saved.world_parameters) or saved.world_parameters.size() != WorldParameters.defaults().size():
|
||||
return "invalid state.world_parameters"
|
||||
for key in WorldParameters.defaults():
|
||||
if not saved.world_parameters.has(key) or saved.world_parameters[key] < 1.0:
|
||||
return "invalid world parameter " + key
|
||||
if key in ["Bur", "Exp", "Agg"] and saved.world_parameters[key] > 19.0:
|
||||
return "invalid world scale " + key
|
||||
if saved.has("trends"):
|
||||
if not _number_map(saved.trends) or saved.trends.size() != WorldParameters.TRENDS.size():
|
||||
return "invalid state.trends"
|
||||
for key in WorldParameters.TRENDS:
|
||||
if not saved.trends.has(key) or saved.trends[key] >= 1.0:
|
||||
return "invalid trend " + key
|
||||
for field in required:
|
||||
if not saved.has(field):
|
||||
return "missing state." + field
|
||||
|
||||
Reference in New Issue
Block a user