broken_seals_2d/game/scenes/terra_2d_world/levelgen.gd

69 lines
4.3 KiB
GDScript3
Raw Normal View History

2022-02-26 01:22:34 +01:00
tool
extends Terrain2DLevelGenerator
func _generate_chunk(chunk : Terrain2DChunk):
chunk.channel_ensure_allocated(Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
chunk.channel_ensure_allocated(Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS, 0)
2022-02-26 01:22:34 +01:00
chunk.set_voxel(2, 0, 0, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
chunk.set_voxel(3, 1, 0, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
chunk.set_voxel(4, 1, 1, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
chunk.set_voxel(1, 0, 1, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
var def_flag : int = Terrain2DChunkDefault.FLAG_CHANNEL_WALL_NORTH | Terrain2DChunkDefault.FLAG_CHANNEL_WALL_SOUTH | Terrain2DChunkDefault.FLAG_CHANNEL_WALL_EAST | Terrain2DChunkDefault.FLAG_CHANNEL_WALL_WEST #| Terrain2DChunkDefault.FLAG_CHANNEL_WALL_HOLE
var def_flag_back : int = Terrain2DChunkDefault.FLAG_CHANNEL_WALL_NORTH | Terrain2DChunkDefault.FLAG_CHANNEL_WALL_WEST #| Terrain2DChunkDefault.FLAG_CHANNEL_WALL_HOLE
chunk.set_voxel(3, 3, 3, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
chunk.set_voxel(def_flag_back, 3, 3, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
chunk.set_voxel(3, 4, 6, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
chunk.set_voxel(def_flag, 4, 6, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
2022-03-03 18:00:51 +01:00
for x in range(8, 11):
for y in range(8, 11):
chunk.set_voxel(3, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
if x == 8 && y == 8:
chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_NORTH | Terrain2DChunkDefault.FLAG_CHANNEL_WALL_WEST | Terrain2DChunkDefault.FLAG_CHANNEL_COLLIDER, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
2022-03-03 18:00:51 +01:00
chunk.set_voxel(3, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
elif x == 10 && y == 10:
chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_EAST | Terrain2DChunkDefault.FLAG_CHANNEL_WALL_SOUTH | Terrain2DChunkDefault.FLAG_CHANNEL_COLLIDER, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
2022-03-03 18:00:51 +01:00
chunk.set_voxel(3, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
elif x == 8 && y == 10:
chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_WEST | Terrain2DChunkDefault.FLAG_CHANNEL_WALL_SOUTH | Terrain2DChunkDefault.FLAG_CHANNEL_COLLIDER, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
2022-03-03 18:00:51 +01:00
elif x == 8:
chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_WEST | Terrain2DChunkDefault.FLAG_CHANNEL_COLLIDER, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
2022-03-03 18:00:51 +01:00
elif y == 8 && x == 10:
chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_NORTH | Terrain2DChunkDefault.FLAG_CHANNEL_WALL_EAST | Terrain2DChunkDefault.FLAG_CHANNEL_COLLIDER, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
2022-03-03 18:00:51 +01:00
elif y == 8:
chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_NORTH | Terrain2DChunkDefault.FLAG_CHANNEL_COLLIDER, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
2022-03-03 18:00:51 +01:00
elif x == 10:
chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_EAST | Terrain2DChunkDefault.FLAG_CHANNEL_COLLIDER, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
2022-03-03 18:00:51 +01:00
elif y == 10:
chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_SOUTH | Terrain2DChunkDefault.FLAG_CHANNEL_COLLIDER, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
2022-03-03 18:00:51 +01:00
else:
chunk.set_voxel(0, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
# chunk.set_voxel(def_flag, x, y, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
#chunk.set_voxel(1, 3, 4, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
#chunk.set_voxel(def_flag, 3, 4, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
# chunk.set_voxel(1, 3, 3, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
# chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_EAST, 3, 5, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
# chunk.set_voxel(1, 3, 3, Terrain2DChunkDefault.DEFAULT_CHANNEL_TYPE)
# chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_EAST, 3, 5, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
#
# chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_SOUTH, 6, 4, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
# chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_SOUTH, 7, 4, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
# chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_WEST, 8, 4, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)
# chunk.set_voxel(Terrain2DChunkDefault.FLAG_CHANNEL_WALL_WEST, 9, 4, Terrain2DChunkDefault.DEFAULT_CHANNEL_FLAGS)