diff --git a/entities/data/entity_data.cpp b/entities/data/entity_data.cpp index ff183fc..8850d83 100644 --- a/entities/data/entity_data.cpp +++ b/entities/data/entity_data.cpp @@ -150,14 +150,14 @@ Ref EntityData::_get_ai_instance() { Ref EntityData::get_formation() const { return _formation; } -void EntityData::set_formation(const Ref data) { +void EntityData::set_formation(const Ref &data) { _formation = data; } Ref EntityData::get_loot_db() const { return _lootdb; } -void EntityData::set_loot_db(const Ref lootdb) { +void EntityData::set_loot_db(const Ref &lootdb) { _lootdb = lootdb; } @@ -168,10 +168,21 @@ Ref EntityData::get_vendor_item_data() const { return _vendor_item_data; } -void EntityData::set_vendor_item_data(const Ref data) { +void EntityData::set_vendor_item_data(const Ref &data) { _vendor_item_data = data; } +Ref EntityData::get_spell_train_data() const { + if (!_spell_train_data.is_valid() && _inherits.is_valid()) { + return _inherits->get_spell_train_data(); + } + + return _spell_train_data; +} +void EntityData::set_spell_train_data(const Ref &data) { + _spell_train_data = data; +} + Ref EntityData::get_item_container_data() const { if (!_vendor_item_data.is_valid() && _inherits.is_valid()) { return _inherits->get_item_container_data(); @@ -179,7 +190,7 @@ Ref EntityData::get_item_container_data() const { return _item_container_data; } -void EntityData::set_item_container_data(const Ref data) { +void EntityData::set_item_container_data(const Ref &data) { _item_container_data = data; } @@ -193,7 +204,7 @@ Ref EntityData::get_craft_recipe(int index) { return _craft_recipes[index]; } -void EntityData::set_craft_recipe(int index, Ref craft_data) { +void EntityData::set_craft_recipe(int index, const Ref &craft_data) { ERR_FAIL_INDEX(index, _craft_recipes.size()); _craft_recipes.set(index, craft_data); @@ -645,7 +656,6 @@ void EntityData::son_entity_resource_added(Ref resource) { call("_son_entity_resource_added", resource); } - void EntityData::son_entity_resource_removed(Ref resource) { if (_entity_class_data.is_valid()) { _entity_class_data->son_entity_resource_removed(resource); @@ -922,7 +932,6 @@ void EntityData::con_entity_resource_added(Ref resource) { call("_con_entity_resource_added", resource); } - void EntityData::con_entity_resource_removed(Ref resource) { if (_entity_class_data.is_valid()) { _entity_class_data->con_entity_resource_removed(resource); @@ -932,7 +941,6 @@ void EntityData::con_entity_resource_removed(Ref resource) { call("_con_entity_resource_removed", resource); } - //Equipment bool EntityData::should_deny_equip(Entity *entity, ItemEnums::EquipSlots equip_slot, Ref item) { @@ -1047,6 +1055,7 @@ EntityData::~EntityData() { _lootdb.unref(); _vendor_item_data.unref(); + _spell_train_data.unref(); _item_container_data.unref(); _craft_recipes.clear(); @@ -1284,10 +1293,14 @@ void EntityData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_loot_db", "value"), &EntityData::set_loot_db); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "loot_db", PROPERTY_HINT_RESOURCE_TYPE, "LootDataBase"), "set_loot_db", "get_loot_db"); - //EntityData + //Vendor ClassDB::bind_method(D_METHOD("get_vendor_item_data"), &EntityData::get_vendor_item_data); ClassDB::bind_method(D_METHOD("set_vendor_item_data", "value"), &EntityData::set_vendor_item_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "vendor_item_data", PROPERTY_HINT_RESOURCE_TYPE, "EntityData"), "set_vendor_item_data", "get_vendor_item_data"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "vendor_item_data", PROPERTY_HINT_RESOURCE_TYPE, "VendorItemData"), "set_vendor_item_data", "get_vendor_item_data"); + + ClassDB::bind_method(D_METHOD("get_spell_train_data"), &EntityData::get_spell_train_data); + ClassDB::bind_method(D_METHOD("set_spell_train_data", "value"), &EntityData::set_spell_train_data); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "spell_train_data", PROPERTY_HINT_RESOURCE_TYPE, "VendorItemData"), "set_spell_train_data", "get_spell_train_data"); //ItemContainerData ClassDB::bind_method(D_METHOD("get_item_container_data"), &EntityData::get_item_container_data); diff --git a/entities/data/entity_data.h b/entities/data/entity_data.h index ec7646d..11cb0a7 100644 --- a/entities/data/entity_data.h +++ b/entities/data/entity_data.h @@ -109,22 +109,25 @@ public: Ref _get_ai_instance(); Ref get_formation() const; - void set_formation(const Ref data); + void set_formation(const Ref &data); Ref get_loot_db() const; - void set_loot_db(const Ref data); + void set_loot_db(const Ref &data); Ref get_vendor_item_data() const; - void set_vendor_item_data(const Ref data); + void set_vendor_item_data(const Ref &data); + + Ref get_spell_train_data() const; + void set_spell_train_data(const Ref &data); Ref get_item_container_data() const; - void set_item_container_data(const Ref data); + void set_item_container_data(const Ref &data); //Craft Recipes int get_num_craft_recipes() const; Ref get_craft_recipe(int index); - void set_craft_recipe(int index, Ref recipe); + void set_craft_recipe(int index, const Ref &recipe); Vector get_craft_recipes() const; void set_craft_recipes(const Vector &recipe); @@ -280,6 +283,7 @@ private: Ref _lootdb; Ref _vendor_item_data; + Ref _spell_train_data; Ref _item_container_data; Vector > _craft_recipes; }; diff --git a/entities/data/vendor_item_data.cpp b/entities/data/vendor_item_data.cpp index 70987e5..7c81b9d 100644 --- a/entities/data/vendor_item_data.cpp +++ b/entities/data/vendor_item_data.cpp @@ -25,9 +25,6 @@ SOFTWARE. int VendorItemData::get_num_vendor_datas() { return _vendor_datas.size(); } -void VendorItemData::set_num_vendor_datas(int value) { - _vendor_datas.resize(value); -} Ref VendorItemData::get_vendor_data(int index) { ERR_FAIL_INDEX_V(index, _vendor_datas.size(), Ref()); @@ -64,8 +61,6 @@ VendorItemData::~VendorItemData() { void VendorItemData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_num_vendor_datas"), &VendorItemData::get_num_vendor_datas); - ClassDB::bind_method(D_METHOD("set_num_vendor_datas", "value"), &VendorItemData::set_num_vendor_datas); - ClassDB::bind_method(D_METHOD("get_vendor_data", "index"), &VendorItemData::get_vendor_data); ClassDB::bind_method(D_METHOD("set_vendor_data", "index", "vendor_data"), &VendorItemData::set_vendor_data); diff --git a/entities/data/vendor_item_data.h b/entities/data/vendor_item_data.h index 9480567..0bea0b7 100644 --- a/entities/data/vendor_item_data.h +++ b/entities/data/vendor_item_data.h @@ -33,7 +33,6 @@ class VendorItemData : public Resource { public: //Vendor data int get_num_vendor_datas(); - void set_num_vendor_datas(int value); Ref get_vendor_data(int index); void set_vendor_data(int index, Ref data); @@ -48,7 +47,7 @@ protected: static void _bind_methods(); private: - Vector > _vendor_datas; + Vector > _vendor_datas; }; #endif diff --git a/entities/data/vendor_item_data_entry.cpp b/entities/data/vendor_item_data_entry.cpp index 3b85c24..ade15e7 100644 --- a/entities/data/vendor_item_data_entry.cpp +++ b/entities/data/vendor_item_data_entry.cpp @@ -23,41 +23,59 @@ SOFTWARE. #include "vendor_item_data.h" #include "../../data/items/item_template.h" +#include "../../data/spells/spell.h" Ref VendorItemDataEntry::get_item() { return _item; } -void VendorItemDataEntry::set_item(Ref item) { +void VendorItemDataEntry::set_item(const Ref &item) { _item = item; } -int VendorItemDataEntry::get_item_price() const { - return _item_price; +Ref VendorItemDataEntry::get_spell() { + return _spell; } -void VendorItemDataEntry::set_item_price(int value) { - _item_price = value; +void VendorItemDataEntry::set_spell(const Ref &spell) { + _spell = spell; } -int VendorItemDataEntry::get_item_count() const { - return _item_count; +Ref VendorItemDataEntry::get_cost_item() { + return _cost_item; } -void VendorItemDataEntry::set_item_count(int value) { - _item_count = value; +void VendorItemDataEntry::set_cost_item(const Ref &item) { + _cost_item = item; } -int VendorItemDataEntry::get_item_spawn_time() const { - return _item_spawn_time; +int VendorItemDataEntry::get_price() const { + return _price; } -void VendorItemDataEntry::set_item_spawn_time(int value) { - _item_spawn_time = value; +void VendorItemDataEntry::set_price(const int value) { + _price = value; +} + +int VendorItemDataEntry::get_count() const { + return _count; +} +void VendorItemDataEntry::set_count(const int value) { + _count = value; +} + +int VendorItemDataEntry::get_spawn_time() const { + return _spawn_time; +} +void VendorItemDataEntry::set_spawn_time(const int value) { + _spawn_time = value; } VendorItemDataEntry::VendorItemDataEntry() { - _item_price = 0; - _item_count = 0; - _item_spawn_time = 0; + _price = 0; + _count = 0; + _spawn_time = 0; } VendorItemDataEntry::~VendorItemDataEntry() { + _item.unref(); + _spell.unref(); + _cost_item.unref(); } void VendorItemDataEntry::_bind_methods() { @@ -65,15 +83,23 @@ void VendorItemDataEntry::_bind_methods() { ClassDB::bind_method(D_METHOD("set_item", "item"), &VendorItemDataEntry::set_item); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemTemplate"), "set_item", "get_item"); - ClassDB::bind_method(D_METHOD("get_item_price"), &VendorItemDataEntry::get_item_price); - ClassDB::bind_method(D_METHOD("set_item_price", "value"), &VendorItemDataEntry::set_item_price); - ADD_PROPERTY(PropertyInfo(Variant::INT, "item_price"), "set_item_price", "get_item_price"); + ClassDB::bind_method(D_METHOD("get_spell"), &VendorItemDataEntry::get_spell); + ClassDB::bind_method(D_METHOD("set_spell", "item"), &VendorItemDataEntry::set_spell); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "spell", PROPERTY_HINT_RESOURCE_TYPE, "Spell"), "set_spell", "get_spell"); - ClassDB::bind_method(D_METHOD("get_item_count"), &VendorItemDataEntry::get_item_count); - ClassDB::bind_method(D_METHOD("set_item_count", "value"), &VendorItemDataEntry::set_item_count); - ADD_PROPERTY(PropertyInfo(Variant::INT, "item_count"), "set_item_count", "get_item_count"); + ClassDB::bind_method(D_METHOD("get_cost_item"), &VendorItemDataEntry::get_cost_item); + ClassDB::bind_method(D_METHOD("set_cost_item", "item"), &VendorItemDataEntry::set_cost_item); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "cost_item", PROPERTY_HINT_RESOURCE_TYPE, "ItemTemplate"), "set_cost_item", "get_cost_item"); - ClassDB::bind_method(D_METHOD("get_item_spawn_time"), &VendorItemDataEntry::get_item_spawn_time); - ClassDB::bind_method(D_METHOD("set_item_spawn_time", "value"), &VendorItemDataEntry::set_item_spawn_time); - ADD_PROPERTY(PropertyInfo(Variant::INT, "item_spawn_time"), "set_item_spawn_time", "get_item_spawn_time"); + ClassDB::bind_method(D_METHOD("get_price"), &VendorItemDataEntry::get_price); + ClassDB::bind_method(D_METHOD("set_price", "value"), &VendorItemDataEntry::set_price); + ADD_PROPERTY(PropertyInfo(Variant::INT, "price"), "set_price", "get_price"); + + ClassDB::bind_method(D_METHOD("get_count"), &VendorItemDataEntry::get_count); + ClassDB::bind_method(D_METHOD("set_count", "value"), &VendorItemDataEntry::set_count); + ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count"); + + ClassDB::bind_method(D_METHOD("get_spawn_time"), &VendorItemDataEntry::get_spawn_time); + ClassDB::bind_method(D_METHOD("set_spawn_time", "value"), &VendorItemDataEntry::set_spawn_time); + ADD_PROPERTY(PropertyInfo(Variant::INT, "spawn_time"), "set_spawn_time", "get_spawn_time"); } diff --git a/entities/data/vendor_item_data_entry.h b/entities/data/vendor_item_data_entry.h index a5086ee..8ae711f 100644 --- a/entities/data/vendor_item_data_entry.h +++ b/entities/data/vendor_item_data_entry.h @@ -26,22 +26,29 @@ SOFTWARE. #include "core/resource.h" class ItemTemplate; +class Spell; class VendorItemDataEntry : public Resource { GDCLASS(VendorItemDataEntry, Resource); public: Ref get_item(); - void set_item(Ref item); + void set_item(const Ref &item); - int get_item_price() const; - void set_item_price(int value); + Ref get_spell(); + void set_spell(const Ref &spell); - int get_item_count() const; - void set_item_count(int value); + Ref get_cost_item(); + void set_cost_item(const Ref &item); - int get_item_spawn_time() const; - void set_item_spawn_time(int time); + int get_price() const; + void set_price(const int value); + + int get_count() const; + void set_count(const int value); + + int get_spawn_time() const; + void set_spawn_time(const int time); VendorItemDataEntry(); ~VendorItemDataEntry(); @@ -51,9 +58,12 @@ protected: private: Ref _item; - int _item_price; - int _item_count; - int _item_spawn_time; + Ref _spell; + Ref _cost_item; + + int _price; + int _count; + int _spawn_time; }; #endif