mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-03-30 08:45:29 +02:00
Fixed lots of crashes found by godot's regression test tool throwing improper parameters at methods.
This commit is contained in:
parent
77ed14e2f8
commit
0a5ed34bb7
@ -48,10 +48,14 @@ void CraftRecipe::set_sub_category(const CraftSubCategories value) {
|
||||
}
|
||||
|
||||
Ref<CraftRecipeHelper> CraftRecipe::get_required_tool(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, MAX_REQUIRED_TOOLS, Ref<CraftRecipeHelper>());
|
||||
|
||||
return _required_tools[index];
|
||||
}
|
||||
|
||||
void CraftRecipe::set_required_tool(const int index, const Ref<CraftRecipeHelper> &value) {
|
||||
ERR_FAIL_INDEX(index, MAX_REQUIRED_TOOLS);
|
||||
|
||||
_required_tools[index] = value;
|
||||
}
|
||||
|
||||
@ -64,10 +68,14 @@ void CraftRecipe::set_required_tools_count(const int value) {
|
||||
}
|
||||
|
||||
void CraftRecipe::set_required_material(const int index, const Ref<CraftRecipeHelper> &value) {
|
||||
ERR_FAIL_INDEX(index, MAX_REQUIRED_MATERIALS);
|
||||
|
||||
_required_materials[index] = value;
|
||||
}
|
||||
|
||||
Ref<CraftRecipeHelper> CraftRecipe::get_required_material(int index) {
|
||||
ERR_FAIL_INDEX_V(index, MAX_REQUIRED_MATERIALS, Ref<CraftRecipeHelper>());
|
||||
|
||||
return _required_materials[index];
|
||||
}
|
||||
|
||||
|
@ -28,18 +28,18 @@ SOFTWARE.
|
||||
#include "../../singletons/ess.h"
|
||||
|
||||
Ref<ItemTemplate> EquipmentData::get_slot(int index) {
|
||||
ERR_FAIL_INDEX_V(index, ESS::get_singleton()->equip_slot_get_count(), Ref<ItemTemplate>());
|
||||
ERR_FAIL_INDEX_V(index, _entries.size(), Ref<ItemTemplate>());
|
||||
|
||||
return _entries[index];
|
||||
}
|
||||
void EquipmentData::set_slot(int index, Ref<ItemTemplate> entry) {
|
||||
ERR_FAIL_INDEX(index, ESS::get_singleton()->equip_slot_get_count());
|
||||
ERR_FAIL_INDEX(index, _entries.size());
|
||||
|
||||
_entries.write[index] = entry;
|
||||
}
|
||||
|
||||
Ref<ItemInstance> EquipmentData::get_item(int index) {
|
||||
ERR_FAIL_INDEX_V(index, ESS::get_singleton()->equip_slot_get_count(), Ref<ItemInstance>());
|
||||
ERR_FAIL_INDEX_V(index, _entries.size(), Ref<ItemInstance>());
|
||||
|
||||
Ref<ItemTemplate> ede = _entries[index];
|
||||
|
||||
@ -60,6 +60,8 @@ EquipmentData::~EquipmentData() {
|
||||
}
|
||||
|
||||
bool EquipmentData::_set(const StringName &p_name, const Variant &p_value) {
|
||||
ERR_FAIL_COND_V(!ESS::get_singleton(), false);
|
||||
|
||||
String name = p_name;
|
||||
|
||||
if (name.get_slicec('/', 0) == "slot") {
|
||||
@ -86,6 +88,8 @@ bool EquipmentData::_set(const StringName &p_name, const Variant &p_value) {
|
||||
}
|
||||
|
||||
bool EquipmentData::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
ERR_FAIL_COND_V(!ESS::get_singleton(), false);
|
||||
|
||||
String name = p_name;
|
||||
|
||||
if (name.get_slicec('/', 0) == "slot") {
|
||||
@ -112,6 +116,8 @@ bool EquipmentData::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
}
|
||||
|
||||
void EquipmentData::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->equip_slot_get_count(); ++i) {
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "slot/" + ESS::get_singleton()->equip_slot_get_property_name(i), PROPERTY_HINT_RESOURCE_TYPE, "ItemTemplate"));
|
||||
}
|
||||
|
@ -172,7 +172,9 @@ void ItemInstance::from_dict(const Dictionary &dict) {
|
||||
Dictionary ItemInstance::_to_dict() {
|
||||
Dictionary dict;
|
||||
|
||||
dict["item_path"] = _item_template->get_path();
|
||||
if (_item_template.is_valid()) {
|
||||
dict["item_path"] = _item_template->get_path();
|
||||
}
|
||||
|
||||
dict["stack_size"] = _stack_size;
|
||||
|
||||
|
@ -291,66 +291,98 @@ void ItemTemplate::stat_modifier_set_count(int value) {
|
||||
}
|
||||
|
||||
int ItemTemplate::stat_modifier_get_stat_id(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0);
|
||||
|
||||
return _modifiers[index].stat_id;
|
||||
}
|
||||
|
||||
void ItemTemplate::stat_modifier_set_stat_id(const int index, const int value) {
|
||||
ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD);
|
||||
|
||||
_modifiers[index].stat_id = value;
|
||||
}
|
||||
|
||||
float ItemTemplate::stat_modifier_get_min_base_mod(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0);
|
||||
|
||||
return _modifiers[index].min_base_mod;
|
||||
}
|
||||
|
||||
void ItemTemplate::stat_modifier_set_min_base_mod(const int index, const float value) {
|
||||
ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD);
|
||||
|
||||
_modifiers[index].min_base_mod = value;
|
||||
}
|
||||
|
||||
float ItemTemplate::stat_modifier_get_max_base_mod(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0);
|
||||
|
||||
return _modifiers[index].max_base_mod;
|
||||
}
|
||||
|
||||
void ItemTemplate::stat_modifier_set_max_base_mod(const int index, const float value) {
|
||||
ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD);
|
||||
|
||||
_modifiers[index].max_base_mod = value;
|
||||
}
|
||||
|
||||
float ItemTemplate::stat_modifier_get_min_bonus_mod(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0);
|
||||
|
||||
return _modifiers[index].min_bonus_mod;
|
||||
}
|
||||
|
||||
void ItemTemplate::stat_modifier_set_min_bonus_mod(const int index, const float value) {
|
||||
ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD);
|
||||
|
||||
_modifiers[index].min_bonus_mod = value;
|
||||
}
|
||||
|
||||
float ItemTemplate::stat_modifier_get_max_bonus_mod(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0);
|
||||
|
||||
return _modifiers[index].max_bonus_mod;
|
||||
}
|
||||
|
||||
void ItemTemplate::stat_modifier_set_max_bonus_mod(const int index, const float value) {
|
||||
ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD);
|
||||
|
||||
_modifiers[index].max_bonus_mod = value;
|
||||
}
|
||||
|
||||
float ItemTemplate::stat_modifier_get_min_percent_mod(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0);
|
||||
|
||||
return _modifiers[index].min_percent_mod;
|
||||
}
|
||||
|
||||
void ItemTemplate::stat_modifier_set_min_percent_mod(const int index, const float value) {
|
||||
ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD);
|
||||
|
||||
_modifiers[index].min_percent_mod = value;
|
||||
}
|
||||
|
||||
float ItemTemplate::stat_modifier_get_max_percent_mod(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0);
|
||||
|
||||
return _modifiers[index].max_percent_mod;
|
||||
}
|
||||
|
||||
void ItemTemplate::stat_modifier_set_max_percent_mod(const int index, const float value) {
|
||||
ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD);
|
||||
|
||||
_modifiers[index].max_percent_mod = value;
|
||||
}
|
||||
|
||||
float ItemTemplate::stat_modifier_get_scaling_factor(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0);
|
||||
|
||||
return _modifiers[index].scaling_factor;
|
||||
}
|
||||
|
||||
void ItemTemplate::stat_modifier_set_scaling_factor(const int index, const float value) {
|
||||
ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD);
|
||||
|
||||
_modifiers[index].scaling_factor = value;
|
||||
}
|
||||
|
||||
|
@ -656,6 +656,8 @@ void Entity::setup(Ref<EntityCreateInfo> info) {
|
||||
}
|
||||
|
||||
void Entity::_setup() {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
if (!_s_entity_data.is_valid())
|
||||
return;
|
||||
|
||||
@ -712,11 +714,11 @@ void Entity::_setup() {
|
||||
|
||||
ERR_FAIL_COND(!stat_data.is_valid());
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) {
|
||||
for (int i = 0; i < _stats.size(); ++i) {
|
||||
stat_set_base(i, stat_data->get_base(i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) {
|
||||
for (int i = 0; i < _stats.size(); ++i) {
|
||||
stat_setc_current(i, stat_gets_current(i));
|
||||
stat_set_dirty(i, false);
|
||||
}
|
||||
@ -768,7 +770,7 @@ void Entity::_setup() {
|
||||
if (_s_entity_data->get_equipment_data().is_valid()) {
|
||||
Ref<EquipmentData> eqd = _s_entity_data->get_equipment_data();
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->equip_slot_get_count(); ++i) {
|
||||
for (int i = 0; i < _s_equipment.size(); ++i) {
|
||||
Ref<ItemInstance> ii = eqd->get_item(i);
|
||||
|
||||
if (ii.is_valid())
|
||||
@ -1093,6 +1095,8 @@ int Entity::pet_getc_count() {
|
||||
//// Profiles ////
|
||||
|
||||
Ref<ClassProfile> Entity::get_class_profile() {
|
||||
ERR_FAIL_COND_V(!ProfileManager::get_singleton(), Ref<ClassProfile>());
|
||||
|
||||
return ProfileManager::get_singleton()->getc_player_profile()->get_class_profile(_s_entity_data->get_path());
|
||||
}
|
||||
|
||||
@ -1159,7 +1163,7 @@ Dictionary Entity::_to_dict() {
|
||||
|
||||
Dictionary sd;
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) {
|
||||
for (int i = 0; i < _stats.size(); ++i) {
|
||||
Dictionary sdict;
|
||||
|
||||
sdict["base"] = stat_get_base(i);
|
||||
@ -1177,7 +1181,7 @@ Dictionary Entity::_to_dict() {
|
||||
|
||||
Dictionary equipment;
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->equip_slot_get_count(); ++i) {
|
||||
for (int i = 0; i < _s_equipment.size(); ++i) {
|
||||
Ref<ItemInstance> ii = _s_equipment[i];
|
||||
|
||||
if (ii.is_valid())
|
||||
@ -1292,7 +1296,7 @@ Dictionary Entity::_to_dict() {
|
||||
|
||||
//// Known Spells ////
|
||||
|
||||
if (ESS::get_singleton()->get_use_spell_points())
|
||||
if (ESS::get_singleton() && ESS::get_singleton()->get_use_spell_points())
|
||||
dict["free_spell_points"] = _s_free_spell_points;
|
||||
|
||||
Dictionary known_spells;
|
||||
@ -1341,8 +1345,6 @@ Dictionary Entity::_to_dict() {
|
||||
return dict;
|
||||
}
|
||||
void Entity::_from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
//// Transforms ////
|
||||
|
||||
//Not needed for now
|
||||
@ -1392,7 +1394,7 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
|
||||
Dictionary stats = dict.get("stats", Dictionary());
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) {
|
||||
for (int i = 0; i < _stats.size(); ++i) {
|
||||
Dictionary sd = stats.get(String::num(i), Dictionary());
|
||||
|
||||
stat_set_base(i, sd.get("base", 0));
|
||||
@ -1411,7 +1413,7 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
|
||||
Dictionary equipment = dict.get("equipment", Dictionary());
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->equip_slot_get_count(); ++i) {
|
||||
for (int i = 0; i < _s_equipment.size(); ++i) {
|
||||
if (equipment.has(String::num(i))) {
|
||||
Ref<ItemInstance> ii = _s_equipment[i];
|
||||
|
||||
@ -1600,8 +1602,9 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
|
||||
//// Known Spells ////
|
||||
|
||||
if (ESS::get_singleton()->get_use_spell_points())
|
||||
if (ESS::get_singleton() && ESS::get_singleton()->get_use_spell_points()) {
|
||||
sets_free_spell_points(dict.get("free_spell_points", 0));
|
||||
}
|
||||
|
||||
Dictionary known_spells = dict.get("known_spells", Dictionary());
|
||||
|
||||
@ -2013,42 +2016,42 @@ void Entity::scraft_recipes_set(const Vector<Variant> &resources) {
|
||||
//// Stat System ////
|
||||
|
||||
EntityStat Entity::get_stat(const int stat_id) const {
|
||||
ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), EntityStat());
|
||||
ERR_FAIL_INDEX_V(stat_id, _stats.size(), EntityStat());
|
||||
|
||||
return _stats[stat_id];
|
||||
}
|
||||
|
||||
void Entity::set_stat(const int stat_id, const EntityStat &entry) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.set(stat_id, entry);
|
||||
}
|
||||
|
||||
bool Entity::stat_get_dirty(const int stat_id) const {
|
||||
ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), false);
|
||||
ERR_FAIL_INDEX_V(stat_id, _stats.size(), false);
|
||||
|
||||
return _stats[stat_id].dirty;
|
||||
}
|
||||
void Entity::stat_set_dirty(const int stat_id, const bool value) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].dirty = value;
|
||||
}
|
||||
|
||||
float Entity::stat_get_base(const int stat_id) const {
|
||||
ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0);
|
||||
ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0);
|
||||
|
||||
return _stats[stat_id].base;
|
||||
}
|
||||
void Entity::stat_set_base(const int stat_id, const float value) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].base = value;
|
||||
|
||||
stat_recalculate(stat_id);
|
||||
}
|
||||
void Entity::stat_mod_base(const int stat_id, const float value) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].base += value;
|
||||
|
||||
@ -2056,12 +2059,12 @@ void Entity::stat_mod_base(const int stat_id, const float value) {
|
||||
}
|
||||
|
||||
float Entity::stat_get_base_calculated(const int stat_id) const {
|
||||
ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0);
|
||||
ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0);
|
||||
|
||||
return _stats[stat_id].base_calculated;
|
||||
}
|
||||
void Entity::stat_set_base_calculated(const int stat_id, const float value) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].base_calculated = value;
|
||||
|
||||
@ -2069,19 +2072,19 @@ void Entity::stat_set_base_calculated(const int stat_id, const float value) {
|
||||
}
|
||||
|
||||
float Entity::stat_get_bonus(const int stat_id) const {
|
||||
ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0);
|
||||
ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0);
|
||||
|
||||
return _stats[stat_id].bonus;
|
||||
}
|
||||
void Entity::stat_set_bonus(const int stat_id, const float value) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].bonus = value;
|
||||
|
||||
stat_recalculate(stat_id);
|
||||
}
|
||||
void Entity::stat_mod_bonus(const int stat_id, const float value) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].bonus += value;
|
||||
|
||||
@ -2089,19 +2092,19 @@ void Entity::stat_mod_bonus(const int stat_id, const float value) {
|
||||
}
|
||||
|
||||
float Entity::stat_get_percent(const int stat_id) const {
|
||||
ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0);
|
||||
ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0);
|
||||
|
||||
return _stats[stat_id].percent;
|
||||
}
|
||||
void Entity::stat_set_percent(const int stat_id, const float value) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].percent = value;
|
||||
|
||||
stat_recalculate(stat_id);
|
||||
}
|
||||
void Entity::stat_mod_percent(const int stat_id, const float value) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].percent += value;
|
||||
|
||||
@ -2109,7 +2112,7 @@ void Entity::stat_mod_percent(const int stat_id, const float value) {
|
||||
}
|
||||
|
||||
void Entity::stat_mod(const int stat_id, const float base, const float bonus, const float percent) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].base += base;
|
||||
_stats.write[stat_id].bonus += bonus;
|
||||
@ -2119,23 +2122,23 @@ void Entity::stat_mod(const int stat_id, const float base, const float bonus, co
|
||||
}
|
||||
|
||||
float Entity::stat_gets_current(const int stat_id) const {
|
||||
ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0);
|
||||
ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0);
|
||||
|
||||
return _stats[stat_id].scurrent;
|
||||
}
|
||||
void Entity::stat_sets_current(const int stat_id, const float value) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].scurrent = value;
|
||||
}
|
||||
|
||||
float Entity::stat_getc_current(const int stat_id) const {
|
||||
ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0);
|
||||
ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0);
|
||||
|
||||
return _stats[stat_id].ccurrent;
|
||||
}
|
||||
void Entity::stat_setc_current(const int stat_id, const float value) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
_stats.write[stat_id].ccurrent = value;
|
||||
|
||||
@ -2143,7 +2146,7 @@ void Entity::stat_setc_current(const int stat_id, const float value) {
|
||||
}
|
||||
|
||||
void Entity::stat_recalculate(const int stat_id) {
|
||||
ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(stat_id, _stats.size());
|
||||
|
||||
stat_sets_current(stat_id, (stat_get_base(stat_id) + stat_get_base_calculated(stat_id) + stat_get_bonus(stat_id)) * (stat_get_percent(stat_id) / 100.0));
|
||||
|
||||
@ -2180,14 +2183,14 @@ void Entity::notification_cstat_changed(const int statid, const float current) {
|
||||
}
|
||||
|
||||
void Entity::ssend_stat(int id, int ccurrent) {
|
||||
ERR_FAIL_INDEX(id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(id, _stats.size());
|
||||
|
||||
//Only the owner needs access to stats
|
||||
ORPC(creceive_stat, id, ccurrent);
|
||||
}
|
||||
|
||||
void Entity::creceive_stat(int id, int ccurrent) {
|
||||
ERR_FAIL_INDEX(id, ESS::get_singleton()->stat_get_count());
|
||||
ERR_FAIL_INDEX(id, _stats.size());
|
||||
|
||||
stat_setc_current(id, ccurrent);
|
||||
}
|
||||
@ -2289,7 +2292,7 @@ void Entity::equips(int equip_slot, int bag_slot) {
|
||||
call("_equips", equip_slot, bag_slot);
|
||||
}
|
||||
void Entity::_equips(int equip_slot, int bag_slot) {
|
||||
ERR_FAIL_INDEX(equip_slot, ESS::get_singleton()->equip_slot_get_count());
|
||||
ERR_FAIL_INDEX(equip_slot, _s_equipment.size());
|
||||
ERR_FAIL_COND(!_s_bag.is_valid());
|
||||
|
||||
Ref<ItemInstance> bag_item = _s_bag->get_item(bag_slot);
|
||||
@ -2320,7 +2323,7 @@ void Entity::_equips(int equip_slot, int bag_slot) {
|
||||
ORPC(equip_csuccess, equip_slot, bag_slot);
|
||||
}
|
||||
void Entity::equip_csuccess(int equip_slot, int bag_slot) {
|
||||
ERR_FAIL_INDEX(equip_slot, ESS::get_singleton()->equip_slot_get_count());
|
||||
ERR_FAIL_INDEX(equip_slot, _c_equipment.size());
|
||||
ERR_FAIL_COND(!_c_bag.is_valid());
|
||||
|
||||
Ref<ItemInstance> old_bag_item = _c_bag->get_item(bag_slot);
|
||||
@ -2338,7 +2341,7 @@ void Entity::equip_csuccess(int equip_slot, int bag_slot) {
|
||||
equip_con_success(equip_slot, old_bag_item, old_equipped_item, bag_slot);
|
||||
}
|
||||
void Entity::equip_cfail(int equip_slot, int bag_slot) {
|
||||
ERR_FAIL_INDEX(equip_slot, ESS::get_singleton()->equip_slot_get_count());
|
||||
ERR_FAIL_INDEX(equip_slot, _c_equipment.size());
|
||||
ERR_FAIL_COND(!_c_bag.is_valid());
|
||||
|
||||
Ref<ItemInstance> bag_item = _c_bag->get_item(bag_slot);
|
||||
@ -2348,23 +2351,23 @@ void Entity::equip_cfail(int equip_slot, int bag_slot) {
|
||||
}
|
||||
|
||||
Ref<ItemInstance> Entity::equip_gets_slot(int index) {
|
||||
ERR_FAIL_INDEX_V(index, ESS::get_singleton()->equip_slot_get_count(), Ref<ItemInstance>());
|
||||
ERR_FAIL_INDEX_V(index, _s_equipment.size(), Ref<ItemInstance>());
|
||||
|
||||
return _s_equipment[index];
|
||||
}
|
||||
void Entity::equip_sets_slot(int index, Ref<ItemInstance> item) {
|
||||
ERR_FAIL_INDEX(index, ESS::get_singleton()->equip_slot_get_count());
|
||||
ERR_FAIL_INDEX(index, _s_equipment.size());
|
||||
|
||||
_s_equipment.write[index] = item;
|
||||
}
|
||||
|
||||
Ref<ItemInstance> Entity::equip_getc_slot(int index) {
|
||||
ERR_FAIL_INDEX_V(index, ESS::get_singleton()->equip_slot_get_count(), Ref<ItemInstance>());
|
||||
ERR_FAIL_INDEX_V(index, _c_equipment.size(), Ref<ItemInstance>());
|
||||
|
||||
return _c_equipment[index];
|
||||
}
|
||||
void Entity::equip_setc_slot(int index, Ref<ItemInstance> item) {
|
||||
ERR_FAIL_INDEX(index, ESS::get_singleton()->equip_slot_get_count());
|
||||
ERR_FAIL_INDEX(index, _c_equipment.size());
|
||||
|
||||
_c_equipment.write[index] = item;
|
||||
}
|
||||
@ -2503,6 +2506,8 @@ void Entity::resource_clears() {
|
||||
}
|
||||
|
||||
void Entity::resource_addc_rpc(int index, String data) {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
//Ref<EntityResource> res;
|
||||
|
||||
Dictionary dict = data_as_dict(data);
|
||||
@ -2713,6 +2718,7 @@ void Entity::stake_damage(Ref<SpellDamageInfo> info) {
|
||||
|
||||
void Entity::sdeal_damage_to(Ref<SpellDamageInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(!info->receiver_get());
|
||||
|
||||
//serverside
|
||||
|
||||
@ -2733,6 +2739,7 @@ void Entity::sdeal_damage_to(Ref<SpellDamageInfo> info) {
|
||||
|
||||
void Entity::stake_heal(Ref<SpellHealInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(!info->receiver_get());
|
||||
|
||||
//serverside
|
||||
|
||||
@ -2774,7 +2781,7 @@ void Entity::stake_heal(Ref<SpellHealInfo> info) {
|
||||
|
||||
void Entity::sdeal_heal_to(Ref<SpellHealInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(info->receiver_get() == NULL);
|
||||
ERR_FAIL_COND(!info->receiver_get());
|
||||
|
||||
//serverside
|
||||
|
||||
@ -2972,6 +2979,8 @@ void Entity::levelups(int value) {
|
||||
if (value <= 0)
|
||||
return;
|
||||
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
if (_s_level == ESS::get_singleton()->get_max_character_level())
|
||||
return;
|
||||
|
||||
@ -3017,6 +3026,8 @@ void Entity::item_crequest_use(int item_id) {
|
||||
RPCS(item_uses, item_id);
|
||||
}
|
||||
void Entity::_item_uses(int item_id) {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
Ref<ItemTemplate> it = ESS::get_singleton()->get_resource_db()->get_item_template(item_id);
|
||||
|
||||
ERR_FAIL_COND(!it.is_valid());
|
||||
@ -3133,6 +3144,9 @@ void Entity::notification_saura(int what, Ref<AuraData> data) {
|
||||
for (int i = 0; i < _s_auras.size(); ++i) {
|
||||
Ref<AuraData> ad = _s_auras.get(i);
|
||||
|
||||
ERR_CONTINUE(!ad.is_valid());
|
||||
ERR_CONTINUE(!ad->get_aura().is_valid());
|
||||
|
||||
ad->get_aura()->notification_saura(what, data);
|
||||
}
|
||||
|
||||
@ -3151,6 +3165,9 @@ void Entity::notification_sheal(int what, Ref<SpellHealInfo> info) {
|
||||
for (int i = 0; i < _s_auras.size(); ++i) {
|
||||
Ref<AuraData> ad = _s_auras.get(i);
|
||||
|
||||
ERR_CONTINUE(!ad.is_valid());
|
||||
ERR_CONTINUE(!ad->get_aura().is_valid());
|
||||
|
||||
ad->get_aura()->notification_sheal(what, ad, info);
|
||||
}
|
||||
}
|
||||
@ -3172,6 +3189,9 @@ void Entity::notification_sdamage(int what, Ref<SpellDamageInfo> info) {
|
||||
for (int i = 0; i < _s_auras.size(); ++i) {
|
||||
Ref<AuraData> ad = _s_auras.get(i);
|
||||
|
||||
ERR_CONTINUE(!ad.is_valid());
|
||||
ERR_CONTINUE(!ad->get_aura().is_valid());
|
||||
|
||||
ad->get_aura()->notification_sdamage(what, ad, info);
|
||||
}
|
||||
}
|
||||
@ -3184,6 +3204,9 @@ void Entity::notification_sdeath() {
|
||||
for (int i = 0; i < _s_auras.size(); ++i) {
|
||||
Ref<AuraData> ad = _s_auras.get(i);
|
||||
|
||||
ERR_CONTINUE(!ad.is_valid());
|
||||
ERR_CONTINUE(!ad->get_aura().is_valid());
|
||||
|
||||
ad->get_aura()->notification_sdeath(ad);
|
||||
}
|
||||
|
||||
@ -3267,8 +3290,10 @@ void Entity::aura_adds(Ref<AuraData> aura) {
|
||||
|
||||
notification_saura(SpellEnums::NOTIFICATION_AURA_ADDED, aura);
|
||||
|
||||
if (!aura->get_aura()->aura_get_hide())
|
||||
ERR_FAIL_COND(!aura->get_aura().is_valid());
|
||||
if (!aura->get_aura()->aura_get_hide()) {
|
||||
VRPCOBJ(aura_addc_rpc, JSON::print(aura->to_dict()), aura_addc, aura);
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::aura_removes(Ref<AuraData> aura) {
|
||||
@ -3291,9 +3316,11 @@ void Entity::aura_removes(Ref<AuraData> aura) {
|
||||
|
||||
if (removed) {
|
||||
notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, a);
|
||||
|
||||
if (!aura->get_aura()->aura_get_hide())
|
||||
|
||||
ERR_FAIL_COND(!aura->get_aura().is_valid());
|
||||
if (!aura->get_aura()->aura_get_hide()) {
|
||||
VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3314,8 +3341,10 @@ void Entity::aura_removes_exact(Ref<AuraData> aura) {
|
||||
|
||||
notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, aura);
|
||||
|
||||
if (!aura->get_aura()->aura_get_hide())
|
||||
ERR_FAIL_COND(!aura->get_aura().is_valid());
|
||||
if (!aura->get_aura()->aura_get_hide()) {
|
||||
VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura);
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::aura_removes_expired(Ref<AuraData> aura) {
|
||||
@ -3335,8 +3364,10 @@ void Entity::aura_removes_expired(Ref<AuraData> aura) {
|
||||
|
||||
notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, aura);
|
||||
|
||||
if (!aura->get_aura()->aura_get_hide())
|
||||
ERR_FAIL_COND(!aura->get_aura().is_valid());
|
||||
if (!aura->get_aura()->aura_get_hide()) {
|
||||
VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura);
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::aura_removes_dispelled(Ref<AuraData> aura) {
|
||||
@ -3356,8 +3387,10 @@ void Entity::aura_removes_dispelled(Ref<AuraData> aura) {
|
||||
|
||||
notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, aura);
|
||||
|
||||
if (!aura->get_aura()->aura_get_hide())
|
||||
ERR_FAIL_COND(!aura->get_aura().is_valid());
|
||||
if (!aura->get_aura()->aura_get_hide()) {
|
||||
VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura);
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::aura_refresheds(Ref<AuraData> aura) {
|
||||
@ -3368,8 +3401,10 @@ void Entity::aura_refresheds(Ref<AuraData> aura) {
|
||||
|
||||
notification_saura(SpellEnums::NOTIFICATION_AURA_REFRESHED, aura);
|
||||
|
||||
if (!aura->get_aura()->aura_get_hide())
|
||||
ERR_FAIL_COND(!aura->get_aura().is_valid());
|
||||
if (!aura->get_aura()->aura_get_hide()) {
|
||||
VRPCOBJ(aura_refreshedc_rpc, JSON::print(aura->to_dict()), aura_refreshedc, aura);
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::aura_addc_rpc(String data) {
|
||||
@ -3627,6 +3662,8 @@ void Entity::notification_caura(int what, Ref<AuraData> data) {
|
||||
for (int i = 0; i < _c_auras.size(); ++i) {
|
||||
Ref<AuraData> ad = _c_auras.get(i);
|
||||
|
||||
ERR_CONTINUE(!ad->get_aura().is_valid());
|
||||
|
||||
ad->get_aura()->notification_caura(what, data);
|
||||
}
|
||||
|
||||
@ -3641,6 +3678,8 @@ void Entity::notification_cheal(int what, Ref<SpellHealInfo> info) {
|
||||
for (int i = 0; i < _c_auras.size(); ++i) {
|
||||
Ref<AuraData> ad = _c_auras.get(i);
|
||||
|
||||
ERR_CONTINUE(!ad->get_aura().is_valid());
|
||||
|
||||
ad->get_aura()->notification_cheal(what, ad, info);
|
||||
}
|
||||
|
||||
@ -3652,12 +3691,15 @@ void Entity::notification_cheal(int what, Ref<SpellHealInfo> info) {
|
||||
}
|
||||
void Entity::notification_ccast(int what, Ref<SpellCastInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(!info->get_spell().is_valid());
|
||||
|
||||
info->get_spell()->notification_ccast(what, info);
|
||||
|
||||
for (int i = 0; i < _c_auras.size(); ++i) {
|
||||
Ref<AuraData> ad = _c_auras.get(i);
|
||||
|
||||
ERR_CONTINUE(!ad->get_aura().is_valid());
|
||||
|
||||
ad->get_aura()->notification_aura_ccast(what, ad, info);
|
||||
}
|
||||
|
||||
@ -3672,6 +3714,8 @@ void Entity::notification_cdamage(int what, Ref<SpellDamageInfo> info) {
|
||||
for (int i = 0; i < _c_auras.size(); ++i) {
|
||||
Ref<AuraData> ad = _c_auras.get(i);
|
||||
|
||||
ERR_CONTINUE(!ad->get_aura().is_valid());
|
||||
|
||||
ad->get_aura()->notification_cdamage(what, ad, info);
|
||||
}
|
||||
|
||||
@ -3723,6 +3767,8 @@ void Entity::cast_starts(Ref<SpellCastInfo> info) {
|
||||
for (int i = 0; i < _s_auras.size(); ++i) {
|
||||
Ref<AuraData> ad = _s_auras.get(i);
|
||||
|
||||
ERR_CONTINUE(!ad->get_aura().is_valid());
|
||||
|
||||
ad->get_aura()->notification_aura_scast(SpellEnums::NOTIFICATION_CAST_STARTED, ad, info);
|
||||
}
|
||||
|
||||
@ -3748,6 +3794,9 @@ void Entity::cast_delays() {
|
||||
}
|
||||
|
||||
void Entity::cast_finishs() {
|
||||
ERR_FAIL_COND(!_s_spell_cast_info.is_valid());
|
||||
ERR_FAIL_COND(!_s_spell_cast_info->get_spell().is_valid());
|
||||
|
||||
_s_spell_cast_info->get_spell()->cast_finishs(_s_spell_cast_info);
|
||||
|
||||
notification_scast(SpellEnums::NOTIFICATION_CAST_FINISHED, _s_spell_cast_info);
|
||||
@ -3758,6 +3807,8 @@ void Entity::cast_finishs() {
|
||||
}
|
||||
|
||||
void Entity::cast_interrupts() {
|
||||
ERR_FAIL_COND(!_s_spell_cast_info.is_valid());
|
||||
|
||||
notification_scast(SpellEnums::NOTIFICATION_CAST_INTERRUPTED, _s_spell_cast_info);
|
||||
|
||||
_s_spell_cast_info.unref();
|
||||
@ -3781,24 +3832,31 @@ void Entity::cast_startc(Ref<SpellCastInfo> info) {
|
||||
}
|
||||
|
||||
void Entity::cast_failc() {
|
||||
ERR_FAIL_COND(!_c_spell_cast_info.is_valid());
|
||||
|
||||
notification_ccast(SpellEnums::NOTIFICATION_CAST_FAILED, _c_spell_cast_info);
|
||||
|
||||
_c_spell_cast_info.unref();
|
||||
}
|
||||
|
||||
void Entity::cast_delayc() {
|
||||
ERR_FAIL_COND(!_c_spell_cast_info.is_valid());
|
||||
//c_on_cast_
|
||||
|
||||
notification_scast(SpellEnums::NOTIFICATION_CAST_DELAYED, _c_spell_cast_info);
|
||||
}
|
||||
|
||||
void Entity::cast_finishc() {
|
||||
ERR_FAIL_COND(!_c_spell_cast_info.is_valid());
|
||||
|
||||
notification_ccast(SpellEnums::NOTIFICATION_CAST_FINISHED, _c_spell_cast_info);
|
||||
|
||||
_c_spell_cast_info.unref();
|
||||
}
|
||||
|
||||
void Entity::cast_interruptc() {
|
||||
ERR_FAIL_COND(!_c_spell_cast_info.is_valid());
|
||||
|
||||
notification_ccast(SpellEnums::NOTIFICATION_CAST_INTERRUPTED, _c_spell_cast_info);
|
||||
|
||||
_c_spell_cast_info.unref();
|
||||
@ -4202,6 +4260,8 @@ bool Entity::spell_hass_id(int id) {
|
||||
return false;
|
||||
}
|
||||
void Entity::spell_adds(Ref<Spell> spell) {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
if (spell_hass(spell))
|
||||
return;
|
||||
|
||||
@ -4241,6 +4301,8 @@ void Entity::spell_adds(Ref<Spell> spell) {
|
||||
ORPCOBJ(spell_addc_rpc, spell->get_id(), spell_addc, spell);
|
||||
}
|
||||
void Entity::spell_adds_id(int id) {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
Ref<Spell> spell = ESS::get_singleton()->get_resource_db()->get_spell(id);
|
||||
|
||||
ERR_FAIL_COND(!spell.is_valid());
|
||||
@ -5491,6 +5553,8 @@ void Entity::set_actionbar_locked(bool value) {
|
||||
}
|
||||
|
||||
Ref<ActionBarProfile> Entity::get_action_bar_profile() {
|
||||
ERR_FAIL_COND_V(!ProfileManager::get_singleton(), Ref<ActionBarProfile>());
|
||||
|
||||
if (_action_bar_profile.is_valid())
|
||||
return _action_bar_profile;
|
||||
|
||||
@ -5586,13 +5650,11 @@ void Entity::update(float delta) {
|
||||
}
|
||||
}
|
||||
|
||||
if (ESS::get_singleton()) {
|
||||
for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) {
|
||||
if (stat_get_dirty(i)) {
|
||||
ssend_stat(i, stat_gets_current(i));
|
||||
for (int i = 0; i < _stats.size(); ++i) {
|
||||
if (stat_get_dirty(i)) {
|
||||
ssend_stat(i, stat_gets_current(i));
|
||||
|
||||
stat_set_dirty(i, false);
|
||||
}
|
||||
stat_set_dirty(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5646,6 +5708,8 @@ Entity *Entity::sees_gets(int index) {
|
||||
return _s_sees.get(index);
|
||||
}
|
||||
void Entity::sees_removes_index(int index) {
|
||||
ERR_FAIL_INDEX(index, _s_sees.size());
|
||||
|
||||
Entity *e = _s_sees.get(index);
|
||||
|
||||
if (unlikely(!ObjectDB::instance_validate(e))) {
|
||||
@ -5703,6 +5767,8 @@ Entity *Entity::seen_by_gets(int index) {
|
||||
return _s_seen_by.get(index);
|
||||
}
|
||||
void Entity::seen_by_removes_index(int index) {
|
||||
ERR_FAIL_INDEX(index, _s_sees.size());
|
||||
|
||||
_s_seen_by.remove(index);
|
||||
}
|
||||
void Entity::seen_by_removes(Entity *entity) {
|
||||
@ -5828,9 +5894,10 @@ Entity::Entity() {
|
||||
_maunal_process = false;
|
||||
_deserialized = false;
|
||||
|
||||
_body = NULL;
|
||||
_body_3d = NULL;
|
||||
_body_2d = NULL;
|
||||
_character_skeleton = nullptr;
|
||||
_body = nullptr;
|
||||
_body_3d = nullptr;
|
||||
_body_2d = nullptr;
|
||||
|
||||
_s_guid = 0;
|
||||
_c_guid = 0;
|
||||
@ -6219,6 +6286,8 @@ void Entity::_crafts(int id) {
|
||||
}
|
||||
|
||||
void Entity::_notification_sxp_gained(int value) {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
/*
|
||||
if (ESS::get_singleton()->get_use_class_xp() && ESS::get_singleton()->get_automatic_class_levelups()) {
|
||||
if (ESS::get_singleton()->get_resource_db()->get_xp_data()->can_class_level_up(gets_class_level())) {
|
||||
@ -6243,6 +6312,8 @@ void Entity::_notification_sxp_gained(int value) {
|
||||
}
|
||||
|
||||
void Entity::_notification_slevel_up(int level) {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
if (!gets_entity_data().is_valid())
|
||||
return;
|
||||
|
||||
@ -6350,6 +6421,8 @@ void Entity::_notification_sdeath() {
|
||||
}
|
||||
|
||||
void Entity::_spell_learns(int id) {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
if (ESS::get_singleton()->get_use_spell_points()) {
|
||||
ERR_FAIL_COND(gets_free_spell_points() <= 0);
|
||||
}
|
||||
@ -6654,13 +6727,13 @@ void Entity::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
int property_usange = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) {
|
||||
for (int i = 0; i < _stats.size(); ++i) {
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/base", PROPERTY_HINT_NONE, "", property_usange));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/percent", PROPERTY_HINT_NONE, "", property_usange));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/scurrent", PROPERTY_HINT_NONE, "", property_usange));
|
||||
}
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->equip_slot_get_count(); ++i) {
|
||||
for (int i = 0; i < _s_equipment.size(); ++i) {
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "sequipment/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance", property_usange));
|
||||
}
|
||||
}
|
||||
|
@ -253,6 +253,8 @@ void EntityResource::from_dict(const Dictionary &dict) {
|
||||
Dictionary EntityResource::_to_dict() {
|
||||
Dictionary dict;
|
||||
|
||||
ERR_FAIL_COND_V(!ESS::get_singleton(), dict);
|
||||
|
||||
dict["data_path"] = ESS::get_singleton()->get_resource_db()->get_entity_resource(_id)->get_path();
|
||||
|
||||
dict["dirty"] = _dirty;
|
||||
|
@ -32,6 +32,8 @@ void EntityResourceHealth::_init() {
|
||||
stamina_stat_id = 0;
|
||||
health_stat_id = 0;
|
||||
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
if (ESS::get_singleton()->stat_is_property("Stamina")) {
|
||||
stamina_stat_id = ESS::get_singleton()->stat_get_id("Stamina");
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ void EntityResourceSpeed::_init() {
|
||||
|
||||
speed_stat_id = 0;
|
||||
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
if (ESS::get_singleton()->stat_is_property("Speed"))
|
||||
speed_stat_id = ESS::get_singleton()->stat_get_id("Speed");
|
||||
}
|
||||
|
@ -25,12 +25,14 @@ SOFTWARE.
|
||||
#include "../../singletons/ess.h"
|
||||
|
||||
int ComplexLevelStatData::get_stat_for_level(int main_stat, int level) {
|
||||
ERR_FAIL_COND_V(!ESS::get_singleton(), 0);
|
||||
ERR_FAIL_INDEX_V(level, ESS::get_singleton()->get_max_character_level(), 0);
|
||||
ERR_FAIL_INDEX_V(main_stat, ESS::get_singleton()->stat_get_main_stat_count(), 0);
|
||||
|
||||
return _stat_per_level[level][main_stat];
|
||||
}
|
||||
void ComplexLevelStatData::set_stat_for_level(int main_stat, int level, int value) {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
ERR_FAIL_INDEX(level, ESS::get_singleton()->get_max_character_level());
|
||||
ERR_FAIL_INDEX(main_stat, ESS::get_singleton()->stat_get_main_stat_count());
|
||||
|
||||
@ -48,6 +50,8 @@ int ComplexLevelStatData::_get_stat_diff(int main_stat, int old_level, int new_l
|
||||
}
|
||||
|
||||
ComplexLevelStatData::ComplexLevelStatData() {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
if (ESS::get_singleton()->get_max_character_level()) {
|
||||
_stat_per_level.resize(ESS::get_singleton()->get_max_character_level());
|
||||
|
||||
@ -64,12 +68,14 @@ ComplexLevelStatData::ComplexLevelStatData() {
|
||||
}
|
||||
|
||||
ComplexLevelStatData::~ComplexLevelStatData() {
|
||||
for (int i = 0; i < ESS::get_singleton()->get_max_character_level(); ++i) {
|
||||
for (int i = 0; i < _stat_per_level.size(); ++i) {
|
||||
_stat_per_level.write[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
bool ComplexLevelStatData::_set(const StringName &p_name, const Variant &p_value) {
|
||||
ERR_FAIL_COND_V(!ESS::get_singleton(), false);
|
||||
|
||||
String prop_name = p_name;
|
||||
|
||||
if (prop_name.begins_with("level_")) {
|
||||
@ -100,6 +106,8 @@ bool ComplexLevelStatData::_set(const StringName &p_name, const Variant &p_value
|
||||
}
|
||||
|
||||
bool ComplexLevelStatData::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
ERR_FAIL_COND_V(!ESS::get_singleton(), false);
|
||||
|
||||
String prop_name = p_name;
|
||||
|
||||
if (prop_name.begins_with("level_")) {
|
||||
@ -130,6 +138,8 @@ bool ComplexLevelStatData::_get(const StringName &p_name, Variant &r_ret) const
|
||||
}
|
||||
|
||||
void ComplexLevelStatData::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
ERR_FAIL_COND(!ESS::get_singleton());
|
||||
|
||||
//int property_usange = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL;
|
||||
int property_usange = PROPERTY_USAGE_DEFAULT;
|
||||
|
||||
|
@ -279,6 +279,8 @@ void ESSMaterialCache::initial_setup_default() {
|
||||
|
||||
ESS *ess = ESS::get_singleton();
|
||||
|
||||
ERR_FAIL_COND(!ess);
|
||||
|
||||
ess->ensure_materials_loaded();
|
||||
|
||||
int matc = ess->material_get_num();
|
||||
|
@ -42,6 +42,8 @@ void InputProfile::set_data(const Array &data) {
|
||||
}
|
||||
|
||||
void InputProfile::load_to_projectsettings() {
|
||||
ERR_FAIL_COND(!ProjectSettings::get_singleton());
|
||||
|
||||
for (int i = 0; i < _data.size(); ++i) {
|
||||
Array arr = _data[i];
|
||||
|
||||
@ -98,6 +100,7 @@ void InputProfile::from_dict(const Dictionary &dict) {
|
||||
}
|
||||
|
||||
InputProfile::InputProfile() {
|
||||
_owner = nullptr;
|
||||
}
|
||||
|
||||
void InputProfile::_bind_methods() {
|
||||
|
@ -35,14 +35,20 @@ void InputProfileModifier::add_modifier(String modifier) {
|
||||
}
|
||||
|
||||
String InputProfileModifier::get_modifier(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _modifier_actions->size(), "");
|
||||
|
||||
return _modifier_actions->get(index);
|
||||
}
|
||||
|
||||
void InputProfileModifier::set_modifier(int index, String value) {
|
||||
ERR_FAIL_INDEX(index, _modifier_actions->size());
|
||||
|
||||
_modifier_actions->set(index, value);
|
||||
}
|
||||
|
||||
void InputProfileModifier::remove_modifier(int index) {
|
||||
ERR_FAIL_INDEX(index, _modifier_actions->size());
|
||||
|
||||
_modifier_actions->remove(index);
|
||||
}
|
||||
|
||||
@ -59,14 +65,20 @@ void InputProfileModifier::add_entry(Ref<InputProfileModifierEntry> modifier) {
|
||||
}
|
||||
|
||||
Ref<InputProfileModifierEntry> InputProfileModifier::get_entry(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _entries->size(), Ref<InputProfileModifierEntry>());
|
||||
|
||||
return _entries->get(index);
|
||||
}
|
||||
|
||||
void InputProfileModifier::set_entry(int index, Ref<InputProfileModifierEntry> value) {
|
||||
ERR_FAIL_INDEX(index, _entries->size());
|
||||
|
||||
_entries->set(index, Ref<InputProfileModifierEntry>(value));
|
||||
}
|
||||
|
||||
void InputProfileModifier::remove_entry(int index) {
|
||||
ERR_FAIL_INDEX(index, _entries->size());
|
||||
|
||||
_entries->remove(index);
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,8 @@ int PlayerProfile::get_class_profile_count() const {
|
||||
}
|
||||
|
||||
Ref<ClassProfile> PlayerProfile::get_class_profile_index(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _class_profiles.size(), Ref<ClassProfile>());
|
||||
|
||||
return _class_profiles.get(index);
|
||||
}
|
||||
|
||||
@ -79,6 +81,8 @@ void PlayerProfile::clear_class_profiles() {
|
||||
}
|
||||
|
||||
void PlayerProfile::remove_class_profile(const int index) {
|
||||
ERR_FAIL_INDEX(index, _class_profiles.size());
|
||||
|
||||
_class_profiles.get(index)->disconnect("changed", this, "_on_class_profile_changed");
|
||||
|
||||
_class_profiles.remove(index);
|
||||
|
@ -302,6 +302,8 @@ void CharacterSkeleton2D::remove_model_visual_entry(Ref<ModelVisual> vis, Ref<Mo
|
||||
|
||||
int target_bone_idx = ive->get_bone();
|
||||
|
||||
ERR_FAIL_INDEX(target_bone_idx, _entries.size());
|
||||
|
||||
Vector<Ref<SkeletonModelEntry>> &entries = _entries.write[target_bone_idx];
|
||||
|
||||
for (int i = 0; i < entries.size(); ++i) {
|
||||
|
@ -342,6 +342,8 @@ void CharacterSkeleton3D::remove_model_visual_entry(Ref<ModelVisual> vis, Ref<Mo
|
||||
|
||||
int target_bone_idx = ive->get_bone();
|
||||
|
||||
ERR_FAIL_INDEX(target_bone_idx, _entries.size());
|
||||
|
||||
Vector<Ref<SkeletonModelEntry>> &entries = _entries.write[target_bone_idx];
|
||||
|
||||
for (int i = 0; i < entries.size(); ++i) {
|
||||
|
@ -695,10 +695,14 @@ void MeshMerger::add_vertex(const Vector3 &vertex) {
|
||||
}
|
||||
|
||||
Vector3 MeshMerger::get_vertex(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector3());
|
||||
|
||||
return _vertices.get(idx).vertex;
|
||||
}
|
||||
|
||||
void MeshMerger::remove_vertex(const int idx) {
|
||||
ERR_FAIL_INDEX(idx, _vertices.size());
|
||||
|
||||
_vertices.remove(idx);
|
||||
}
|
||||
|
||||
@ -730,6 +734,8 @@ void MeshMerger::add_normal(const Vector3 &normal) {
|
||||
}
|
||||
|
||||
Vector3 MeshMerger::get_normal(int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector3());
|
||||
|
||||
return _vertices.get(idx).normal;
|
||||
}
|
||||
|
||||
@ -761,6 +767,8 @@ void MeshMerger::add_color(const Color &color) {
|
||||
}
|
||||
|
||||
Color MeshMerger::get_color(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Color());
|
||||
|
||||
return _vertices.get(idx).color;
|
||||
}
|
||||
|
||||
@ -792,6 +800,8 @@ void MeshMerger::add_uv(const Vector2 &uv) {
|
||||
}
|
||||
|
||||
Vector2 MeshMerger::get_uv(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector2());
|
||||
|
||||
return _vertices.get(idx).uv;
|
||||
}
|
||||
|
||||
@ -823,10 +833,14 @@ void MeshMerger::add_uv2(const Vector2 &uv) {
|
||||
}
|
||||
|
||||
Vector2 MeshMerger::get_uv2(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector2());
|
||||
|
||||
return _vertices.get(idx).uv2;
|
||||
}
|
||||
|
||||
Vector<int> MeshMerger::get_bones(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector<int>());
|
||||
|
||||
return _vertices[idx].bones;
|
||||
}
|
||||
void MeshMerger::add_bones(const Vector<int> &vector) {
|
||||
@ -834,6 +848,8 @@ void MeshMerger::add_bones(const Vector<int> &vector) {
|
||||
}
|
||||
|
||||
Vector<float> MeshMerger::get_bone_weights(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector<float>());
|
||||
|
||||
return _vertices[idx].weights;
|
||||
}
|
||||
void MeshMerger::add_bone_weights(const Vector<float> &arr) {
|
||||
@ -857,10 +873,14 @@ void MeshMerger::add_indices(const int index) {
|
||||
}
|
||||
|
||||
int MeshMerger::get_index(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _indices.size(), 0);
|
||||
|
||||
return _indices.get(idx);
|
||||
}
|
||||
|
||||
void MeshMerger::remove_index(const int idx) {
|
||||
ERR_FAIL_INDEX(idx, _indices.size());
|
||||
|
||||
_indices.remove(idx);
|
||||
}
|
||||
|
||||
|
@ -124,8 +124,9 @@ void Prop2DInstanceProp2DJob::clear_lights() {
|
||||
}
|
||||
|
||||
void Prop2DInstanceProp2DJob::_physics_process(float delta) {
|
||||
if (_phase == 0)
|
||||
if (_phase == 0) {
|
||||
phase_physics_process();
|
||||
}
|
||||
}
|
||||
|
||||
void Prop2DInstanceProp2DJob::_execute_phase() {
|
||||
@ -179,6 +180,8 @@ void Prop2DInstanceProp2DJob::_reset() {
|
||||
}
|
||||
|
||||
void Prop2DInstanceProp2DJob::phase_physics_process() {
|
||||
ERR_FAIL_COND(!_prop_instace);
|
||||
|
||||
//TODO this should only update the differences
|
||||
//for (int i = 0; i < _prop_instace->collider_get_num(); ++i) {
|
||||
// PhysicsServer::get_singleton()->free(_prop_instace->collider_body_get(i));
|
||||
|
@ -166,6 +166,8 @@ Node *Prop2DDataEntry::_processor_get_node_for(const Transform2D &transform, Nod
|
||||
n = memnew(Node2D());
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!n, nullptr);
|
||||
|
||||
n->set_transform(transform * get_transform_2d());
|
||||
|
||||
n->set_z_index(get_z_index());
|
||||
|
Loading…
Reference in New Issue
Block a user