@divinevoxel/vlox 0.0.73 → 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 (217) 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 +1 -0
  4. package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -0
  5. package/Init/StartConstructor.js +2 -0
  6. package/Math/index.d.ts +5 -1
  7. package/Mesher/Functions/CompactVoxelSectionMesh.d.ts +4 -0
  8. package/Mesher/Functions/CompactVoxelSectionMesh.js +112 -0
  9. package/Mesher/Functions/MeshSection.d.ts +1 -1
  10. package/Mesher/Functions/MeshSection.js +15 -22
  11. package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
  12. package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
  13. package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +1 -1
  14. package/Mesher/Geomtry/VoxelGeometryBuilder.js +118 -197
  15. package/Mesher/Geomtry/VoxelMesh.js +2 -2
  16. package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +8 -70
  17. package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +18 -183
  18. package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
  19. package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
  20. package/Mesher/Geomtry/VoxelMeshBuffers.js +2 -2
  21. package/Mesher/InitTask.js +5 -1
  22. package/Mesher/Models/Common/BoxGeometryNode.js +7 -7
  23. package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
  24. package/Mesher/Models/Common/Calc/CalcConstants.js +1 -1
  25. package/Mesher/Models/Common/QuadGeometryNode.js +2 -2
  26. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +7 -7
  27. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +22 -25
  28. package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +2 -2
  29. package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +2 -2
  30. package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +2 -2
  31. package/Mesher/Models/VoxelConstructor.d.ts +3 -3
  32. package/Mesher/Models/VoxelConstructor.js +8 -8
  33. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +2 -2
  34. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -9
  35. package/Mesher/Models/VoxelModelBuilder.js +1 -8
  36. package/Mesher/Types/Mesher.types.d.ts +1 -0
  37. package/Models/Defaults/CubeVoxelModels.js +16 -39
  38. package/Models/Defaults/LiquidVoxelModel.js +3 -3
  39. package/Models/Defaults/PanelVoxelModels.js +10 -36
  40. package/Models/Defaults/StairVoxelModel.js +6 -21
  41. package/Models/Examples.js +23 -44
  42. package/Models/Rules/Classes/VoxelRulesModel.d.ts +1 -1
  43. package/Models/Rules/Classes/VoxelRulesModel.js +3 -3
  44. package/Models/Rules/Functions/BuildFinalInputs.d.ts +1 -1
  45. package/Models/Rules/Functions/BuildFinalInputs.js +13 -13
  46. package/Models/Rules/VoxelModelRuleBuilderRegister.js +8 -8
  47. package/Models/VoxelModel.types.d.ts +3 -3
  48. package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
  49. package/Renderer/InitTasks.js +1 -9
  50. package/Renderer/MeshManager.d.ts +1 -1
  51. package/Renderer/MeshManager.js +24 -23
  52. package/Renderer/MeshRegister.d.ts +5 -5
  53. package/Renderer/MeshRegister.js +2 -2
  54. package/Settings/EngineSettings.d.ts +1 -0
  55. package/Settings/EngineSettings.js +6 -3
  56. package/Settings/EngineSettings.types.d.ts +7 -21
  57. package/Settings/EngineSettings.types.js +6 -14
  58. package/Tasks/Logic/InitTasks.d.ts +1 -0
  59. package/Tasks/Logic/InitTasks.js +10 -0
  60. package/Tasks/Logic/VoxelLogicUpdate.d.ts +3 -0
  61. package/Tasks/Logic/VoxelLogicUpdate.js +71 -0
  62. package/Tasks/Propagation/Explosion/ExplosionManager.d.ts +2 -2
  63. package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -2
  64. package/Tasks/Propagation/Flow/FlowManager.d.ts +4 -4
  65. package/Tasks/Propagation/Flow/FlowRemove.d.ts +2 -2
  66. package/Tasks/Propagation/Flow/FlowUpdate.d.ts +2 -2
  67. package/Tasks/Propagation/Flow/WorldFlow.d.ts +2 -2
  68. package/Tasks/Propagation/Illumanation/RGBUpdate.d.ts +3 -3
  69. package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +3 -3
  70. package/Tasks/Propagation/Illumanation/WorldRGB.d.ts +2 -2
  71. package/Tasks/Propagation/Illumanation/WorldSun.d.ts +2 -2
  72. package/Tasks/Propagation/Illumanation/WorldSun.js +8 -15
  73. package/Tasks/Propagation/InitTasks.js +4 -4
  74. package/Tasks/Propagation/Power/PowerUpdate.d.ts +3 -0
  75. package/Tasks/Propagation/Power/PowerUpdate.js +80 -0
  76. package/Tasks/Tasks.types.d.ts +2 -2
  77. package/Tasks/TasksIds.d.ts +2 -1
  78. package/Tasks/TasksIds.js +1 -0
  79. package/Tasks/Update/Common.d.ts +3 -0
  80. package/Tasks/Update/Common.js +41 -0
  81. package/Tasks/Update/EreaseUpdate.d.ts +3 -0
  82. package/Tasks/Update/EreaseUpdate.js +66 -0
  83. package/Tasks/Update/InitTasks.d.ts +2 -2
  84. package/Tasks/Update/InitTasks.js +3 -1
  85. package/Tasks/Update/PaintUpdate.d.ts +3 -0
  86. package/Tasks/Update/PaintUpdate.js +89 -0
  87. package/Tasks/Update/VoxelUpdate.d.ts +2 -5
  88. package/Tasks/Update/VoxelUpdate.js +5 -147
  89. package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +15 -7
  90. package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +20 -7
  91. package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
  92. package/Tasks/WorldGeneration/WorldGenBrush.js +2 -2
  93. package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
  94. package/Templates/Functions/CreateTemplate.d.ts +1 -1
  95. package/Tools/Brush/AdvancedBrushTool.js +1 -1
  96. package/Tools/Brush/Brush.d.ts +2 -2
  97. package/Tools/Brush/Brush.js +1 -1
  98. package/Tools/Tasks/TasksTool.d.ts +1 -0
  99. package/Tools/Tasks/TasksTool.js +2 -0
  100. package/Util/Binary/BinaryBuffer.d.ts +17 -11
  101. package/Util/Binary/BinaryBuffer.js +65 -59
  102. package/Util/Binary/BinaryTree.d.ts +46 -0
  103. package/Util/Binary/BinaryTree.js +104 -0
  104. package/Voxels/Cursor/VoxelCursor.interface.d.ts +7 -2
  105. package/Voxels/Cursor/VoxelCursor.interface.js +46 -2
  106. package/Voxels/Cursor/VoxelLightData.js +1 -1
  107. package/Voxels/Data/VoxelTag.types.d.ts +17 -2
  108. package/Voxels/Data/VoxelTag.types.js +6 -1
  109. package/Voxels/Data/VoxelTagsRegister.js +5 -0
  110. package/Voxels/Functions/BuildStateData.d.ts +6 -6
  111. package/Voxels/Functions/BuildStateData.js +31 -31
  112. package/Voxels/Functions/BuildTagAndPaletteData.js +5 -0
  113. package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
  114. package/Voxels/Indexes/VoxelIndex.js +16 -18
  115. package/Voxels/InitVoxelData.js +12 -8
  116. package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.d.ts +5 -0
  117. package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.js +6 -0
  118. package/Voxels/Logic/Classes/VoxelLogic.d.ts +11 -0
  119. package/Voxels/Logic/Classes/VoxelLogic.js +49 -0
  120. package/Voxels/Logic/Classes/VoxelLogicType.d.ts +4 -0
  121. package/Voxels/Logic/Classes/VoxelLogicType.js +2 -0
  122. package/Voxels/Logic/VoxelLogic.types.d.ts +23 -0
  123. package/Voxels/Logic/VoxelLogic.types.js +1 -0
  124. package/Voxels/Logic/VoxelLogicRegister.d.ts +9 -0
  125. package/Voxels/Logic/VoxelLogicRegister.js +15 -0
  126. package/Voxels/State/SchemaRegister.js +10 -5
  127. package/Voxels/State/State.types.d.ts +1 -1
  128. package/Voxels/State/StateTreeReader.d.ts +1 -1
  129. package/Voxels/State/StateTreeReader.js +2 -3
  130. package/Voxels/Types/Voxel.types.d.ts +3 -0
  131. package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
  132. package/World/Archive/Archive.types.d.ts +31 -12
  133. package/World/Archive/Classes/ArchiveClasses.d.ts +66 -0
  134. package/World/Archive/Classes/ArchiveClasses.js +78 -0
  135. package/World/Archive/Classes/ImportedSection.d.ts +40 -0
  136. package/World/Archive/Classes/ImportedSection.js +307 -0
  137. package/World/Archive/Classes/ImportedSector.d.ts +23 -0
  138. package/World/Archive/Classes/ImportedSector.js +97 -0
  139. package/World/Archive/Functions/ArchiveArea.d.ts +1 -1
  140. package/World/Archive/Functions/ArchiveArea.js +39 -36
  141. package/World/Archive/Functions/ArchiveSector.js +210 -404
  142. package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
  143. package/World/Archive/Functions/CreateArchivedSection.js +207 -0
  144. package/World/Archive/Functions/ImportSector.d.ts +1 -3
  145. package/World/Archive/Functions/ImportSector.js +13 -244
  146. package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
  147. package/World/Archive/Functions/RemoveDuplicates.js +92 -0
  148. package/World/Archive/Functions/Shared.d.ts +2 -2
  149. package/World/Archive/Functions/Shared.js +15 -40
  150. package/World/Archive/InitTasks.js +7 -10
  151. package/World/Cursor/SectionCursor.d.ts +1 -1
  152. package/World/Cursor/SectorCursor.d.ts +1 -1
  153. package/World/Cursor/WorldCursor.d.ts +4 -3
  154. package/World/Cursor/WorldCursor.js +16 -13
  155. package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
  156. package/World/Cursor/WorldVoxelCursor.js +23 -14
  157. package/World/Dimension/Dimension.d.ts +4 -1
  158. package/World/Dimension/Dimension.js +8 -1
  159. package/World/Section/Section.d.ts +17 -4
  160. package/World/Section/Section.js +68 -6
  161. package/World/Section/SectionState.d.ts +4 -2
  162. package/World/Section/SectionState.js +4 -2
  163. package/World/Sector/Sector.d.ts +7 -1
  164. package/World/Sector/Sector.js +37 -4
  165. package/World/Sector/SectorState.d.ts +3 -2
  166. package/World/Sector/SectorState.js +3 -2
  167. package/World/Types/WorldData.types.d.ts +2 -7
  168. package/World/WorldRegister.d.ts +9 -9
  169. package/World/WorldRegister.js +9 -6
  170. package/World/WorldSpaces.js +6 -6
  171. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
  172. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +6 -4
  173. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +9 -5
  174. package/WorldSimulation/Internal/Classes/Queues/BuildQueue.d.ts +5 -0
  175. package/WorldSimulation/Internal/Classes/Queues/BuildQueue.js +6 -0
  176. package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.d.ts +5 -0
  177. package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.js +6 -0
  178. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.js +1 -1
  179. package/WorldSimulation/Internal/Classes/TickQueue.d.ts +12 -0
  180. package/{Tasks/IWG/Internal/Classes/BuildQueue.js → WorldSimulation/Internal/Classes/TickQueue.js} +16 -7
  181. package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
  182. package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +6 -6
  183. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.js +9 -9
  184. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.d.ts +1 -1
  185. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.js +4 -4
  186. package/WorldSimulation/Internal/Functions/runTickUpdate.d.ts +2 -0
  187. package/{Tasks/IWG/Internal/Functions/runBuildUpdate.js → WorldSimulation/Internal/Functions/runTickUpdate.js} +29 -19
  188. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.js +13 -13
  189. package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.d.ts +2 -2
  190. package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.js +1 -1
  191. package/WorldSimulation/Internal/WorldSimulationDimensions.d.ts +6 -0
  192. package/{Tasks/IWG/Internal/IWGDimensions.js → WorldSimulation/Internal/WorldSimulationDimensions.js} +1 -1
  193. package/WorldSimulation/Internal/WorldSimulationTasks.d.ts +30 -0
  194. package/{Tasks/IWG/Internal/IWGTasks.js → WorldSimulation/Internal/WorldSimulationTasks.js} +14 -14
  195. package/WorldSimulation/Internal/WorldSimulationTools.d.ts +8 -0
  196. package/{Tasks/IWG/Internal/IWGTools.js → WorldSimulation/Internal/WorldSimulationTools.js} +1 -1
  197. package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.d.ts +1 -1
  198. package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.js +11 -11
  199. package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.js +5 -5
  200. package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +5 -5
  201. package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +21 -21
  202. package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
  203. package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
  204. package/package.json +1 -1
  205. package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +0 -11
  206. package/Tasks/IWG/Internal/Classes/IWGTaskBase.d.ts +0 -15
  207. package/Tasks/IWG/Internal/Functions/runBuildUpdate.d.ts +0 -2
  208. package/Tasks/IWG/Internal/IWGDimensions.d.ts +0 -6
  209. package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -30
  210. package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
  211. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.js +0 -0
  212. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.d.ts +0 -0
  213. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.js +0 -0
  214. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.d.ts +0 -0
  215. /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.d.ts +0 -0
  216. /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.d.ts +0 -0
  217. /package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.d.ts +0 -0
@@ -1,90 +1,96 @@
1
1
  import { getBitArrayIndex, getHalfNibbleArrayIndex, getNibbleArrayIndex, setBitArrayIndex, setHalfNibbleArrayIndex, setNibbleArrayIndex, } from "./BinaryArrays";
2
- const excludeStore = ["16-bit", "8-bit", "value"];
2
+ export var BinaryBufferTypes;
3
+ (function (BinaryBufferTypes) {
4
+ BinaryBufferTypes[BinaryBufferTypes["Value"] = 0] = "Value";
5
+ BinaryBufferTypes[BinaryBufferTypes["BitArray"] = 1] = "BitArray";
6
+ BinaryBufferTypes[BinaryBufferTypes["HalfNibbleArray"] = 2] = "HalfNibbleArray";
7
+ BinaryBufferTypes[BinaryBufferTypes["NibbleArray"] = 4] = "NibbleArray";
8
+ BinaryBufferTypes[BinaryBufferTypes["ByteArray"] = 8] = "ByteArray";
9
+ BinaryBufferTypes[BinaryBufferTypes["ShortArray"] = 16] = "ShortArray";
10
+ })(BinaryBufferTypes || (BinaryBufferTypes = {}));
3
11
  export class BinaryBuffer {
4
- static BytePaletteMax = 256;
5
- static NibblePaletteMax = 16;
6
- static HalfNibblePaletteMax = 4;
7
- static BitPaletteMax = 2;
12
+ static ByteArrayMax = 256;
13
+ static NibbleArrayMax = 16;
14
+ static HalfNibbleArrayMax = 4;
15
+ static BitArrayMax = 2;
8
16
  static DetermineSubByteArray = (paletteSize) => {
9
- if (paletteSize == BinaryBuffer.BitPaletteMax)
10
- return "1-bit";
11
- if (paletteSize > BinaryBuffer.BitPaletteMax &&
12
- paletteSize <= BinaryBuffer.HalfNibblePaletteMax)
13
- return "2-bit";
14
- if (paletteSize > BinaryBuffer.HalfNibblePaletteMax &&
15
- paletteSize <= BinaryBuffer.NibblePaletteMax)
16
- return "4-bit";
17
- if (paletteSize > BinaryBuffer.NibblePaletteMax &&
18
- paletteSize <= BinaryBuffer.BytePaletteMax)
19
- return "8-bit";
17
+ if (paletteSize == BinaryBuffer.BitArrayMax)
18
+ return BinaryBufferTypes.BitArray;
19
+ if (paletteSize > BinaryBuffer.BitArrayMax &&
20
+ paletteSize <= BinaryBuffer.HalfNibbleArrayMax)
21
+ return BinaryBufferTypes.HalfNibbleArray;
22
+ if (paletteSize > BinaryBuffer.HalfNibbleArrayMax &&
23
+ paletteSize <= BinaryBuffer.NibbleArrayMax)
24
+ return BinaryBufferTypes.NibbleArray;
25
+ if (paletteSize > BinaryBuffer.NibbleArrayMax &&
26
+ paletteSize <= BinaryBuffer.ByteArrayMax)
27
+ return BinaryBufferTypes.ByteArray;
20
28
  return null;
21
29
  };
22
30
  static CreateBufferForType(type, length) {
23
- if (type == "16-bit")
31
+ if (type == BinaryBufferTypes.ShortArray)
24
32
  return new Uint16Array(length);
25
- if (type == "8-bit")
26
- return new Uint8Array(length);
27
- if (type == "1-bit")
28
- return new Uint8Array(length);
29
- if (type == "2-bit")
30
- return new Uint8Array(length);
31
- if (type == "4-bit")
32
- return new Uint8Array(length);
33
33
  return new Uint8Array(length);
34
34
  }
35
35
  static GetConvertedBufferSize(source, type) {
36
- if (type == "16-bit" || type == "8-bit")
36
+ if (type == BinaryBufferTypes.ShortArray ||
37
+ type == BinaryBufferTypes.ByteArray)
37
38
  return source.length;
38
- if (type == "1-bit")
39
+ if (type == BinaryBufferTypes.BitArray)
39
40
  return source.length / 8;
40
- if (type == "4-bit")
41
- return source.length / 2;
42
- if (type == "2-bit")
41
+ if (type == BinaryBufferTypes.HalfNibbleArray)
43
42
  return source.length / 4;
44
- if (type == "value")
43
+ if (type == BinaryBufferTypes.NibbleArray)
44
+ return source.length / 2;
45
+ if (type == BinaryBufferTypes.Value)
45
46
  return 1;
46
47
  return source.length;
47
48
  }
48
49
  static GetIndexLength(source, type) {
49
- if (type == "16-bit" || type == "8-bit")
50
+ if (type == BinaryBufferTypes.ShortArray ||
51
+ type == BinaryBufferTypes.ByteArray)
50
52
  return source.length;
51
- if (type == "1-bit")
53
+ if (type == BinaryBufferTypes.BitArray)
52
54
  return source.length * 8;
53
- if (type == "4-bit")
54
- return source.length * 2;
55
- if (type == "2-bit")
55
+ if (type == BinaryBufferTypes.HalfNibbleArray)
56
56
  return source.length * 4;
57
- if (type == "value")
57
+ if (type == BinaryBufferTypes.NibbleArray)
58
+ return source.length * 2;
59
+ if (type == BinaryBufferTypes.Value)
58
60
  return 1;
59
61
  return source.length;
60
62
  }
61
63
  static ReadBufferAtIndex(source, type, index) {
62
- if (type == "16-bit" || type == "8-bit")
64
+ if (type == BinaryBufferTypes.ShortArray ||
65
+ type == BinaryBufferTypes.ByteArray)
63
66
  return source[index];
64
- if (type == "1-bit")
67
+ if (type == BinaryBufferTypes.BitArray)
65
68
  return getBitArrayIndex(source, index);
66
- if (type == "4-bit")
69
+ if (type == BinaryBufferTypes.NibbleArray)
67
70
  return getNibbleArrayIndex(source, index);
68
- if (type == "2-bit")
71
+ if (type == BinaryBufferTypes.HalfNibbleArray)
69
72
  return getHalfNibbleArrayIndex(source, index);
70
73
  return source[index];
71
74
  }
72
75
  static SetBufferAtIndex(source, type, index, value) {
73
- if (type == "16-bit" || type == "8-bit") {
76
+ if (type == BinaryBufferTypes.ShortArray ||
77
+ type == BinaryBufferTypes.ByteArray) {
74
78
  return (source[index] = value);
75
79
  }
76
- if (type == "1-bit")
80
+ if (type == BinaryBufferTypes.BitArray)
77
81
  return setBitArrayIndex(source, index, value);
78
- if (type == "4-bit")
82
+ if (type == BinaryBufferTypes.NibbleArray)
79
83
  return setNibbleArrayIndex(source, index, value);
80
- if (type == "2-bit")
84
+ if (type == BinaryBufferTypes.HalfNibbleArray)
81
85
  return setHalfNibbleArrayIndex(source, index, value);
82
86
  return source[index];
83
87
  }
84
88
  static Convert(source, sourceType, destinationType) {
85
89
  if (sourceType == destinationType ||
86
- (sourceType == "16-bit" && destinationType == "8-bit") ||
87
- (sourceType == "8-bit" && destinationType == "16-bit")) {
90
+ (sourceType == BinaryBufferTypes.ShortArray &&
91
+ destinationType == BinaryBufferTypes.ByteArray) ||
92
+ (sourceType == BinaryBufferTypes.ByteArray &&
93
+ destinationType == BinaryBufferTypes.ShortArray)) {
88
94
  const destination = this.CreateBufferForType(destinationType, this.GetConvertedBufferSize(source, destinationType));
89
95
  destination.set(source);
90
96
  return destination;
@@ -99,32 +105,32 @@ export class BinaryBuffer {
99
105
  static Create(data) {
100
106
  return {
101
107
  buffer: 0,
108
+ type: BinaryBufferTypes.Value,
102
109
  ...data,
103
110
  };
104
111
  }
112
+ bufferView;
105
113
  constructor(data) {
106
114
  this.buffer = data.buffer;
107
- if (data.type) {
108
- this.type = data.type;
109
- }
110
- else {
111
- if (typeof data.buffer === "number")
112
- this.type = "value";
113
- if (data.buffer instanceof Uint16Array)
114
- this.type = "16-bit";
115
- if (data.buffer instanceof Uint8Array)
116
- this.type = "8-bit";
115
+ this.type = data.type;
116
+ if (typeof this.buffer !== "number") {
117
+ if (this.type == BinaryBufferTypes.ShortArray) {
118
+ this.bufferView = new Uint16Array(this.buffer);
119
+ }
120
+ else {
121
+ this.bufferView = new Uint8Array(this.buffer);
122
+ }
117
123
  }
118
124
  }
119
125
  getValue(index) {
120
126
  if (typeof this.buffer == "number")
121
127
  return this.buffer;
122
- return BinaryBuffer.ReadBufferAtIndex(this.buffer, this.type, index);
128
+ return BinaryBuffer.ReadBufferAtIndex(this.bufferView, this.type, index);
123
129
  }
124
130
  toJSON() {
125
131
  return {
126
132
  buffer: this.buffer,
127
- ...(excludeStore.includes(this.type) ? {} : { type: this.type }),
133
+ type: this.type,
128
134
  };
129
135
  }
130
136
  }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * A class to help with indexing a full flat binary tree defined by the number of levels it has.
3
+ */
4
+ export declare class FlatBinaryTreeIndex {
5
+ levels: number;
6
+ constructor(levels: number);
7
+ /** Gets the number of nodes at a level of the tree */
8
+ getLevelSize(level: number): number;
9
+ /**
10
+ * Gets the flat index of a node indexed by the level it's on and its relative index in that level.
11
+ */
12
+ getIndexAtLevel(level: number, node: number): number;
13
+ /**
14
+ * Gets the level and relative index of a node's flat index.
15
+ */
16
+ getLevelAndIndex(index: number): [level: number, relativeIndex: number];
17
+ /**
18
+ * Gets the flat left child of a node, where the node is indexed by its level and its relative index at that level.
19
+ * @returns -1 if no child exist
20
+ */
21
+ getLeftChildAtLevel(level: number, node: number): number;
22
+ /**
23
+ * Gets the flat right child of a node, where the node is indexed by its level and its relative index at that level.
24
+ * @returns -1 if no child exist
25
+ */
26
+ getRightChildAtLevel(level: number, node: number): number;
27
+ /**
28
+ * Gets the flat index of the parent of a node, where the node is indexed by its level and its relative index at that level.
29
+ * @returns -1 if level has no parent
30
+ */
31
+ getParentAtLevel(level: number, node: number): number;
32
+ /** Gets the flat index of the left child of the node.
33
+ * @returns -1 if no child exist
34
+ */
35
+ getLeftChild(node: number): number;
36
+ /** Gets the flat index of the right child of the node.
37
+ * @returns -1 if no child exist
38
+ */
39
+ getRightChild(node: number): number;
40
+ /** Gets the flat index of the parent of the node.
41
+ * @returns -1 if no parent exist
42
+ */
43
+ getParent(node: number): number;
44
+ /** Gets the total number of nodes in the tree */
45
+ getTotalSize(): number;
46
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * A class to help with indexing a full flat binary tree defined by the number of levels it has.
3
+ */
4
+ export class FlatBinaryTreeIndex {
5
+ levels;
6
+ constructor(levels) {
7
+ this.levels = levels;
8
+ }
9
+ /** Gets the number of nodes at a level of the tree */
10
+ getLevelSize(level) {
11
+ if (level < 0 || level >= this.levels) {
12
+ throw new Error("Invalid level");
13
+ }
14
+ return 1 << level; // Equivalent to 2^level
15
+ }
16
+ /**
17
+ * Gets the flat index of a node indexed by the level it's on and its relative index in that level.
18
+ */
19
+ getIndexAtLevel(level, node) {
20
+ if (level < 0 || level >= this.levels) {
21
+ throw new Error("Invalid level");
22
+ }
23
+ const levelSize = this.getLevelSize(level);
24
+ if (node < 0 || node >= levelSize) {
25
+ throw new Error("Invalid node index at the given level");
26
+ }
27
+ return (1 << level) - 1 + node;
28
+ }
29
+ /**
30
+ * Gets the level and relative index of a node's flat index.
31
+ */
32
+ getLevelAndIndex(index) {
33
+ const totalNodes = (1 << this.levels) - 1;
34
+ if (index < 0 || index >= totalNodes) {
35
+ throw new Error("Invalid node index");
36
+ }
37
+ const level = Math.floor(Math.log2(index + 1));
38
+ const firstIndexAtLevel = (1 << level) - 1;
39
+ const relativeIndex = index - firstIndexAtLevel;
40
+ return [level, relativeIndex];
41
+ }
42
+ /**
43
+ * Gets the flat left child of a node, where the node is indexed by its level and its relative index at that level.
44
+ * @returns -1 if no child exist
45
+ */
46
+ getLeftChildAtLevel(level, node) {
47
+ if (level + 1 >= this.levels) {
48
+ return -1;
49
+ }
50
+ const nodeIndex = this.getIndexAtLevel(level, node);
51
+ return this.getLeftChild(nodeIndex);
52
+ }
53
+ /**
54
+ * Gets the flat right child of a node, where the node is indexed by its level and its relative index at that level.
55
+ * @returns -1 if no child exist
56
+ */
57
+ getRightChildAtLevel(level, node) {
58
+ if (level + 1 >= this.levels) {
59
+ return -1;
60
+ }
61
+ const nodeIndex = this.getIndexAtLevel(level, node);
62
+ return this.getRightChild(nodeIndex);
63
+ }
64
+ /**
65
+ * Gets the flat index of the parent of a node, where the node is indexed by its level and its relative index at that level.
66
+ * @returns -1 if level has no parent
67
+ */
68
+ getParentAtLevel(level, node) {
69
+ if (level === 0) {
70
+ return -1;
71
+ }
72
+ const nodeIndex = this.getIndexAtLevel(level, node);
73
+ return this.getParent(nodeIndex);
74
+ }
75
+ /** Gets the flat index of the left child of the node.
76
+ * @returns -1 if no child exist
77
+ */
78
+ getLeftChild(node) {
79
+ const leftChildIndex = 2 * node + 1;
80
+ const totalNodes = (1 << this.levels) - 1;
81
+ return leftChildIndex < totalNodes ? leftChildIndex : -1;
82
+ }
83
+ /** Gets the flat index of the right child of the node.
84
+ * @returns -1 if no child exist
85
+ */
86
+ getRightChild(node) {
87
+ const rightChildIndex = 2 * node + 2;
88
+ const totalNodes = (1 << this.levels) - 1;
89
+ return rightChildIndex < totalNodes ? rightChildIndex : -1;
90
+ }
91
+ /** Gets the flat index of the parent of the node.
92
+ * @returns -1 if no parent exist
93
+ */
94
+ getParent(node) {
95
+ if (node === 0) {
96
+ return -1; // Root node has no parent
97
+ }
98
+ return Math.floor((node - 1) / 2);
99
+ }
100
+ /** Gets the total number of nodes in the tree */
101
+ getTotalSize() {
102
+ return (1 << this.levels) - 1; // Equivalent to 2^levels - 1
103
+ }
104
+ }
@@ -21,7 +21,7 @@ export declare abstract class VoxelCursorInterface {
21
21
  abstract mod: WritableArrayLike<number>;
22
22
  /**
23
23
  *
24
- * @param mode 0 for add 1 for remove 2 for the voxel needs a buried check only
24
+ * @param mode 0 for add 1 for remove 2 for the voxel needs a buried and logic check only
25
25
  */
26
26
  abstract updateVoxel(mode: 0 | 1 | 2): void;
27
27
  _lightData: VoxelLightData;
@@ -49,8 +49,13 @@ export declare abstract class VoxelCursorInterface {
49
49
  hasSunLight(): boolean;
50
50
  getLight(): number;
51
51
  setLight(light: number): this;
52
- isLightSource(): boolean;
52
+ isLightSource(): any;
53
+ doesVoxelAffectLogic(): boolean;
53
54
  getLightSourceValue(): number;
55
+ getPower(): number;
56
+ setPower(level: number): this;
57
+ isPowerSource(): boolean;
58
+ getPowerSourceValue(): number;
54
59
  noAO(): boolean;
55
60
  isRenderable(): boolean;
56
61
  isAir(): boolean;
@@ -4,12 +4,13 @@ import { VoxelTagStates } from "../Data/VoxelTagStates";
4
4
  import { VoxelTagIds, } from "../../Voxels/Data/VoxelTag.types";
5
5
  import { VoxelTagsRegister } from "../../Voxels/Data/VoxelTagsRegister";
6
6
  import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
7
+ import { VoxelLogicRegister } from "../../Voxels/Logic/VoxelLogicRegister";
7
8
  export class VoxelCursorInterface {
8
9
  _loadedId = 0;
9
10
  id = 0;
10
11
  secondaryId = 0;
11
- _tags;
12
- _substanceTags;
12
+ _tags = {};
13
+ _substanceTags = {};
13
14
  __secondary = false;
14
15
  // private _section: Section;
15
16
  _index = 0;
@@ -123,15 +124,58 @@ export class VoxelCursorInterface {
123
124
  isLightSource() {
124
125
  if (this._loadedId <= 0)
125
126
  return false;
127
+ if (VoxelLogicRegister.voxels[this._loadedId]?.hasTag(VoxelTagIds.isLightSource)) {
128
+ return VoxelLogicRegister.voxels[this._loadedId].getTagValue(VoxelTagIds.isLightSource, this);
129
+ }
126
130
  return VoxelTagStates.isRegistered(this._loadedId, VoxelTagIds.isLightSource)
127
131
  ? VoxelTagStates.getValue(this._loadedId, VoxelTagIds.isLightSource, this.getState()) === true
128
132
  : this._tags[VoxelTagIds.isLightSource];
129
133
  }
134
+ doesVoxelAffectLogic() {
135
+ if (this._tags["dve_can_be_powered"] ||
136
+ this._tags["dve_can_hold_power"] ||
137
+ this._tags["dve_can_carry_power"] ||
138
+ this._tags["dve_is_power_source"])
139
+ return true;
140
+ return false;
141
+ }
130
142
  getLightSourceValue() {
131
143
  if (this._loadedId <= 0)
132
144
  return 0;
133
145
  return this._tags[VoxelTagIds.lightValue];
134
146
  }
147
+ getPower() {
148
+ if (this._loadedId == 0)
149
+ return -1;
150
+ if (this._substanceTags["dve_is_liquid"])
151
+ return -1;
152
+ if (!this._tags["dve_can_carry_power"] &&
153
+ !this._tags["dve_can_hold_power"] &&
154
+ !this._tags["dve_can_be_powered"] &&
155
+ !this._tags["dve_is_power_source"])
156
+ return -1;
157
+ const level = VoxelLevelReader.getLevel(this.level[this._index]);
158
+ if (this._tags["dve_is_power_source"] &&
159
+ this._tags["dve_power_value"] > level)
160
+ return this._tags["dve_power_value"];
161
+ return level;
162
+ }
163
+ setPower(level) {
164
+ this.level[this._index] = VoxelLevelReader.setLevel(this.level[this._index], level);
165
+ return this;
166
+ }
167
+ isPowerSource() {
168
+ if (this._loadedId <= 0)
169
+ return false;
170
+ return VoxelTagStates.isRegistered(this._loadedId, VoxelTagIds.isPowerSource)
171
+ ? VoxelTagStates.getValue(this._loadedId, VoxelTagIds.isPowerSource, this.getState()) === true
172
+ : this._tags[VoxelTagIds.isPowerSource];
173
+ }
174
+ getPowerSourceValue() {
175
+ if (this._loadedId <= 0)
176
+ return 0;
177
+ return this._tags[VoxelTagIds.powerValue];
178
+ }
135
179
  noAO() {
136
180
  if (this._loadedId <= 0)
137
181
  return false;
@@ -3,7 +3,7 @@
3
3
  * Used to decode light color info.
4
4
  */
5
5
  export class VoxelLightData {
6
- _lightValues = new Uint16Array([0, 0, 0, 0]);
6
+ _lightValues = [0, 0, 0, 0];
7
7
  sumRGB(value) {
8
8
  return this.getR(value) + this.getG(value) + this.getB(value);
9
9
  }
@@ -6,10 +6,15 @@ export declare enum VoxelTagIds {
6
6
  colliderID = "dve_collider_id",
7
7
  checkCollisions = "dve_check_collisions",
8
8
  isLightSource = "dve_is_light_source",
9
+ lightValue = "dve_light_value",
9
10
  noAO = "dve_no_ao",
10
11
  isTransparent = "dve_is_transparent",
11
- lightValue = "dve_light_value",
12
- canHaveSecondary = "dve_can_have_secondary"
12
+ canHaveSecondary = "dve_can_have_secondary",
13
+ canBePowered = "dve_can_be_powered",
14
+ canCarryPower = "dve_can_carry_power",
15
+ canHoldPower = "dve_can_hold_power",
16
+ isPowerSource = "dve_is_power_source",
17
+ powerValue = "dve_power_value"
13
18
  }
14
19
  export interface VoxelTags {
15
20
  /** The material used to render the voxel. Used by the engine to assign meshes to the proper material. */
@@ -37,6 +42,16 @@ export interface VoxelTags {
37
42
  [VoxelTagIds.canHaveSecondary]: boolean;
38
43
  /** The hardness level of the voxel, affecting how it is broken or interacted with. */
39
44
  [VoxelTagIds.hardness]: number;
45
+ /** Whether or not the voxel can be powered */
46
+ [VoxelTagIds.canBePowered]: boolean;
47
+ /** Whether or not the voxel can carry power */
48
+ [VoxelTagIds.canCarryPower]: boolean;
49
+ /** Whether or not the voxel can hold power. */
50
+ [VoxelTagIds.canHoldPower]: boolean;
51
+ /** Whether or not the voxel is a power source*/
52
+ [VoxelTagIds.isPowerSource]: boolean;
53
+ /** If the voxel is a power source this is its value */
54
+ [VoxelTagIds.powerValue]: number;
40
55
  }
41
56
  export declare enum VoxelSubstanceTagIdds {
42
57
  parent = "dve_parent_substance",
@@ -7,10 +7,15 @@ export var VoxelTagIds;
7
7
  VoxelTagIds["colliderID"] = "dve_collider_id";
8
8
  VoxelTagIds["checkCollisions"] = "dve_check_collisions";
9
9
  VoxelTagIds["isLightSource"] = "dve_is_light_source";
10
+ VoxelTagIds["lightValue"] = "dve_light_value";
10
11
  VoxelTagIds["noAO"] = "dve_no_ao";
11
12
  VoxelTagIds["isTransparent"] = "dve_is_transparent";
12
- VoxelTagIds["lightValue"] = "dve_light_value";
13
13
  VoxelTagIds["canHaveSecondary"] = "dve_can_have_secondary";
14
+ VoxelTagIds["canBePowered"] = "dve_can_be_powered";
15
+ VoxelTagIds["canCarryPower"] = "dve_can_carry_power";
16
+ VoxelTagIds["canHoldPower"] = "dve_can_hold_power";
17
+ VoxelTagIds["isPowerSource"] = "dve_is_power_source";
18
+ VoxelTagIds["powerValue"] = "dve_power_value";
14
19
  })(VoxelTagIds || (VoxelTagIds = {}));
15
20
  export var VoxelSubstanceTagIdds;
16
21
  (function (VoxelSubstanceTagIdds) {
@@ -12,6 +12,11 @@ export class VoxelTagsRegister {
12
12
  VoxelTagIds.noAO,
13
13
  VoxelTagIds.isTransparent,
14
14
  VoxelTagIds.canHaveSecondary,
15
+ VoxelTagIds.isPowerSource,
16
+ VoxelTagIds.canBePowered,
17
+ VoxelTagIds.canCarryPower,
18
+ VoxelTagIds.canHoldPower,
19
+ VoxelTagIds.powerValue
15
20
  ];
16
21
  static IncludedSubstnacesTags = [
17
22
  VoxelSubstanceTagIds.parent,
@@ -5,21 +5,21 @@ import { VoxelEffectSyncData } from "../Effects/VoxelEffects.types";
5
5
  export declare function BuildStateData(model: VoxelRulesModoel, geoPalette: StringPalette): {
6
6
  schema: (BinarySchemaNodeData | VoxelRelationsScehmaNodeData)[];
7
7
  effects: VoxelEffectSyncData[];
8
- shapeStateGeometryPalette: number[][];
8
+ stateGeometryPalette: number[][];
9
9
  condiotnalShapeStateGeometryPalette: number[][];
10
- shapeStateTree: any[];
10
+ stateTree: any[];
11
11
  geometryLinkPalette: Record<string, number>;
12
12
  geometryLinkStateMap: number[];
13
13
  relativeByteCount: number;
14
- shapeStatePalette: number[][];
15
- shapeStateRecord: Record<string, number>;
14
+ statePalette: number[][];
15
+ stateRecord: Record<string, number>;
16
16
  condiotnalNodeStateTree: any;
17
17
  condiotnalStatements: StateLogicStatement[];
18
- condiotnalShapeStatePalette: number[][];
18
+ condiotnalStatePalette: number[][];
19
19
  condiotnalShapeStateRecord: Record<string, number>;
20
20
  condiotanlStatePalette: number[][][];
21
21
  condiotanlGeometryStatePalette: number[][][];
22
- shapeStateRelativeGeometryMap: number[][];
22
+ stateRelativeGeometryMap: number[][];
23
23
  relativeGeometryByteIndexMap: number[];
24
24
  condiotnalShapeStateRelativeGeometryMap: number[][];
25
25
  };