18 lines
758 B
GDScript
18 lines
758 B
GDScript
tool
|
|
extends TileMap
|
|
|
|
## Dictates whether tileset collision information should be exposed to game context.
|
|
export var expose_collisions: bool = true
|
|
|
|
func _enter_tree() -> void:
|
|
# It's okay to fail here for non-grid contexts.
|
|
if get_parent().connect("cell_size_changed", self, "_update_cell_size"):
|
|
_update_cell_size(get_parent().cell_size, get_parent().cell_size)
|
|
|
|
func _update_cell_size(_p_old_cell_size: Vector2, p_new_cell_size: Vector2) -> void:
|
|
# We're assuming that all tile textures are of same dimensions.
|
|
# todo: Diagnose mismatch by walking over all textures?
|
|
var tileset_texture_size := tile_set.tile_get_texture(0).get_size()
|
|
scale = p_new_cell_size / tileset_texture_size
|
|
cell_size = p_new_cell_size / scale
|