-
Notifications
You must be signed in to change notification settings - Fork 31
/
meta_worker.gd
49 lines (41 loc) · 1.95 KB
/
meta_worker.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# This file is part of Unidot Importer. See LICENSE.txt for full MIT license.
# Copyright (c) 2021-present Lyuma <[email protected]> and contributors
# SPDX-License-Identifier: MIT
@tool
extends "./thread_worker.gd"
const binary_parser := preload("./deresuteme/decode.gd")
const yaml_parser := preload("./yaml_parser.gd")
const tarfile := preload("./tarfile.gd")
const package_file := preload("./package_file.gd")
class ThreadWork:
var asset: package_file.PkgAsset
var extra: Object
var asset_main_object_type: String
# asset: package_file.PkgAsset object
func push_asset(asset: package_file.PkgAsset, extra: Object):
var tw = ThreadWork.new()
tw.asset = asset
tw.extra = extra
self.push_work_obj(tw)
func _run_single_item(tw_: Object, thread_subdir: String):
var tw: ThreadWork = tw_ as ThreadWork
asset_processing_started.emit(tw)
var path = tw.asset.orig_pathname
if tw.asset.metadata_tar_header != null:
var sf = tw.asset.metadata_tar_header.get_stringfile()
tw.asset.parsed_meta = asset_database.parse_meta(sf, path)
var imp_type: String = tw.asset.parsed_meta.importer_type
tw.asset.parsed_meta.dependency_guids = {}
#print(path + ": " + imp_type)
if imp_type == "PrefabImporter" or imp_type == "NativeFormatImporter" or (imp_type == "DefaultImporter" and path.to_lower().ends_with(".scene")):
if tw.asset.asset_tar_header != null:
var buf: PackedByteArray = tw.asset.asset_tar_header.get_data()
if buf[8] == 0 and buf[9] == 0:
var bp = binary_parser.new(tw.asset.parsed_meta, buf, true) # writes guid references
tw.asset_main_object_type = bp.get_main_object_type()
else:
var yaml_str: String = buf.get_string_from_ascii()
yaml_parser.parse_dependency_guids(yaml_str, tw.asset.parsed_meta)
tw.asset_main_object_type = yaml_parser.parse_main_object_type(yaml_str)
#print("" + path + ":" + str(tw.asset.parsed_meta.dependency_guids) + " : " + str(tw.asset.parsed_meta.meta_dependency_guids))
asset_processing_finished.emit(tw)