@divinevoxel/vlox 0.0.71 → 0.0.73
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/Main/InitDataGenerator.js +0 -9
- package/Contexts/Base/Remote/DataSync.types.d.ts +0 -5
- package/Contexts/Base/Remote/InitDataSync.js +17 -31
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -1
- package/Init/StartConstructor.js +7 -7
- package/Init/StartWorld.d.ts +1 -1
- package/Init/StartWorld.js +0 -12
- package/Math/Indexing.d.ts +12 -3
- package/Math/Indexing.js +24 -15
- package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
- package/Mesher/Functions/CompactVoxelMesh.js +4 -5
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +72 -66
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshTexture.js +3 -4
- package/Mesher/Functions/MeshVoxel.js +20 -26
- package/Mesher/Geomtry/Primitives/QuadVertexData.d.ts +12 -10
- package/Mesher/Geomtry/Primitives/QuadVertexData.js +49 -56
- package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +2 -2
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +108 -125
- package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
- package/Mesher/Geomtry/VoxelMesh.js +2 -2
- package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.d.ts +2 -9
- package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.js +4 -16
- package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +9 -8
- package/Mesher/Geomtry/VoxelMeshBuffers.js +49 -0
- package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +10 -0
- package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +10 -0
- package/Mesher/Geomtry/index.d.ts +0 -1
- package/Mesher/Geomtry/index.js +0 -1
- package/Mesher/InitMesher.js +2 -11
- package/Mesher/InitTask.js +10 -22
- package/Mesher/Models/Common/BoundsFunctions.d.ts +1 -3
- package/Mesher/Models/Common/BoundsFunctions.js +0 -16
- package/Mesher/Models/Common/Calc/CalcConstants.js +14 -31
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -8
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +50 -52
- package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.d.ts +2 -2
- package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.js +1 -1
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.d.ts +1 -5
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +40 -42
- package/Mesher/Models/Nodes/GeometryNode.d.ts +3 -5
- package/Mesher/Models/Nodes/GeometryNode.js +1 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +3 -6
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +55 -40
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +52 -51
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +18 -19
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +37 -40
- package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.d.ts +1 -1
- package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.js +1 -1
- package/Mesher/Models/RenderedMaterials.d.ts +6 -0
- package/Mesher/{RenderedMaterials.js → Models/RenderedMaterials.js} +2 -2
- package/Mesher/Models/VoxelConstructor.d.ts +4 -5
- package/Mesher/Models/VoxelConstructor.js +23 -12
- package/Mesher/Models/{VoxelGeometryLookUp.d.ts → VoxelGeometryBuilderCacheSpace.d.ts} +6 -14
- package/Mesher/Models/{VoxelGeometryLookUp.js → VoxelGeometryBuilderCacheSpace.js} +26 -44
- package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +10 -8
- package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +44 -19
- package/Mesher/Models/VoxelModelConstructorRegister.js +3 -3
- package/Models/Defaults/CubeVoxelGeometry.js +4 -0
- package/Models/Defaults/CubeVoxelModels.js +344 -344
- package/Models/Defaults/LiquidVoxelModel.js +2 -2
- package/Models/Defaults/PanelVoxelModels.js +432 -432
- package/Models/Defaults/StairVoxelModel.js +576 -576
- package/Models/Examples.js +469 -456
- package/Models/Indexing/VoxelAOResultsIndex.d.ts +4 -4
- package/Models/Indexing/VoxelAOResultsIndex.js +15 -9
- package/Models/Indexing/VoxelFaceCullResultsIndex.d.ts +3 -3
- package/Models/Indexing/VoxelFaceCullResultsIndex.js +14 -9
- package/Models/Indexing/VoxelFaceTransparentResultsIndex.d.ts +1 -1
- package/Models/Indexing/VoxelFaceTransparentResultsIndex.js +1 -1
- package/Models/Rules/Functions/BuildFinalInputs.js +9 -7
- package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
- package/Models/Rules/Functions/BuildRules.js +4 -4
- package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
- package/Models/VoxelModel.types.d.ts +14 -5
- package/Renderer/Classes/SectorMesh.d.ts +3 -4
- package/Renderer/Classes/SectorMesh.js +6 -11
- package/Renderer/InitTasks.js +6 -7
- package/Renderer/MeshManager.js +2 -2
- package/Renderer/MeshRegister.js +2 -1
- package/Settings/EngineSettings.d.ts +1 -1
- package/Settings/EngineSettings.js +3 -5
- package/Settings/EngineSettings.types.d.ts +17 -18
- package/Settings/EngineSettings.types.js +16 -15
- package/Tasks/IWG/IWG.d.ts +2 -1
- package/Tasks/IWG/IWG.js +9 -3
- package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +11 -0
- package/Tasks/IWG/Internal/Classes/BuildQueue.js +49 -0
- package/Tasks/IWG/Internal/Classes/Generator.d.ts +6 -1
- package/Tasks/IWG/Internal/Classes/Generator.js +14 -2
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.js +2 -2
- package/Tasks/IWG/Internal/Functions/getSectorState.js +4 -7
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +21 -2
- package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +5 -6
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -4
- package/Tasks/IWG/Internal/IWGTasks.js +12 -31
- package/Tasks/IWG/Internal/IWGTools.d.ts +1 -1
- package/Tasks/IWG/Procedures/SaveAllSectors.js +2 -0
- package/Tasks/Propagation/Flow/FlowManager.d.ts +0 -2
- package/Tasks/Propagation/Flow/FlowManager.js +86 -87
- package/Tasks/Propagation/Flow/WorldFlow.js +2 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -2
- package/Tasks/Update/InitTasks.d.ts +2 -1
- package/Tasks/Update/InitTasks.js +6 -6
- package/Tasks/Update/UpdateTask.d.ts +3 -1
- package/Tasks/Update/UpdateTask.js +28 -2
- package/Tasks/Update/VoxelUpdate.js +21 -7
- package/Tasks/WorldGeneration/WorldGenBrush.js +2 -1
- package/Templates/Cursor/TemplateCursor.d.ts +2 -2
- package/Templates/Cursor/TemplateCursor.js +1 -2
- package/Templates/Functions/CreateTemplate.js +1 -1
- package/Templates/VoxelTemplate.js +6 -8
- package/Templates/VoxelTemplates.types.d.ts +1 -1
- package/Textures/Classes/CompiledTexture.d.ts +18 -0
- package/Textures/Classes/CompiledTexture.js +50 -0
- package/Textures/Classes/CompiledTextureAnimation.d.ts +12 -0
- package/Textures/Classes/CompiledTextureAnimation.js +27 -0
- package/Textures/Classes/TextureAnimationTexture.d.ts +10 -0
- package/Textures/Classes/TextureAnimationTexture.js +32 -0
- package/Textures/Functions/BuildTextureData.d.ts +10 -0
- package/Textures/Functions/BuildTextureData.js +205 -0
- package/Textures/Texture.types.d.ts +50 -64
- package/Textures/TextureManager.d.ts +8 -19
- package/Textures/TextureManager.js +28 -166
- package/Tools/Brush/Brush.d.ts +1 -3
- package/Tools/Brush/Brush.js +43 -12
- package/Util/Binary/BinaryArrays.d.ts +6 -0
- package/Util/Binary/BinaryArrays.js +25 -0
- package/Util/Binary/BinaryBuffer.d.ts +29 -0
- package/Util/Binary/BinaryBuffer.js +130 -0
- package/Util/Binary/BinaryFunctions.d.ts +3 -0
- package/Util/Binary/BinaryFunctions.js +11 -0
- package/Util/StringPalette.d.ts +1 -0
- package/Util/StringPalette.js +8 -0
- package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.d.ts +6 -6
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +11 -16
- package/Voxels/Cursor/VoxelCursor.interface.js +35 -58
- package/Voxels/Cursor/VoxelCursor.js +13 -12
- package/Voxels/Cursor/VoxelLightData.d.ts +3 -4
- package/Voxels/Cursor/VoxelLightData.js +8 -7
- package/Voxels/Data/VoxelPalettesRegister.d.ts +8 -0
- package/Voxels/Data/VoxelPalettesRegister.js +8 -0
- package/Voxels/Data/VoxelTag.types.d.ts +56 -0
- package/Voxels/Data/VoxelTag.types.js +23 -0
- package/Voxels/{State → Data}/VoxelTagStates.d.ts +2 -2
- package/Voxels/{State → Data}/VoxelTagStates.js +5 -5
- package/Voxels/Data/VoxelTagsRegister.d.ts +9 -0
- package/Voxels/Data/VoxelTagsRegister.js +32 -0
- package/Voxels/Functions/BuildStateData.js +12 -12
- package/Voxels/Functions/BuildTagAndPaletteData.d.ts +13 -0
- package/Voxels/Functions/BuildTagAndPaletteData.js +55 -0
- package/Voxels/Indexes/VoxelIndex.js +3 -3
- package/Voxels/InitVoxelData.js +31 -73
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/Types/Voxel.types.d.ts +20 -42
- package/Voxels/Types/Voxel.types.js +6 -17
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +11 -13
- package/Voxels/Types/VoxelSubstances.types.d.ts +2 -15
- package/Voxels/Types/VoxelSubstances.types.js +1 -9
- package/World/Archive/Archive.types.d.ts +38 -34
- package/World/Archive/Functions/ArchiveArea.js +18 -30
- package/World/Archive/Functions/ArchiveSector.js +484 -213
- package/World/Archive/Functions/ImportSector.d.ts +3 -3
- package/World/Archive/Functions/ImportSector.js +205 -151
- package/World/Archive/Functions/Shared.d.ts +6 -0
- package/World/Archive/Functions/Shared.js +75 -0
- package/World/Archive/InitTasks.js +30 -13
- package/World/Cursor/SectionCursor.d.ts +3 -2
- package/World/Cursor/SectionCursor.js +9 -4
- package/World/Cursor/SectorCursor.d.ts +3 -2
- package/World/Cursor/SectorCursor.js +5 -3
- package/World/Cursor/WorldCursor.d.ts +2 -2
- package/World/Cursor/WorldCursor.js +6 -3
- package/World/Cursor/WorldVoxelCursor.d.ts +7 -7
- package/World/Cursor/WorldVoxelCursor.js +21 -24
- package/World/InitTasks.d.ts +1 -1
- package/World/Lock/WorldLock.d.ts +1 -1
- package/World/Section/Section.d.ts +31 -23
- package/World/Section/Section.js +116 -18
- package/World/Section/SectionState.d.ts +10 -0
- package/World/Section/SectionState.js +11 -0
- package/World/Sector/Sector.d.ts +24 -9
- package/World/Sector/Sector.js +92 -21
- package/World/Sector/SectorHeightMap.js +3 -5
- package/World/Sector/SectorState.d.ts +21 -0
- package/World/Sector/SectorState.js +28 -0
- package/World/WorldRegister.d.ts +4 -0
- package/World/WorldRegister.js +15 -3
- package/World/WorldSpaces.d.ts +6 -0
- package/World/WorldSpaces.js +25 -6
- package/package.json +1 -1
- package/Data/Cursor/DataCursor.interface.d.ts +0 -5
- package/Data/Cursor/DataCursor.interface.js +0 -2
- package/Data/Register/MappedDataRegister.d.ts +0 -5
- package/Data/Register/MappedDataRegister.js +0 -9
- package/Data/Register/MappedRegisterBase.d.ts +0 -14
- package/Data/Register/MappedRegisterBase.js +0 -50
- package/Data/Structs/StructBuilder.d.ts +0 -34
- package/Data/Structs/StructBuilder.js +0 -157
- package/Data/Structs/StructBuilder.types.d.ts +0 -30
- package/Mesher/Functions/CompactMesh.d.ts +0 -2
- package/Mesher/Functions/CompactMesh.js +0 -42
- package/Mesher/Geomtry/Buffers.js +0 -81
- package/Mesher/Geomtry/GeometryNormals.d.ts +0 -10
- package/Mesher/Geomtry/GeometryNormals.js +0 -52
- package/Mesher/Geomtry/MeshData.types.d.ts +0 -13
- package/Mesher/Geomtry/MeshData.types.js +0 -6
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +0 -7
- package/Mesher/Geomtry/Tools/MesherDataTools.js +0 -12
- package/Mesher/Geomtry/Tools/index.d.ts +0 -1
- package/Mesher/Geomtry/Tools/index.js +0 -1
- package/Mesher/RenderedMaterials.d.ts +0 -6
- package/Models/Rules/VoxelModelManager.js +0 -82
- package/Textures/TextureAnimations.d.ts +0 -4
- package/Textures/TextureAnimations.js +0 -35
- package/Textures/TextureArray.d.ts +0 -47
- package/Textures/TextureArray.js +0 -202
- package/Textures/TextureBuilder.d.ts +0 -13
- package/Textures/TextureBuilder.js +0 -120
- package/Textures/TextureRegister.d.ts +0 -9
- package/Textures/TextureRegister.js +0 -28
- package/Tools/Data/SubstanceDataTool.d.ts +0 -13
- package/Tools/Data/SubstanceDataTool.js +0 -51
- package/Voxels/Palettes/MaterialPalette.d.ts +0 -9
- package/Voxels/Palettes/MaterialPalette.js +0 -11
- package/Voxels/Palettes/SubstancePalette.d.ts +0 -9
- package/Voxels/Palettes/SubstancePalette.js +0 -11
- package/Voxels/Palettes/VoxelPalette.d.ts +0 -11
- package/Voxels/Palettes/VoxelPalette.js +0 -15
- package/Voxels/Segments/MaterialDataGenerator.d.ts +0 -6
- package/Voxels/Segments/MaterialDataGenerator.js +0 -12
- package/Voxels/Segments/SubstanceDataGenerator.d.ts +0 -6
- package/Voxels/Segments/SubstanceDataGenerator.js +0 -35
- package/Voxels/Segments/VoxelDataGenerator.d.ts +0 -10
- package/Voxels/Segments/VoxelDataGenerator.js +0 -56
- package/Voxels/Structs/Builder/SubstanceStructBuilder.d.ts +0 -2
- package/Voxels/Structs/Builder/SubstanceStructBuilder.js +0 -42
- package/Voxels/Structs/Builder/VoxelStructBuilder.d.ts +0 -2
- package/Voxels/Structs/Builder/VoxelStructBuilder.js +0 -68
- package/Voxels/Structs/SubstanceStruct.d.ts +0 -17
- package/Voxels/Structs/SubstanceStruct.js +0 -17
- package/Voxels/Structs/VoxelStruct.d.ts +0 -27
- package/Voxels/Structs/VoxelStruct.js +0 -29
- package/World/Section/SectionHeightMap.d.ts +0 -10
- package/World/Section/SectionHeightMap.js +0 -39
- package/World/Section/SectionStruct.d.ts +0 -8
- package/World/Section/SectionStruct.js +0 -29
- package/World/Section/SectionStructProperties.d.ts +0 -10
- package/World/Section/SectionStructProperties.js +0 -11
- package/World/Sector/SectorStruct.d.ts +0 -1
- package/World/Sector/SectorStruct.js +0 -46
- package/World/Sector/SectorStructIds.d.ts +0 -13
- package/World/Sector/SectorStructIds.js +0 -14
- package/World/Structs/WorldDataStructProperties.d.ts +0 -8
- package/World/Structs/WorldDataStructProperties.js +0 -9
- /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
- /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.d.ts +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.js +0 -0
- /package/{Data/Structs/StructBuilder.types.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
- /package/Voxels/{VoxelLevelReader.d.ts → Cursor/VoxelLevelReader.d.ts} +0 -0
- /package/Voxels/{VoxelLevelReader.js → Cursor/VoxelLevelReader.js} +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.js +0 -0
package/World/Sector/Sector.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { RemoteBinaryStruct } from "@amodx/binary/";
|
|
2
1
|
import { Section } from "../Section/Section.js";
|
|
3
2
|
import { WorldSpaces } from "../WorldSpaces";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
3
|
+
import { getBitArrayIndex, setBitArrayIndex, } from "../../Util/Binary/BinaryArrays.js";
|
|
4
|
+
import { SectorState, SectorStateDefaultBitFlags } from "./SectorState.js";
|
|
5
|
+
import { forceMultipleOf2 } from "../../Util/Binary/BinaryFunctions.js";
|
|
7
6
|
export class Sector {
|
|
8
|
-
|
|
7
|
+
position;
|
|
8
|
+
static FlagIds = SectorState.Flags;
|
|
9
|
+
static TimeStampIds = SectorState.TimeStamps;
|
|
9
10
|
static GetHeaderSize() {
|
|
10
|
-
return forceMultipleOf2(
|
|
11
|
+
return forceMultipleOf2(
|
|
12
|
+
//12 bytes fot flags
|
|
13
|
+
12 +
|
|
14
|
+
//12 * 4 bytes for time stamps
|
|
15
|
+
12 * 4);
|
|
11
16
|
}
|
|
12
17
|
static GetBufferSize() {
|
|
13
18
|
const totalSections = WorldSpaces.sector.bounds.y / WorldSpaces.section.bounds.y;
|
|
@@ -15,45 +20,111 @@ export class Sector {
|
|
|
15
20
|
}
|
|
16
21
|
static CreateNew() {
|
|
17
22
|
const buffer = new SharedArrayBuffer(this.GetBufferSize());
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
const flagArray = new Uint8Array(buffer, 0, 12);
|
|
24
|
+
const timeStampArray = new Uint32Array(buffer, 12, 12);
|
|
20
25
|
const sections = [];
|
|
21
|
-
const totalSections = WorldSpaces.sector.
|
|
26
|
+
const totalSections = WorldSpaces.sector.sectionVolumne;
|
|
22
27
|
for (let i = 0; i < totalSections; i++) {
|
|
23
28
|
sections[i] = Section.CreateNew(i, buffer);
|
|
24
29
|
}
|
|
25
30
|
return {
|
|
26
|
-
position: [0, 0, 0],
|
|
27
31
|
buffer,
|
|
32
|
+
flagArray,
|
|
33
|
+
timeStampArray,
|
|
28
34
|
sections,
|
|
29
35
|
};
|
|
30
36
|
}
|
|
31
37
|
sections = [];
|
|
32
38
|
bufferView;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
this.sectorState = new DataView(data.buffer);
|
|
39
|
+
constructor(data, position) {
|
|
40
|
+
this.position = position;
|
|
41
|
+
this.flagArray = data.flagArray;
|
|
42
|
+
this.timeStampArray = data.timeStampArray;
|
|
38
43
|
this.buffer = data.buffer;
|
|
39
44
|
this.bufferView = new Uint8Array(data.buffer);
|
|
40
45
|
for (let i = 0; i < data.sections.length; i++) {
|
|
41
46
|
this.sections[i] = new Section(this, i, data.sections[i]);
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
|
-
getSection(y) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
getSection(x, y, z) {
|
|
50
|
+
return this.sections[WorldSpaces.section.getIndex(x, y, z)];
|
|
51
|
+
}
|
|
52
|
+
setBitFlag(index, value) {
|
|
53
|
+
setBitArrayIndex(this.flagArray, index, value ? 1 : 0);
|
|
54
|
+
}
|
|
55
|
+
getBitFlag(index) {
|
|
56
|
+
return getBitArrayIndex(this.flagArray, index) == 1;
|
|
57
|
+
}
|
|
58
|
+
setStored(stored) {
|
|
59
|
+
this.setBitFlag(SectorStateDefaultBitFlags.isStored, stored);
|
|
60
|
+
}
|
|
61
|
+
isStored() {
|
|
62
|
+
return this.getBitFlag(SectorStateDefaultBitFlags.isStored);
|
|
63
|
+
}
|
|
64
|
+
setTimeStamp(index, value) {
|
|
65
|
+
this.timeStampArray[index] = value;
|
|
66
|
+
}
|
|
67
|
+
getTimeStamp(index) {
|
|
68
|
+
return this.timeStampArray[index];
|
|
69
|
+
}
|
|
70
|
+
*getRenerableSections() {
|
|
71
|
+
for (const section of this.sections) {
|
|
72
|
+
const [min, max] = section.getMinMax();
|
|
73
|
+
if (min == Infinity || max == -Infinity)
|
|
74
|
+
continue;
|
|
75
|
+
yield section;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
anySectionDirty() {
|
|
79
|
+
for (let i = 0; i < this.sections.length; i++) {
|
|
80
|
+
if (this.sections[i].isDirty() && !this.sections[i].isInProgress())
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
storeFlags() {
|
|
86
|
+
const stored = {};
|
|
87
|
+
for (const key in SectorState.StoredFlags) {
|
|
88
|
+
stored[key] = this.getBitFlag(SectorState.StoredFlags[key]);
|
|
89
|
+
}
|
|
90
|
+
return stored;
|
|
91
|
+
}
|
|
92
|
+
loadFlags(flags) {
|
|
93
|
+
for (const flag in flags) {
|
|
94
|
+
const storedIndex = SectorState.StoredFlags[flag];
|
|
95
|
+
if (storedIndex === undefined) {
|
|
96
|
+
console.warn(`${flag} does not exist on stored flags for sector`);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
this.setBitFlag(storedIndex, flags[flag]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
storeTimestamps() {
|
|
103
|
+
const stored = {};
|
|
104
|
+
for (const key in SectorState.StoredTimeStamps) {
|
|
105
|
+
stored[key] = this.getTimeStamp(SectorState.StoredTimeStamps[key]);
|
|
106
|
+
}
|
|
107
|
+
return stored;
|
|
108
|
+
}
|
|
109
|
+
loadTimestamps(stored) {
|
|
110
|
+
for (const timeStamp in stored) {
|
|
111
|
+
const storedIndex = SectorState.StoredTimeStamps[timeStamp];
|
|
112
|
+
if (storedIndex === undefined) {
|
|
113
|
+
console.warn(`${timeStamp} does not exist on stored timestamps for sector`);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
this.setTimeStamp(storedIndex, stored[timeStamp]);
|
|
117
|
+
}
|
|
48
118
|
}
|
|
49
119
|
toJSON() {
|
|
50
120
|
const sections = [];
|
|
51
121
|
for (const section of this.sections) {
|
|
52
|
-
sections.push(section.
|
|
122
|
+
sections.push(section.toJSON());
|
|
53
123
|
}
|
|
54
124
|
return {
|
|
55
|
-
position: this.position,
|
|
56
125
|
buffer: this.buffer,
|
|
126
|
+
flagArray: this.flagArray,
|
|
127
|
+
timeStampArray: this.timeStampArray,
|
|
57
128
|
sections,
|
|
58
129
|
};
|
|
59
130
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { $2dMooreNeighborhood } from "../../Math/CardinalNeighbors";
|
|
2
|
-
import { SectionHeightMap } from "../Section/SectionHeightMap";
|
|
3
2
|
import { WorldRegister } from "../WorldRegister";
|
|
4
3
|
import { WorldSpaces } from "../WorldSpaces";
|
|
5
4
|
export class SectorHeightMap {
|
|
@@ -32,12 +31,11 @@ export class SectorHeightMap {
|
|
|
32
31
|
const section = sector.sections[i];
|
|
33
32
|
if (!section)
|
|
34
33
|
continue;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let [sectionMin, sectionMax] = SectionHeightMap.getMinMax();
|
|
34
|
+
const sectionPOS = section.getPosition();
|
|
35
|
+
let [sectionMin, sectionMax] = section.getMinMax();
|
|
38
36
|
if (Math.abs(sectionMax) == Infinity)
|
|
39
37
|
continue;
|
|
40
|
-
sectionMax = sectionPOS + sectionMax;
|
|
38
|
+
sectionMax = sectionPOS[1] + sectionMax;
|
|
41
39
|
if (maxHeight < sectionMax) {
|
|
42
40
|
maxHeight = sectionMax;
|
|
43
41
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare enum SectorStateDefaultBitFlags {
|
|
2
|
+
isWorldGenDone = 0,
|
|
3
|
+
isWorldDecorDone = 1,
|
|
4
|
+
isWorldPropagationDone = 2,
|
|
5
|
+
isWorldSunDone = 3,
|
|
6
|
+
isDirty = 4,
|
|
7
|
+
isStored = 5
|
|
8
|
+
}
|
|
9
|
+
export declare enum SectorStateDefaultTimeStamps {
|
|
10
|
+
lastSaveTimestamp = 0
|
|
11
|
+
}
|
|
12
|
+
export declare class SectorState {
|
|
13
|
+
/**The default bit flags for secotrs */
|
|
14
|
+
static Flags: typeof SectorStateDefaultBitFlags;
|
|
15
|
+
/**An array of bit flags tht are preserved when the sector is stored */
|
|
16
|
+
static StoredFlags: Record<string, number>;
|
|
17
|
+
/**The default timestamps for secotrs */
|
|
18
|
+
static TimeStamps: typeof SectorStateDefaultTimeStamps;
|
|
19
|
+
/**An array of bit timestamps tht are preserved when the sector is stored */
|
|
20
|
+
static StoredTimeStamps: Record<string, number>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export var SectorStateDefaultBitFlags;
|
|
2
|
+
(function (SectorStateDefaultBitFlags) {
|
|
3
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["isWorldGenDone"] = 0] = "isWorldGenDone";
|
|
4
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["isWorldDecorDone"] = 1] = "isWorldDecorDone";
|
|
5
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["isWorldPropagationDone"] = 2] = "isWorldPropagationDone";
|
|
6
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["isWorldSunDone"] = 3] = "isWorldSunDone";
|
|
7
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["isDirty"] = 4] = "isDirty";
|
|
8
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["isStored"] = 5] = "isStored";
|
|
9
|
+
})(SectorStateDefaultBitFlags || (SectorStateDefaultBitFlags = {}));
|
|
10
|
+
export var SectorStateDefaultTimeStamps;
|
|
11
|
+
(function (SectorStateDefaultTimeStamps) {
|
|
12
|
+
SectorStateDefaultTimeStamps[SectorStateDefaultTimeStamps["lastSaveTimestamp"] = 0] = "lastSaveTimestamp";
|
|
13
|
+
})(SectorStateDefaultTimeStamps || (SectorStateDefaultTimeStamps = {}));
|
|
14
|
+
export class SectorState {
|
|
15
|
+
/**The default bit flags for secotrs */
|
|
16
|
+
static Flags = SectorStateDefaultBitFlags;
|
|
17
|
+
/**An array of bit flags tht are preserved when the sector is stored */
|
|
18
|
+
static StoredFlags = {
|
|
19
|
+
dve_is_world_gen_done: SectorStateDefaultBitFlags.isWorldGenDone,
|
|
20
|
+
dve_is_world_decoration_done: SectorStateDefaultBitFlags.isWorldDecorDone,
|
|
21
|
+
dve_is_world_progation_done: SectorStateDefaultBitFlags.isWorldPropagationDone,
|
|
22
|
+
dve_is_world_sun_done: SectorStateDefaultBitFlags.isWorldSunDone,
|
|
23
|
+
};
|
|
24
|
+
/**The default timestamps for secotrs */
|
|
25
|
+
static TimeStamps = SectorStateDefaultTimeStamps;
|
|
26
|
+
/**An array of bit timestamps tht are preserved when the sector is stored */
|
|
27
|
+
static StoredTimeStamps = {};
|
|
28
|
+
}
|
package/World/WorldRegister.d.ts
CHANGED
|
@@ -19,9 +19,13 @@ declare class WorldRegisterDimensions {
|
|
|
19
19
|
declare class WorldRegisterSectors {
|
|
20
20
|
static setSecotrPool(enabled: boolean): void;
|
|
21
21
|
static add(dimensionId: string, x: number, y: number, z: number, sector: SectorData): Sector;
|
|
22
|
+
static addAt(location: LocationData, sector: SectorData): Sector;
|
|
22
23
|
static new(dimensionId: string, x: number, y: number, z: number): boolean;
|
|
24
|
+
static newAt(location: LocationData): boolean;
|
|
23
25
|
static get(dimensionId: string, x: number, y: number, z: number): false | Sector;
|
|
26
|
+
static getAt(location: LocationData): false | Sector;
|
|
24
27
|
static remove(dimensionId: string, x: number, y: number, z: number): boolean;
|
|
28
|
+
static removeAt(location: LocationData): boolean;
|
|
25
29
|
}
|
|
26
30
|
export declare class WorldRegister {
|
|
27
31
|
static _dimensions: Map<string, Dimension>;
|
package/World/WorldRegister.js
CHANGED
|
@@ -35,6 +35,7 @@ class SectorPool {
|
|
|
35
35
|
}
|
|
36
36
|
static returnSector(secotr) {
|
|
37
37
|
secotr.bufferView.fill(0);
|
|
38
|
+
this._secotrs.push(secotr.toJSON());
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
class WorldRegisterSectors {
|
|
@@ -46,21 +47,26 @@ class WorldRegisterSectors {
|
|
|
46
47
|
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
47
48
|
if (!dimension)
|
|
48
49
|
dimension = WorldRegister.dimensions.add(dimensionId);
|
|
49
|
-
WorldSpaces.sector.getPositionVec3Array(x, y, z
|
|
50
|
-
const newSector = new Sector(sector);
|
|
50
|
+
const newSector = new Sector(sector, WorldSpaces.sector.getPositionVec3Array(x, y, z));
|
|
51
51
|
dimension.sectors.set(WorldSpaces.hash.hashVec3Array(newSector.position), newSector);
|
|
52
52
|
return newSector;
|
|
53
53
|
}
|
|
54
|
+
static addAt(location, sector) {
|
|
55
|
+
return this.add(...location, sector);
|
|
56
|
+
}
|
|
54
57
|
static new(dimensionId, x, y, z) {
|
|
55
58
|
if (this.get(dimensionId, x, y, z))
|
|
56
59
|
return false;
|
|
57
60
|
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
58
61
|
if (!dimension)
|
|
59
62
|
dimension = WorldRegister.dimensions.add(dimensionId);
|
|
60
|
-
const sector = this.add(dimensionId, x, y, z,
|
|
63
|
+
const sector = this.add(dimensionId, x, y, z, SectorPool.getSector());
|
|
61
64
|
WorldDataHooks.sectors.onNew([dimensionId, x, y, z], sector);
|
|
62
65
|
return true;
|
|
63
66
|
}
|
|
67
|
+
static newAt(location) {
|
|
68
|
+
return this.new(...location);
|
|
69
|
+
}
|
|
64
70
|
static get(dimensionId, x, y, z) {
|
|
65
71
|
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
66
72
|
if (!dimension)
|
|
@@ -68,6 +74,9 @@ class WorldRegisterSectors {
|
|
|
68
74
|
const sector = dimension.sectors.get(WorldSpaces.hash.hashVec3(WorldSpaces.sector.getPosition(x, y, z, tempPosition)));
|
|
69
75
|
return sector || false;
|
|
70
76
|
}
|
|
77
|
+
static getAt(location) {
|
|
78
|
+
return this.get(...location);
|
|
79
|
+
}
|
|
71
80
|
static remove(dimensionId, x, y, z) {
|
|
72
81
|
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
73
82
|
if (!dimension)
|
|
@@ -83,6 +92,9 @@ class WorldRegisterSectors {
|
|
|
83
92
|
dimension.sectors.delete(sectorKey);
|
|
84
93
|
return true;
|
|
85
94
|
}
|
|
95
|
+
static removeAt(location) {
|
|
96
|
+
return this.remove(...location);
|
|
97
|
+
}
|
|
86
98
|
}
|
|
87
99
|
export class WorldRegister {
|
|
88
100
|
static _dimensions = new Map();
|
package/World/WorldSpaces.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ declare class SectorSpace {
|
|
|
23
23
|
static power2Axes: Vector3Like;
|
|
24
24
|
static bounds: Vector3Like;
|
|
25
25
|
static volumne: number;
|
|
26
|
+
static sectionBounds: Vector3Like;
|
|
27
|
+
static sectionVolumne: number;
|
|
26
28
|
static getPosition(x: number, y: number, z: number, refPosition?: Vector3Like): Vector3Like;
|
|
27
29
|
static getPositionVec3Array(x: number, y: number, z: number, refPosition?: Vec3Array): Vec3Array;
|
|
28
30
|
}
|
|
@@ -33,12 +35,16 @@ declare class SectionSpace {
|
|
|
33
35
|
static getPosition(x: number, y: number, z: number, refPosition?: Vector3Like): Vector3Like;
|
|
34
36
|
static getPositionVec3Array(x: number, y: number, z: number, refPosition?: Vec3Array): Vec3Array;
|
|
35
37
|
static getIndex(x: number, y: number, z: number): number;
|
|
38
|
+
static getPositionFromIndex(index: number, refPosition?: Vector3Like): Vector3Like;
|
|
39
|
+
static getPositionFromIndexVec3Array(index: number, refPosition?: Vec3Array): Vec3Array;
|
|
36
40
|
}
|
|
37
41
|
declare class VoxelSpace {
|
|
38
42
|
static bounds: Vector3Like;
|
|
39
43
|
static getPosition(x: number, y: number, z: number, refPosition?: Vector3Like): Vector3Like;
|
|
40
44
|
static getPositionVec3Array(x: number, y: number, z: number, refPosition?: Vec3Array): Vec3Array;
|
|
45
|
+
static getPositionFromIndex(index: number, refPosition?: Vector3Like): Vector3Like;
|
|
41
46
|
static getIndex(x: number, y: number, z: number): number;
|
|
47
|
+
static getIndexFromPosition(x: number, y: number, z: number): number;
|
|
42
48
|
}
|
|
43
49
|
declare class Hash {
|
|
44
50
|
static hashVec3(vector3: Vector3Like): string;
|
package/World/WorldSpaces.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//types
|
|
2
2
|
import { EngineSettings } from "../Settings/EngineSettings.js";
|
|
3
3
|
import { Vector3Like } from "@amodx/math";
|
|
4
|
-
import { CubeHashVec3, CubeHashVec3Array, GetYXZOrderArrayIndex, } from "../Math/Indexing.js";
|
|
4
|
+
import { CubeHashVec3, CubeHashVec3Array, GetYXZOrderArrayIndex, GetYXZOrderArrayPositionVec3, GetYXZOrderArrayPositionVec3Array, } from "../Math/Indexing.js";
|
|
5
5
|
const tempPosition = Vector3Like.Create();
|
|
6
6
|
const tempPosition2 = Vector3Like.Create();
|
|
7
7
|
class WorldBounds {
|
|
@@ -57,6 +57,8 @@ class SectorSpace {
|
|
|
57
57
|
static power2Axes = Vector3Like.Create();
|
|
58
58
|
static bounds = Vector3Like.Create();
|
|
59
59
|
static volumne = 0;
|
|
60
|
+
static sectionBounds = Vector3Like.Create();
|
|
61
|
+
static sectionVolumne = 0;
|
|
60
62
|
static getPosition(x, y, z, refPosition = Vector3Like.Create()) {
|
|
61
63
|
CubeHashVec3(x, y, z, SectorSpace.power2Axes.x, SectorSpace.power2Axes.y, SectorSpace.power2Axes.z, refPosition);
|
|
62
64
|
return refPosition;
|
|
@@ -81,7 +83,13 @@ class SectionSpace {
|
|
|
81
83
|
static getIndex(x, y, z) {
|
|
82
84
|
SectionSpace.getPosition(x, y, z, tempPosition);
|
|
83
85
|
SectorSpace.getPosition(x, y, z, tempPosition2);
|
|
84
|
-
return (tempPosition.y - tempPosition2.y) / SectionSpace.bounds.y;
|
|
86
|
+
return GetYXZOrderArrayIndex((tempPosition.x - tempPosition2.x) / SectionSpace.bounds.x, (tempPosition.y - tempPosition2.y) / SectionSpace.bounds.y, (tempPosition.z - tempPosition2.z) / SectionSpace.bounds.z, SectorSpace.sectionBounds.x, SectorSpace.sectionBounds.y, SectorSpace.sectionBounds.z);
|
|
87
|
+
}
|
|
88
|
+
static getPositionFromIndex(index, refPosition = Vector3Like.Create()) {
|
|
89
|
+
return GetYXZOrderArrayPositionVec3(index, SectorSpace.sectionBounds.x, SectorSpace.sectionBounds.y, SectorSpace.sectionBounds.z, refPosition);
|
|
90
|
+
}
|
|
91
|
+
static getPositionFromIndexVec3Array(index, refPosition = [0, 0, 0]) {
|
|
92
|
+
return GetYXZOrderArrayPositionVec3Array(index, SectorSpace.sectionBounds.x, SectorSpace.sectionBounds.y, SectorSpace.sectionBounds.z, refPosition);
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
95
|
class VoxelSpace {
|
|
@@ -100,10 +108,16 @@ class VoxelSpace {
|
|
|
100
108
|
refPosition[2] = z - refPosition[2];
|
|
101
109
|
return refPosition;
|
|
102
110
|
}
|
|
111
|
+
static getPositionFromIndex(index, refPosition = Vector3Like.Create()) {
|
|
112
|
+
return GetYXZOrderArrayPositionVec3(index, SectionSpace.bounds.x, SectionSpace.bounds.y, SectionSpace.bounds.z, refPosition);
|
|
113
|
+
}
|
|
103
114
|
static getIndex(x, y, z) {
|
|
104
115
|
const position = this.getPosition(x, y, z, tempPosition);
|
|
105
116
|
return GetYXZOrderArrayIndex(position.x, position.y, position.z, SectionSpace.bounds.x, SectionSpace.bounds.y, SectionSpace.bounds.z);
|
|
106
117
|
}
|
|
118
|
+
static getIndexFromPosition(x, y, z) {
|
|
119
|
+
return GetYXZOrderArrayIndex(x, y, z, SectionSpace.bounds.x, SectionSpace.bounds.y, SectionSpace.bounds.z);
|
|
120
|
+
}
|
|
107
121
|
}
|
|
108
122
|
class Hash {
|
|
109
123
|
static hashVec3(vector3) {
|
|
@@ -132,6 +146,8 @@ EngineSettings.addEventListener("synced", (event) => {
|
|
|
132
146
|
SectorSpace.bounds.x = 1 << SectorSpace.power2Axes.x;
|
|
133
147
|
SectorSpace.bounds.y = 1 << SectorSpace.power2Axes.y;
|
|
134
148
|
SectorSpace.bounds.z = 1 << SectorSpace.power2Axes.z;
|
|
149
|
+
SectorSpace.volumne =
|
|
150
|
+
SectorSpace.bounds.x * SectorSpace.bounds.y * SectorSpace.bounds.z;
|
|
135
151
|
SectionSpace.power2Axes.x = settings.sections.power2Size.x;
|
|
136
152
|
SectionSpace.power2Axes.y = settings.sections.power2Size.y;
|
|
137
153
|
SectionSpace.power2Axes.z = settings.sections.power2Size.z;
|
|
@@ -140,8 +156,11 @@ EngineSettings.addEventListener("synced", (event) => {
|
|
|
140
156
|
SectionSpace.bounds.z = 1 << SectionSpace.power2Axes.z;
|
|
141
157
|
SectionSpace.volumne =
|
|
142
158
|
SectionSpace.bounds.x * SectionSpace.bounds.y * SectionSpace.bounds.z;
|
|
143
|
-
SectorSpace.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
159
|
+
SectorSpace.sectionBounds.x = SectorSpace.bounds.x / SectionSpace.bounds.x;
|
|
160
|
+
SectorSpace.sectionBounds.y = SectorSpace.bounds.y / SectionSpace.bounds.y;
|
|
161
|
+
SectorSpace.sectionBounds.z = SectorSpace.bounds.z / SectionSpace.bounds.z;
|
|
162
|
+
SectorSpace.sectionVolumne =
|
|
163
|
+
SectorSpace.sectionBounds.x *
|
|
164
|
+
SectorSpace.sectionBounds.y *
|
|
165
|
+
SectorSpace.sectionBounds.z;
|
|
147
166
|
});
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { VoxelCursorInterface } from "../../Voxels/Cursor/VoxelCursor.interface";
|
|
2
|
-
export declare abstract class DataCursorInterface {
|
|
3
|
-
abstract getVoxel(x: number, y: number, z: number): VoxelCursorInterface | null;
|
|
4
|
-
abstract inBounds(x: number, y: number, z: number): boolean;
|
|
5
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MappedRegisterBase } from "./MappedRegisterBase.js";
|
|
2
|
-
export class MappedDataRegister {
|
|
3
|
-
static stringMaps = new MappedRegisterBase();
|
|
4
|
-
static objectMaps = new MappedRegisterBase();
|
|
5
|
-
}
|
|
6
|
-
MappedDataRegister.stringMaps.addSegment("voxel");
|
|
7
|
-
MappedDataRegister.objectMaps.addSegment("voxel");
|
|
8
|
-
MappedDataRegister.stringMaps.addSegment("substance");
|
|
9
|
-
MappedDataRegister.objectMaps.addSegment("substance");
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare class MappedRegisterSegment<Data> extends EventTarget {
|
|
2
|
-
entries: Map<string, Data[]>;
|
|
3
|
-
onEntryAdded(id: string, run: (data: Data[]) => void): void;
|
|
4
|
-
add(id: string, data: Data[]): void;
|
|
5
|
-
get(id: string): Data[] | undefined;
|
|
6
|
-
}
|
|
7
|
-
export declare class MappedRegisterBase<Data> {
|
|
8
|
-
segments: Map<string, MappedRegisterSegment<Data>>;
|
|
9
|
-
addSegment(id: string): MappedRegisterSegment<Data>;
|
|
10
|
-
getSegment(id: string): MappedRegisterSegment<Data>;
|
|
11
|
-
sync(segment: string, id: string, value: Data[]): void;
|
|
12
|
-
get(segment: string, id: string, index: number): Data | null;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const getSyncId = (id) => `entry-synced-${id}`;
|
|
2
|
-
class MappedRegisterSegment extends EventTarget {
|
|
3
|
-
entries = new Map();
|
|
4
|
-
onEntryAdded(id, run) {
|
|
5
|
-
const entrySyncedId = getSyncId(id);
|
|
6
|
-
const listener = () => {
|
|
7
|
-
run(this.entries.get(id));
|
|
8
|
-
this.removeEventListener(entrySyncedId, listener);
|
|
9
|
-
};
|
|
10
|
-
this.addEventListener(entrySyncedId, listener);
|
|
11
|
-
}
|
|
12
|
-
add(id, data) {
|
|
13
|
-
this.entries.set(id, data);
|
|
14
|
-
this.dispatchEvent(new Event(getSyncId(id)));
|
|
15
|
-
}
|
|
16
|
-
get(id) {
|
|
17
|
-
return this.entries.get(id);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export class MappedRegisterBase {
|
|
21
|
-
segments = new Map();
|
|
22
|
-
addSegment(id) {
|
|
23
|
-
if (this.segments.has(id))
|
|
24
|
-
return this.segments.get(id);
|
|
25
|
-
const newSegment = new MappedRegisterSegment();
|
|
26
|
-
this.segments.set(id, newSegment);
|
|
27
|
-
return newSegment;
|
|
28
|
-
}
|
|
29
|
-
getSegment(id) {
|
|
30
|
-
const segment = this.segments.get(id);
|
|
31
|
-
if (!segment)
|
|
32
|
-
throw new Error(`Segment with id ${id} does not exist`);
|
|
33
|
-
return segment;
|
|
34
|
-
}
|
|
35
|
-
sync(segment, id, value) {
|
|
36
|
-
const segmentMap = this.addSegment(segment);
|
|
37
|
-
segmentMap.add(id, value);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
get(segment, id, index) {
|
|
41
|
-
const segmentMap = this.segments.get(segment);
|
|
42
|
-
if (!segmentMap)
|
|
43
|
-
return null;
|
|
44
|
-
const mapped = segmentMap.get(id);
|
|
45
|
-
if (!mapped) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
return mapped[index];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { TagBuilderNodes } from "Data/Structs/StructBuilder.types.js";
|
|
2
|
-
import { BinaryStructData, BinraryStructBase } from "@amodx/binary/";
|
|
3
|
-
import { BinaryStruct } from "@amodx/binary/";
|
|
4
|
-
export declare class StructBuilder {
|
|
5
|
-
id: string;
|
|
6
|
-
dataSegment: string;
|
|
7
|
-
_built: boolean;
|
|
8
|
-
_nodeMap: Map<string, TagBuilderNodes>;
|
|
9
|
-
_stringMaps: Map<string, {
|
|
10
|
-
count: number;
|
|
11
|
-
found: Record<string, number>;
|
|
12
|
-
map: string[];
|
|
13
|
-
allowedComms: string[];
|
|
14
|
-
}>;
|
|
15
|
-
_objectMaps: Map<string, {
|
|
16
|
-
count: number;
|
|
17
|
-
found: Record<string, number>;
|
|
18
|
-
map: any[];
|
|
19
|
-
allowedComms: string[];
|
|
20
|
-
}>;
|
|
21
|
-
_defaults: Map<string, number>;
|
|
22
|
-
_initData: BinaryStructData;
|
|
23
|
-
constructor(id: string, dataSegment: string);
|
|
24
|
-
addNode(node: TagBuilderNodes | TagBuilderNodes[]): void;
|
|
25
|
-
getNode(id: string): TagBuilderNodes | undefined;
|
|
26
|
-
setDefaults(tagManager: BinraryStructBase): void;
|
|
27
|
-
hasNode(id: string): boolean;
|
|
28
|
-
setNode(id: string, value: any, tagManager: BinraryStructBase): false | undefined;
|
|
29
|
-
build(totalTagIndexes?: number): BinaryStruct;
|
|
30
|
-
getMaps(): {
|
|
31
|
-
objectMaps: Record<string, any[]>;
|
|
32
|
-
stringMaps: Record<string, string[]>;
|
|
33
|
-
};
|
|
34
|
-
}
|