Godsim/scripts/Tile.gd

35 lines
720 B
GDScript3
Raw Normal View History

2024-05-30 02:14:08 +03:00
extends StaticBody3D
2024-05-30 06:55:13 +03:00
enum TileType {
Empty,
Plain,
Forest
}
2024-05-30 02:14:08 +03:00
2024-05-30 06:55:13 +03:00
@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;
2024-05-30 02:14:08 +03:00
2024-05-30 06:55:13 +03:00
func _ready():
update_tile()
2024-05-30 02:14:08 +03:00
2024-05-30 06:55:13 +03:00
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
2024-05-30 02:14:08 +03:00
func _process(delta):
pass