/**************************************************************************/1/* path_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"33#include "scene/resources/curve.h"3435class Timer;3637class Path2D : public Node2D {38GDCLASS(Path2D, Node2D);3940Ref<Curve2D> curve;4142void _curve_changed();4344#ifdef DEBUG_ENABLED45RID debug_mesh_rid;46RID debug_instance;4748void _debug_create();49void _debug_update();50void _debug_free();51#endif // DEBUG_ENABLED5253protected:54void _notification(int p_what);55static void _bind_methods();5657public:58#ifdef DEBUG_ENABLED59virtual Rect2 _edit_get_rect() const override;60virtual bool _edit_use_rect() const override;61virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;62#endif6364void set_curve(const Ref<Curve2D> &p_curve);65Ref<Curve2D> get_curve() const;66};6768class PathFollow2D : public Node2D {69GDCLASS(PathFollow2D, Node2D);7071public:72private:73Path2D *path = nullptr;74real_t progress = 0.0;75Timer *update_timer = nullptr;76real_t h_offset = 0.0;77real_t v_offset = 0.0;78bool cubic = true;79bool loop = true;80bool rotates = true;8182void _update_transform();8384protected:85void _validate_property(PropertyInfo &p_property) const;8687void _notification(int p_what);88static void _bind_methods();8990public:91void path_changed();9293void set_progress(real_t p_progress);94real_t get_progress() const;9596void set_h_offset(real_t p_h_offset);97real_t get_h_offset() const;9899void set_v_offset(real_t p_v_offset);100real_t get_v_offset() const;101102void set_progress_ratio(real_t p_ratio);103real_t get_progress_ratio() const;104105void set_loop(bool p_loop);106bool has_loop() const;107108void set_rotation_enabled(bool p_enabled);109bool is_rotation_enabled() const;110111void set_cubic_interpolation_enabled(bool p_enabled);112bool is_cubic_interpolation_enabled() const;113114PackedStringArray get_configuration_warnings() const override;115};116117118