@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.
- package/Contexts/Base/Remote/InitDataSync.js +4 -0
- package/Contexts/Base/Remote/InitWorldDataSync.js +1 -1
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -0
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -0
- package/Init/StartConstructor.js +2 -0
- package/Math/index.d.ts +5 -1
- package/Mesher/Functions/CompactVoxelSectionMesh.d.ts +4 -0
- package/Mesher/Functions/CompactVoxelSectionMesh.js +112 -0
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +15 -22
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
- package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +1 -1
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +118 -197
- package/Mesher/Geomtry/VoxelMesh.js +2 -2
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +8 -70
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +18 -183
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
- package/Mesher/Geomtry/VoxelMeshBuffers.js +2 -2
- package/Mesher/InitTask.js +5 -1
- package/Mesher/Models/Common/BoxGeometryNode.js +7 -7
- package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
- package/Mesher/Models/Common/Calc/CalcConstants.js +1 -1
- package/Mesher/Models/Common/QuadGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +7 -7
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +22 -25
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +2 -2
- package/Mesher/Models/VoxelConstructor.d.ts +3 -3
- package/Mesher/Models/VoxelConstructor.js +8 -8
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +2 -2
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -9
- package/Mesher/Models/VoxelModelBuilder.js +1 -8
- package/Mesher/Types/Mesher.types.d.ts +1 -0
- package/Models/Defaults/CubeVoxelModels.js +16 -39
- package/Models/Defaults/LiquidVoxelModel.js +3 -3
- package/Models/Defaults/PanelVoxelModels.js +10 -36
- package/Models/Defaults/StairVoxelModel.js +6 -21
- package/Models/Examples.js +23 -44
- package/Models/Rules/Classes/VoxelRulesModel.d.ts +1 -1
- package/Models/Rules/Classes/VoxelRulesModel.js +3 -3
- package/Models/Rules/Functions/BuildFinalInputs.d.ts +1 -1
- package/Models/Rules/Functions/BuildFinalInputs.js +13 -13
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +8 -8
- package/Models/VoxelModel.types.d.ts +3 -3
- package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
- package/Renderer/InitTasks.js +1 -9
- package/Renderer/MeshManager.d.ts +1 -1
- package/Renderer/MeshManager.js +24 -23
- package/Renderer/MeshRegister.d.ts +5 -5
- package/Renderer/MeshRegister.js +2 -2
- package/Settings/EngineSettings.d.ts +1 -0
- package/Settings/EngineSettings.js +6 -3
- package/Settings/EngineSettings.types.d.ts +7 -21
- package/Settings/EngineSettings.types.js +6 -14
- package/Tasks/Logic/InitTasks.d.ts +1 -0
- package/Tasks/Logic/InitTasks.js +10 -0
- package/Tasks/Logic/VoxelLogicUpdate.d.ts +3 -0
- package/Tasks/Logic/VoxelLogicUpdate.js +71 -0
- package/Tasks/Propagation/Explosion/ExplosionManager.d.ts +2 -2
- package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -2
- package/Tasks/Propagation/Flow/FlowManager.d.ts +4 -4
- package/Tasks/Propagation/Flow/FlowRemove.d.ts +2 -2
- package/Tasks/Propagation/Flow/FlowUpdate.d.ts +2 -2
- package/Tasks/Propagation/Flow/WorldFlow.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/RGBUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.js +8 -15
- package/Tasks/Propagation/InitTasks.js +4 -4
- package/Tasks/Propagation/Power/PowerUpdate.d.ts +3 -0
- package/Tasks/Propagation/Power/PowerUpdate.js +80 -0
- package/Tasks/Tasks.types.d.ts +2 -2
- package/Tasks/TasksIds.d.ts +2 -1
- package/Tasks/TasksIds.js +1 -0
- package/Tasks/Update/Common.d.ts +3 -0
- package/Tasks/Update/Common.js +41 -0
- package/Tasks/Update/EreaseUpdate.d.ts +3 -0
- package/Tasks/Update/EreaseUpdate.js +66 -0
- package/Tasks/Update/InitTasks.d.ts +2 -2
- package/Tasks/Update/InitTasks.js +3 -1
- package/Tasks/Update/PaintUpdate.d.ts +3 -0
- package/Tasks/Update/PaintUpdate.js +89 -0
- package/Tasks/Update/VoxelUpdate.d.ts +2 -5
- package/Tasks/Update/VoxelUpdate.js +5 -147
- package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +15 -7
- package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +20 -7
- package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
- package/Tasks/WorldGeneration/WorldGenBrush.js +2 -2
- package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
- package/Templates/Functions/CreateTemplate.d.ts +1 -1
- package/Tools/Brush/AdvancedBrushTool.js +1 -1
- package/Tools/Brush/Brush.d.ts +2 -2
- package/Tools/Brush/Brush.js +1 -1
- package/Tools/Tasks/TasksTool.d.ts +1 -0
- package/Tools/Tasks/TasksTool.js +2 -0
- package/Util/Binary/BinaryBuffer.d.ts +17 -11
- package/Util/Binary/BinaryBuffer.js +65 -59
- package/Util/Binary/BinaryTree.d.ts +46 -0
- package/Util/Binary/BinaryTree.js +104 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +7 -2
- package/Voxels/Cursor/VoxelCursor.interface.js +46 -2
- package/Voxels/Cursor/VoxelLightData.js +1 -1
- package/Voxels/Data/VoxelTag.types.d.ts +17 -2
- package/Voxels/Data/VoxelTag.types.js +6 -1
- package/Voxels/Data/VoxelTagsRegister.js +5 -0
- package/Voxels/Functions/BuildStateData.d.ts +6 -6
- package/Voxels/Functions/BuildStateData.js +31 -31
- package/Voxels/Functions/BuildTagAndPaletteData.js +5 -0
- package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
- package/Voxels/Indexes/VoxelIndex.js +16 -18
- package/Voxels/InitVoxelData.js +12 -8
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.d.ts +5 -0
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.js +6 -0
- package/Voxels/Logic/Classes/VoxelLogic.d.ts +11 -0
- package/Voxels/Logic/Classes/VoxelLogic.js +49 -0
- package/Voxels/Logic/Classes/VoxelLogicType.d.ts +4 -0
- package/Voxels/Logic/Classes/VoxelLogicType.js +2 -0
- package/Voxels/Logic/VoxelLogic.types.d.ts +23 -0
- package/Voxels/Logic/VoxelLogic.types.js +1 -0
- package/Voxels/Logic/VoxelLogicRegister.d.ts +9 -0
- package/Voxels/Logic/VoxelLogicRegister.js +15 -0
- package/Voxels/State/SchemaRegister.js +10 -5
- package/Voxels/State/State.types.d.ts +1 -1
- package/Voxels/State/StateTreeReader.d.ts +1 -1
- package/Voxels/State/StateTreeReader.js +2 -3
- package/Voxels/Types/Voxel.types.d.ts +3 -0
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
- package/World/Archive/Archive.types.d.ts +31 -12
- package/World/Archive/Classes/ArchiveClasses.d.ts +66 -0
- package/World/Archive/Classes/ArchiveClasses.js +78 -0
- package/World/Archive/Classes/ImportedSection.d.ts +40 -0
- package/World/Archive/Classes/ImportedSection.js +307 -0
- package/World/Archive/Classes/ImportedSector.d.ts +23 -0
- package/World/Archive/Classes/ImportedSector.js +97 -0
- package/World/Archive/Functions/ArchiveArea.d.ts +1 -1
- package/World/Archive/Functions/ArchiveArea.js +39 -36
- package/World/Archive/Functions/ArchiveSector.js +210 -404
- package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
- package/World/Archive/Functions/CreateArchivedSection.js +207 -0
- package/World/Archive/Functions/ImportSector.d.ts +1 -3
- package/World/Archive/Functions/ImportSector.js +13 -244
- package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
- package/World/Archive/Functions/RemoveDuplicates.js +92 -0
- package/World/Archive/Functions/Shared.d.ts +2 -2
- package/World/Archive/Functions/Shared.js +15 -40
- package/World/Archive/InitTasks.js +7 -10
- package/World/Cursor/SectionCursor.d.ts +1 -1
- package/World/Cursor/SectorCursor.d.ts +1 -1
- package/World/Cursor/WorldCursor.d.ts +4 -3
- package/World/Cursor/WorldCursor.js +16 -13
- package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
- package/World/Cursor/WorldVoxelCursor.js +23 -14
- package/World/Dimension/Dimension.d.ts +4 -1
- package/World/Dimension/Dimension.js +8 -1
- package/World/Section/Section.d.ts +17 -4
- package/World/Section/Section.js +68 -6
- package/World/Section/SectionState.d.ts +4 -2
- package/World/Section/SectionState.js +4 -2
- package/World/Sector/Sector.d.ts +7 -1
- package/World/Sector/Sector.js +37 -4
- package/World/Sector/SectorState.d.ts +3 -2
- package/World/Sector/SectorState.js +3 -2
- package/World/Types/WorldData.types.d.ts +2 -7
- package/World/WorldRegister.d.ts +9 -9
- package/World/WorldRegister.js +9 -6
- package/World/WorldSpaces.js +6 -6
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +6 -4
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +9 -5
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.js +6 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.js +6 -0
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.js +1 -1
- package/WorldSimulation/Internal/Classes/TickQueue.d.ts +12 -0
- package/{Tasks/IWG/Internal/Classes/BuildQueue.js → WorldSimulation/Internal/Classes/TickQueue.js} +16 -7
- package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
- package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +6 -6
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.js +9 -9
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.js +4 -4
- package/WorldSimulation/Internal/Functions/runTickUpdate.d.ts +2 -0
- package/{Tasks/IWG/Internal/Functions/runBuildUpdate.js → WorldSimulation/Internal/Functions/runTickUpdate.js} +29 -19
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.js +13 -13
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.js +1 -1
- package/WorldSimulation/Internal/WorldSimulationDimensions.d.ts +6 -0
- package/{Tasks/IWG/Internal/IWGDimensions.js → WorldSimulation/Internal/WorldSimulationDimensions.js} +1 -1
- package/WorldSimulation/Internal/WorldSimulationTasks.d.ts +30 -0
- package/{Tasks/IWG/Internal/IWGTasks.js → WorldSimulation/Internal/WorldSimulationTasks.js} +14 -14
- package/WorldSimulation/Internal/WorldSimulationTools.d.ts +8 -0
- package/{Tasks/IWG/Internal/IWGTools.js → WorldSimulation/Internal/WorldSimulationTools.js} +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.js +11 -11
- package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.js +5 -5
- package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +5 -5
- package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +21 -21
- package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
- package/package.json +1 -1
- package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +0 -11
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.d.ts +0 -15
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.d.ts +0 -2
- package/Tasks/IWG/Internal/IWGDimensions.d.ts +0 -6
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -30
- package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.d.ts +0 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { BinaryBuffer, BinaryBufferTypes, } from "../../../Util/Binary/BinaryBuffer";
|
|
2
|
+
import { getLightBuffer, lightSegments } from "./Shared";
|
|
3
|
+
export function CreateArchivedSection(archiveSection, sectorPalettes) {
|
|
4
|
+
const palettes = {};
|
|
5
|
+
if (archiveSection.ids.remapped)
|
|
6
|
+
palettes.id = Uint16Array.from(archiveSection.palettes.ids._palette);
|
|
7
|
+
if (archiveSection.level.remapped)
|
|
8
|
+
palettes.level = Uint8Array.from(archiveSection.palettes.level._palette);
|
|
9
|
+
if (archiveSection.light.sun.remapped) {
|
|
10
|
+
palettes.light ??= {};
|
|
11
|
+
palettes.light.sun = Uint8Array.from(archiveSection.palettes.light.sun._palette);
|
|
12
|
+
}
|
|
13
|
+
if (archiveSection.light.red.remapped) {
|
|
14
|
+
palettes.light ??= {};
|
|
15
|
+
palettes.light.red = Uint8Array.from(archiveSection.palettes.light.red._palette);
|
|
16
|
+
}
|
|
17
|
+
if (archiveSection.light.green.remapped) {
|
|
18
|
+
palettes.light ??= {};
|
|
19
|
+
palettes.light.green = Uint8Array.from(archiveSection.palettes.light.green._palette);
|
|
20
|
+
}
|
|
21
|
+
if (archiveSection.light.blue.remapped) {
|
|
22
|
+
palettes.light ??= {};
|
|
23
|
+
palettes.light.blue = Uint8Array.from(archiveSection.palettes.light.blue._palette);
|
|
24
|
+
}
|
|
25
|
+
if (archiveSection.state.remapped) {
|
|
26
|
+
for (const i in archiveSection.palettes.state) {
|
|
27
|
+
palettes.state ??= [];
|
|
28
|
+
palettes.state[i] = Uint16Array.from(archiveSection.palettes.state[i]._palette);
|
|
29
|
+
}
|
|
30
|
+
for (const i in archiveSection.palettes.secondaryState) {
|
|
31
|
+
palettes.secondaryState ??= [];
|
|
32
|
+
palettes.secondaryState[i] = Uint16Array.from(archiveSection.palettes.secondaryState[i]._palette);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (archiveSection.mod.remapped) {
|
|
36
|
+
for (const i in archiveSection.palettes.mod) {
|
|
37
|
+
palettes.mod ??= [];
|
|
38
|
+
palettes.mod[i] = Uint16Array.from(archiveSection.palettes.mod[i]._palette);
|
|
39
|
+
}
|
|
40
|
+
for (const i in archiveSection.palettes.secondaryMod) {
|
|
41
|
+
palettes.secondaryMod ??= [];
|
|
42
|
+
palettes.secondaryMod[i] = Uint16Array.from(archiveSection.palettes.secondaryMod[i]._palette);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (archiveSection.secondary.remapped) {
|
|
46
|
+
palettes.secondaryId = Uint16Array.from(archiveSection.palettes.secondaryId._palette);
|
|
47
|
+
palettes.secondaryValue = Uint16Array.from(archiveSection.palettes.secondaryValue._palette);
|
|
48
|
+
}
|
|
49
|
+
const buffers = {};
|
|
50
|
+
//id
|
|
51
|
+
if (archiveSection.ids.allTheSame) {
|
|
52
|
+
if (archiveSection.ids.buffer[0] !== 0) {
|
|
53
|
+
buffers.id = archiveSection.ids.buffer[0];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (archiveSection.ids.isPaletted) {
|
|
57
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.ids.remapped
|
|
58
|
+
? archiveSection.palettes.ids.size
|
|
59
|
+
: sectorPalettes.ids.size);
|
|
60
|
+
buffers.id = BinaryBuffer.Create({
|
|
61
|
+
buffer: BinaryBuffer.Convert(archiveSection.ids.buffer, BinaryBufferTypes.ShortArray, type).buffer,
|
|
62
|
+
type,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
buffers.id = BinaryBuffer.Create({
|
|
67
|
+
buffer: archiveSection.ids.buffer.buffer,
|
|
68
|
+
type: BinaryBufferTypes.ShortArray,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//level
|
|
72
|
+
if (archiveSection.level.allTheSame) {
|
|
73
|
+
if (archiveSection.level.buffer[0] !== 0) {
|
|
74
|
+
buffers.level = archiveSection.level.buffer[0];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else if (archiveSection.level.isPaletted) {
|
|
78
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.level.remapped
|
|
79
|
+
? archiveSection.palettes.level.size
|
|
80
|
+
: sectorPalettes.level.size);
|
|
81
|
+
buffers.level = BinaryBuffer.Create({
|
|
82
|
+
buffer: BinaryBuffer.Convert(archiveSection.level.buffer, BinaryBufferTypes.ByteArray, type).buffer,
|
|
83
|
+
type,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
buffers.level = BinaryBuffer.Create({
|
|
88
|
+
buffer: archiveSection.original.level.slice().buffer,
|
|
89
|
+
type: BinaryBufferTypes.ByteArray,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
for (const semgnet of lightSegments) {
|
|
93
|
+
if (archiveSection.light[semgnet].allTheSame) {
|
|
94
|
+
if (archiveSection.light[semgnet].value !== 0) {
|
|
95
|
+
buffers.light ??= {};
|
|
96
|
+
buffers.light[semgnet] = archiveSection.light[semgnet].value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (archiveSection.light[semgnet].isPaletted) {
|
|
100
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.light[semgnet].remapped
|
|
101
|
+
? archiveSection.palettes.light[semgnet].size
|
|
102
|
+
: sectorPalettes.light[semgnet].size);
|
|
103
|
+
buffers.light ??= {};
|
|
104
|
+
buffers.light[semgnet] = BinaryBuffer.Create({
|
|
105
|
+
buffer: BinaryBuffer.Convert(archiveSection.light[semgnet].buffer, BinaryBufferTypes.ByteArray, type).buffer,
|
|
106
|
+
type,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
buffers.light ??= {};
|
|
111
|
+
buffers.light[semgnet] = BinaryBuffer.Create({
|
|
112
|
+
buffer: getLightBuffer(semgnet, archiveSection.original.light).buffer,
|
|
113
|
+
type: BinaryBufferTypes.NibbleArray,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (archiveSection.state.allTheSame) {
|
|
118
|
+
if (archiveSection.state.buffer[0] !== 0) {
|
|
119
|
+
buffers.state = archiveSection.state.buffer[0];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else if (archiveSection.state.isPaletted) {
|
|
123
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.state.remapped
|
|
124
|
+
? archiveSection.palettes.maxStatePaletteSize
|
|
125
|
+
: sectorPalettes.maxStatePaletteSize);
|
|
126
|
+
buffers.state = BinaryBuffer.Create({
|
|
127
|
+
buffer: BinaryBuffer.Convert(archiveSection.state.buffer, BinaryBufferTypes.ShortArray, type).buffer,
|
|
128
|
+
type,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
buffers.state = BinaryBuffer.Create({
|
|
133
|
+
buffer: archiveSection.state.buffer.buffer,
|
|
134
|
+
type: BinaryBufferTypes.ShortArray,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (archiveSection.mod.allTheSame) {
|
|
138
|
+
if (archiveSection.mod.buffer[0] !== 0) {
|
|
139
|
+
buffers.mod = archiveSection.mod.buffer[0];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else if (archiveSection.mod.isPaletted) {
|
|
143
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.mod.remapped
|
|
144
|
+
? archiveSection.palettes.maxModPaletteSize
|
|
145
|
+
: sectorPalettes.maxModPaletteSize);
|
|
146
|
+
buffers.mod = BinaryBuffer.Create({
|
|
147
|
+
buffer: BinaryBuffer.Convert(archiveSection.mod.buffer, BinaryBufferTypes.ShortArray, type).buffer,
|
|
148
|
+
type,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
buffers.mod = BinaryBuffer.Create({
|
|
153
|
+
buffer: archiveSection.mod.buffer.buffer,
|
|
154
|
+
type: BinaryBufferTypes.ShortArray,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (archiveSection.secondary.allTheSame) {
|
|
158
|
+
if (archiveSection.secondary.buffer[0] !== 0) {
|
|
159
|
+
buffers.secondary = archiveSection.secondary.buffer[0];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else if (archiveSection.secondary.isPaletted) {
|
|
163
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.secondary.remapped
|
|
164
|
+
? Math.max(archiveSection.palettes.secondaryValue.size, archiveSection.palettes.secondaryId.size)
|
|
165
|
+
: Math.max(sectorPalettes.secondaryValue.size, sectorPalettes.secondaryId.size));
|
|
166
|
+
buffers.secondary = BinaryBuffer.Create({
|
|
167
|
+
buffer: BinaryBuffer.Convert(archiveSection.secondary.buffer, BinaryBufferTypes.ShortArray, type).buffer,
|
|
168
|
+
type,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
buffers.secondary = BinaryBuffer.Create({
|
|
173
|
+
buffer: archiveSection.secondary.buffer.buffer,
|
|
174
|
+
type: BinaryBufferTypes.ShortArray,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (archiveSection.isBuriedAllTheSame) {
|
|
178
|
+
if (archiveSection.buriedValue !== 0) {
|
|
179
|
+
buffers.buried = archiveSection.buriedValue;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
buffers.buried = archiveSection.original.buried.slice();
|
|
184
|
+
}
|
|
185
|
+
if (archiveSection.isVoxelMapAllTheSame) {
|
|
186
|
+
if (archiveSection.voxelMapValue !== 0) {
|
|
187
|
+
buffers.voxelMap = archiveSection.voxelMapValue;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
buffers.voxelMap = archiveSection.original.voxelMap.slice();
|
|
192
|
+
}
|
|
193
|
+
if (archiveSection.isDirtyMapAllTheSame) {
|
|
194
|
+
if (archiveSection.dirtyMapValue !== 0) {
|
|
195
|
+
buffers.dirtyMap = archiveSection.dirtyMapValue;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
buffers.dirtyMap = archiveSection.original.dirtyMap.slice();
|
|
200
|
+
}
|
|
201
|
+
const flags = archiveSection.original.storeFlags();
|
|
202
|
+
return {
|
|
203
|
+
...(Object.keys(flags).length ? { flags } : {}),
|
|
204
|
+
...(Object.keys(palettes).length ? { palettes } : {}),
|
|
205
|
+
buffers,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SectorData } from "../../index";
|
|
2
2
|
import { ArchivedSectorData } from "../Archive.types";
|
|
3
3
|
type RunData = {
|
|
4
4
|
version?: number;
|
|
5
|
-
loadColumnState?: (data: Record<string, any>, sector: SectorData) => void;
|
|
6
|
-
loadSectionState?: (keys: string[], data: any[], section: SectionData) => void;
|
|
7
5
|
};
|
|
8
6
|
export default function ImportSector(archivedSector: ArchivedSectorData, archiveData: RunData): SectorData;
|
|
9
7
|
export {};
|
|
@@ -1,245 +1,17 @@
|
|
|
1
1
|
import { Sector } from "../../index";
|
|
2
|
-
import {
|
|
3
|
-
import { StringPalette } from "../../../Util/StringPalette";
|
|
4
|
-
import { SchemaRegister } from "../../../Voxels/State/SchemaRegister";
|
|
5
|
-
import { VoxelPalettesRegister } from "../../../Voxels/Data/VoxelPalettesRegister";
|
|
6
|
-
import { VoxelTagsRegister } from "../../../Voxels/Data/VoxelTagsRegister";
|
|
7
|
-
import { BinaryBuffer } from "../../../Util/Binary/BinaryBuffer";
|
|
8
|
-
import { lightSegments, lightSemgnetSet } from "./Shared";
|
|
9
|
-
const getImportedSectorData = (sector) => {
|
|
10
|
-
return {
|
|
11
|
-
sector,
|
|
12
|
-
idPalette: new StringPalette(sector.palettes.id),
|
|
13
|
-
secondaryId: new StringPalette(sector.palettes.secondaryId),
|
|
14
|
-
levelPalette: sector.palettes.level
|
|
15
|
-
? new NumberPalette(sector.palettes.level)
|
|
16
|
-
: undefined,
|
|
17
|
-
lightPalette: {
|
|
18
|
-
sun: sector.palettes.light.sun
|
|
19
|
-
? new NumberPalette(sector.palettes.light.sun)
|
|
20
|
-
: null,
|
|
21
|
-
red: sector.palettes.light.red
|
|
22
|
-
? new NumberPalette(sector.palettes.light.red)
|
|
23
|
-
: null,
|
|
24
|
-
green: sector.palettes.light.green
|
|
25
|
-
? new NumberPalette(sector.palettes.light.green)
|
|
26
|
-
: null,
|
|
27
|
-
blue: sector.palettes.light.blue
|
|
28
|
-
? new NumberPalette(sector.palettes.light.blue)
|
|
29
|
-
: null,
|
|
30
|
-
},
|
|
31
|
-
statePalette: new NumberPalette(sector.palettes.state),
|
|
32
|
-
modPalette: new NumberPalette(sector.palettes.mod),
|
|
33
|
-
secondaryState: new NumberPalette(sector.palettes.secondaryState),
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
const getImportedSectionData = (section) => {
|
|
37
|
-
return {
|
|
38
|
-
section,
|
|
39
|
-
buffers: {
|
|
40
|
-
ids: !section.buffers.id
|
|
41
|
-
? new BinaryBuffer({ buffer: 0 })
|
|
42
|
-
: typeof section.buffers.id == "number"
|
|
43
|
-
? new BinaryBuffer({ buffer: section.buffers.id })
|
|
44
|
-
: new BinaryBuffer(section.buffers.id),
|
|
45
|
-
level: !section.buffers.level
|
|
46
|
-
? new BinaryBuffer({ buffer: 0 })
|
|
47
|
-
: typeof section.buffers.level == "number"
|
|
48
|
-
? new BinaryBuffer({ buffer: section.buffers.level })
|
|
49
|
-
: new BinaryBuffer(section.buffers.level),
|
|
50
|
-
light: {
|
|
51
|
-
sun: !section.buffers.light?.sun
|
|
52
|
-
? new BinaryBuffer({ buffer: 0 })
|
|
53
|
-
: typeof section.buffers.light.sun == "number"
|
|
54
|
-
? new BinaryBuffer({ buffer: section.buffers.light.sun })
|
|
55
|
-
: new BinaryBuffer(section.buffers.light.sun),
|
|
56
|
-
red: !section.buffers.light?.red
|
|
57
|
-
? new BinaryBuffer({ buffer: 0 })
|
|
58
|
-
: typeof section.buffers.light.red == "number"
|
|
59
|
-
? new BinaryBuffer({ buffer: section.buffers.light.red })
|
|
60
|
-
: new BinaryBuffer(section.buffers.light.red),
|
|
61
|
-
green: !section.buffers.light?.green
|
|
62
|
-
? new BinaryBuffer({ buffer: 0 })
|
|
63
|
-
: typeof section.buffers.light.green == "number"
|
|
64
|
-
? new BinaryBuffer({ buffer: section.buffers.light.green })
|
|
65
|
-
: new BinaryBuffer(section.buffers.light.green),
|
|
66
|
-
blue: !section.buffers.light?.blue
|
|
67
|
-
? new BinaryBuffer({ buffer: 0 })
|
|
68
|
-
: typeof section.buffers.light.blue == "number"
|
|
69
|
-
? new BinaryBuffer({ buffer: section.buffers.light.blue })
|
|
70
|
-
: new BinaryBuffer(section.buffers.light.blue),
|
|
71
|
-
},
|
|
72
|
-
state: !section.buffers.state
|
|
73
|
-
? new BinaryBuffer({ buffer: 0 })
|
|
74
|
-
: typeof section.buffers.state == "number"
|
|
75
|
-
? new BinaryBuffer({ buffer: section.buffers.state })
|
|
76
|
-
: new BinaryBuffer(section.buffers.state),
|
|
77
|
-
mod: !section.buffers.mod
|
|
78
|
-
? new BinaryBuffer({ buffer: 0 })
|
|
79
|
-
: typeof section.buffers.mod == "number"
|
|
80
|
-
? new BinaryBuffer({ buffer: section.buffers.mod })
|
|
81
|
-
: new BinaryBuffer(section.buffers.mod),
|
|
82
|
-
secondary: !section.buffers.secondary
|
|
83
|
-
? new BinaryBuffer({ buffer: 0 })
|
|
84
|
-
: typeof section.buffers.secondary == "number"
|
|
85
|
-
? new BinaryBuffer({ buffer: section.buffers.secondary })
|
|
86
|
-
: new BinaryBuffer(section.buffers.secondary),
|
|
87
|
-
},
|
|
88
|
-
idPalette: section.palettes?.id
|
|
89
|
-
? new NumberPalette(section.palettes?.id)
|
|
90
|
-
: undefined,
|
|
91
|
-
lightPalette: {
|
|
92
|
-
sun: section.palettes?.light?.sun
|
|
93
|
-
? new NumberPalette(section.palettes?.light?.sun)
|
|
94
|
-
: null,
|
|
95
|
-
red: section.palettes?.light?.red
|
|
96
|
-
? new NumberPalette(section.palettes?.light?.red)
|
|
97
|
-
: null,
|
|
98
|
-
green: section.palettes?.light?.green
|
|
99
|
-
? new NumberPalette(section.palettes?.light?.green)
|
|
100
|
-
: null,
|
|
101
|
-
blue: section.palettes?.light?.blue
|
|
102
|
-
? new NumberPalette(section.palettes?.light?.blue)
|
|
103
|
-
: null,
|
|
104
|
-
},
|
|
105
|
-
levelPalette: section.palettes?.level
|
|
106
|
-
? new NumberPalette(section.palettes?.level)
|
|
107
|
-
: undefined,
|
|
108
|
-
statePalette: section.palettes?.state
|
|
109
|
-
? new NumberPalette(section.palettes?.state)
|
|
110
|
-
: undefined,
|
|
111
|
-
modPalette: section.palettes?.mod
|
|
112
|
-
? new NumberPalette(section.palettes?.mod)
|
|
113
|
-
: undefined,
|
|
114
|
-
secondaryState: section.palettes?.secondaryState
|
|
115
|
-
? new NumberPalette(section.palettes?.secondaryState)
|
|
116
|
-
: undefined,
|
|
117
|
-
secondaryId: section.palettes?.secondaryId
|
|
118
|
-
? new NumberPalette(section.palettes?.secondaryId)
|
|
119
|
-
: undefined,
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
const getId = (value, importedSector, importedSection) => {
|
|
123
|
-
if (importedSection.buffers.ids.type == "value") {
|
|
124
|
-
return VoxelPalettesRegister.voxels.getNumberId(importedSector.idPalette.getStringId(value));
|
|
125
|
-
}
|
|
126
|
-
if (importedSection.idPalette) {
|
|
127
|
-
return VoxelPalettesRegister.voxels.getNumberId(importedSector.idPalette.getStringId(importedSection.idPalette.getValue(value)));
|
|
128
|
-
}
|
|
129
|
-
return VoxelPalettesRegister.voxels.getNumberId(importedSector.idPalette.getStringId(value));
|
|
130
|
-
};
|
|
131
|
-
const getLight = (index, importedSector, importedSection) => {
|
|
132
|
-
let finalLight = 0;
|
|
133
|
-
for (let l = 0; l < lightSegments.length; l++) {
|
|
134
|
-
const segment = lightSegments[l];
|
|
135
|
-
let value = 0;
|
|
136
|
-
if (importedSection.buffers.light[segment].type == "value") {
|
|
137
|
-
value = importedSection.buffers.light[segment].getValue(index);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
if (importedSection.buffers.light[segment].type == "4-bit") {
|
|
141
|
-
value = importedSection.buffers.light[segment].getValue(index);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
if (importedSection.lightPalette[segment]) {
|
|
145
|
-
value = importedSection.lightPalette[segment].getValue(importedSection.buffers.light[segment].getValue(index));
|
|
146
|
-
}
|
|
147
|
-
else if (importedSector.lightPalette[segment]) {
|
|
148
|
-
value = importedSector.lightPalette[segment].getValue(importedSection.buffers.light[segment].getValue(index));
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
finalLight = lightSemgnetSet[segment](value, finalLight);
|
|
153
|
-
}
|
|
154
|
-
return finalLight;
|
|
155
|
-
};
|
|
156
|
-
const getLevel = (value, importedSector, importedSection) => {
|
|
157
|
-
if (importedSection.levelPalette) {
|
|
158
|
-
return importedSection.levelPalette.getValue(value);
|
|
159
|
-
}
|
|
160
|
-
if (importedSector.levelPalette) {
|
|
161
|
-
return importedSector.levelPalette.getValue(value);
|
|
162
|
-
}
|
|
163
|
-
return value;
|
|
164
|
-
};
|
|
165
|
-
const getState = (voxelId, value, processedState, importedSector, importedSection) => {
|
|
166
|
-
const voxelStringId = VoxelPalettesRegister.voxels.getStringId(voxelId);
|
|
167
|
-
if (!SchemaRegister.hasVoxelSchema(voxelStringId))
|
|
168
|
-
return value;
|
|
169
|
-
let stateId = -1;
|
|
170
|
-
if (importedSection.section.buffers.state instanceof Uint16Array ||
|
|
171
|
-
typeof importedSection.section.buffers.state == "number") {
|
|
172
|
-
stateId = value;
|
|
173
|
-
}
|
|
174
|
-
if (importedSection.statePalette) {
|
|
175
|
-
stateId = importedSection.statePalette.getValue(value);
|
|
176
|
-
}
|
|
177
|
-
else if (importedSector.statePalette) {
|
|
178
|
-
stateId = value;
|
|
179
|
-
}
|
|
180
|
-
if (processedState[stateId] !== undefined)
|
|
181
|
-
return processedState[stateId];
|
|
182
|
-
value = SchemaRegister.getVoxelSchemas(voxelStringId).state.fromStateObject(importedSector.sector.palettes.stateMap[stateId]);
|
|
183
|
-
processedState[stateId] = value;
|
|
184
|
-
return value;
|
|
185
|
-
};
|
|
186
|
-
const getMod = (voxelId, value, processedMod, importedSector, importedSection) => {
|
|
187
|
-
const voxelStringId = VoxelPalettesRegister.voxels.getStringId(voxelId);
|
|
188
|
-
if (!SchemaRegister.hasVoxelSchema(voxelStringId))
|
|
189
|
-
return value;
|
|
190
|
-
let modId = -1;
|
|
191
|
-
if (importedSection.section.buffers.state instanceof Uint16Array ||
|
|
192
|
-
typeof importedSection.section.buffers.state == "number") {
|
|
193
|
-
modId = value;
|
|
194
|
-
}
|
|
195
|
-
if (importedSection.modPalette) {
|
|
196
|
-
modId = importedSection.modPalette.getValue(value);
|
|
197
|
-
}
|
|
198
|
-
else if (importedSector.modPalette) {
|
|
199
|
-
modId = value;
|
|
200
|
-
}
|
|
201
|
-
if (processedMod[modId] !== undefined)
|
|
202
|
-
return processedMod[modId];
|
|
203
|
-
value = SchemaRegister.getVoxelSchemas(voxelStringId).mod.fromStateObject(importedSector.sector.palettes.modMap[modId]);
|
|
204
|
-
processedMod[modId] = value;
|
|
205
|
-
return value;
|
|
206
|
-
};
|
|
207
|
-
const getSecondary = (voxelId, value, importedSector, importedSection) => {
|
|
208
|
-
if (VoxelTagsRegister.VoxelTags[voxelId]["dve_can_have_secondary"]) {
|
|
209
|
-
if (importedSection.secondaryId) {
|
|
210
|
-
return VoxelPalettesRegister.voxels.getNumberId(importedSector.secondaryId.getStringId(importedSection.secondaryId.getValue(value)));
|
|
211
|
-
}
|
|
212
|
-
return VoxelPalettesRegister.voxels.getNumberId(importedSector.sector.palettes.secondaryId[value]);
|
|
213
|
-
}
|
|
214
|
-
if (typeof importedSection.section.buffers.secondary == "number") {
|
|
215
|
-
return value;
|
|
216
|
-
}
|
|
217
|
-
if (importedSection.secondaryState && importedSector.secondaryState) {
|
|
218
|
-
return importedSector.secondaryState.getValue(importedSection.secondaryState.getValue(value));
|
|
219
|
-
}
|
|
220
|
-
if (importedSector.secondaryState) {
|
|
221
|
-
return importedSector.secondaryState.getId(value);
|
|
222
|
-
}
|
|
223
|
-
return value;
|
|
224
|
-
};
|
|
2
|
+
import { ImportedSector } from "../Classes/ImportedSector";
|
|
225
3
|
export default function ImportSector(archivedSector, archiveData) {
|
|
226
4
|
const sector = new Sector(Sector.CreateNew(), [
|
|
5
|
+
archivedSector.location[0],
|
|
227
6
|
archivedSector.location[1],
|
|
228
7
|
archivedSector.location[2],
|
|
229
|
-
archivedSector.location[3],
|
|
230
8
|
]);
|
|
231
9
|
sector.loadFlags(archivedSector.flags);
|
|
232
10
|
sector.loadTimestamps(archivedSector.timestamps);
|
|
233
|
-
const importedSector =
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const archivedSectionValue = archivedSector.sections[sectionIndex];
|
|
238
|
-
const archivedSection = typeof archivedSectionValue == "string"
|
|
239
|
-
? archivedSector.duplicates?.sections?.[archivedSectionValue]
|
|
240
|
-
: archivedSectionValue;
|
|
241
|
-
const importedSection = getImportedSectionData(archivedSection);
|
|
242
|
-
const section = sector.sections[sectionIndex];
|
|
11
|
+
const importedSector = new ImportedSector(archivedSector);
|
|
12
|
+
for (const importedSection of importedSector.sections) {
|
|
13
|
+
const archivedSection = importedSection.section;
|
|
14
|
+
const section = sector.sections[importedSection.sectionIndex];
|
|
243
15
|
archivedSection.flags && section.loadFlags(archivedSection.flags);
|
|
244
16
|
if (!ArrayBuffer.isView(archivedSection.buffers.buried)) {
|
|
245
17
|
for (let i = 0; i < section.buried.length; i++) {
|
|
@@ -272,17 +44,14 @@ export default function ImportSector(archivedSector, archiveData) {
|
|
|
272
44
|
}
|
|
273
45
|
}
|
|
274
46
|
for (let i = 0; i < section.ids.length; i++) {
|
|
275
|
-
section.ids[i] =
|
|
276
|
-
section.level[i] =
|
|
277
|
-
section.light[i] = getLight(i
|
|
278
|
-
section.secondary[i] =
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
section.state[i] = getState(secondary ? section.secondary[i] : section.ids[i], importedSection.buffers.state.getValue(i), processedState, importedSector, importedSection);
|
|
282
|
-
section.mod[i] = getMod(secondary ? section.secondary[i] : section.ids[i], importedSection.buffers.mod.getValue(i), processedMod, importedSector, importedSection);
|
|
47
|
+
section.ids[i] = importedSection.getId(i);
|
|
48
|
+
section.level[i] = importedSection.getLevel(i);
|
|
49
|
+
section.light[i] = importedSection.getLight(i);
|
|
50
|
+
section.secondary[i] = importedSection.getSecondary(i);
|
|
51
|
+
section.state[i] = importedSection.getState(i);
|
|
52
|
+
section.mod[i] = importedSection.getMod(i);
|
|
283
53
|
}
|
|
284
|
-
sector.sections[sectionIndex] = section;
|
|
285
54
|
}
|
|
286
|
-
sector.setBitFlag(Sector.FlagIds.
|
|
55
|
+
sector.setBitFlag(Sector.FlagIds.stored, true);
|
|
287
56
|
return sector;
|
|
288
57
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { uint16To4CharString } from "./Shared";
|
|
2
|
+
function traverseSection(source, target) {
|
|
3
|
+
if (typeof source == "object" && typeof target == "object") {
|
|
4
|
+
if (Object.keys(source).length != Object.keys(target).length)
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
for (const key in source) {
|
|
8
|
+
if (!(key in target))
|
|
9
|
+
return false;
|
|
10
|
+
const sourceValue = source[key];
|
|
11
|
+
const targetValue = target[key];
|
|
12
|
+
if (!ArrayBuffer.isView(sourceValue) &&
|
|
13
|
+
typeof sourceValue === "object" &&
|
|
14
|
+
sourceValue !== null &&
|
|
15
|
+
!ArrayBuffer.isView(targetValue) &&
|
|
16
|
+
typeof targetValue == "object" &&
|
|
17
|
+
targetValue !== null) {
|
|
18
|
+
if (!traverseSection(sourceValue, targetValue))
|
|
19
|
+
return false;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (typeof sourceValue === "number" ||
|
|
23
|
+
typeof sourceValue === "string" ||
|
|
24
|
+
typeof targetValue === "number" ||
|
|
25
|
+
typeof targetValue === "string") {
|
|
26
|
+
if (sourceValue !== targetValue)
|
|
27
|
+
return false;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (sourceValue instanceof Uint8Array ||
|
|
31
|
+
sourceValue instanceof Uint16Array) {
|
|
32
|
+
if (!(targetValue instanceof sourceValue.constructor))
|
|
33
|
+
return false;
|
|
34
|
+
if (sourceValue.length !== targetValue.length)
|
|
35
|
+
return false;
|
|
36
|
+
let target = targetValue;
|
|
37
|
+
for (let i = 0; i < target.length; i++) {
|
|
38
|
+
if (sourceValue[i] != target[i])
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
export function compareSection(section1, section2) {
|
|
46
|
+
return traverseSection(section1, section2);
|
|
47
|
+
}
|
|
48
|
+
export function RemoveDuplicates(data) {
|
|
49
|
+
const duplicateSectionMap = new Map();
|
|
50
|
+
let duplicateSections = [];
|
|
51
|
+
for (let i = 0; i < data.sections.length; i++) {
|
|
52
|
+
for (let j = i + 1; j < data.sections.length; j++) {
|
|
53
|
+
const section1 = data.sections[i];
|
|
54
|
+
const section2 = data.sections[j];
|
|
55
|
+
if (typeof section1 == "string" || typeof section2 == "string")
|
|
56
|
+
continue;
|
|
57
|
+
let index = -1;
|
|
58
|
+
if (compareSection(section1, section2)) {
|
|
59
|
+
if (duplicateSectionMap.has(section2)) {
|
|
60
|
+
index = duplicateSectionMap.get(section2)[1];
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
let found = false;
|
|
64
|
+
for (let k = 0; k < duplicateSections.length; k++) {
|
|
65
|
+
if (compareSection(section1, duplicateSections[k])) {
|
|
66
|
+
index = k;
|
|
67
|
+
found = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!found) {
|
|
71
|
+
duplicateSections.push(section1);
|
|
72
|
+
index = duplicateSections.length - 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
duplicateSectionMap.set(section1, [i, index]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const sections = {};
|
|
80
|
+
for (let i = 0; i < data.sections.length; i++) {
|
|
81
|
+
const section = data.sections[i];
|
|
82
|
+
if (duplicateSectionMap.has(section)) {
|
|
83
|
+
const [, dupIndex] = duplicateSectionMap.get(section);
|
|
84
|
+
const id = uint16To4CharString(dupIndex);
|
|
85
|
+
data.sections[i] = id;
|
|
86
|
+
sections[id] = section;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
data.duplicates = {
|
|
90
|
+
sections,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ArchivedLightSegments
|
|
1
|
+
import { ArchivedLightSegments } from "../Archive.types";
|
|
2
2
|
export declare const lightSegments: ArchivedLightSegments[];
|
|
3
3
|
export declare const lightSemgnetGet: Record<ArchivedLightSegments, (value: number) => number>;
|
|
4
4
|
export declare const lightSemgnetSet: Record<ArchivedLightSegments, (value: number, source: number) => number>;
|
|
5
5
|
export declare function uint16To4CharString(value: number): string;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function getLightBuffer(light: ArchivedLightSegments, buffer: Uint16Array): Uint8Array;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setNibbleArrayIndex } from "../../../Util/Binary/BinaryArrays";
|
|
1
2
|
import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData";
|
|
2
3
|
const lightData = new VoxelLightData();
|
|
3
4
|
export const lightSegments = [
|
|
@@ -31,45 +32,19 @@ export function uint16To4CharString(value) {
|
|
|
31
32
|
const result = chars.join("").replace(/^0+(?!$)/, "");
|
|
32
33
|
return result;
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return false;
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (typeof sourceValue === "number" ||
|
|
51
|
-
typeof sourceValue === "string" ||
|
|
52
|
-
typeof targetValue === "number" ||
|
|
53
|
-
typeof targetValue === "string") {
|
|
54
|
-
if (sourceValue !== targetValue)
|
|
55
|
-
return false;
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (sourceValue instanceof Uint8Array ||
|
|
59
|
-
sourceValue instanceof Uint16Array) {
|
|
60
|
-
if (!(targetValue instanceof sourceValue.constructor))
|
|
61
|
-
return false;
|
|
62
|
-
if (sourceValue.length !== targetValue.length)
|
|
63
|
-
return false;
|
|
64
|
-
let target = targetValue;
|
|
65
|
-
for (let i = 0; i < target.length; i++) {
|
|
66
|
-
if (sourceValue[i] != target[i])
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
35
|
+
export function getLightBuffer(light, buffer) {
|
|
36
|
+
const array = new Uint8Array(buffer.length / 2);
|
|
37
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
38
|
+
let l = 0;
|
|
39
|
+
if (light == "sun")
|
|
40
|
+
l = lightData.getS(buffer[i]);
|
|
41
|
+
if (light == "red")
|
|
42
|
+
l = lightData.getR(buffer[i]);
|
|
43
|
+
if (light == "green")
|
|
44
|
+
l = lightData.getG(buffer[i]);
|
|
45
|
+
if (light == "blue")
|
|
46
|
+
l = lightData.getB(buffer[i]);
|
|
47
|
+
setNibbleArrayIndex(array, i, l);
|
|
70
48
|
}
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
export function compareSection(section1, section2) {
|
|
74
|
-
return traverseSection(section1, section2);
|
|
49
|
+
return array;
|
|
75
50
|
}
|