2024-05-30 06:55:13 +03:00
|
|
|
extends Node3D
|
|
|
|
|
|
|
|
enum TileType {
|
|
|
|
Empty,
|
|
|
|
Plain,
|
|
|
|
Forest
|
|
|
|
}
|
|
|
|
|
|
|
|
var tile_exemplar = preload("res://scenes/models/tile.tscn");
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
var start_tile = tile_exemplar.instantiate()
|
2024-05-31 02:41:00 +03:00
|
|
|
start_tile.add_to_group("Persistent")
|
|
|
|
|
2024-05-30 06:55:13 +03:00
|
|
|
add_child(start_tile);
|
|
|
|
pass
|
|
|
|
|
2024-06-03 02:45:29 +03:00
|
|
|
func mark_empty_tiles():
|
2024-05-30 06:55:13 +03:00
|
|
|
var tiles = get_children()
|
2024-06-03 02:26:23 +03:00
|
|
|
var available = []
|
2024-05-30 06:55:13 +03:00
|
|
|
for tile in tiles:
|
2024-05-31 22:46:56 +03:00
|
|
|
tile.update_tile()
|
2024-05-30 06:55:13 +03:00
|
|
|
if tile.tile_type == TileType.Empty: continue
|
2024-06-03 02:45:29 +03:00
|
|
|
var free_dirs = tile.get_empty_dirs_around()
|
2024-05-30 06:55:13 +03:00
|
|
|
for dir in free_dirs:
|
|
|
|
var pos: Vector3 = tile.position
|
|
|
|
match dir:
|
|
|
|
"north":
|
|
|
|
pos.x += 10
|
|
|
|
"south":
|
|
|
|
pos.x -= 10
|
|
|
|
"west":
|
|
|
|
pos.z -= 10
|
|
|
|
"east":
|
|
|
|
pos.z += 10
|
2024-06-03 02:26:23 +03:00
|
|
|
if (available.has(pos)): continue
|
2024-06-03 02:45:29 +03:00
|
|
|
var empty_tile = tile_exemplar.instantiate()
|
|
|
|
empty_tile.tile_type = TileType.Empty
|
|
|
|
empty_tile.add_to_group("Persistent")
|
|
|
|
add_child(empty_tile)
|
2024-06-03 02:26:23 +03:00
|
|
|
|
2024-06-03 02:45:29 +03:00
|
|
|
empty_tile.position = pos;
|
2024-06-03 02:26:23 +03:00
|
|
|
available.push_back(pos)
|
2024-06-03 02:45:29 +03:00
|
|
|
empty_tile.update_tile()
|