Path: blob/master/scene/2d/navigation/navigation_region_2d.h
9904 views
/**************************************************************************/1/* navigation_region_2d.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/resources/2d/navigation_polygon.h"3334class NavigationRegion2D : public Node2D {35GDCLASS(NavigationRegion2D, Node2D);3637bool enabled = true;38bool use_edge_connections = true;3940RID region;41RID map_override;42uint32_t navigation_layers = 1;43real_t enter_cost = 0.0;44real_t travel_cost = 1.0;45Ref<NavigationPolygon> navigation_polygon;4647Transform2D current_global_transform;4849void _navigation_polygon_changed();5051Rect2 bounds;5253#ifdef DEBUG_ENABLED54private:55RID debug_mesh_rid;56RID debug_instance_rid;5758bool debug_mesh_dirty = true;5960void _set_debug_visible(bool p_visible);61void _update_debug_mesh();62void _update_debug_edge_connections_mesh();63void _update_debug_baking_rect();64void _navigation_map_changed(RID p_map);65void _navigation_debug_changed();66#endif // DEBUG_ENABLED6768protected:69void _notification(int p_what);70static void _bind_methods();7172#ifndef DISABLE_DEPRECATED73bool _set(const StringName &p_name, const Variant &p_value);74bool _get(const StringName &p_name, Variant &r_ret) const;75#endif // DISABLE_DEPRECATED7677public:78#ifdef DEBUG_ENABLED79virtual Rect2 _edit_get_rect() const override;80virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;81#endif // DEBUG_ENABLED82RID get_rid() const;8384void set_enabled(bool p_enabled);85bool is_enabled() const;8687void set_navigation_map(RID p_navigation_map);88RID get_navigation_map() const;8990void set_use_edge_connections(bool p_enabled);91bool get_use_edge_connections() const;9293void set_navigation_layers(uint32_t p_navigation_layers);94uint32_t get_navigation_layers() const;9596void set_navigation_layer_value(int p_layer_number, bool p_value);97bool get_navigation_layer_value(int p_layer_number) const;9899RID get_region_rid() const;100101void set_enter_cost(real_t p_enter_cost);102real_t get_enter_cost() const;103104void set_travel_cost(real_t p_travel_cost);105real_t get_travel_cost() const;106107void set_navigation_polygon(const Ref<NavigationPolygon> &p_navigation_polygon);108Ref<NavigationPolygon> get_navigation_polygon() const;109110PackedStringArray get_configuration_warnings() const override;111112void bake_navigation_polygon(bool p_on_thread);113void _bake_finished();114bool is_baking() const;115116Rect2 get_bounds() const { return bounds; }117118NavigationRegion2D();119~NavigationRegion2D();120121private:122void _update_bounds();123void _region_enter_navigation_map();124void _region_exit_navigation_map();125void _region_update_transform();126};127128129