mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
Now cooldowns are updated.
This commit is contained in:
parent
e9c30b870d
commit
5692eec91e
@ -2357,6 +2357,24 @@ void Entity::registers() {
|
||||
}
|
||||
|
||||
void Entity::update(float delta) {
|
||||
for (int i = 0; i < _s_cooldowns->size(); ++i) {
|
||||
Ref<Cooldown> cd = _s_cooldowns->get(i);
|
||||
|
||||
if (cd->update(delta)) {
|
||||
removes_cooldown(cd->get_spell_id());
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _s_category_cooldowns->size(); ++i) {
|
||||
Ref<CategoryCooldown> cd = _s_category_cooldowns->get(i);
|
||||
|
||||
if (cd->update(delta)) {
|
||||
removes_category_cooldown(cd->get_category_id());
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
update_auras(delta);
|
||||
|
||||
if (_s_spell_cast_info.is_valid() && _s_spell_cast_info->get_is_casting()) {
|
||||
|
@ -21,6 +21,18 @@ void CategoryCooldown::set_remaining(int value)
|
||||
_remaining = value;
|
||||
}
|
||||
|
||||
bool CategoryCooldown::update(float delta) {
|
||||
_remaining -= delta;
|
||||
|
||||
if (_remaining <= 0) {
|
||||
_remaining = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CategoryCooldown::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_category_id"), &CategoryCooldown::get_category_id);
|
||||
@ -30,4 +42,6 @@ void CategoryCooldown::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_remaining"), &CategoryCooldown::get_remaining);
|
||||
ClassDB::bind_method(D_METHOD("set_remaining", "value"), &CategoryCooldown::set_remaining);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "remaining"), "set_remaining", "get_remaining");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("update", "delta"), &CategoryCooldown::update);
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ public:
|
||||
|
||||
int get_remaining();
|
||||
void set_remaining(int value);
|
||||
|
||||
bool update(float delta);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -21,6 +21,18 @@ void Cooldown::set_remaining(int value)
|
||||
_remaining = value;
|
||||
}
|
||||
|
||||
bool Cooldown::update(float delta) {
|
||||
_remaining -= delta;
|
||||
|
||||
if (_remaining <= 0) {
|
||||
_remaining = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Cooldown::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_spell_id"), &Cooldown::get_spell_id);
|
||||
@ -30,4 +42,6 @@ void Cooldown::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_remaining"), &Cooldown::get_remaining);
|
||||
ClassDB::bind_method(D_METHOD("set_remaining", "value"), &Cooldown::set_remaining);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "remaining"), "set_remaining", "get_remaining");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("update", "delta"), &Cooldown::update);
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ public:
|
||||
|
||||
int get_remaining();
|
||||
void set_remaining(int value);
|
||||
|
||||
bool update(float delta);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
Loading…
Reference in New Issue
Block a user