| 1 | /**************************************************************************/ |
| 2 | /* skeleton_modification_stack_2d.h */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #ifndef SKELETON_MODIFICATION_STACK_2D_H |
| 32 | #define SKELETON_MODIFICATION_STACK_2D_H |
| 33 | |
| 34 | #include "scene/2d/skeleton_2d.h" |
| 35 | #include "scene/resources/skeleton_modification_2d.h" |
| 36 | |
| 37 | /////////////////////////////////////// |
| 38 | // SkeletonModificationStack2D |
| 39 | /////////////////////////////////////// |
| 40 | |
| 41 | class Skeleton2D; |
| 42 | class SkeletonModification2D; |
| 43 | class Bone2D; |
| 44 | |
| 45 | class SkeletonModificationStack2D : public Resource { |
| 46 | GDCLASS(SkeletonModificationStack2D, Resource); |
| 47 | friend class Skeleton2D; |
| 48 | friend class SkeletonModification2D; |
| 49 | |
| 50 | protected: |
| 51 | static void _bind_methods(); |
| 52 | void _get_property_list(List<PropertyInfo> *p_list) const; |
| 53 | bool _set(const StringName &p_path, const Variant &p_value); |
| 54 | bool _get(const StringName &p_path, Variant &r_ret) const; |
| 55 | |
| 56 | public: |
| 57 | Skeleton2D *skeleton = nullptr; |
| 58 | bool is_setup = false; |
| 59 | bool enabled = false; |
| 60 | float strength = 1.0; |
| 61 | |
| 62 | enum EXECUTION_MODE { |
| 63 | execution_mode_process, |
| 64 | execution_mode_physics_process |
| 65 | }; |
| 66 | |
| 67 | Vector<Ref<SkeletonModification2D>> modifications = Vector<Ref<SkeletonModification2D>>(); |
| 68 | |
| 69 | void setup(); |
| 70 | void execute(float p_delta, int p_execution_mode); |
| 71 | |
| 72 | bool editor_gizmo_dirty = false; |
| 73 | void draw_editor_gizmos(); |
| 74 | void set_editor_gizmos_dirty(bool p_dirty); |
| 75 | |
| 76 | void enable_all_modifications(bool p_enable); |
| 77 | Ref<SkeletonModification2D> get_modification(int p_mod_idx) const; |
| 78 | void add_modification(Ref<SkeletonModification2D> p_mod); |
| 79 | void delete_modification(int p_mod_idx); |
| 80 | void set_modification(int p_mod_idx, Ref<SkeletonModification2D> p_mod); |
| 81 | |
| 82 | void set_modification_count(int p_count); |
| 83 | int get_modification_count() const; |
| 84 | |
| 85 | void set_skeleton(Skeleton2D *p_skeleton); |
| 86 | Skeleton2D *get_skeleton() const; |
| 87 | |
| 88 | bool get_is_setup() const; |
| 89 | |
| 90 | void set_enabled(bool p_enabled); |
| 91 | bool get_enabled() const; |
| 92 | |
| 93 | void set_strength(float p_strength); |
| 94 | float get_strength() const; |
| 95 | |
| 96 | SkeletonModificationStack2D(); |
| 97 | }; |
| 98 | |
| 99 | #endif // SKELETON_MODIFICATION_STACK_2D_H |
| 100 | |