mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-22 17:18:12 +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 ////
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user