Godsim/scripts/Earth.gd

39 lines
771 B
GDScript3
Raw Normal View History

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()
add_child(start_tile);
func _physics_process(delta):
pass
func mark_free_tiles():
var tiles = get_children()
for tile in tiles:
if tile.tile_type == TileType.Empty: continue
var free_dirs = tile.get_free_dirs_around();
for dir in free_dirs:
var free_tile = tile_exemplar.instantiate()
free_tile.tile_type = TileType.Empty
add_child(free_tile)
var pos: Vector3 = tile.position
match dir:
"north":
pos.x += 10
"south":
pos.x -= 10
"west":
pos.z -= 10
"east":
pos.z += 10
free_tile.position = pos;
free_tile.update_tile()