diff --git a/SCsub b/SCsub index cc6f075..a840fef 100644 --- a/SCsub +++ b/SCsub @@ -65,6 +65,7 @@ module_env.add_source_files(env.modules_sources,"ui/unit_frame.cpp") module_env.add_source_files(env.modules_sources,"drag_and_drop/es_drag_and_drop.cpp") module_env.add_source_files(env.modules_sources,"skeleton/character_skeleton.cpp") +module_env.add_source_files(env.modules_sources,"skeleton/character_skeleton_3d.cpp") module_env.add_source_files(env.modules_sources,"utility/entity_create_info.cpp") diff --git a/register_types.cpp b/register_types.cpp index d0ba740..421ad54 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -58,6 +58,7 @@ #include "drag_and_drop/es_drag_and_drop.h" #include "skeleton/character_skeleton.h" +#include "skeleton/character_skeleton_3d.h" #include "utility/entity_create_info.h" #include "utility/cooldown.h" @@ -155,6 +156,7 @@ void register_entity_spell_system_types() { ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); diff --git a/skeleton/character_skeleton_3d.cpp b/skeleton/character_skeleton_3d.cpp index 6202823..857f42b 100644 --- a/skeleton/character_skeleton_3d.cpp +++ b/skeleton/character_skeleton_3d.cpp @@ -1,12 +1,12 @@ -#include "character_skeleton.h" +#include "character_skeleton_3d.h" -NodePath CharacterSkeleton::get_bone_path(int index) { +NodePath CharacterSkeleton3D::get_bone_path(int index) { ERR_FAIL_INDEX_V(index, EntityEnums::SKELETON_POINTS_MAX, NodePath()); return _bone_paths[index]; } -void CharacterSkeleton::set_bone_path(int index, NodePath path) { +void CharacterSkeleton3D::set_bone_path(int index, NodePath path) { ERR_FAIL_INDEX(index, EntityEnums::SKELETON_POINTS_MAX); _bone_paths[index] = path; @@ -14,26 +14,26 @@ void CharacterSkeleton::set_bone_path(int index, NodePath path) { _bone_nodes[index] = get_node_or_null(path); } -Ref CharacterSkeleton::get_visual(int index) { +Ref CharacterSkeleton3D::get_visual(int index) { ERR_FAIL_INDEX_V(index, EntityEnums::SKELETON_POINTS_MAX, Ref()); return _visuals[index]; } -void CharacterSkeleton::set_visual(int index, Ref entry) { +void CharacterSkeleton3D::set_visual(int index, Ref entry) { ERR_FAIL_INDEX(index, EntityEnums::SKELETON_POINTS_MAX); _visuals[index] = entry; } -Node *CharacterSkeleton::get_bone_node(EntityEnums::CharacterSkeletonPoints node_id) { +Node *CharacterSkeleton3D::get_bone_node(EntityEnums::CharacterSkeletonPoints node_id) { return _bone_nodes[node_id]; } -NodePath CharacterSkeleton::get_animation_player_path() { +NodePath CharacterSkeleton3D::get_animation_player_path() { return _animation_player_path; } -void CharacterSkeleton::set_animation_player_path(NodePath path) { +void CharacterSkeleton3D::set_animation_player_path(NodePath path) { _animation_player_path = path; Node *node = get_node_or_null(_animation_player_path); @@ -45,15 +45,15 @@ void CharacterSkeleton::set_animation_player_path(NodePath path) { } } -AnimationPlayer *CharacterSkeleton::get_animation_player() { +AnimationPlayer *CharacterSkeleton3D::get_animation_player() { return _animation_player; } -NodePath CharacterSkeleton::get_animation_tree_path() { +NodePath CharacterSkeleton3D::get_animation_tree_path() { return _animation_tree_path; } -void CharacterSkeleton::set_animation_tree_path(NodePath path) { +void CharacterSkeleton3D::set_animation_tree_path(NodePath path) { _animation_tree_path = path; Node *node = get_node_or_null(_animation_tree_path); @@ -65,11 +65,11 @@ void CharacterSkeleton::set_animation_tree_path(NodePath path) { } } -AnimationTree *CharacterSkeleton::get_animation_tree() { +AnimationTree *CharacterSkeleton3D::get_animation_tree() { return _animation_tree; } -void CharacterSkeleton::update_nodes() { +void CharacterSkeleton3D::update_nodes() { for (int i = 0; i < EntityEnums::SKELETON_POINTS_MAX; ++i) { _bone_nodes[i] = get_node_or_null(_bone_paths[i]); } @@ -78,7 +78,7 @@ void CharacterSkeleton::update_nodes() { set_animation_tree_path(_animation_tree_path); } -CharacterSkeleton::CharacterSkeleton() { +CharacterSkeleton3D::CharacterSkeleton3D() { for (int i = 0; i < EntityEnums::SKELETON_POINTS_MAX; ++i) { _bone_nodes[i] = NULL; } @@ -86,7 +86,7 @@ CharacterSkeleton::CharacterSkeleton() { _animation_player = NULL; } -void CharacterSkeleton::_notification(int p_what) { +void CharacterSkeleton3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { update_nodes(); @@ -99,12 +99,12 @@ void CharacterSkeleton::_notification(int p_what) { } } -void CharacterSkeleton::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_bone_path", "index"), &CharacterSkeleton::get_bone_path); - ClassDB::bind_method(D_METHOD("set_bone_path", "index", "path"), &CharacterSkeleton::set_bone_path); +void CharacterSkeleton3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_bone_path", "index"), &CharacterSkeleton3D::get_bone_path); + ClassDB::bind_method(D_METHOD("set_bone_path", "index", "path"), &CharacterSkeleton3D::set_bone_path); - ClassDB::bind_method(D_METHOD("get_visual", "index"), &CharacterSkeleton::get_visual); - ClassDB::bind_method(D_METHOD("set_visual", "index", "entry"), &CharacterSkeleton::set_visual); + ClassDB::bind_method(D_METHOD("get_visual", "index"), &CharacterSkeleton3D::get_visual); + ClassDB::bind_method(D_METHOD("set_visual", "index", "entry"), &CharacterSkeleton3D::set_visual); ADD_GROUP("Visuals", "visual_"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "visual_root", PROPERTY_HINT_RESOURCE_TYPE, "CharacterSkeletonVisualEntry"), "set_visual", "get_visual", EntityEnums::SKELETON_POINT_ROOT); @@ -144,18 +144,18 @@ void CharacterSkeleton::_bind_methods() { ADD_GROUP("Bone Paths", "bone_path_"); ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_root"), "set_bone_path", "get_bone_path", EntityEnums::SKELETON_POINT_ROOT); - ClassDB::bind_method(D_METHOD("get_bone_node", "bone_idx"), &CharacterSkeleton::get_bone_node); + ClassDB::bind_method(D_METHOD("get_bone_node", "bone_idx"), &CharacterSkeleton3D::get_bone_node); - ClassDB::bind_method(D_METHOD("get_animation_player_path"), &CharacterSkeleton::get_animation_player_path); - ClassDB::bind_method(D_METHOD("set_animation_player_path", "path"), &CharacterSkeleton::set_animation_player_path); + ClassDB::bind_method(D_METHOD("get_animation_player_path"), &CharacterSkeleton3D::get_animation_player_path); + ClassDB::bind_method(D_METHOD("set_animation_player_path", "path"), &CharacterSkeleton3D::set_animation_player_path); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "animation_player_path"), "set_animation_player_path", "get_animation_player_path"); - ClassDB::bind_method(D_METHOD("get_animation_tree_path"), &CharacterSkeleton::get_animation_tree_path); - ClassDB::bind_method(D_METHOD("set_animation_tree_path", "path"), &CharacterSkeleton::set_animation_tree_path); + ClassDB::bind_method(D_METHOD("get_animation_tree_path"), &CharacterSkeleton3D::get_animation_tree_path); + ClassDB::bind_method(D_METHOD("set_animation_tree_path", "path"), &CharacterSkeleton3D::set_animation_tree_path); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "animation_tree_path"), "set_animation_tree_path", "get_animation_tree_path"); - ClassDB::bind_method(D_METHOD("get_animation_player"), &CharacterSkeleton::get_animation_player); - ClassDB::bind_method(D_METHOD("get_animation_tree"), &CharacterSkeleton::get_animation_tree); + ClassDB::bind_method(D_METHOD("get_animation_player"), &CharacterSkeleton3D::get_animation_player); + ClassDB::bind_method(D_METHOD("get_animation_tree"), &CharacterSkeleton3D::get_animation_tree); - ClassDB::bind_method(D_METHOD("update_nodes"), &CharacterSkeleton::update_nodes); + ClassDB::bind_method(D_METHOD("update_nodes"), &CharacterSkeleton3D::update_nodes); } diff --git a/skeleton/character_skeleton_3d.h b/skeleton/character_skeleton_3d.h index 681e9be..620afde 100644 --- a/skeleton/character_skeleton_3d.h +++ b/skeleton/character_skeleton_3d.h @@ -1,11 +1,7 @@ -#ifndef CHARACTER_SKELETON_H -#define CHARACTER_SKELETON_H +#ifndef CHARACTER_SKELETON_3D_H +#define CHARACTER_SKELETON_3D_H -#ifdef ENTITIES_2D -#include "scene/2d/node_2d.h" -#else -#include "scene/3d/spatial.h" -#endif +#include "character_skeleton.h" #include "core/node_path.h" #include "core/ustring.h" @@ -15,17 +11,8 @@ #include "../data/character_skeleton_visual_entry.h" #include "../entity_enums.h" -#ifdef ENTITIES_2D - -class CharacterSkeleton : public Node2D { - GDCLASS(CharacterSkeleton, Node2D); - -#else - -class CharacterSkeleton : public Spatial { - GDCLASS(CharacterSkeleton, Spatial); - -#endif +class CharacterSkeleton3D : public CharacterSkeleton { + GDCLASS(CharacterSkeleton3D, CharacterSkeleton); public: NodePath get_bone_path(int index); @@ -48,7 +35,7 @@ public: void update_nodes(); - CharacterSkeleton(); + CharacterSkeleton3D(); protected: static void _bind_methods();