@divinevoxel/vlox 0.0.72 → 0.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/Contexts/Base/Remote/InitDataSync.js +4 -0
  2. package/Contexts/Base/Remote/InitWorldDataSync.js +1 -1
  3. package/Contexts/Render/DivineVoxelEngineRender.d.ts +2 -1
  4. package/Contexts/World/DivineVoxelEngineWorld.d.ts +2 -1
  5. package/Init/StartConstructor.js +8 -4
  6. package/Init/StartWorld.d.ts +1 -1
  7. package/Math/index.d.ts +5 -1
  8. package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
  9. package/Mesher/Functions/CompactVoxelMesh.js +1 -1
  10. package/Mesher/Functions/CompactVoxelSectionMesh.d.ts +4 -0
  11. package/Mesher/Functions/CompactVoxelSectionMesh.js +112 -0
  12. package/Mesher/Functions/MeshSection.d.ts +1 -1
  13. package/Mesher/Functions/MeshSection.js +27 -22
  14. package/Mesher/Functions/MeshTexture.d.ts +1 -1
  15. package/Mesher/Functions/MeshTexture.js +3 -4
  16. package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
  17. package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
  18. package/Mesher/Geomtry/Primitives/QuadVertexData.d.ts +12 -10
  19. package/Mesher/Geomtry/Primitives/QuadVertexData.js +49 -56
  20. package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +2 -2
  21. package/Mesher/Geomtry/VoxelGeometryBuilder.js +120 -199
  22. package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
  23. package/Mesher/Geomtry/VoxelMesh.js +4 -4
  24. package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +16 -0
  25. package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +51 -0
  26. package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
  27. package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
  28. package/Mesher/Geomtry/{Buffers.js → VoxelMeshBuffers.js} +2 -2
  29. package/Mesher/Geomtry/index.d.ts +0 -1
  30. package/Mesher/Geomtry/index.js +0 -1
  31. package/Mesher/InitMesher.js +1 -1
  32. package/Mesher/InitTask.js +9 -23
  33. package/Mesher/Models/Common/BoxGeometryNode.js +7 -7
  34. package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
  35. package/Mesher/Models/Common/Calc/CalcConstants.js +1 -1
  36. package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -2
  37. package/Mesher/Models/Common/Calc/FaceDataCalc.js +37 -30
  38. package/Mesher/Models/Common/QuadGeometryNode.js +2 -2
  39. package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.d.ts +2 -2
  40. package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.js +1 -1
  41. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +18 -24
  42. package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -2
  43. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +1 -0
  44. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +40 -31
  45. package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +2 -2
  46. package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +2 -2
  47. package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +2 -2
  48. package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.d.ts +1 -1
  49. package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.js +1 -1
  50. package/Mesher/Models/RenderedMaterials.d.ts +6 -0
  51. package/Mesher/{RenderedMaterials.js → Models/RenderedMaterials.js} +2 -2
  52. package/Mesher/Models/VoxelConstructor.d.ts +6 -6
  53. package/Mesher/Models/VoxelConstructor.js +8 -8
  54. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +3 -5
  55. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -32
  56. package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +4 -5
  57. package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +5 -8
  58. package/Mesher/Types/Mesher.types.d.ts +1 -0
  59. package/Models/Defaults/CubeVoxelGeometry.js +4 -0
  60. package/Models/Defaults/CubeVoxelModels.js +360 -383
  61. package/Models/Defaults/LiquidVoxelModel.js +5 -5
  62. package/Models/Defaults/PanelVoxelModels.js +442 -468
  63. package/Models/Defaults/StairVoxelModel.js +582 -597
  64. package/Models/Examples.js +490 -498
  65. package/Models/Rules/Classes/VoxelRulesModel.d.ts +1 -1
  66. package/Models/Rules/Classes/VoxelRulesModel.js +3 -3
  67. package/Models/Rules/Functions/BuildFinalInputs.d.ts +1 -1
  68. package/Models/Rules/Functions/BuildFinalInputs.js +21 -19
  69. package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
  70. package/Models/Rules/Functions/BuildRules.js +2 -2
  71. package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
  72. package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
  73. package/Models/VoxelModel.types.d.ts +17 -8
  74. package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
  75. package/Renderer/Classes/SectorMesh.d.ts +3 -4
  76. package/Renderer/Classes/SectorMesh.js +6 -11
  77. package/Renderer/InitTasks.js +1 -10
  78. package/Renderer/MeshManager.d.ts +1 -1
  79. package/Renderer/MeshManager.js +26 -25
  80. package/Renderer/MeshRegister.d.ts +5 -5
  81. package/Renderer/MeshRegister.js +4 -3
  82. package/Settings/EngineSettings.d.ts +2 -1
  83. package/Settings/EngineSettings.js +6 -5
  84. package/Settings/EngineSettings.types.d.ts +24 -39
  85. package/Settings/EngineSettings.types.js +22 -29
  86. package/Tasks/Logic/InitTasks.d.ts +1 -0
  87. package/Tasks/Logic/InitTasks.js +10 -0
  88. package/Tasks/Logic/VoxelLogicUpdate.d.ts +3 -0
  89. package/Tasks/Logic/VoxelLogicUpdate.js +71 -0
  90. package/Tasks/Propagation/Explosion/ExplosionManager.d.ts +2 -2
  91. package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -2
  92. package/Tasks/Propagation/Flow/FlowManager.d.ts +4 -4
  93. package/Tasks/Propagation/Flow/FlowRemove.d.ts +2 -2
  94. package/Tasks/Propagation/Flow/FlowUpdate.d.ts +2 -2
  95. package/Tasks/Propagation/Flow/WorldFlow.d.ts +2 -2
  96. package/Tasks/Propagation/Illumanation/RGBUpdate.d.ts +3 -3
  97. package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +3 -3
  98. package/Tasks/Propagation/Illumanation/WorldRGB.d.ts +2 -2
  99. package/Tasks/Propagation/Illumanation/WorldSun.d.ts +2 -2
  100. package/Tasks/Propagation/Illumanation/WorldSun.js +8 -15
  101. package/Tasks/Propagation/InitTasks.js +4 -4
  102. package/Tasks/Propagation/Power/PowerUpdate.d.ts +3 -0
  103. package/Tasks/Propagation/Power/PowerUpdate.js +80 -0
  104. package/Tasks/Tasks.types.d.ts +2 -2
  105. package/Tasks/TasksIds.d.ts +2 -1
  106. package/Tasks/TasksIds.js +1 -0
  107. package/Tasks/Update/Common.d.ts +3 -0
  108. package/Tasks/Update/Common.js +41 -0
  109. package/Tasks/Update/EreaseUpdate.d.ts +3 -0
  110. package/Tasks/Update/EreaseUpdate.js +66 -0
  111. package/Tasks/Update/InitTasks.d.ts +2 -2
  112. package/Tasks/Update/InitTasks.js +3 -1
  113. package/Tasks/Update/PaintUpdate.d.ts +3 -0
  114. package/Tasks/Update/PaintUpdate.js +89 -0
  115. package/Tasks/Update/VoxelUpdate.d.ts +2 -5
  116. package/Tasks/Update/VoxelUpdate.js +7 -143
  117. package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +16 -6
  118. package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +44 -5
  119. package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
  120. package/Tasks/WorldGeneration/WorldGenBrush.js +3 -3
  121. package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
  122. package/Templates/Cursor/TemplateCursor.d.ts +2 -2
  123. package/Templates/Cursor/TemplateCursor.js +1 -2
  124. package/Templates/Functions/CreateTemplate.d.ts +1 -1
  125. package/Templates/VoxelTemplates.types.d.ts +1 -1
  126. package/Textures/Classes/CompiledTexture.d.ts +18 -0
  127. package/Textures/Classes/CompiledTexture.js +50 -0
  128. package/Textures/Classes/CompiledTextureAnimation.d.ts +12 -0
  129. package/Textures/Classes/CompiledTextureAnimation.js +27 -0
  130. package/Textures/Classes/TextureAnimationTexture.d.ts +10 -0
  131. package/Textures/Classes/TextureAnimationTexture.js +32 -0
  132. package/Textures/Functions/BuildTextureData.d.ts +10 -0
  133. package/Textures/Functions/BuildTextureData.js +205 -0
  134. package/Textures/Texture.types.d.ts +50 -64
  135. package/Textures/TextureManager.d.ts +8 -19
  136. package/Textures/TextureManager.js +28 -166
  137. package/Tools/Brush/AdvancedBrushTool.js +1 -1
  138. package/Tools/Brush/Brush.d.ts +3 -3
  139. package/Tools/Brush/Brush.js +40 -8
  140. package/Tools/Tasks/TasksTool.d.ts +1 -0
  141. package/Tools/Tasks/TasksTool.js +2 -0
  142. package/Util/Binary/BinaryArrays.d.ts +6 -0
  143. package/Util/Binary/BinaryArrays.js +25 -0
  144. package/Util/Binary/BinaryBuffer.d.ts +35 -0
  145. package/Util/Binary/BinaryBuffer.js +136 -0
  146. package/Util/Binary/{BitArray.d.ts → BinaryFunctions.d.ts} +1 -2
  147. package/Util/Binary/BinaryFunctions.js +11 -0
  148. package/{Mesher/Tools/VoxelMeshBVHBuilder.d.ts → Util/Binary/BinaryTree.d.ts} +1 -33
  149. package/Util/Binary/BinaryTree.js +104 -0
  150. package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
  151. package/Voxels/Cursor/VoxelCursor.interface.d.ts +8 -3
  152. package/Voxels/Cursor/VoxelCursor.interface.js +54 -13
  153. package/Voxels/Cursor/VoxelLightData.js +1 -1
  154. package/Voxels/Data/VoxelPalettesRegister.d.ts +0 -5
  155. package/Voxels/Data/VoxelPalettesRegister.js +0 -9
  156. package/Voxels/Data/VoxelTag.types.d.ts +17 -2
  157. package/Voxels/Data/VoxelTag.types.js +6 -1
  158. package/Voxels/Data/VoxelTagsRegister.js +12 -7
  159. package/Voxels/Functions/BuildStateData.d.ts +6 -6
  160. package/Voxels/Functions/BuildStateData.js +37 -37
  161. package/Voxels/Functions/BuildTagAndPaletteData.js +6 -3
  162. package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
  163. package/Voxels/Indexes/VoxelIndex.js +16 -18
  164. package/Voxels/InitVoxelData.js +24 -21
  165. package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.d.ts +5 -0
  166. package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.js +6 -0
  167. package/Voxels/Logic/Classes/VoxelLogic.d.ts +11 -0
  168. package/Voxels/Logic/Classes/VoxelLogic.js +49 -0
  169. package/Voxels/Logic/Classes/VoxelLogicType.d.ts +4 -0
  170. package/Voxels/Logic/Classes/VoxelLogicType.js +2 -0
  171. package/Voxels/Logic/VoxelLogic.types.d.ts +23 -0
  172. package/Voxels/Logic/VoxelLogic.types.js +1 -0
  173. package/Voxels/Logic/VoxelLogicRegister.d.ts +9 -0
  174. package/Voxels/Logic/VoxelLogicRegister.js +15 -0
  175. package/Voxels/State/Schema/StateSchema.d.ts +1 -1
  176. package/Voxels/State/SchemaRegister.js +10 -5
  177. package/Voxels/State/State.types.d.ts +1 -1
  178. package/Voxels/State/StateTreeReader.d.ts +1 -1
  179. package/Voxels/State/StateTreeReader.js +2 -3
  180. package/Voxels/Types/Voxel.types.d.ts +21 -0
  181. package/Voxels/Types/Voxel.types.js +6 -2
  182. package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
  183. package/World/Archive/Archive.types.d.ts +65 -42
  184. package/World/Archive/Classes/ArchiveClasses.d.ts +66 -0
  185. package/World/Archive/Classes/ArchiveClasses.js +78 -0
  186. package/World/Archive/Classes/ImportedSection.d.ts +40 -0
  187. package/World/Archive/Classes/ImportedSection.js +307 -0
  188. package/World/Archive/Classes/ImportedSector.d.ts +23 -0
  189. package/World/Archive/Classes/ImportedSector.js +97 -0
  190. package/World/Archive/Functions/ArchiveArea.d.ts +1 -1
  191. package/World/Archive/Functions/ArchiveArea.js +49 -54
  192. package/World/Archive/Functions/ArchiveSector.js +373 -282
  193. package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
  194. package/World/Archive/Functions/CreateArchivedSection.js +207 -0
  195. package/World/Archive/Functions/ImportSector.d.ts +2 -4
  196. package/World/Archive/Functions/ImportSector.js +50 -220
  197. package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
  198. package/World/Archive/Functions/RemoveDuplicates.js +92 -0
  199. package/World/Archive/Functions/Shared.d.ts +6 -0
  200. package/World/Archive/Functions/Shared.js +50 -0
  201. package/World/Archive/InitTasks.js +37 -23
  202. package/World/Cursor/SectionCursor.d.ts +3 -3
  203. package/World/Cursor/SectionCursor.js +2 -3
  204. package/World/Cursor/SectorCursor.d.ts +3 -3
  205. package/World/Cursor/SectorCursor.js +1 -2
  206. package/World/Cursor/WorldCursor.d.ts +6 -5
  207. package/World/Cursor/WorldCursor.js +17 -15
  208. package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
  209. package/World/Cursor/WorldVoxelCursor.js +24 -14
  210. package/World/Dimension/Dimension.d.ts +4 -1
  211. package/World/Dimension/Dimension.js +8 -1
  212. package/World/InitTasks.d.ts +1 -1
  213. package/World/Lock/WorldLock.d.ts +1 -1
  214. package/World/Section/Section.d.ts +27 -18
  215. package/World/Section/Section.js +125 -21
  216. package/World/Section/SectionState.d.ts +12 -0
  217. package/World/Section/SectionState.js +13 -0
  218. package/World/Sector/Sector.d.ts +20 -6
  219. package/World/Sector/Sector.js +100 -17
  220. package/World/Sector/SectorHeightMap.js +2 -2
  221. package/World/Sector/SectorState.d.ts +16 -7
  222. package/World/Sector/SectorState.js +29 -15
  223. package/World/Types/WorldData.types.d.ts +2 -7
  224. package/World/Types/WorldStorage.interface.js +1 -0
  225. package/World/WorldRegister.d.ts +13 -9
  226. package/World/WorldRegister.js +24 -9
  227. package/World/WorldSpaces.d.ts +4 -0
  228. package/World/WorldSpaces.js +25 -12
  229. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
  230. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +10 -3
  231. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +19 -3
  232. package/WorldSimulation/Internal/Classes/Queues/BuildQueue.d.ts +5 -0
  233. package/WorldSimulation/Internal/Classes/Queues/BuildQueue.js +6 -0
  234. package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.d.ts +5 -0
  235. package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.js +6 -0
  236. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.js +1 -1
  237. package/WorldSimulation/Internal/Classes/TickQueue.d.ts +12 -0
  238. package/WorldSimulation/Internal/Classes/TickQueue.js +58 -0
  239. package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
  240. package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +8 -8
  241. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.js +9 -9
  242. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.d.ts +1 -1
  243. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.js +4 -4
  244. package/WorldSimulation/Internal/Functions/runTickUpdate.d.ts +2 -0
  245. package/{Tasks/IWG/Internal/Functions/runBuildUpdate.js → WorldSimulation/Internal/Functions/runTickUpdate.js} +38 -9
  246. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.js +13 -13
  247. package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.d.ts +2 -2
  248. package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.js +1 -1
  249. package/WorldSimulation/Internal/WorldSimulationDimensions.d.ts +6 -0
  250. package/{Tasks/IWG/Internal/IWGDimensions.js → WorldSimulation/Internal/WorldSimulationDimensions.js} +1 -1
  251. package/WorldSimulation/Internal/WorldSimulationTasks.d.ts +30 -0
  252. package/{Tasks/IWG/Internal/IWGTasks.js → WorldSimulation/Internal/WorldSimulationTasks.js} +14 -24
  253. package/WorldSimulation/Internal/WorldSimulationTools.d.ts +8 -0
  254. package/{Tasks/IWG/Internal/IWGTools.js → WorldSimulation/Internal/WorldSimulationTools.js} +1 -1
  255. package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.d.ts +1 -1
  256. package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.js +11 -11
  257. package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.js +7 -5
  258. package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +6 -5
  259. package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +29 -23
  260. package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
  261. package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
  262. package/package.json +1 -1
  263. package/Mesher/Functions/CompactMesh.d.ts +0 -2
  264. package/Mesher/Functions/CompactMesh.js +0 -42
  265. package/Mesher/Geomtry/GeometryNormals.d.ts +0 -10
  266. package/Mesher/Geomtry/GeometryNormals.js +0 -52
  267. package/Mesher/Geomtry/MeshData.types.d.ts +0 -13
  268. package/Mesher/Geomtry/MeshData.types.js +0 -6
  269. package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +0 -7
  270. package/Mesher/Geomtry/Tools/MesherDataTools.js +0 -12
  271. package/Mesher/Geomtry/Tools/index.d.ts +0 -1
  272. package/Mesher/Geomtry/Tools/index.js +0 -1
  273. package/Mesher/RenderedMaterials.d.ts +0 -6
  274. package/Mesher/Tools/VoxelMeshBVHBuilder.js +0 -216
  275. package/Models/Rules/VoxelModelManager.js +0 -82
  276. package/Tasks/IWG/Internal/Classes/IWGTaskBase.d.ts +0 -15
  277. package/Tasks/IWG/Internal/Functions/runBuildUpdate.d.ts +0 -2
  278. package/Tasks/IWG/Internal/IWGDimensions.d.ts +0 -6
  279. package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -34
  280. package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
  281. package/Textures/TextureAnimations.d.ts +0 -4
  282. package/Textures/TextureAnimations.js +0 -35
  283. package/Textures/TextureArray.d.ts +0 -47
  284. package/Textures/TextureArray.js +0 -202
  285. package/Textures/TextureBuilder.d.ts +0 -13
  286. package/Textures/TextureBuilder.js +0 -120
  287. package/Textures/TextureRegister.d.ts +0 -9
  288. package/Textures/TextureRegister.js +0 -28
  289. package/Tools/DataCursor.interface.d.ts +0 -5
  290. package/Tools/DataCursor.interface.js +0 -2
  291. package/Util/Binary/BitArray.js +0 -16
  292. package/World/Structs/WorldDataStructProperties.d.ts +0 -8
  293. package/World/Structs/WorldDataStructProperties.js +0 -9
  294. /package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +0 -0
  295. /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
  296. /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
  297. /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
  298. /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
  299. /package/{World/Storage/WorldStorage.interface.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
  300. /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
  301. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.js +0 -0
  302. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.d.ts +0 -0
  303. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.js +0 -0
  304. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.d.ts +0 -0
  305. /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.d.ts +0 -0
  306. /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.d.ts +0 -0
  307. /package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.d.ts +0 -0
@@ -1,340 +1,431 @@
1
- import { StringPalette } from "../../../Util/StringPalette";
2
- import { NumberPalette } from "../../../Util/NumberPalette";
3
1
  import { WorldRegister } from "../../../World/WorldRegister";
4
- import { convertToPaletteBuffer } from "../../../Util/Binary/Palettes";
5
2
  import { SchemaRegister } from "../../../Voxels/State/SchemaRegister";
6
3
  import { VoxelPalettesRegister } from "../../../Voxels/Data/VoxelPalettesRegister";
7
4
  import { VoxelTagsRegister } from "../../../Voxels/Data/VoxelTagsRegister";
8
- const getProcessedSection = (section) => {
9
- return {
10
- section,
11
- palettes: getSectionPalettes(),
12
- // ids
13
- ids: new Uint16Array(section.ids.length),
14
- idsAllTheSame: true,
15
- remappedIds: false,
16
- // light
17
- light: new Uint16Array(section.light.length),
18
- lightAllTheSame: true,
19
- isLightPaletted: false,
20
- remappedLight: false,
21
- // level
22
- level: new Uint8Array(section.level.length),
23
- levelAllTheSame: true,
24
- isLevelPaletted: false,
25
- remappedLevel: false,
26
- // state
27
- state: new Uint16Array(section.state.length),
28
- stateAllTheSame: true,
29
- isStatePaletted: false,
30
- remappedState: false,
31
- // mod
32
- mod: new Uint16Array(section.mod.length),
33
- modAllTheSame: true,
34
- isModPaletted: false,
35
- remappedMod: false,
36
- // secondary
37
- secondary: new Uint16Array(section.secondary.length),
38
- isSecondaryPaletted: false,
39
- secondaryAllTheSame: true,
40
- remappedSecondary: false,
41
- };
42
- };
43
- function getSectionPalettes() {
44
- return {
45
- ids: new NumberPalette(),
46
- level: new NumberPalette(),
47
- light: new NumberPalette(),
48
- state: new NumberPalette(),
49
- mod: new NumberPalette(),
50
- secondaryId: new NumberPalette(),
51
- secondaryState: new NumberPalette(),
52
- };
53
- }
54
- function getColumnPalettes() {
55
- return {
56
- ids: new StringPalette(),
57
- level: new NumberPalette(),
58
- light: new NumberPalette(),
59
- stateIdMap: [],
60
- state: new NumberPalette(),
61
- modIdMap: [],
62
- mod: new NumberPalette(),
63
- secondaryId: new StringPalette(),
64
- secondaryState: new NumberPalette(),
65
- };
66
- }
67
- function GetArchivedSection(archiveSection, sectorPalettes) {
68
- const palettes = {};
69
- if (archiveSection.remappedIds)
70
- palettes.id = Uint16Array.from(archiveSection.palettes.ids._palette);
71
- if (archiveSection.remappedLevel)
72
- palettes.level = Uint8Array.from(archiveSection.palettes.level._palette);
73
- if (archiveSection.remappedLight)
74
- palettes.light = Uint16Array.from(archiveSection.palettes.light._palette);
75
- if (archiveSection.remappedState)
76
- palettes.state = Uint16Array.from(archiveSection.palettes.state._palette);
77
- if (archiveSection.remappedMod)
78
- palettes.mod = Uint16Array.from(archiveSection.palettes.mod._palette);
79
- if (archiveSection.remappedSecondary) {
80
- palettes.secondaryId = Uint16Array.from(archiveSection.palettes.secondaryId._palette);
81
- palettes.secondaryState = Uint16Array.from(archiveSection.palettes.secondaryState._palette);
82
- }
83
- return {
84
- state: {},
85
- palettes,
86
- buffers: {
87
- id: archiveSection.idsAllTheSame
88
- ? archiveSection.ids[0]
89
- : convertToPaletteBuffer(archiveSection.remappedIds
90
- ? archiveSection.palettes.ids.size
91
- : sectorPalettes.ids.size, archiveSection.ids),
92
- level: archiveSection.isLevelPaletted
93
- ? archiveSection.level[0]
94
- : archiveSection.isLevelPaletted
95
- ? convertToPaletteBuffer(archiveSection.remappedLevel
96
- ? archiveSection.palettes.level.size
97
- : sectorPalettes.level.size, archiveSection.level)
98
- : new Uint8Array(archiveSection.section.level.slice()),
99
- light: archiveSection.lightAllTheSame
100
- ? archiveSection.light[0]
101
- : archiveSection.isLightPaletted
102
- ? convertToPaletteBuffer(archiveSection.remappedLight
103
- ? archiveSection.palettes.light.size
104
- : sectorPalettes.light.size, archiveSection.light)
105
- : new Uint16Array(archiveSection.section.light.slice()),
106
- state: archiveSection.stateAllTheSame
107
- ? archiveSection.state[0]
108
- : archiveSection.isStatePaletted
109
- ? convertToPaletteBuffer(archiveSection.remappedState
110
- ? archiveSection.palettes.state.size
111
- : sectorPalettes.state.size, archiveSection.state)
112
- : new Uint16Array(archiveSection.section.state.slice()),
113
- mod: archiveSection.modAllTheSame
114
- ? archiveSection.mod[0]
115
- : archiveSection.isModPaletted
116
- ? convertToPaletteBuffer(archiveSection.remappedMod
117
- ? archiveSection.palettes.mod.size
118
- : sectorPalettes.mod.size, archiveSection.mod)
119
- : new Uint16Array(archiveSection.section.mod.slice()),
120
- secondary: archiveSection.secondaryAllTheSame
121
- ? archiveSection.secondary[0]
122
- : archiveSection.isSecondaryPaletted
123
- ? convertToPaletteBuffer(archiveSection.remappedSecondary
124
- ? Math.max(archiveSection.palettes.secondaryState.size, archiveSection.palettes.secondaryId.size)
125
- : Math.max(sectorPalettes.secondaryState.size, sectorPalettes.secondaryId.size), archiveSection.secondary)
126
- : new Uint16Array(archiveSection.secondary),
127
- },
128
- };
129
- }
5
+ import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData";
6
+ import { EngineSettings } from "../../../Settings/EngineSettings";
7
+ import { BinaryBuffer } from "../../../Util/Binary/BinaryBuffer";
8
+ import { lightSegments, lightSemgnetGet } from "./Shared";
9
+ import { ProcessedSection, SectorPalette, VoxelStateObjectMap, } from "../Classes/ArchiveClasses";
10
+ import { CreateArchivedSection } from "./CreateArchivedSection";
11
+ import { RemoveDuplicates } from "./RemoveDuplicates";
12
+ import { NumberPalette } from "../../../Util/NumberPalette";
13
+ const lightData = new VoxelLightData();
130
14
  export default function ArchiveSector(archiveData) {
131
15
  const sector = WorldRegister.sectors.get(archiveData.location[0], archiveData.location[1], archiveData.location[2], archiveData.location[3]);
132
16
  if (!sector)
133
- throw new Error(`Column at location ${location} does not exist when trying to arhicve it.`);
134
- const sectorPalettes = getColumnPalettes();
17
+ throw new Error(`Sector at location ${location} does not exist when trying to arhicve it.`);
18
+ const sectorPalettes = new SectorPalette();
135
19
  const processedSections = [];
136
- for (const section of sector.sections) {
20
+ for (let sectionIndex = 0; sectionIndex < sector.sections.length; sectionIndex++) {
21
+ const section = sector.sections[sectionIndex];
22
+ const processedSection = new ProcessedSection(section);
23
+ {
24
+ let value = section.buried[0];
25
+ processedSection.isBuriedAllTheSame = true;
26
+ for (let i = 0; i < section.buried.length; i++) {
27
+ if (value != section.buried[i]) {
28
+ processedSection.isBuriedAllTheSame = false;
29
+ break;
30
+ }
31
+ }
32
+ processedSection.buriedValue = value;
33
+ }
34
+ {
35
+ let value = section.voxelMap[0];
36
+ processedSection.isVoxelMapAllTheSame = true;
37
+ for (let i = 0; i < section.voxelMap.length; i++) {
38
+ if (value != section.voxelMap[i]) {
39
+ processedSection.isVoxelMapAllTheSame = false;
40
+ break;
41
+ }
42
+ }
43
+ processedSection.voxelMapValue = value;
44
+ }
45
+ {
46
+ let value = section.dirtyMap[0];
47
+ processedSection.isDirtyMapAllTheSame = true;
48
+ for (let i = 0; i < section.dirtyMap.length; i++) {
49
+ if (value != section.dirtyMap[i]) {
50
+ processedSection.isDirtyMapAllTheSame = false;
51
+ break;
52
+ }
53
+ }
54
+ processedSection.dirtyMapValue = value;
55
+ }
56
+ const firstId = section.ids[0];
57
+ const firstLight = section.light[0];
58
+ const firstLevel = section.level[0];
59
+ const firstState = section.state[0];
60
+ const firstMod = section.mod[0];
61
+ const firstSecondary = section.secondary[0];
62
+ const firstLightLevels = {
63
+ sun: lightData.getS(firstLight),
64
+ red: lightData.getR(firstLight),
65
+ green: lightData.getG(firstLight),
66
+ blue: lightData.getB(firstLight),
67
+ };
137
68
  const length = section.ids.length;
138
- let firstId = -1;
139
- let firstLight = -1;
140
- let firstLevel = -1;
141
- let firstState = -1;
142
- let firstMod = -1;
143
- let firstSecondary = -1;
144
- const processedSection = getProcessedSection(section);
145
69
  for (let i = 0; i < length; i++) {
146
70
  const stringId = VoxelPalettesRegister.voxels.getStringId(section.ids[i]);
147
71
  const voxelId = !sectorPalettes.ids.isRegistered(stringId)
148
72
  ? sectorPalettes.ids.register(stringId)
149
73
  : sectorPalettes.ids.getNumberId(stringId);
74
+ processedSection.ids.value = voxelId;
150
75
  if (!processedSection.palettes.ids.isRegistered(voxelId))
151
76
  processedSection.palettes.ids.register(voxelId);
152
- if (firstId == -1)
153
- firstId = voxelId;
154
77
  const secondaryId = VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"] &&
155
78
  VoxelPalettesRegister.voxels.getStringId(section.secondary[i]);
156
79
  const voxelSecondary = secondaryId
157
80
  ? !sectorPalettes.secondaryId.isRegistered(secondaryId)
158
81
  ? sectorPalettes.secondaryId.register(secondaryId)
159
82
  : sectorPalettes.secondaryId.getNumberId(secondaryId)
160
- : !sectorPalettes.secondaryState.isRegistered(section.secondary[i])
161
- ? sectorPalettes.secondaryState.register(section.secondary[i])
162
- : sectorPalettes.secondaryState.getId(section.secondary[i]);
163
- secondaryId
164
- ? !processedSection.palettes.secondaryId.isRegistered(voxelSecondary) &&
165
- processedSection.palettes.secondaryId.register(voxelSecondary)
166
- : !processedSection.palettes.secondaryState.isRegistered(voxelSecondary) &&
167
- processedSection.palettes.secondaryState.register(voxelSecondary);
168
- if (firstSecondary == -1)
169
- firstSecondary = section.secondary[i];
83
+ : !sectorPalettes.secondaryValue.isRegistered(section.secondary[i])
84
+ ? sectorPalettes.secondaryValue.register(section.secondary[i])
85
+ : sectorPalettes.secondaryValue.getId(section.secondary[i]);
86
+ if (VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"]) {
87
+ if (!processedSection.palettes.secondaryId.isRegistered(voxelSecondary))
88
+ processedSection.palettes.secondaryId.register(voxelSecondary);
89
+ }
90
+ else {
91
+ if (!processedSection.palettes.secondaryValue.isRegistered(voxelSecondary))
92
+ processedSection.palettes.secondaryValue.register(voxelSecondary);
93
+ }
170
94
  const voxelLevel = !sectorPalettes.level.isRegistered(section.level[i])
171
95
  ? sectorPalettes.level.register(section.level[i])
172
96
  : sectorPalettes.level.getId(section.level[i]);
173
97
  if (!processedSection.palettes.level.isRegistered(section.level[i]))
174
98
  processedSection.palettes.level.register(section.level[i]);
175
- if (firstLevel == -1)
176
- firstLevel = voxelLevel;
99
+ let stateMap;
100
+ if (secondaryId) {
101
+ if (!sectorPalettes.secondaryStateMap[voxelSecondary]) {
102
+ stateMap = new VoxelStateObjectMap();
103
+ sectorPalettes.secondaryStateMap[voxelId] = stateMap;
104
+ }
105
+ else {
106
+ stateMap = sectorPalettes.secondaryStateMap[voxelSecondary];
107
+ }
108
+ }
109
+ else {
110
+ if (!sectorPalettes.stateMap[voxelId]) {
111
+ stateMap = new VoxelStateObjectMap();
112
+ sectorPalettes.stateMap[voxelId] = stateMap;
113
+ }
114
+ else {
115
+ stateMap = sectorPalettes.stateMap[voxelId];
116
+ }
117
+ }
177
118
  let voxelState = -1;
178
- if (!sectorPalettes.state.isRegistered(section.state[i])) {
179
- voxelState = sectorPalettes.state.register(section.state[i]);
180
- sectorPalettes.stateIdMap[voxelState] = secondaryId
181
- ? section.secondary[i]
182
- : section.ids[i];
119
+ if (!stateMap.palette.isRegistered(section.state[i])) {
120
+ voxelState = stateMap.palette.register(section.state[i]);
183
121
  }
184
122
  else {
185
- voxelState = sectorPalettes.state.getId(section.state[i]);
123
+ voxelState = stateMap.palette.getId(section.state[i]);
124
+ }
125
+ if (!processedSection.palettes.state[voxelId]) {
126
+ processedSection.palettes.state[voxelId] = new NumberPalette();
127
+ }
128
+ if (!processedSection.palettes.state[voxelId].isRegistered(voxelState))
129
+ processedSection.palettes.state[voxelId].register(voxelState);
130
+ let modMap;
131
+ if (secondaryId) {
132
+ if (!sectorPalettes.secondaryModMap[voxelSecondary]) {
133
+ modMap = new VoxelStateObjectMap();
134
+ sectorPalettes.secondaryModMap[voxelSecondary] = modMap;
135
+ }
136
+ else {
137
+ modMap = sectorPalettes.secondaryModMap[voxelSecondary];
138
+ }
139
+ }
140
+ else {
141
+ if (!sectorPalettes.modMap[voxelId]) {
142
+ modMap = new VoxelStateObjectMap();
143
+ sectorPalettes.modMap[voxelSecondary] = modMap;
144
+ }
145
+ else {
146
+ modMap = sectorPalettes.modMap[voxelId];
147
+ }
186
148
  }
187
- if (!processedSection.palettes.state.isRegistered(voxelState))
188
- processedSection.palettes.state.register(voxelState);
189
- if (firstState == -1)
190
- firstState = voxelState;
191
149
  let voxelMod = -1;
192
- if (!sectorPalettes.mod.isRegistered(section.mod[i])) {
193
- voxelMod = sectorPalettes.mod.register(section.mod[i]);
194
- sectorPalettes.stateIdMap[voxelMod] = secondaryId
195
- ? section.secondary[i]
196
- : section.ids[i];
150
+ if (!modMap.palette.isRegistered(section.mod[i])) {
151
+ voxelMod = modMap.palette.register(section.mod[i]);
197
152
  }
198
153
  else {
199
- voxelMod = sectorPalettes.mod.getId(section.mod[i]);
154
+ voxelMod = modMap.palette.getId(section.mod[i]);
155
+ }
156
+ if (!processedSection.palettes.mod[voxelId]) {
157
+ processedSection.palettes.mod[voxelId] = new NumberPalette();
200
158
  }
201
- if (!processedSection.palettes.mod.isRegistered(voxelMod))
202
- processedSection.palettes.mod.register(voxelMod);
203
- if (firstMod == -1)
204
- firstMod = voxelMod;
205
- const voxelLight = !sectorPalettes.light.isRegistered(section.light[i])
206
- ? sectorPalettes.light.register(section.light[i])
207
- : sectorPalettes.light.getId(section.light[i]);
208
- if (!processedSection.palettes.light.isRegistered(section.light[i]))
209
- processedSection.palettes.light.register(section.light[i]);
210
- if (firstLight == -1)
211
- firstLight = voxelLight;
212
- if (voxelId != firstId)
213
- processedSection.idsAllTheSame = false;
214
- if (voxelLevel != firstLevel)
215
- processedSection.levelAllTheSame = false;
216
- if (voxelState != firstState)
217
- processedSection.stateAllTheSame = false;
218
- if (voxelMod != firstMod)
219
- processedSection.modAllTheSame = false;
220
- if (voxelLight != firstLight)
221
- processedSection.lightAllTheSame = false;
222
- if (voxelSecondary != firstSecondary)
223
- processedSection.secondaryAllTheSame = false;
224
- processedSection.ids[i] = voxelId;
225
- processedSection.level[i] = voxelLevel;
226
- processedSection.state[i] = voxelState;
227
- processedSection.mod[i] = voxelMod;
228
- processedSection.secondary[i] = voxelSecondary;
229
- processedSection.light[i] = voxelLight;
159
+ if (!processedSection.palettes.mod[voxelId].isRegistered(voxelMod))
160
+ processedSection.palettes.mod[voxelId].register(voxelMod);
161
+ for (let l = 0; l < lightSegments.length; l++) {
162
+ const segment = lightSegments[l];
163
+ const light = lightSemgnetGet[segment](section.light[i]);
164
+ if (light != firstLightLevels[segment])
165
+ processedSection.light[segment].allTheSame = false;
166
+ processedSection.light[segment].value = light;
167
+ const voxelLight = !sectorPalettes.light[segment].isRegistered(light)
168
+ ? sectorPalettes.light[segment].register(light)
169
+ : sectorPalettes.light[segment].getId(light);
170
+ if (!processedSection.palettes.light[segment].isRegistered(light))
171
+ processedSection.palettes.light[segment].register(light);
172
+ processedSection.light[segment].buffer[i] = voxelLight;
173
+ }
174
+ if (section.ids[i] != firstId)
175
+ processedSection.ids.allTheSame = false;
176
+ if (section.level[i] != firstLevel)
177
+ processedSection.level.allTheSame = false;
178
+ if (section.state[i] != firstState)
179
+ processedSection.state.allTheSame = false;
180
+ if (section.mod[i] != firstMod)
181
+ processedSection.mod.allTheSame = false;
182
+ if (section.secondary[i] != firstSecondary)
183
+ processedSection.secondary.allTheSame = false;
184
+ processedSection.ids.buffer[i] = voxelId;
185
+ processedSection.level.buffer[i] = voxelLevel;
186
+ processedSection.state.buffer[i] = voxelState;
187
+ processedSection.mod.buffer[i] = voxelMod;
188
+ processedSection.secondary.buffer[i] = voxelSecondary;
230
189
  }
231
- processedSections.push(processedSection);
190
+ processedSections[sectionIndex] = processedSection;
191
+ }
192
+ let neededPalettes = {
193
+ level: false,
194
+ light: {
195
+ sun: false,
196
+ red: false,
197
+ green: false,
198
+ blue: false,
199
+ },
200
+ };
201
+ for (const state of sectorPalettes.stateMap) {
202
+ if (!state)
203
+ continue;
204
+ if (state.palette.size > sectorPalettes.maxStatePaletteSize)
205
+ sectorPalettes.maxStatePaletteSize = state.palette.size;
232
206
  }
233
- for (const section of processedSections) {
234
- const reMapIds = section.palettes.ids.size < sectorPalettes.ids.size &&
235
- section.palettes.ids.size <= 255 &&
236
- !section.idsAllTheSame;
237
- const reMapLevel = section.palettes.level.size < sectorPalettes.level.size &&
238
- section.palettes.level.size <= 255 &&
239
- !section.levelAllTheSame;
240
- const reMapState = section.palettes.state.size < sectorPalettes.state.size &&
241
- section.palettes.state.size <= 255 &&
242
- !section.stateAllTheSame;
243
- const reMapMod = section.palettes.mod.size < sectorPalettes.mod.size &&
244
- section.palettes.mod.size <= 255 &&
245
- !section.modAllTheSame;
246
- const reMapLight = section.palettes.light.size < sectorPalettes.light.size &&
247
- section.palettes.light.size <= 255 &&
248
- !section.lightAllTheSame;
249
- const reMapSecondary = Math.max(section.palettes.secondaryId.size, section.palettes.secondaryState.size) <
250
- Math.max(sectorPalettes.secondaryState.size, sectorPalettes.secondaryId.size) &&
251
- Math.max(section.palettes.secondaryId.size, section.palettes.secondaryState.size) <= 255 &&
252
- !section.secondaryAllTheSame;
253
- section.isLightPaletted =
254
- sectorPalettes.light.size < 65_535 && section.palettes.light.size < 255;
255
- section.isLevelPaletted =
256
- sectorPalettes.level.size < 255 && section.palettes.level.size < 255;
257
- section.isStatePaletted =
258
- sectorPalettes.state.size < 65_535 && section.palettes.state.size < 255;
259
- section.isModPaletted =
260
- sectorPalettes.mod.size < 65_535 && section.palettes.mod.size < 255;
261
- section.isSecondaryPaletted =
262
- sectorPalettes.secondaryState.size < 65_535 &&
263
- section.palettes.secondaryState.size < 255 &&
264
- section.palettes.secondaryId.size < 255;
265
- section.remappedIds = reMapIds;
266
- section.remappedLight = reMapLight && section.isLightPaletted;
267
- section.remappedState = reMapState && section.isStatePaletted;
268
- section.remappedMod = reMapMod && section.isModPaletted;
269
- section.remappedSecondary = reMapSecondary && section.isSecondaryPaletted;
270
- if (!reMapIds && !reMapLight && !reMapSecondary && !reMapState)
207
+ for (const mod of sectorPalettes.modMap) {
208
+ if (!mod)
271
209
  continue;
272
- const length = section.section.ids.length;
210
+ if (mod.palette.size > sectorPalettes.maxModPaletteSize)
211
+ sectorPalettes.maxModPaletteSize = mod.palette.size;
212
+ }
213
+ for (const archivedSection of processedSections) {
214
+ for (const stateId in archivedSection.palettes.state) {
215
+ const state = archivedSection.palettes.state[stateId];
216
+ if (!state)
217
+ continue;
218
+ if (state.size > archivedSection.palettes.maxStatePaletteSize)
219
+ archivedSection.palettes.maxStatePaletteSize = state.size;
220
+ }
221
+ for (const modId in archivedSection.palettes.mod) {
222
+ const mod = archivedSection.palettes.state[modId];
223
+ if (!mod)
224
+ continue;
225
+ if (mod.size > archivedSection.palettes.maxModPaletteSize)
226
+ archivedSection.palettes.maxModPaletteSize = mod.size;
227
+ }
228
+ //ids
229
+ archivedSection.ids.isPaletted =
230
+ sectorPalettes.ids.size <= BinaryBuffer.ByteArrayMax ||
231
+ archivedSection.palettes.ids.size <= BinaryBuffer.ByteArrayMax;
232
+ archivedSection.ids.remapped =
233
+ sectorPalettes.ids.size > BinaryBuffer.ByteArrayMax &&
234
+ archivedSection.palettes.ids.size <= BinaryBuffer.ByteArrayMax &&
235
+ !archivedSection.ids.allTheSame;
236
+ //level
237
+ archivedSection.level.isPaletted =
238
+ sectorPalettes.level.size <= BinaryBuffer.NibbleArrayMax &&
239
+ archivedSection.palettes.level.size <= BinaryBuffer.NibbleArrayMax;
240
+ archivedSection.level.remapped =
241
+ sectorPalettes.level.size > BinaryBuffer.NibbleArrayMax &&
242
+ archivedSection.palettes.level.size <= BinaryBuffer.NibbleArrayMax &&
243
+ !archivedSection.level.allTheSame;
244
+ if (archivedSection.level.isPaletted && !archivedSection.level.remapped) {
245
+ neededPalettes.level = true;
246
+ }
247
+ //state
248
+ archivedSection.state.isPaletted =
249
+ sectorPalettes.maxStatePaletteSize <= BinaryBuffer.ByteArrayMax ||
250
+ archivedSection.palettes.maxStatePaletteSize <= BinaryBuffer.ByteArrayMax;
251
+ archivedSection.state.remapped =
252
+ sectorPalettes.maxStatePaletteSize > BinaryBuffer.ByteArrayMax &&
253
+ archivedSection.palettes.maxStatePaletteSize <=
254
+ BinaryBuffer.ByteArrayMax &&
255
+ !archivedSection.state.allTheSame;
256
+ //mod
257
+ archivedSection.mod.isPaletted =
258
+ sectorPalettes.maxModPaletteSize <= BinaryBuffer.ByteArrayMax ||
259
+ archivedSection.palettes.maxModPaletteSize <= BinaryBuffer.ByteArrayMax;
260
+ archivedSection.mod.remapped =
261
+ sectorPalettes.maxModPaletteSize > BinaryBuffer.ByteArrayMax &&
262
+ archivedSection.palettes.maxModPaletteSize <= BinaryBuffer.ByteArrayMax &&
263
+ !archivedSection.mod.allTheSame;
264
+ for (const semgnet of lightSegments) {
265
+ archivedSection.light[semgnet].isPaletted =
266
+ sectorPalettes.light[semgnet].size <= BinaryBuffer.HalfNibbleArrayMax ||
267
+ archivedSection.palettes.light[semgnet].size <=
268
+ BinaryBuffer.HalfNibbleArrayMax;
269
+ archivedSection.light[semgnet].remapped =
270
+ sectorPalettes.light[semgnet].size > BinaryBuffer.HalfNibbleArrayMax &&
271
+ archivedSection.palettes.light[semgnet].size <=
272
+ BinaryBuffer.HalfNibbleArrayMax &&
273
+ !archivedSection.light[semgnet].allTheSame;
274
+ if (archivedSection.light[semgnet].isPaletted &&
275
+ !archivedSection.light[semgnet].remapped) {
276
+ neededPalettes.light[semgnet] = true;
277
+ }
278
+ }
279
+ //secondary
280
+ archivedSection.secondary.isPaletted =
281
+ (sectorPalettes.secondaryValue.size <= BinaryBuffer.ByteArrayMax &&
282
+ sectorPalettes.secondaryId.size <= BinaryBuffer.ByteArrayMax) ||
283
+ (archivedSection.palettes.secondaryValue.size <=
284
+ BinaryBuffer.ByteArrayMax &&
285
+ archivedSection.palettes.secondaryId.size <= BinaryBuffer.ByteArrayMax);
286
+ archivedSection.secondary.remapped =
287
+ Math.max(sectorPalettes.secondaryValue.size, sectorPalettes.secondaryId.size) > BinaryBuffer.ByteArrayMax &&
288
+ Math.max(archivedSection.palettes.secondaryId.size, archivedSection.palettes.secondaryValue.size) <= BinaryBuffer.ByteArrayMax &&
289
+ !archivedSection.secondary.allTheSame;
290
+ if (!archivedSection.ids.remapped &&
291
+ !archivedSection.light.sun.remapped &&
292
+ !archivedSection.light.red.remapped &&
293
+ !archivedSection.light.green.remapped &&
294
+ !archivedSection.light.blue.remapped &&
295
+ !archivedSection.secondary.remapped &&
296
+ !archivedSection.mod.remapped &&
297
+ !archivedSection.level.remapped)
298
+ continue;
299
+ const length = archivedSection.original.ids.length;
273
300
  for (let i = 0; i < length; i++) {
274
- if (reMapIds)
275
- section.ids[i] = section.palettes.ids.getId(section.ids[i]);
276
- if (reMapLight)
277
- section.light[i] = section.palettes.light.getId(section.section.light[i]);
278
- if (reMapLevel)
279
- section.level[i] = section.palettes.level.getId(section.section.level[i]);
280
- if (reMapState)
281
- section.state[i] = section.palettes.state.getId(sectorPalettes.state.getId(section.section.state[i]));
282
- if (reMapMod)
283
- section.mod[i] = section.palettes.mod.getId(sectorPalettes.mod.getId(section.section.mod[i]));
284
- if (reMapSecondary)
285
- section.secondary[i] = VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"]
286
- ? section.palettes.secondaryId.getId(section.secondary[i])
287
- : section.palettes.secondaryState.getId(section.secondary[i]);
301
+ let secondary = false;
302
+ if (VoxelTagsRegister.VoxelTags[archivedSection.original.ids[i]]["dve_can_have_secondary"] &&
303
+ archivedSection.original.secondary[i] !== 0) {
304
+ secondary = true;
305
+ }
306
+ let stateId = !secondary
307
+ ? archivedSection.ids.buffer[i]
308
+ : archivedSection.secondary.buffer[i];
309
+ if (archivedSection.state.remapped)
310
+ archivedSection.state.buffer[i] = archivedSection.palettes.state[stateId].getId(sectorPalettes.stateMap[stateId].palette.getId(archivedSection.state.buffer[i]));
311
+ if (archivedSection.mod.remapped)
312
+ archivedSection.mod.buffer[i] = archivedSection.palettes.mod[stateId].getId(sectorPalettes.modMap[archivedSection.ids.buffer[i]].palette.getId(stateId));
313
+ if (archivedSection.ids.remapped)
314
+ archivedSection.ids.buffer[i] =
315
+ archivedSection.palettes.ids.getId(stateId);
316
+ for (let l = 0; l < lightSegments.length; l++) {
317
+ const segment = lightSegments[l];
318
+ if (archivedSection.light[segment].remapped) {
319
+ archivedSection.light[segment].buffer[i] =
320
+ archivedSection.palettes.light[segment].getId(lightSemgnetGet[segment](archivedSection.original.light[i]));
321
+ }
322
+ }
323
+ if (archivedSection.level.remapped)
324
+ archivedSection.level.buffer[i] = archivedSection.palettes.level.getId(archivedSection.original.level[i]);
325
+ if (archivedSection.secondary.remapped)
326
+ archivedSection.secondary.buffer[i] = secondary
327
+ ? archivedSection.palettes.secondaryId.getId(archivedSection.secondary.buffer[i])
328
+ : archivedSection.palettes.secondaryValue.getId(archivedSection.secondary.buffer[i]);
329
+ }
330
+ }
331
+ const palettes = {
332
+ id: sectorPalettes.ids._palette,
333
+ stateMap: [],
334
+ secondaryStateMap: [],
335
+ modMap: [],
336
+ secondaryModMap: [],
337
+ light: {},
338
+ secondaryId: sectorPalettes.secondaryId._palette,
339
+ secondaryValue: new Uint16Array(sectorPalettes.secondaryValue._palette),
340
+ };
341
+ const stateMap = palettes.stateMap;
342
+ for (let i = 0; i < sectorPalettes.stateMap.length; i++) {
343
+ const states = sectorPalettes.stateMap[i]?.palette;
344
+ if (!states)
345
+ continue;
346
+ const voxelId = sectorPalettes.ids._palette[i];
347
+ if (!SchemaRegister.hasVoxelSchema(voxelId))
348
+ continue;
349
+ const schema = SchemaRegister.getVoxelSchemas(voxelId);
350
+ const voxelStates = [];
351
+ stateMap[i] = voxelStates;
352
+ for (let k = 0; k < states._palette.length; k++) {
353
+ voxelStates[k] = schema.state.getStateObject(states._palette[k]);
288
354
  }
289
355
  }
290
- const stateMap = {};
291
- for (let i = 0; i < sectorPalettes.state._palette.length; i++) {
292
- const state = sectorPalettes.state._palette[i];
293
- const voxelId = VoxelPalettesRegister.voxels.getStringId(sectorPalettes.stateIdMap[i]);
356
+ const secondaryStateMap = palettes.secondaryStateMap;
357
+ for (let i = 0; i < sectorPalettes.secondaryStateMap.length; i++) {
358
+ const states = sectorPalettes.secondaryStateMap[i]?.palette;
359
+ if (!states)
360
+ continue;
361
+ const voxelId = sectorPalettes.secondaryId._palette[i];
294
362
  if (!SchemaRegister.hasVoxelSchema(voxelId))
295
363
  continue;
296
364
  const schema = SchemaRegister.getVoxelSchemas(voxelId);
297
- stateMap[i] = schema.state.getStateObject(state);
365
+ const voxelStates = [];
366
+ secondaryStateMap[i] = voxelStates;
367
+ for (let k = 0; k < states._palette.length; k++) {
368
+ voxelStates[k] = schema.state.getStateObject(states._palette[k]);
369
+ }
298
370
  }
299
- const modMap = {};
300
- for (let i = 0; i < sectorPalettes.mod._palette.length; i++) {
301
- const mod = sectorPalettes.mod._palette[i];
302
- const voxelId = VoxelPalettesRegister.voxels.getStringId(sectorPalettes.modIdMap[i]);
371
+ const modMap = palettes.modMap;
372
+ for (let i = 0; i < sectorPalettes.modMap.length; i++) {
373
+ const mods = sectorPalettes.modMap[i]?.palette;
374
+ if (!mods)
375
+ continue;
376
+ const voxelId = sectorPalettes.ids._palette[i];
303
377
  if (!SchemaRegister.hasVoxelSchema(voxelId))
304
378
  continue;
305
379
  const schema = SchemaRegister.getVoxelSchemas(voxelId);
306
- modMap[i] = schema.mod.getStateObject(mod);
380
+ const voxelMods = [];
381
+ modMap[i] = voxelMods;
382
+ for (let k = 0; k < mods._palette.length; k++) {
383
+ voxelMods[k] = schema.mod.getStateObject(mods._palette[k]);
384
+ }
385
+ }
386
+ const secondaryModMap = palettes.modMap;
387
+ for (let i = 0; i < sectorPalettes.secondaryModMap.length; i++) {
388
+ const mods = sectorPalettes.secondaryModMap[i]?.palette;
389
+ if (!mods)
390
+ continue;
391
+ const voxelId = sectorPalettes.secondaryId._palette[i];
392
+ if (!SchemaRegister.hasVoxelSchema(voxelId))
393
+ continue;
394
+ const schema = SchemaRegister.getVoxelSchemas(voxelId);
395
+ const voxelMods = [];
396
+ secondaryModMap[i] = voxelMods;
397
+ for (let k = 0; k < mods._palette.length; k++) {
398
+ voxelMods[k] = schema.mod.getStateObject(mods._palette[k]);
399
+ }
307
400
  }
308
401
  const sections = [];
309
- for (const section of processedSections) {
310
- sections.push(GetArchivedSection(section, sectorPalettes));
402
+ for (let sectionIndex = 0; sectionIndex < processedSections.length; sectionIndex++) {
403
+ sections[sectionIndex] = CreateArchivedSection(processedSections[sectionIndex], sectorPalettes);
311
404
  }
312
- const palettes = {
313
- id: sectorPalettes.ids._palette,
314
- stateMap,
315
- modMap,
316
- state: new Uint16Array(sectorPalettes.state._palette),
317
- mod: new Uint16Array(sectorPalettes.mod._palette),
318
- };
319
- if (sectorPalettes.light.size < 255)
320
- palettes.light = new Uint16Array(sectorPalettes.light._palette);
321
- if (sectorPalettes.level.size < 255)
405
+ if (neededPalettes.level) {
322
406
  palettes.level = new Uint8Array(sectorPalettes.level._palette);
323
- if (sectorPalettes.light.size < 255)
324
- palettes.light = new Uint16Array(sectorPalettes.light._palette);
325
- if (sectorPalettes.secondaryId.size > 0)
326
- palettes.secondaryId = sectorPalettes.secondaryId._palette;
327
- if (sectorPalettes.secondaryState.size < 255)
328
- palettes.secondaryState = new Uint16Array(sectorPalettes.secondaryState._palette);
329
- return {
407
+ }
408
+ for (const segment of lightSegments) {
409
+ if (neededPalettes.light[segment]) {
410
+ palettes.light[segment] = new Uint8Array(sectorPalettes.light[segment]._palette);
411
+ }
412
+ }
413
+ const archivedSector = {
330
414
  version: "",
331
- location: [...archiveData.location],
332
- sectorState: {},
415
+ vloxVersion: EngineSettings.version,
416
+ dimension: WorldRegister.dimensions.get(archiveData.location[0]).id,
417
+ location: [
418
+ archiveData.location[1],
419
+ archiveData.location[2],
420
+ archiveData.location[3],
421
+ ],
422
+ flags: sector.storeFlags(),
423
+ timestamps: sector.storeTimestamps(),
333
424
  buffers: {},
334
- keys: {
335
- sectionState: [],
336
- },
337
425
  palettes,
426
+ duplicates: {},
338
427
  sections,
339
428
  };
429
+ RemoveDuplicates(archivedSector);
430
+ return archivedSector;
340
431
  }