35 lines
720 B
GDScript
35 lines
720 B
GDScript
extends StaticBody3D
|
|
|
|
enum TileType {
|
|
Empty,
|
|
Plain,
|
|
Forest
|
|
}
|
|
|
|
@export var tile_type: TileType = TileType.Empty;
|
|
|
|
func update_tile():
|
|
var children = find_children("*tile");
|
|
for child in children:
|
|
if TileType.keys()[tile_type] == child.name.split("_")[0]:
|
|
child.visible = true;
|
|
else:
|
|
child.visible = false;
|
|
|
|
func _ready():
|
|
update_tile()
|
|
|
|
func get_free_dirs_around():
|
|
var free_tiles_around = []
|
|
if tile_type == TileType.Empty: return free_tiles_around
|
|
var raycasts = find_children("ray*");
|
|
|
|
for raycast: RayCast3D in raycasts:
|
|
raycast.force_raycast_update()
|
|
if !raycast.is_colliding():
|
|
free_tiles_around.append(raycast.name.split("_")[1])
|
|
return free_tiles_around
|
|
|
|
func _process(delta):
|
|
pass
|