diff options
author | jacopograndi <jacopo.grandi@outlook.it> | 2022-02-08 11:24:51 +0100 |
---|---|---|
committer | jacopograndi <jacopo.grandi@outlook.it> | 2022-02-08 11:24:51 +0100 |
commit | eea642395bb0ef706c7241d4a749f3e0ac4cc460 (patch) | |
tree | 6c015c9315b0102247661f942b018ccf8c45551d /scripts/load_map.gd | |
parent | e8b2ea6b2bf789b7942d86faebbcc4d810741f25 (diff) |
revised wave generation
Diffstat (limited to 'scripts/load_map.gd')
-rw-r--r-- | scripts/load_map.gd | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/load_map.gd b/scripts/load_map.gd index 13d9255..6a2c67c 100644 --- a/scripts/load_map.gd +++ b/scripts/load_map.gd @@ -1,7 +1,7 @@ extends Node var mapname = "map0.json" -var mappath = "user://" +var mappath = "./assets/maps/" var _world : VoxelMesh = null var _path_holder : Node = null @@ -29,6 +29,14 @@ func get_map_state (): fetch() var state = {} + state["voxels-palette"] = [] + for id in _world.voxel_set.get_ids(): + var col : Color = _world.voxel_set.get_voxel(id).color + var pal = { + "color": [ col.r, col.g, col.b, col.a ], + "id": id } + state["voxels-palette"] += [pal] + state["voxels"] = [] for pos in _world.get_voxels(): var vox = { "pos": [pos.x, pos.y, pos.z], "id":_world.get_voxel_id(pos) } @@ -60,7 +68,14 @@ func get_map_state (): func set_map_state (state): fetch() + _world.erase_voxels() + + _world.voxel_set.erase_voxels() + for vox in state["voxels-palette"]: + var col = Color(vox.color[0], vox.color[1], vox.color[2], vox.color[3]) + _world.voxel_set.add_voxel({ "color": col }) + for vox in state["voxels"]: var vecpos = Vector3(vox.pos[0], vox.pos[1], vox.pos[2]); _world.set_voxel(vecpos, vox.id) |