mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
More getters, setters, and a small fix.
This commit is contained in:
parent
895525a998
commit
e6e717719b
@ -1,6 +1,7 @@
|
||||
#include "item_instance.h"
|
||||
|
||||
#include "item_template.h"
|
||||
#include "../inventory/bag.h"
|
||||
|
||||
int ItemInstance::get_id() {
|
||||
return _id;
|
||||
@ -24,6 +25,23 @@ void ItemInstance::set_inventory_position_y(const int value) {
|
||||
_inventory_position_y = value;
|
||||
}
|
||||
|
||||
Ref<Bag> ItemInstance::get_bag() const {
|
||||
if (_bag == NULL) {
|
||||
return Ref<Bag>(NULL);
|
||||
}
|
||||
|
||||
return *_bag;
|
||||
}
|
||||
|
||||
void ItemInstance::set_bag(const Ref<Bag> bag) {
|
||||
if (_bag == NULL) {
|
||||
_bag = memnew(Ref<Bag>(NULL));
|
||||
} else {
|
||||
_bag->unref();
|
||||
(*_bag) = bag;
|
||||
}
|
||||
}
|
||||
|
||||
Ref<ItemTemplate> ItemInstance::get_item_template() const {
|
||||
return _item_template;
|
||||
}
|
||||
@ -90,8 +108,7 @@ void ItemInstance::set_count(int value) {
|
||||
ItemInstance::ItemInstance() {
|
||||
_id = 0;
|
||||
|
||||
_s_bag = NULL;
|
||||
_c_bag = NULL;
|
||||
_bag = NULL;
|
||||
|
||||
_count = 0;
|
||||
|
||||
@ -103,6 +120,11 @@ ItemInstance::ItemInstance() {
|
||||
}
|
||||
|
||||
ItemInstance::~ItemInstance() {
|
||||
if (_bag != NULL) {
|
||||
_bag->unref();
|
||||
|
||||
memdelete(_bag);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemInstance::_validate_property(PropertyInfo &property) const {
|
||||
@ -130,6 +152,9 @@ void ItemInstance::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_inventory_position_y", "value"), &ItemInstance::set_inventory_position_y);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "inventory_position_y"), "set_inventory_position_y", "get_inventory_position_y");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_bag"), &ItemInstance::get_bag);
|
||||
ClassDB::bind_method(D_METHOD("set_bag", "bag"), &ItemInstance::set_bag);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_item_template"), &ItemInstance::get_item_template);
|
||||
ClassDB::bind_method(D_METHOD("set_item_template", "value"), &ItemInstance::set_item_template);
|
||||
|
||||
|
@ -24,6 +24,9 @@ public:
|
||||
int get_inventory_position_y() const;
|
||||
void set_inventory_position_y(const int value);
|
||||
|
||||
Ref<Bag> get_bag() const;
|
||||
void set_bag(const Ref<Bag> bag);
|
||||
|
||||
Ref<ItemTemplate> get_item_template() const;
|
||||
void set_item_template(const Ref<ItemTemplate> value);
|
||||
|
||||
@ -73,8 +76,7 @@ private:
|
||||
|
||||
int _count;
|
||||
|
||||
Ref<Bag> *_s_bag;
|
||||
Ref<Bag> *_c_bag;
|
||||
Ref<Bag> *_bag;
|
||||
|
||||
int _modifier_count;
|
||||
Ref<ItemStatModifier> _modifiers[MAX_ITEM_STAT_MOD];
|
||||
|
@ -322,7 +322,7 @@ void ItemTemplate::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_rarity"), &ItemTemplate::get_rarity);
|
||||
ClassDB::bind_method(D_METHOD("set_rarity", "count"), &ItemTemplate::set_rarity);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "rarity", PROPERTY_HINT_FLAGS, ItemEnums::BINDING_STRING_RARITY), "set_rarity", "get_rarity");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "rarity", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_RARITY), "set_rarity", "get_rarity");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_inventory_size_x"), &ItemTemplate::get_inventory_size_x);
|
||||
ClassDB::bind_method(D_METHOD("set_inventory_size_x", "value"), &ItemTemplate::set_inventory_size_x);
|
||||
|
Loading…
Reference in New Issue
Block a user