Skip to content

Commit

Permalink
Merge pull request #9 from justarandomguyintheinternet/main
Browse files Browse the repository at this point in the history
Updated entSpawner import script
  • Loading branch information
manavortex authored Aug 2, 2024
2 parents e9749e8 + d883b37 commit a500377
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Scripts/Internal/entSpawner/import_object_spawner.wscript
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Imports an entitySpawner json export
// @author keanuwheeze
// @version 0.9
// @version 0.91

//////////////// Modify this //////////////////

Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit a500377

Please sign in to comment.