aboutsummaryrefslogtreecommitdiff
path: root/game/addons/zylann.hterrain/hterrain_resource_loader.gd
diff options
context:
space:
mode:
author Gone2Daly <71726742+Gone2Daly@users.noreply.github.com>2023-07-22 21:05:42 +0200
committer Gone2Daly <71726742+Gone2Daly@users.noreply.github.com>2023-07-22 21:05:42 +0200
commit71b3cd829f80de4c2cd3972d8bfd5ee470a5d180 (patch)
treeb4280fde6eef2ae6987648bc7bf8e00e9011bb7f /game/addons/zylann.hterrain/hterrain_resource_loader.gd
parentce9022d0df74d6c33db3686622be2050d873ab0b (diff)
init_testtest3d
Diffstat (limited to 'game/addons/zylann.hterrain/hterrain_resource_loader.gd')
-rw-r--r--game/addons/zylann.hterrain/hterrain_resource_loader.gd35
1 files changed, 35 insertions, 0 deletions
diff --git a/game/addons/zylann.hterrain/hterrain_resource_loader.gd b/game/addons/zylann.hterrain/hterrain_resource_loader.gd
new file mode 100644
index 0000000..ccc176b
--- /dev/null
+++ b/game/addons/zylann.hterrain/hterrain_resource_loader.gd
@@ -0,0 +1,35 @@
+@tool
+class_name HTerrainDataLoader
+extends ResourceFormatLoader
+
+
+const HTerrainData = preload("./hterrain_data.gd")
+
+
+func _get_recognized_extensions() -> PackedStringArray:
+ return PackedStringArray([HTerrainData.META_EXTENSION])
+
+
+func _get_resource_type(path: String) -> String:
+ var ext := path.get_extension().to_lower()
+ if ext == HTerrainData.META_EXTENSION:
+ return "Resource"
+ return ""
+
+
+# TODO Handle UIDs?
+# By default Godot will return INVALID_ID,
+# which makes this resource only tracked by path, like scripts
+#
+# func _get_resource_uid(path: String) -> int:
+# return ???
+
+
+func _handles_type(typename: StringName) -> bool:
+ return typename == &"Resource"
+
+
+func _load(path: String, original_path: String, use_sub_threads: bool, cache_mode: int):
+ var res = HTerrainData.new()
+ res.load_data(path.get_base_dir())
+ return res