Files
admin 4463e524aa style: apply gdformat formatting across the entire project
Auto-format all GDScript files using gdformat from gdtoolkit.
This is a baseline formatting pass to ensure consistent style:

- Normalizes indentation and spacing
- Wraps long lines to 100 characters
- Removes trailing whitespace
- Standardizes blank lines between functions

68 files reformatted, 8 files left unchanged (3rd-party addon files
with parse errors excluded).
2026-07-05 23:06:23 +02:00

47 lines
1.1 KiB
GDScript

class_name VillageStateRecord
extends RefCounted
const SCHEMA_VERSION := 1
var data: Dictionary
func _init(record_data: Dictionary = {}) -> void:
data = record_data.duplicate(true)
static func capture(village: SimVillage) -> VillageStateRecord:
return VillageStateRecord.new(
{
"schema_version": SCHEMA_VERSION,
"food": village.food,
"wood": village.wood,
"safety": village.safety,
"knowledge": village.knowledge
}
)
static func from_dictionary(record_data: Dictionary) -> VillageStateRecord:
if int(record_data.get("schema_version", -1)) != SCHEMA_VERSION:
return null
if not record_data.has_all(["food", "wood", "safety", "knowledge"]):
return null
return VillageStateRecord.new(record_data)
func restore(debug_logs: bool) -> SimVillage:
var village := SimVillage.new()
village.debug_logs = debug_logs
village.food = float(data["food"])
village.wood = float(data["wood"])
village.safety = float(data["safety"])
village.knowledge = float(data["knowledge"])
village.update_modifiers()
village.update_priorities()
return village
func to_dictionary() -> Dictionary:
return data.duplicate(true)