mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
Bindings for XPData.
This commit is contained in:
parent
2c8becc27a
commit
544aa45a80
@ -2,32 +2,40 @@
|
||||
|
||||
int XPData::get_max_level()
|
||||
{
|
||||
return _xp_required->size();
|
||||
return _xp_required.size();
|
||||
}
|
||||
|
||||
int XPData::xp_required_for_level(int level) {
|
||||
level -= 1;
|
||||
if (level >= _xp_required->size()) {
|
||||
return -1;
|
||||
}
|
||||
return _xp_required->get(level);
|
||||
ERR_FAIL_COND_V(level < 0, 1);
|
||||
ERR_FAIL_COND_V(level > _xp_required.size(), 99999999);
|
||||
|
||||
return _xp_required.get(level);
|
||||
}
|
||||
|
||||
bool XPData::can_level_up(int level)
|
||||
{
|
||||
level -= 1;
|
||||
return level < _xp_required->size();
|
||||
bool XPData::can_level_up(int level) {
|
||||
return level <= _xp_required.size();
|
||||
}
|
||||
|
||||
XPData::XPData()
|
||||
{
|
||||
_xp_required = memnew(PoolIntArray());
|
||||
PoolIntArray XPData::get_xps() {
|
||||
return _xp_required;
|
||||
}
|
||||
void XPData::set_xps(const PoolIntArray &xps) {
|
||||
_xp_required = xps;
|
||||
}
|
||||
|
||||
XPData::XPData() {
|
||||
}
|
||||
|
||||
XPData::~XPData() {
|
||||
memdelete(_xp_required);
|
||||
}
|
||||
|
||||
void XPData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_max_level"), &XPData::get_max_level);
|
||||
ClassDB::bind_method(D_METHOD("xp_required_for_level", "level"), &XPData::xp_required_for_level);
|
||||
ClassDB::bind_method(D_METHOD("can_level_up", "level"), &XPData::can_level_up);
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_xps"), &XPData::get_xps);
|
||||
ClassDB::bind_method(D_METHOD("set_xps", "auras"), &XPData::set_xps);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "xps"), "set_xps", "get_xps");
|
||||
}
|
||||
|
@ -8,18 +8,23 @@
|
||||
class XPData : public Resource {
|
||||
GDCLASS(XPData, Resource);
|
||||
|
||||
private:
|
||||
PoolIntArray *_xp_required;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
int get_max_level();
|
||||
int xp_required_for_level(int level);
|
||||
bool can_level_up(int level);
|
||||
|
||||
PoolIntArray get_xps();
|
||||
void set_xps(const PoolIntArray &xps);
|
||||
|
||||
XPData();
|
||||
~XPData();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
|
||||
private:
|
||||
PoolIntArray _xp_required;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -3218,7 +3218,7 @@ void Entity::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("adds_xp", "value"), &Entity::adds_xp);
|
||||
ClassDB::bind_method(D_METHOD("addc_xp", "value"), &Entity::addc_xp);
|
||||
ClassDB::bind_method(D_METHOD("s_levelup", "value"), &Entity::s_levelup);
|
||||
ClassDB::bind_method(D_METHOD("c_levelup", "value"), &Entity::c_levelup);
|
||||
ClassDB::bind_method(D_METHOD("c_levelup", "value"), &Entity::c_levelup);
|
||||
|
||||
//Aura Manipulation
|
||||
ClassDB::bind_method(D_METHOD("sadd_aura", "aura"), &Entity::sadd_aura);
|
||||
|
Loading…
Reference in New Issue
Block a user