entity_spell_system/data/items/item_visual_entry.cpp

117 lines
4.9 KiB
C++
Raw Normal View History

/*
Copyright (c) 2019-2020 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "item_visual_entry.h"
2019-10-26 15:13:04 +02:00
ItemEnums::EntityTextureLayers ItemVisualEntry::get_override_layer() {
return _override_layer;
}
2019-10-26 15:13:04 +02:00
void ItemVisualEntry::set_override_layer(ItemEnums::EntityTextureLayers layer) {
_override_layer = layer;
}
#ifdef MESH_DATA_RESOURCE_PRESENT
Ref<MeshDataResource> ItemVisualEntry::get_mesh(int index) {
return _mesh[index];
}
void ItemVisualEntry::set_mesh(int index, Ref<MeshDataResource> mesh) {
_mesh[index] = mesh;
}
#endif
Ref<Texture> ItemVisualEntry::get_texture(int index) {
return _texture[index];
}
void ItemVisualEntry::set_texture(int index, Ref<Texture> texture) {
_texture[index] = texture;
}
Color ItemVisualEntry::get_color() {
return _color;
}
void ItemVisualEntry::set_color(Color color) {
_color = color;
}
Ref<PackedScene> ItemVisualEntry::get_effect() {
return _effect;
}
void ItemVisualEntry::set_effect(Ref<PackedScene> effect) {
_effect = effect;
}
Vector3 ItemVisualEntry::get_effect_offset(int index) {
return _effect_offset[index];
}
void ItemVisualEntry::set_effect_offset(int index, Vector3 offset) {
_effect_offset[index] = offset;
}
ItemVisualEntry::ItemVisualEntry() {
2019-10-26 15:13:04 +02:00
_override_layer = ItemEnums::ENTITY_TEXTURE_LAYER_NONE;
_color = Color(1, 1, 1, 1);
}
ItemVisualEntry::~ItemVisualEntry() {
for (int i = 0; i < EntityEnums::GENDER_COUNT; ++i) {
#ifdef MESH_DATA_RESOURCE_PRESENT
_mesh[i].unref();
#endif
_texture[i].unref();
}
_effect.unref();
}
void ItemVisualEntry::_bind_methods() {
2019-10-26 15:13:04 +02:00
ClassDB::bind_method(D_METHOD("get_override_layer"), &ItemVisualEntry::get_override_layer);
ClassDB::bind_method(D_METHOD("set_override_layer", "value"), &ItemVisualEntry::set_override_layer);
ADD_PROPERTY(PropertyInfo(Variant::INT, "override_layer", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_ENTITY_TEXTURE_LAYERS), "set_override_layer", "get_override_layer");
#ifdef MESH_DATA_RESOURCE_PRESENT
ClassDB::bind_method(D_METHOD("get_mesh", "index"), &ItemVisualEntry::get_mesh);
ClassDB::bind_method(D_METHOD("set_mesh", "index", "value"), &ItemVisualEntry::set_mesh);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "mesh_male", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh", "get_mesh", EntityEnums::GENDER_MALE);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "mesh_female", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh", "get_mesh", EntityEnums::GENDER_FEMALE);
#endif
ClassDB::bind_method(D_METHOD("get_texture", "index"), &ItemVisualEntry::get_texture);
ClassDB::bind_method(D_METHOD("set_texture", "index", "value"), &ItemVisualEntry::set_texture);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_male", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", EntityEnums::GENDER_MALE);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_female", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", EntityEnums::GENDER_FEMALE);
ClassDB::bind_method(D_METHOD("get_color"), &ItemVisualEntry::get_color);
ClassDB::bind_method(D_METHOD("set_color", "value"), &ItemVisualEntry::set_color);
2019-10-26 15:13:04 +02:00
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("set_effect", "value"), &ItemVisualEntry::set_effect);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "effect_male", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_effect", "get_effect");
ClassDB::bind_method(D_METHOD("get_effect_offset", "index"), &ItemVisualEntry::get_effect_offset);
ClassDB::bind_method(D_METHOD("set_effect_offset", "index", "value"), &ItemVisualEntry::set_effect_offset);
ADD_PROPERTYI(PropertyInfo(Variant::VECTOR3, "effect_offset_male"), "set_effect_offset", "get_effect_offset", EntityEnums::GENDER_MALE);
ADD_PROPERTYI(PropertyInfo(Variant::VECTOR3, "effect_offset_female"), "set_effect_offset", "get_effect_offset", EntityEnums::GENDER_FEMALE);
}