:github_url: hide .. _class_PolygonPathFinder: PolygonPathFinder ================= **继承:** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` .. container:: contribute There is currently no description for this class. Please help us by `contributing one `__! .. rst-class:: classref-reftable-group 方法 ---- .. table:: :widths: auto +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector2Array` | :ref:`find_path`\ (\ from\: :ref:`Vector2`, to\: :ref:`Vector2`\ ) | +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Rect2` | :ref:`get_bounds`\ (\ ) |const| | +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_closest_point`\ (\ point\: :ref:`Vector2`\ ) |const| | +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector2Array` | :ref:`get_intersections`\ (\ from\: :ref:`Vector2`, to\: :ref:`Vector2`\ ) |const| | +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_point_penalty`\ (\ idx\: :ref:`int`\ ) |const| | +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_point_inside`\ (\ point\: :ref:`Vector2`\ ) |const| | +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_point_penalty`\ (\ idx\: :ref:`int`, penalty\: :ref:`float`\ ) | +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`setup`\ (\ points\: :ref:`PackedVector2Array`, connections\: :ref:`PackedInt32Array`\ ) | +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 方法说明 -------- .. _class_PolygonPathFinder_method_find_path: .. rst-class:: classref-method :ref:`PackedVector2Array` **find_path**\ (\ from\: :ref:`Vector2`, to\: :ref:`Vector2`\ ) :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PolygonPathFinder_method_get_bounds: .. rst-class:: classref-method :ref:`Rect2` **get_bounds**\ (\ ) |const| :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PolygonPathFinder_method_get_closest_point: .. rst-class:: classref-method :ref:`Vector2` **get_closest_point**\ (\ point\: :ref:`Vector2`\ ) |const| :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PolygonPathFinder_method_get_intersections: .. rst-class:: classref-method :ref:`PackedVector2Array` **get_intersections**\ (\ from\: :ref:`Vector2`, to\: :ref:`Vector2`\ ) |const| :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PolygonPathFinder_method_get_point_penalty: .. rst-class:: classref-method :ref:`float` **get_point_penalty**\ (\ idx\: :ref:`int`\ ) |const| :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PolygonPathFinder_method_is_point_inside: .. rst-class:: classref-method :ref:`bool` **is_point_inside**\ (\ point\: :ref:`Vector2`\ ) |const| :ref:`🔗` 如果 ``point`` 在多边形区域内部,则返回 ``true``\ 。 .. tabs:: .. code-tab:: gdscript var polygon_path_finder = PolygonPathFinder.new() var points = [Vector2(0.0, 0.0), Vector2(1.0, 0.0), Vector2(0.0, 1.0)] var connections = [0, 1, 1, 2, 2, 0] polygon_path_finder.setup(points, connections) print(polygon_path_finder.is_point_inside(Vector2(0.2, 0.2))) # 输出 true print(polygon_path_finder.is_point_inside(Vector2(1.0, 1.0))) # 输出 false .. code-tab:: csharp var polygonPathFinder = new PolygonPathFinder(); Vector2[] points = [ new Vector2(0.0f, 0.0f), new Vector2(1.0f, 0.0f), new Vector2(0.0f, 1.0f) ]; int[] connections = [0, 1, 1, 2, 2, 0]; polygonPathFinder.Setup(points, connections); GD.Print(polygonPathFinder.IsPointInside(new Vector2(0.2f, 0.2f))); // 输出 True GD.Print(polygonPathFinder.IsPointInside(new Vector2(1.0f, 1.0f))); // 输出 False .. rst-class:: classref-item-separator ---- .. _class_PolygonPathFinder_method_set_point_penalty: .. rst-class:: classref-method |void| **set_point_penalty**\ (\ idx\: :ref:`int`, penalty\: :ref:`float`\ ) :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PolygonPathFinder_method_setup: .. rst-class:: classref-method |void| **setup**\ (\ points\: :ref:`PackedVector2Array`, connections\: :ref:`PackedInt32Array`\ ) :ref:`🔗` 使用两个数组设置 **PolygonPathFinder**\ :点数组中定义了多边形的顶点,索引数组则决定了多边形的边。 \ ``connections`` 的长度必须为偶数,为奇数时会返回错误。 .. tabs:: .. code-tab:: gdscript var polygon_path_finder = PolygonPathFinder.new() var points = [Vector2(0.0, 0.0), Vector2(1.0, 0.0), Vector2(0.0, 1.0)] var connections = [0, 1, 1, 2, 2, 0] polygon_path_finder.setup(points, connections) .. code-tab:: csharp var polygonPathFinder = new PolygonPathFinder(); Vector2[] points = [ new Vector2(0.0f, 0.0f), new Vector2(1.0f, 0.0f), new Vector2(0.0f, 1.0f) ]; int[] connections = [0, 1, 1, 2, 2, 0]; polygonPathFinder.Setup(points, connections); .. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)` .. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)` .. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)` .. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)` .. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)` .. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)` .. |void| replace:: :abbr:`void (无返回值。)`