2019-05-06 18:07:07 +02:00
|
|
|
#include "category_cooldown.h"
|
|
|
|
|
2019-08-05 01:36:33 +02:00
|
|
|
int CategoryCooldown::get_category_id() const
|
2019-05-06 18:07:07 +02:00
|
|
|
{
|
|
|
|
return _category_id;
|
|
|
|
}
|
|
|
|
|
2019-08-05 01:36:33 +02:00
|
|
|
void CategoryCooldown::set_category_id(const int value)
|
2019-05-06 18:07:07 +02:00
|
|
|
{
|
|
|
|
_category_id = value;
|
|
|
|
}
|
|
|
|
|
2019-08-05 01:36:33 +02:00
|
|
|
float CategoryCooldown::get_remaining() const
|
2019-05-06 18:07:07 +02:00
|
|
|
{
|
|
|
|
return _remaining;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-08-05 01:36:33 +02:00
|
|
|
void CategoryCooldown::set_remaining(const float value)
|
2019-05-06 18:07:07 +02:00
|
|
|
{
|
|
|
|
_remaining = value;
|
|
|
|
}
|
|
|
|
|
2019-08-05 01:36:33 +02:00
|
|
|
bool CategoryCooldown::update(const float delta) {
|
2019-05-27 18:28:27 +02:00
|
|
|
_remaining -= delta;
|
|
|
|
|
|
|
|
if (_remaining <= 0) {
|
|
|
|
_remaining = 0;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-05-06 18:07:07 +02:00
|
|
|
|
|
|
|
void CategoryCooldown::_bind_methods() {
|
|
|
|
ClassDB::bind_method(D_METHOD("get_category_id"), &CategoryCooldown::get_category_id);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_category_id", "value"), &CategoryCooldown::set_category_id);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "category_id"), "set_category_id", "get_category_id");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_remaining"), &CategoryCooldown::get_remaining);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_remaining", "value"), &CategoryCooldown::set_remaining);
|
2019-08-05 01:36:33 +02:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "remaining"), "set_remaining", "get_remaining");
|
2019-05-27 18:28:27 +02:00
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("update", "delta"), &CategoryCooldown::update);
|
2019-05-06 18:07:07 +02:00
|
|
|
}
|