Path: blob/master/scene/2d/navigation/navigation_link_2d.h
9904 views
/**************************************************************************/1/* navigation_link_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/2d/node_2d.h"3334class NavigationLink2D : public Node2D {35GDCLASS(NavigationLink2D, Node2D);3637bool enabled = true;38RID link;39RID map_override;40bool bidirectional = true;41uint32_t navigation_layers = 1;42Vector2 end_position;43Vector2 start_position;44real_t enter_cost = 0.0;45real_t travel_cost = 1.0;4647Transform2D current_global_transform;4849#ifdef DEBUG_ENABLED50void _update_debug_mesh();51#endif // DEBUG_ENABLED5253protected:54static void _bind_methods();55void _notification(int p_what);5657#ifndef DISABLE_DEPRECATED58bool _set(const StringName &p_name, const Variant &p_value);59bool _get(const StringName &p_name, Variant &r_ret) const;60#endif // DISABLE_DEPRECATED6162public:63#ifdef DEBUG_ENABLED64virtual Rect2 _edit_get_rect() const override;65virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;66#endif // DEBUG_ENABLED67RID get_rid() const;6869void set_enabled(bool p_enabled);70bool is_enabled() const { return enabled; }7172void set_navigation_map(RID p_navigation_map);73RID get_navigation_map() const;7475void set_bidirectional(bool p_bidirectional);76bool is_bidirectional() const { return bidirectional; }7778void set_navigation_layers(uint32_t p_navigation_layers);79uint32_t get_navigation_layers() const { return navigation_layers; }8081void set_navigation_layer_value(int p_layer_number, bool p_value);82bool get_navigation_layer_value(int p_layer_number) const;8384void set_start_position(Vector2 p_position);85Vector2 get_start_position() const { return start_position; }8687void set_end_position(Vector2 p_position);88Vector2 get_end_position() const { return end_position; }8990void set_global_start_position(Vector2 p_position);91Vector2 get_global_start_position() const;9293void set_global_end_position(Vector2 p_position);94Vector2 get_global_end_position() const;9596void set_enter_cost(real_t p_enter_cost);97real_t get_enter_cost() const { return enter_cost; }9899void set_travel_cost(real_t p_travel_cost);100real_t get_travel_cost() const { return travel_cost; }101102PackedStringArray get_configuration_warnings() const override;103104NavigationLink2D();105~NavigationLink2D();106107private:108void _link_enter_navigation_map();109void _link_exit_navigation_map();110void _link_update_transform();111};112113114