diff --git a/Scripts/Internal/entSpawner/import_object_spawner.wscript b/Scripts/Internal/entSpawner/import_object_spawner.wscript index f36d798..24a84ed 100644 --- a/Scripts/Internal/entSpawner/import_object_spawner.wscript +++ b/Scripts/Internal/entSpawner/import_object_spawner.wscript @@ -1,6 +1,6 @@ // Imports an entitySpawner json export // @author keanuwheeze -// @version 0.9 +// @version 0.91 //////////////// Modify this ////////////////// @@ -104,13 +104,15 @@ const insertNode = (sector, node) => { // Hash for interactivity nodeData.QuestPrefabRefHash.$value = wkit.HashString(JSON.stringify(nodeData), "fnv1a64").toString() - + sector.Data.RootChunk.nodeData.Data.push(nodeData) let worldNode = JSON.parse(wkit.CreateInstanceAsJSON(node.type)) + sortInstanceData(node.data) deepCopy(node.data, worldNode) + // Debug name for wkit worldNode.debugName.$value = node.name || "" sector.Data.RootChunk.nodes.push({HandleId : sector.Data.RootChunk.nodes.length.toString() , Data : worldNode}) @@ -146,6 +148,22 @@ const addSectorToBlock = (block, info, root) => { block.Data.RootChunk.descriptors.push(descriptor) } +const sortInstanceData = (data) => { + if (data["instanceData"]) { + const instanceDataSorted = [] + + for (const dictKey in data["instanceData"]["Data"]["buffer"]["Data"]["CruidDict"]) { + for (const dataEntry of data["instanceData"]["Data"]["buffer"]["Data"]["Chunks"]) { + if (dataEntry["id"] === data["instanceData"]["Data"]["buffer"]["Data"]["CruidDict"][dictKey]) { + instanceDataSorted.push(dataEntry) + } + } + } + + data["instanceData"]["Data"]["buffer"]["Data"]["Chunks"] = instanceDataSorted + } +} + //TODO: Put these in a list // BufferID - Flags - Type - Data