diff --git a/data/aura.cpp b/data/aura.cpp index 1f61a81..6d4b915 100644 --- a/data/aura.cpp +++ b/data/aura.cpp @@ -490,7 +490,6 @@ void Aura::son_hit(Ref data) { call("_son_hit", data); } - void Aura::son_before_damage(Ref data) { ERR_FAIL_COND(!data.is_valid()); @@ -519,7 +518,6 @@ void Aura::son_damage_dealt(Ref data) { call("_son_damage_dealt", data); } - void Aura::son_before_heal(Ref data) { ERR_FAIL_COND(!data.is_valid()); @@ -608,12 +606,15 @@ void Aura::setup_aura_data(Ref data, Ref info) { ERR_FAIL_COND(!data.is_valid() || !info.is_valid()); //always exists - call("setup_aura_data", data, info); + call("_setup_aura_data", data, info); } void Aura::_setup_aura_data(Ref data, Ref info) { + ERR_FAIL_COND(info->get_caster() == NULL); + data->set_aura(Ref(this)); data->set_caster(info->get_caster()); + data->set_remaining_time(get_time()); if (is_damage_enabled()) { calculate_initial_damage(data, info); @@ -648,13 +649,10 @@ void Aura::handle_aura_damage(Ref aura_data, Ref data call("_handle_aura_damage", aura_data, data); } - void Aura::_sapply_passives_damage_receive(Ref data) { - } void Aura::_sapply_passives_damage_deal(Ref data) { - } void Aura::_calculate_initial_damage(Ref aura_data, Ref info) { @@ -662,6 +660,8 @@ void Aura::_calculate_initial_damage(Ref aura_data, Ref } void Aura::_handle_aura_damage(Ref aura_data, Ref data) { + ERR_FAIL_COND(data->get_dealer() == NULL); + data->set_damage(aura_data->get_damage()); data->get_dealer()->sdeal_damage_to(data); @@ -716,6 +716,8 @@ void Aura::_handle_aura_heal(Ref aura_data, Ref data) { } void Aura::_sapply(Ref info) { + ERR_FAIL_COND(info->get_target() == NULL || info->get_caster() == NULL || !info->get_aura().is_valid()); + Ref aura = info->get_aura(); Ref ad(memnew(AuraData())); @@ -725,14 +727,20 @@ void Aura::_sapply(Ref info) { } void Aura::_sremove(Ref aura) { + ERR_FAIL_COND(aura->get_owner() == NULL); + aura->get_owner()->sremove_aura(aura); } void Aura::_sremove_expired(Ref aura) { + ERR_FAIL_COND(aura->get_owner() == NULL); + aura->get_owner()->sremove_aura_expired(aura); } void Aura::_sremove_dispell(Ref aura) { + ERR_FAIL_COND(aura->get_owner() == NULL); + aura->get_owner()->sremove_aura_dispelled(aura); } @@ -761,7 +769,6 @@ void Aura::_supdate(Ref aura, float delta) { } } - void Aura::_validate_property(PropertyInfo &property) const { String prop = property.name; @@ -914,7 +921,7 @@ void Aura::_bind_methods() { ClassDB::bind_method(D_METHOD("get_is_debuff"), &Aura::get_is_debuff); ClassDB::bind_method(D_METHOD("set_is_debuff", "value"), &Aura::set_is_debuff); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_debuff"), "set_is_debuff", "get_is_debuff"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debuff"), "set_is_debuff", "get_is_debuff"); ClassDB::bind_method(D_METHOD("get_aura_type"), &Aura::get_aura_type); ClassDB::bind_method(D_METHOD("set_aura_type", "value"), &Aura::set_aura_type); @@ -1084,10 +1091,6 @@ void Aura::_bind_methods() { BIND_CONSTANT(MAX_AURA_STATS); BIND_CONSTANT(MAX_TRIGGER_DATA); - - //ClassDB::bind_method(D_METHOD("get_damage_scale_for_level"), &Aura::get_damage_scale_for_level); - //ClassDB::bind_method(D_METHOD("get_heal_scale_for_level"), &Aura::get_heal_scale_for_level); - //ClassDB::bind_method(D_METHOD("get_absorb_scale_for_level"), &Aura::get_absorb_scale_for_level); } /* diff --git a/entities/entity.cpp b/entities/entity.cpp index 231d9d7..81c4fa2 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -259,27 +259,6 @@ Entity::Entity() { _s_target = NULL; _c_target = NULL; - /* - auras = new Vector(); - serverAuras = new Vector(); - - c_spell_name = ""; - - cTalents = new Vector(); - sTalents = new Vector(); - owner = owner;*/ - - /* - cCraftMaterialInventory = new Vector(); - sCraftMaterialInventory = new Vector(); - cInventory = new Vector(); - sInventory = new Vector(); - owner = owner; - for (int i = 0; i < 21; i += 1) { - cInventory->Add(null); - sInventory->Add(null); - }*/ - for (int i = 0; i < Stat::STAT_ID_TOTAL_STATS; ++i) { _stats[i] = Ref(memnew(Stat(static_cast(i)))); } @@ -315,48 +294,9 @@ Entity::Entity() { _heal_taken = Ref(get_stat_enum(Stat::STAT_ID_HEAL_TAKEN)); _melee_damage = Ref(get_stat_enum(Stat::STAT_ID_MELEE_DAMAGE)); _spell_damage = Ref(get_stat_enum(Stat::STAT_ID_SPELL_DAMAGE)); - - _s_auras = memnew(Vector >()); - _c_auras = memnew(Vector >()); - - _s_cooldowns = memnew(Vector >()); - _c_cooldowns = memnew(Vector >()); - - _s_cooldown_map = memnew(CooldownHashMap()); - _c_cooldown_map = memnew(CooldownHashMap()); - - _s_category_cooldowns = memnew(Vector >()); - _c_category_cooldowns = memnew(Vector >()); - - _s_category_cooldown_map = memnew(CategoryCooldownHashMap()); - _c_category_cooldown_map = memnew(CategoryCooldownHashMap()); } Entity::~Entity() { - _s_auras->clear(); - _c_auras->clear(); - memdelete(_s_auras); - memdelete(_c_auras); - - _s_cooldowns->clear(); - _c_cooldowns->clear(); - memdelete(_s_cooldowns); - memdelete(_c_cooldowns); - - _s_cooldown_map->clear(); - _c_cooldown_map->clear(); - memdelete(_s_cooldown_map); - memdelete(_c_cooldown_map); - - _s_category_cooldowns->clear(); - _c_category_cooldowns->clear(); - memdelete(_s_category_cooldowns); - memdelete(_c_category_cooldowns); - - _s_category_cooldown_map->clear(); - _c_category_cooldown_map->clear(); - memdelete(_s_category_cooldown_map); - memdelete(_c_category_cooldown_map); } void Entity::initialize(Ref info) { @@ -709,8 +649,8 @@ void Entity::creceive_mana_changed(int amount) { void Entity::son_before_aura_applied(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_before_aura_applied(data); } @@ -719,8 +659,8 @@ void Entity::son_before_aura_applied(Ref data) { void Entity::son_after_aura_applied(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); if (ad == data) { continue; @@ -746,8 +686,8 @@ void Entity::crequest_spell_cast(int spell_id) { } void Entity::update_auras(float delta) { - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->supdate(ad, delta); } @@ -756,8 +696,8 @@ void Entity::update_auras(float delta) { void Entity::son_before_cast(Ref info) { ERR_FAIL_COND(!info.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_before_cast(info); } @@ -766,8 +706,8 @@ void Entity::son_before_cast(Ref info) { void Entity::son_before_cast_target(Ref info) { ERR_FAIL_COND(!info.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_before_cast_target(info); } @@ -776,8 +716,8 @@ void Entity::son_before_cast_target(Ref info) { void Entity::son_hit(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_hit(data); } @@ -786,8 +726,8 @@ void Entity::son_hit(Ref data) { void Entity::son_before_damage(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_before_damage(data); } @@ -796,8 +736,8 @@ void Entity::son_before_damage(Ref data) { void Entity::son_damage_receive(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_damage_receive(data); } @@ -806,8 +746,8 @@ void Entity::son_damage_receive(Ref data) { void Entity::son_dealt_damage(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_dealt_damage(data); } @@ -817,8 +757,8 @@ void Entity::son_damage_dealt(Ref data) { ERR_FAIL_COND(!data.is_valid()); //serverside - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_damage_dealt(data); } @@ -827,8 +767,8 @@ void Entity::son_damage_dealt(Ref data) { void Entity::son_before_heal(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_before_heal(data); } @@ -837,8 +777,8 @@ void Entity::son_before_heal(Ref data) { void Entity::son_heal_receive(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_heal_receive(data); } @@ -847,8 +787,8 @@ void Entity::son_heal_receive(Ref data) { void Entity::son_dealt_heal(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_dealt_heal(data); } @@ -858,8 +798,8 @@ void Entity::son_heal_dealt(Ref data) { ERR_FAIL_COND(!data.is_valid()); //serverside - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_heal_dealt(data); } @@ -868,8 +808,8 @@ void Entity::son_heal_dealt(Ref data) { void Entity::sapply_passives_damage_receive(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->sapply_passives_damage_receive(data); } @@ -878,8 +818,8 @@ void Entity::sapply_passives_damage_receive(Ref data) { void Entity::sapply_passives_damage_deal(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->sapply_passives_damage_deal(data); } @@ -888,8 +828,8 @@ void Entity::sapply_passives_damage_deal(Ref data) { void Entity::sapply_passives_heal_receive(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->sapply_passives_heal_receive(data); } @@ -898,8 +838,8 @@ void Entity::sapply_passives_heal_receive(Ref data) { void Entity::sapply_passives_heal_deal(Ref data) { ERR_FAIL_COND(!data.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->sapply_passives_heal_deal(data); } @@ -908,8 +848,8 @@ void Entity::sapply_passives_heal_deal(Ref data) { void Entity::son_cast_finished(Ref info) { ERR_FAIL_COND(!info.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_cast_finished(info); } @@ -918,8 +858,8 @@ void Entity::son_cast_finished(Ref info) { void Entity::son_cast_started(Ref info) { ERR_FAIL_COND(!info.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_cast_started(info); } @@ -928,8 +868,8 @@ void Entity::son_cast_started(Ref info) { void Entity::son_cast_failed(Ref info) { ERR_FAIL_COND(!info.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_cast_failed(info); } @@ -938,8 +878,8 @@ void Entity::son_cast_failed(Ref info) { void Entity::son_cast_finished_target(Ref info) { ERR_FAIL_COND(!info.is_valid()); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_cast_finished_target(info); } @@ -952,7 +892,7 @@ void Entity::sadd_aura(Ref aura) { aura->set_owner(this); - _s_auras->push_back(aura); + _s_auras.push_back(aura); son_after_aura_applied(aura); @@ -964,13 +904,13 @@ void Entity::sadd_aura(Ref aura) { void Entity::sremove_aura(Ref aura) { ERR_FAIL_COND(!aura.is_valid()); - for (int i = 0; i < _s_auras->size(); i++) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); i++) { + Ref ad = _s_auras.get(i); if (ad == aura) { ad->get_aura()->son_remove(ad); - _s_auras->remove(i); + _s_auras.remove(i); break; } @@ -984,13 +924,13 @@ void Entity::sremove_aura(Ref aura) { void Entity::sremove_aura_expired(Ref aura) { ERR_FAIL_COND(!aura.is_valid()); - for (int i = 0; i < _s_auras->size(); i++) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); i++) { + Ref ad = _s_auras.get(i); if (ad == aura) { ad->get_aura()->son_remove(ad); - _s_auras->remove(i); + _s_auras.remove(i); break; } @@ -1004,13 +944,13 @@ void Entity::sremove_aura_expired(Ref aura) { void Entity::sremove_aura_dispelled(Ref aura) { ERR_FAIL_COND(!aura.is_valid()); - for (int i = 0; i < _s_auras->size(); i++) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); i++) { + Ref ad = _s_auras.get(i); if (ad == aura) { ad->get_aura()->son_remove(ad); - _s_auras->remove(i); + _s_auras.remove(i); break; } @@ -1024,16 +964,16 @@ void Entity::sremove_aura_dispelled(Ref aura) { void Entity::cadd_aura(Ref data) { ERR_FAIL_COND(!data.is_valid()); - _c_auras->push_back(data); + _c_auras.push_back(data); emit_signal("caura_added", data); } void Entity::cremove_aura(Ref aura) { ERR_FAIL_COND(!aura.is_valid()); - for (int i = 0; i < _c_auras->size(); i++) { - if (_c_auras->get(i) == aura) { - _c_auras->remove(i); + for (int i = 0; i < _c_auras.size(); i++) { + if (_c_auras.get(i) == aura) { + _c_auras.remove(i); break; } } @@ -1044,9 +984,9 @@ void Entity::cremove_aura(Ref aura) { void Entity::cremove_aura_dispelled(Ref aura) { ERR_FAIL_COND(!aura.is_valid()); - for (int i = 0; i < _c_auras->size(); i++) { - if (_c_auras->get(i) == aura) { - _c_auras->remove(i); + for (int i = 0; i < _c_auras.size(); i++) { + if (_c_auras.get(i) == aura) { + _c_auras.remove(i); break; } } @@ -1057,9 +997,9 @@ void Entity::cremove_aura_dispelled(Ref aura) { void Entity::cremove_aura_expired(Ref aura) { ERR_FAIL_COND(!aura.is_valid()); - for (int i = 0; i < _c_auras->size(); i++) { - if (_c_auras->get(i) == aura) { - _c_auras->remove(i); + for (int i = 0; i < _c_auras.size(); i++) { + if (_c_auras.get(i) == aura) { + _c_auras.remove(i); break; } } @@ -1068,23 +1008,23 @@ void Entity::cremove_aura_expired(Ref aura) { } int Entity::sget_aura_count() { - return _s_auras->size(); + return _s_auras.size(); } Ref Entity::sget_aura(int index) { - ERR_FAIL_INDEX_V(index, _s_auras->size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _s_auras.size(), Ref(NULL)); - return Ref(_s_auras->get(index)); + return Ref(_s_auras.get(index)); } int Entity::cget_aura_count() { - return _s_auras->size(); + return _s_auras.size(); } Ref Entity::cget_aura(int index) { - ERR_FAIL_INDEX_V(index, _c_auras->size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _c_auras.size(), Ref(NULL)); - return Ref(_c_auras->get(index)); + return Ref(_c_auras.get(index)); } void Entity::moved() { @@ -1113,8 +1053,8 @@ void Entity::setup_on_player_moves(Entity *bopmccc, Vector *sspells) { void Entity::sstart_casting(Ref info) { _s_spell_cast_info = Ref(info); - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_before_cast(info); } @@ -1127,8 +1067,8 @@ void Entity::sstart_casting(Ref info) { } void Entity::sfail_cast() { - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_before_cast(_s_spell_cast_info); } @@ -1137,8 +1077,8 @@ void Entity::sfail_cast() { } void Entity::sdelay_cast() { - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_before_cast(_s_spell_cast_info); } @@ -1148,8 +1088,8 @@ void Entity::sdelay_cast() { void Entity::sfinish_cast() { - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_cast_finished(_s_spell_cast_info); } @@ -1164,8 +1104,8 @@ void Entity::sfinish_cast() { } void Entity::sinterrupt_cast() { - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); ad->get_aura()->son_before_cast(_s_spell_cast_info); } @@ -1202,25 +1142,25 @@ void Entity::cinterrupt_cast() { //// Cooldowns //// Vector > *Entity::gets_cooldowns() { - return _s_cooldowns; + return &_s_cooldowns; } Vector > *Entity::getc_cooldowns() { - return _c_cooldowns; + return &_c_cooldowns; } HashMap > *Entity::gets_cooldown_map() { - return _s_cooldown_map; + return &_s_cooldown_map; } HashMap > *Entity::getc_cooldown_map() { - return _c_cooldown_map; + return &_c_cooldown_map; } bool Entity::hass_cooldown(int spell_id) { - return _s_cooldown_map->has(spell_id); + return _s_cooldown_map.has(spell_id); } void Entity::adds_cooldown(int spell_id, float value) { - if (_s_cooldown_map->has(spell_id)) { - Ref cd = _s_cooldown_map->get(spell_id); + if (_s_cooldown_map.has(spell_id)) { + Ref cd = _s_cooldown_map.get(spell_id); cd->set_remaining(value); @@ -1232,20 +1172,20 @@ void Entity::adds_cooldown(int spell_id, float value) { Ref cd; cd.instance(); - _s_cooldown_map->set(spell_id, cd); - _s_cooldowns->push_back(cd); + _s_cooldown_map.set(spell_id, cd); + _s_cooldowns.push_back(cd); emit_signal("scooldown_added", cd); addc_cooldown(spell_id, value); } void Entity::removes_cooldown(int spell_id) { - if (_s_cooldown_map->has(spell_id)) { - _s_cooldown_map->erase(spell_id); + if (_s_cooldown_map.has(spell_id)) { + _s_cooldown_map.erase(spell_id); } - for (int i = 0; i < _s_cooldowns->size(); ++i) { - if (_s_cooldowns->get(i)->get_spell_id() == spell_id) { - _s_cooldowns->remove(i); + for (int i = 0; i < _s_cooldowns.size(); ++i) { + if (_s_cooldowns.get(i)->get_spell_id() == spell_id) { + _s_cooldowns.remove(i); return; } } @@ -1253,27 +1193,27 @@ void Entity::removes_cooldown(int spell_id) { emit_signal("scooldown_removed", spell_id); } Ref Entity::gets_cooldown(int spell_id) { - if (!_s_cooldown_map->has(spell_id)) { + if (!_s_cooldown_map.has(spell_id)) { return Ref(); } - return _s_cooldown_map->get(spell_id); + return _s_cooldown_map.get(spell_id); } Ref Entity::gets_cooldown_index(int index) { - ERR_FAIL_INDEX_V(index, _s_cooldowns->size(), Ref()); + ERR_FAIL_INDEX_V(index, _s_cooldowns.size(), Ref()); - return _s_cooldowns->get(index); + return _s_cooldowns.get(index); } int Entity::gets_cooldown_count() { - return _s_cooldowns->size(); + return _s_cooldowns.size(); } bool Entity::hasc_cooldown(int spell_id) { - return _c_cooldown_map->has(spell_id); + return _c_cooldown_map.has(spell_id); } void Entity::addc_cooldown(int spell_id, float value) { - if (_c_cooldown_map->has(spell_id)) { - Ref cd = _c_cooldown_map->get(spell_id); + if (_c_cooldown_map.has(spell_id)) { + Ref cd = _c_cooldown_map.get(spell_id); cd->set_remaining(value); @@ -1284,19 +1224,19 @@ void Entity::addc_cooldown(int spell_id, float value) { Ref cd; cd.instance(); - _c_cooldown_map->set(spell_id, cd); - _c_cooldowns->push_back(cd); + _c_cooldown_map.set(spell_id, cd); + _c_cooldowns.push_back(cd); emit_signal("ccooldown_added", cd); } void Entity::removec_cooldown(int spell_id) { - if (_c_cooldown_map->has(spell_id)) { - _c_cooldown_map->erase(spell_id); + if (_c_cooldown_map.has(spell_id)) { + _c_cooldown_map.erase(spell_id); } - for (int i = 0; i < _c_cooldowns->size(); ++i) { - if (_c_cooldowns->get(i)->get_spell_id() == spell_id) { - _c_cooldowns->remove(i); + for (int i = 0; i < _c_cooldowns.size(); ++i) { + if (_c_cooldowns.get(i)->get_spell_id() == spell_id) { + _c_cooldowns.remove(i); return; } } @@ -1304,42 +1244,42 @@ void Entity::removec_cooldown(int spell_id) { emit_signal("ccooldown_removed", spell_id); } Ref Entity::getc_cooldown(int spell_id) { - if (!_c_cooldown_map->has(spell_id)) { + if (!_c_cooldown_map.has(spell_id)) { return Ref(); } - return _c_cooldown_map->get(spell_id); + return _c_cooldown_map.get(spell_id); } Ref Entity::getc_cooldown_index(int index) { - ERR_FAIL_INDEX_V(index, _c_cooldowns->size(), Ref()); + ERR_FAIL_INDEX_V(index, _c_cooldowns.size(), Ref()); - return _c_cooldowns->get(index); + return _c_cooldowns.get(index); } int Entity::getc_cooldown_count() { - return _c_cooldowns->size(); + return _c_cooldowns.size(); } //Category Cooldowns Vector > *Entity::gets_category_cooldowns() { - return _s_category_cooldowns; + return &_s_category_cooldowns; } Vector > *Entity::getc_category_cooldowns() { - return _c_category_cooldowns; + return &_c_category_cooldowns; } HashMap > *Entity::gets_category_cooldown_map() { - return _s_category_cooldown_map; + return &_s_category_cooldown_map; } HashMap > *Entity::getc_category_cooldown_map() { - return _c_category_cooldown_map; + return &_c_category_cooldown_map; } bool Entity::hass_category_cooldown(int spell_id) { - return _s_category_cooldown_map->has(spell_id); + return _s_category_cooldown_map.has(spell_id); } void Entity::adds_category_cooldown(int spell_id, float value) { - if (_s_category_cooldown_map->has(spell_id)) { - Ref cc = _s_category_cooldown_map->get(spell_id); + if (_s_category_cooldown_map.has(spell_id)) { + Ref cc = _s_category_cooldown_map.get(spell_id); cc->set_remaining(value); @@ -1350,19 +1290,19 @@ void Entity::adds_category_cooldown(int spell_id, float value) { Ref cc; cc.instance(); - _s_category_cooldown_map->set(spell_id, cc); - _s_category_cooldowns->push_back(cc); + _s_category_cooldown_map.set(spell_id, cc); + _s_category_cooldowns.push_back(cc); emit_signal("scategory_cooldown_added", cc); } void Entity::removes_category_cooldown(int category_id) { - if (_s_category_cooldown_map->has(category_id)) { - _s_category_cooldown_map->erase(category_id); + if (_s_category_cooldown_map.has(category_id)) { + _s_category_cooldown_map.erase(category_id); } - for (int i = 0; i < _s_category_cooldowns->size(); ++i) { - if (_s_category_cooldowns->get(i)->get_category_id() == category_id) { - _s_category_cooldowns->remove(i); + for (int i = 0; i < _s_category_cooldowns.size(); ++i) { + if (_s_category_cooldowns.get(i)->get_category_id() == category_id) { + _s_category_cooldowns.remove(i); return; } } @@ -1370,27 +1310,27 @@ void Entity::removes_category_cooldown(int category_id) { emit_signal("scategory_cooldown_removed", category_id); } Ref Entity::gets_category_cooldown(int category_id) { - if (!_s_category_cooldown_map->has(category_id)) { + if (!_s_category_cooldown_map.has(category_id)) { return Ref(); } - return _s_category_cooldown_map->get(category_id); + return _s_category_cooldown_map.get(category_id); } Ref Entity::gets_category_cooldown_index(int index) { - ERR_FAIL_INDEX_V(index, _s_category_cooldowns->size(), Ref()); + ERR_FAIL_INDEX_V(index, _s_category_cooldowns.size(), Ref()); - return _s_category_cooldowns->get(index); + return _s_category_cooldowns.get(index); } int Entity::gets_category_cooldown_count() { - return _s_category_cooldowns->size(); + return _s_category_cooldowns.size(); } bool Entity::hasc_category_cooldown(int spell_id) { - return _c_category_cooldown_map->has(spell_id); + return _c_category_cooldown_map.has(spell_id); } void Entity::addc_category_cooldown(int spell_id, float value) { - if (_c_category_cooldown_map->has(spell_id)) { - Ref cc = _c_category_cooldown_map->get(spell_id); + if (_c_category_cooldown_map.has(spell_id)) { + Ref cc = _c_category_cooldown_map.get(spell_id); cc->set_remaining(value); @@ -1401,19 +1341,19 @@ void Entity::addc_category_cooldown(int spell_id, float value) { Ref cc; cc.instance(); - _c_category_cooldown_map->set(spell_id, cc); - _c_category_cooldowns->push_back(cc); + _c_category_cooldown_map.set(spell_id, cc); + _c_category_cooldowns.push_back(cc); emit_signal("ccategory_cooldown_added", cc); } void Entity::removec_category_cooldown(int category_id) { - if (_c_category_cooldown_map->has(category_id)) { - _c_category_cooldown_map->erase(category_id); + if (_c_category_cooldown_map.has(category_id)) { + _c_category_cooldown_map.erase(category_id); } - for (int i = 0; i < _c_category_cooldowns->size(); ++i) { - if (_c_category_cooldowns->get(i)->get_category_id() == category_id) { - _c_category_cooldowns->remove(i); + for (int i = 0; i < _c_category_cooldowns.size(); ++i) { + if (_c_category_cooldowns.get(i)->get_category_id() == category_id) { + _c_category_cooldowns.remove(i); return; } } @@ -1421,19 +1361,19 @@ void Entity::removec_category_cooldown(int category_id) { emit_signal("ccategory_cooldown_removed", category_id); } Ref Entity::getc_category_cooldown(int category_id) { - if (!_c_category_cooldown_map->has(category_id)) { + if (!_c_category_cooldown_map.has(category_id)) { return Ref(); } - return _c_category_cooldown_map->get(category_id); + return _c_category_cooldown_map.get(category_id); } Ref Entity::getc_category_cooldown_index(int index) { - ERR_FAIL_INDEX_V(index, _c_category_cooldowns->size(), Ref()); + ERR_FAIL_INDEX_V(index, _c_category_cooldowns.size(), Ref()); - return _c_category_cooldowns->get(index); + return _c_category_cooldowns.get(index); } int Entity::getc_category_cooldown_count() { - return _c_category_cooldowns->size(); + return _c_category_cooldowns.size(); } @@ -1457,14 +1397,14 @@ void Entity::son_death() { } void Entity::sremove_auras_with_group(int aura_group) { - for (int i = 0; i < _s_auras->size(); ++i) { - Ref ad = _s_auras->get(i); + for (int i = 0; i < _s_auras.size(); ++i) { + Ref ad = _s_auras.get(i); if (ad->get_aura()->get_aura_group() == aura_group) { cremove_aura(ad); - _s_auras->remove(i); + _s_auras.remove(i); emit_signal("saura_removed", ad); @@ -2357,8 +2297,8 @@ void Entity::registers() { } void Entity::update(float delta) { - for (int i = 0; i < _s_cooldowns->size(); ++i) { - Ref cd = _s_cooldowns->get(i); + for (int i = 0; i < _s_cooldowns.size(); ++i) { + Ref cd = _s_cooldowns.get(i); if (cd->update(delta)) { removes_cooldown(cd->get_spell_id()); @@ -2366,8 +2306,8 @@ void Entity::update(float delta) { } } - for (int i = 0; i < _s_category_cooldowns->size(); ++i) { - Ref cd = _s_category_cooldowns->get(i); + for (int i = 0; i < _s_category_cooldowns.size(); ++i) { + Ref cd = _s_category_cooldowns.get(i); if (cd->update(delta)) { removes_category_cooldown(cd->get_category_id()); diff --git a/entities/entity.h b/entities/entity.h index d63f902..a6dd136 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -70,9 +70,6 @@ enum PlayerSendFlags { SEND_FLAG_AURAS, }; -typedef HashMap > CooldownHashMap; -typedef HashMap > CategoryCooldownHashMap; - #ifdef ENTITIES_2D class Entity : public KinematicBody2D { GDCLASS(Entity, KinematicBody2D); @@ -582,24 +579,24 @@ private: //// AuraComponent //// - Vector > *_s_auras; - Vector > *_c_auras; + Vector > _s_auras; + Vector > _c_auras; EntityEnums::EntityType _s_entity_type; EntityEnums::EntityType _c_entity_type; //// Cooldowns //// - Vector > *_s_cooldowns; - Vector > *_c_cooldowns; + Vector > _s_cooldowns; + Vector > _c_cooldowns; - HashMap > *_s_cooldown_map; - HashMap > *_c_cooldown_map; + HashMap > _s_cooldown_map; + HashMap > _c_cooldown_map; - Vector > *_s_category_cooldowns; - Vector > *_c_category_cooldowns; + Vector > _s_category_cooldowns; + Vector > _c_category_cooldowns; - CategoryCooldownHashMap *_s_category_cooldown_map; - CategoryCooldownHashMap *_c_category_cooldown_map; + HashMap > _s_category_cooldown_map; + HashMap > _c_category_cooldown_map; //// targetComponent //// @@ -609,8 +606,8 @@ private: //// TalentComponent //// - Vector *_s_talents; - Vector *_c_talents; + Vector > _s_talents; + Vector > _c_talents; //// Inventory //// diff --git a/entities/player_talent.h b/entities/player_talent.h index 61164af..aed1e2d 100644 --- a/entities/player_talent.h +++ b/entities/player_talent.h @@ -1,10 +1,10 @@ #ifndef PLAYER_TALENT_H #define PLAYER_TALENT_H -#include "core/object.h" +#include "core/reference.h" -class PlayerTalent : public Object { - GDCLASS(PlayerTalent, Object); +class PlayerTalent : public Reference { + GDCLASS(PlayerTalent, Reference); public: int get_talent_id();