project_teddy/addons/zylann.hterrain/hterrain_resource_saver.gd

30 lines
734 B
GDScript3
Raw Normal View History

2023-04-11 13:31:11 -06:00
@tool
class_name HTerrainDataSaver
extends ResourceFormatSaver
const HTerrainData = preload("./hterrain_data.gd")
func _get_recognized_extensions(res: Resource) -> PackedStringArray:
if res != null and res is HTerrainData:
return PackedStringArray([HTerrainData.META_EXTENSION])
return PackedStringArray()
func _recognize(res: Resource) -> bool:
return res is HTerrainData
func _save(resource: Resource, path: String, flags: int) -> Error:
if resource.save_data(path.get_base_dir()):
return OK
# This can occur if at least one map of the terrain fails to save.
# It doesnt necessarily mean the entire terrain failed to save.
return FAILED
# TODO Handle UIDs
# func _set_uid(path: String, uid: int) -> int:
# ???