mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-20 17:14:44 +01:00
Small fixes.
This commit is contained in:
parent
267b6c2082
commit
9efe65cc39
@ -838,17 +838,6 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
} else {
|
||||
_s_bag->from_dict(bagd);
|
||||
}
|
||||
/*
|
||||
if (!_c_bag.is_valid()) {
|
||||
Ref<Bag> bag;
|
||||
bag.instance();
|
||||
|
||||
bag->from_dict(bagd);
|
||||
|
||||
setc_bag(bag);
|
||||
} else {
|
||||
_c_bag->from_dict(bagd);
|
||||
}*/
|
||||
}
|
||||
|
||||
//// Actionbars ////
|
||||
@ -4297,7 +4286,7 @@ void Entity::sswap_items(int slot_id_1, int slot_id_2) {
|
||||
}
|
||||
void Entity::cswap_items(int slot_id_1, int slot_id_2) {
|
||||
ERR_FAIL_COND(!_c_bag.is_valid());
|
||||
|
||||
|
||||
_c_bag->swap_items(slot_id_1, slot_id_2);
|
||||
}
|
||||
void Entity::cdeny_item_swap(int slot_id_1, int slot_id_2) {
|
||||
@ -4354,7 +4343,7 @@ void Entity::sremove_target_item(const int slot_id) {
|
||||
}
|
||||
void Entity::cremove_target_item(const int slot_id) {
|
||||
ERR_FAIL_COND(!_c_target_bag.is_valid());
|
||||
|
||||
|
||||
_c_target_bag->remove_item(slot_id);
|
||||
}
|
||||
void Entity::cdenyremove_target_item(const int slot_id) {
|
||||
|
@ -215,6 +215,10 @@ void Bag::set_size(const int size) {
|
||||
|
||||
_bag_size = size;
|
||||
|
||||
if (_items.size() < _bag_size) {
|
||||
_items.resize(_bag_size);
|
||||
}
|
||||
|
||||
emit_signal("size_changed", Ref<Bag>(this));
|
||||
}
|
||||
|
||||
@ -283,13 +287,11 @@ void Bag::_remove_items(Ref<ItemTemplate> item, int count) {
|
||||
remove_item(i);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Dictionary Bag::to_dict() {
|
||||
return call("_to_dict");
|
||||
}
|
||||
@ -319,6 +321,8 @@ Dictionary Bag::_to_dict() {
|
||||
void Bag::_from_dict(const Dictionary &dict) {
|
||||
_items.clear();
|
||||
|
||||
set_size(dict.get("bag_size", 0));
|
||||
|
||||
Dictionary items = dict.get("items", Dictionary());
|
||||
|
||||
Array keys = items.keys();
|
||||
@ -327,13 +331,18 @@ void Bag::_from_dict(const Dictionary &dict) {
|
||||
Ref<ItemInstance> ii;
|
||||
ii.instance();
|
||||
|
||||
ii->from_dict(items[String::num(i)]);
|
||||
ii->from_dict(items[keys.get(i)]);
|
||||
|
||||
_items.push_back(ii);
|
||||
int key = keys.get(i);
|
||||
|
||||
if (key >= _items.size()) {
|
||||
_items.resize(key + 1);
|
||||
}
|
||||
|
||||
_items.set(key, ii);
|
||||
}
|
||||
|
||||
_allowed_item_types = dict.get("allowed_item_types", 0xFFFFFF);
|
||||
set_size(dict.get("bag_size", 0));
|
||||
}
|
||||
|
||||
Bag::Bag() {
|
||||
@ -347,7 +356,7 @@ Bag::~Bag() {
|
||||
|
||||
void Bag::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "could_add"), "_add_item", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance")));
|
||||
BIND_VMETHOD(MethodInfo("_add_item_at", PropertyInfo(Variant::INT, "index") , PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance")));
|
||||
BIND_VMETHOD(MethodInfo("_add_item_at", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance"), "_get_item", PropertyInfo(Variant::INT, "index")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance"), "_remove_item", PropertyInfo(Variant::INT, "index")));
|
||||
BIND_VMETHOD(MethodInfo("_swap_items", PropertyInfo(Variant::INT, "item1_index"), PropertyInfo(Variant::INT, "item2_index")));
|
||||
|
Loading…
Reference in New Issue
Block a user