Small cleanups.

This commit is contained in:
Relintai 2019-10-26 15:13:04 +02:00
parent 56a333bef5
commit 952bbb113d
4 changed files with 20 additions and 53 deletions

View File

@ -1,24 +1,10 @@
#include "item_visual_entry.h" #include "item_visual_entry.h"
int ItemVisualEntry::get_id() { ItemEnums::EntityTextureLayers ItemVisualEntry::get_override_layer() {
return _id; return _override_layer;
} }
void ItemVisualEntry::set_id(int id) { void ItemVisualEntry::set_override_layer(ItemEnums::EntityTextureLayers layer) {
_id = id; _override_layer = layer;
}
EntityEnums::CharacterSkeletonPoints ItemVisualEntry::get_target_bone() {
return _target_bone;
}
void ItemVisualEntry::set_target_bone(EntityEnums::CharacterSkeletonPoints bone) {
_target_bone = bone;
}
ItemEnums::EntityTextureLayers ItemVisualEntry::get_layer() {
return _layer;
}
void ItemVisualEntry::set_layer(ItemEnums::EntityTextureLayers layer) {
_layer = layer;
} }
Ref<MeshDataResource> ItemVisualEntry::get_mesh() { Ref<MeshDataResource> ItemVisualEntry::get_mesh() {
@ -50,10 +36,8 @@ void ItemVisualEntry::set_effect(Ref<PackedScene> effect) {
} }
ItemVisualEntry::ItemVisualEntry() { ItemVisualEntry::ItemVisualEntry() {
_id = 0;
_target_bone = EntityEnums::SKELETON_POINT_HEAD; _override_layer = ItemEnums::ENTITY_TEXTURE_LAYER_NONE;
_layer = ItemEnums::ENTITY_TEXTURE_LAYER_NONE;
_color = Color(1, 1, 1, 1); _color = Color(1, 1, 1, 1);
} }
@ -65,17 +49,9 @@ ItemVisualEntry::~ItemVisualEntry() {
} }
void ItemVisualEntry::_bind_methods() { void ItemVisualEntry::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_id"), &ItemVisualEntry::get_id); ClassDB::bind_method(D_METHOD("get_override_layer"), &ItemVisualEntry::get_override_layer);
ClassDB::bind_method(D_METHOD("set_id", "value"), &ItemVisualEntry::set_id); ClassDB::bind_method(D_METHOD("set_override_layer", "value"), &ItemVisualEntry::set_override_layer);
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); ADD_PROPERTY(PropertyInfo(Variant::INT, "override_layer", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_ENTITY_TEXTURE_LAYERS), "set_override_layer", "get_override_layer");
ClassDB::bind_method(D_METHOD("get_target_bone"), &ItemVisualEntry::get_target_bone);
ClassDB::bind_method(D_METHOD("set_target_bone", "bone"), &ItemVisualEntry::set_target_bone);
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_bone", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_CHARCATER_SKELETON_POINTS), "set_target_bone", "get_target_bone");
ClassDB::bind_method(D_METHOD("get_layer"), &ItemVisualEntry::get_layer);
ClassDB::bind_method(D_METHOD("set_layer", "value"), &ItemVisualEntry::set_layer);
ADD_PROPERTY(PropertyInfo(Variant::INT, "layer", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_ENTITY_TEXTURE_LAYERS), "set_layer", "get_layer");
ClassDB::bind_method(D_METHOD("get_mesh"), &ItemVisualEntry::get_mesh); ClassDB::bind_method(D_METHOD("get_mesh"), &ItemVisualEntry::get_mesh);
ClassDB::bind_method(D_METHOD("set_mesh", "value"), &ItemVisualEntry::set_mesh); ClassDB::bind_method(D_METHOD("set_mesh", "value"), &ItemVisualEntry::set_mesh);
@ -87,7 +63,7 @@ void ItemVisualEntry::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_color"), &ItemVisualEntry::get_color); ClassDB::bind_method(D_METHOD("get_color"), &ItemVisualEntry::get_color);
ClassDB::bind_method(D_METHOD("set_color", "value"), &ItemVisualEntry::set_color); ClassDB::bind_method(D_METHOD("set_color", "value"), &ItemVisualEntry::set_color);
ADD_PROPERTY(PropertyInfo(Variant::INT, "color"), "set_color", "get_color"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ClassDB::bind_method(D_METHOD("get_effect"), &ItemVisualEntry::get_effect); ClassDB::bind_method(D_METHOD("get_effect"), &ItemVisualEntry::get_effect);
ClassDB::bind_method(D_METHOD("set_effect", "value"), &ItemVisualEntry::set_effect); ClassDB::bind_method(D_METHOD("set_effect", "value"), &ItemVisualEntry::set_effect);

View File

@ -17,14 +17,8 @@ class ItemVisualEntry : public Resource {
GDCLASS(ItemVisualEntry, Resource); GDCLASS(ItemVisualEntry, Resource);
public: public:
int get_id(); ItemEnums::EntityTextureLayers get_override_layer();
void set_id(int id); void set_override_layer(ItemEnums::EntityTextureLayers layer);
EntityEnums::CharacterSkeletonPoints get_target_bone();
void set_target_bone(EntityEnums::CharacterSkeletonPoints bone);
ItemEnums::EntityTextureLayers get_layer();
void set_layer(ItemEnums::EntityTextureLayers layer);
Ref<MeshDataResource> get_mesh(); Ref<MeshDataResource> get_mesh();
void set_mesh(Ref<MeshDataResource> mesh); void set_mesh(Ref<MeshDataResource> mesh);
@ -45,10 +39,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
private: private:
int _id; ItemEnums::EntityTextureLayers _override_layer;
EntityEnums::CharacterSkeletonPoints _target_bone;
ItemEnums::EntityTextureLayers _layer;
Ref<MeshDataResource> _mesh; Ref<MeshDataResource> _mesh;
Ref<Texture> _texture; Ref<Texture> _texture;

View File

@ -93,7 +93,7 @@ void CharacterSkeleton3D::add_item_visual(Ref<ItemVisual> vis) {
Ref<ItemVisualEntry> e = vis->get_visual(i); Ref<ItemVisualEntry> e = vis->get_visual(i);
if (e.is_valid()) if (e.is_valid())
add_item_visual_entry(vis, e); add_item_visual_entry(vis, e, i);
} }
_item_visuals.push_back(vis); _item_visuals.push_back(vis);
@ -110,7 +110,7 @@ void CharacterSkeleton3D::remove_item_visual(Ref<ItemVisual> vis) {
Ref<ItemVisualEntry> e = vis->get_visual(i); Ref<ItemVisualEntry> e = vis->get_visual(i);
if (e.is_valid()) if (e.is_valid())
remove_item_visual_entry(vis, e); remove_item_visual_entry(vis, e, i);
} }
_item_visuals.remove(index); _item_visuals.remove(index);
@ -139,11 +139,11 @@ void CharacterSkeleton3D::clear_item_visuals() {
set_process(true); set_process(true);
} }
void CharacterSkeleton3D::add_item_visual_entry(Ref<ItemVisual> vis, Ref<ItemVisualEntry> ive) { void CharacterSkeleton3D::add_item_visual_entry(Ref<ItemVisual> vis, Ref<ItemVisualEntry> ive, int target_bone) {
ERR_FAIL_COND(!vis.is_valid()); ERR_FAIL_COND(!vis.is_valid());
ERR_FAIL_COND(!ive.is_valid()); ERR_FAIL_COND(!ive.is_valid());
int target_bone_idx = static_cast<int>(ive->get_target_bone()); int target_bone_idx = target_bone;
Vector<Ref<SkeletonModelEntry> > &entries = _entries[target_bone_idx]; Vector<Ref<SkeletonModelEntry> > &entries = _entries[target_bone_idx];
@ -167,11 +167,11 @@ void CharacterSkeleton3D::add_item_visual_entry(Ref<ItemVisual> vis, Ref<ItemVis
_model_dirty = true; _model_dirty = true;
set_process(true); set_process(true);
} }
void CharacterSkeleton3D::remove_item_visual_entry(Ref<ItemVisual> vis, Ref<ItemVisualEntry> ive) { void CharacterSkeleton3D::remove_item_visual_entry(Ref<ItemVisual> vis, Ref<ItemVisualEntry> ive, int target_bone) {
ERR_FAIL_COND(!vis.is_valid()); ERR_FAIL_COND(!vis.is_valid());
ERR_FAIL_COND(!ive.is_valid()); ERR_FAIL_COND(!ive.is_valid());
int target_bone_idx = static_cast<int>(ive->get_target_bone()); int target_bone_idx = target_bone;
Vector<Ref<SkeletonModelEntry> > &entries = _entries[target_bone_idx]; Vector<Ref<SkeletonModelEntry> > &entries = _entries[target_bone_idx];

View File

@ -53,8 +53,8 @@ public:
int get_item_visual_count(); int get_item_visual_count();
void clear_item_visuals(); void clear_item_visuals();
void add_item_visual_entry(Ref<ItemVisual> vis, Ref<ItemVisualEntry> ive); void add_item_visual_entry(Ref<ItemVisual> vis, Ref<ItemVisualEntry> ive, int target_bone);
void remove_item_visual_entry(Ref<ItemVisual> vis, Ref<ItemVisualEntry> ive); void remove_item_visual_entry(Ref<ItemVisual> vis, Ref<ItemVisualEntry> ive, int target_bone);
Ref<SkeletonModelEntry> get_model_entry(const int bone_index, const int index); Ref<SkeletonModelEntry> get_model_entry(const int bone_index, const int index);
int get_model_entry_count(const int bone_index); int get_model_entry_count(const int bone_index);