2020-01-31 19:34:47 +01:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2019-08-24 15:53:56 +02:00
|
|
|
#include "item_visual_entry.h"
|
|
|
|
|
2019-10-26 15:13:04 +02:00
|
|
|
ItemEnums::EntityTextureLayers ItemVisualEntry::get_override_layer() {
|
|
|
|
return _override_layer;
|
2019-10-24 22:06:47 +02:00
|
|
|
}
|
2019-10-26 15:13:04 +02:00
|
|
|
void ItemVisualEntry::set_override_layer(ItemEnums::EntityTextureLayers layer) {
|
|
|
|
_override_layer = layer;
|
2019-10-24 22:06:47 +02:00
|
|
|
}
|
|
|
|
|
2019-12-20 16:13:33 +01:00
|
|
|
#ifdef MESH_DATA_RESOURCE_PRESENT
|
2019-11-03 22:39:19 +01:00
|
|
|
Ref<MeshDataResource> ItemVisualEntry::get_mesh(int index) {
|
|
|
|
return _mesh[index];
|
2019-10-24 22:06:47 +02:00
|
|
|
}
|
2019-11-03 22:39:19 +01:00
|
|
|
void ItemVisualEntry::set_mesh(int index, Ref<MeshDataResource> mesh) {
|
|
|
|
_mesh[index] = mesh;
|
2019-10-24 22:06:47 +02:00
|
|
|
}
|
2019-12-20 16:13:33 +01:00
|
|
|
#endif
|
2019-10-24 22:06:47 +02:00
|
|
|
|
2019-11-03 22:39:19 +01:00
|
|
|
Ref<Texture> ItemVisualEntry::get_texture(int index) {
|
|
|
|
return _texture[index];
|
2019-10-24 22:06:47 +02:00
|
|
|
}
|
2019-11-03 22:39:19 +01:00
|
|
|
void ItemVisualEntry::set_texture(int index, Ref<Texture> texture) {
|
|
|
|
_texture[index] = texture;
|
2019-10-24 22:06:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2019-08-24 15:53:56 +02:00
|
|
|
|
2019-11-03 22:39:19 +01:00
|
|
|
Vector3 ItemVisualEntry::get_effect_offset(int index) {
|
|
|
|
return _effect_offset[index];
|
|
|
|
}
|
|
|
|
void ItemVisualEntry::set_effect_offset(int index, Vector3 offset) {
|
|
|
|
_effect_offset[index] = offset;
|
|
|
|
}
|
2019-10-24 22:06:47 +02:00
|
|
|
|
2019-11-03 22:39:19 +01:00
|
|
|
ItemVisualEntry::ItemVisualEntry() {
|
2019-10-26 15:13:04 +02:00
|
|
|
_override_layer = ItemEnums::ENTITY_TEXTURE_LAYER_NONE;
|
2019-10-24 22:06:47 +02:00
|
|
|
|
|
|
|
_color = Color(1, 1, 1, 1);
|
2019-08-24 15:53:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ItemVisualEntry::~ItemVisualEntry() {
|
2019-11-03 22:39:19 +01:00
|
|
|
for (int i = 0; i < EntityEnums::GENDER_COUNT; ++i) {
|
2020-01-09 04:27:19 +01:00
|
|
|
#ifdef MESH_DATA_RESOURCE_PRESENT
|
2019-11-03 22:39:19 +01:00
|
|
|
_mesh[i].unref();
|
2020-01-09 04:27:19 +01:00
|
|
|
#endif
|
|
|
|
|
2019-11-03 22:39:19 +01:00
|
|
|
_texture[i].unref();
|
|
|
|
}
|
|
|
|
|
2019-10-24 22:06:47 +02:00
|
|
|
_effect.unref();
|
2019-08-24 15:53:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
2019-10-24 22:06:47 +02:00
|
|
|
|
2020-01-09 04:27:19 +01:00
|
|
|
#ifdef MESH_DATA_RESOURCE_PRESENT
|
2019-11-03 22:39:19 +01:00
|
|
|
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);
|
2020-01-09 04:27:19 +01:00
|
|
|
#endif
|
2019-10-24 22:06:47 +02:00
|
|
|
|
2019-11-03 22:39:19 +01:00
|
|
|
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);
|
2019-10-24 22:06:47 +02:00
|
|
|
|
|
|
|
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");
|
2019-10-24 22:06:47 +02:00
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_effect"), &ItemVisualEntry::get_effect);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_effect", "value"), &ItemVisualEntry::set_effect);
|
2019-11-03 22:39:19 +01:00
|
|
|
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);
|
2019-08-24 15:53:56 +02:00
|
|
|
}
|