tochie-kit/nodes/GridContext.gd

22 lines
575 B
GDScript

extends TK_Context
class_name TK_GridContext
## todo: Cell visualization.
## todo: Integration of TileMap.
export var cell_size: Vector2 = Vector2(64, 64)
func local_position_to_context_position(p_position: Vector2) -> Vector2:
return p_position / cell_size
func is_path_traversible(p_from: Vector2, p_to: Vector2) -> bool:
# todo:
return true
func try_moving(p_game_object: Node2D, p_from: Vector2, p_to: Vector2) -> bool:
if not is_path_traversible(p_from, p_to):
return false
p_game_object.position = cell_size * p_to
return true