2019-04-20 14:02:55 +02:00
|
|
|
#include "player.h"
|
|
|
|
|
2019-09-16 21:57:55 +02:00
|
|
|
#include "../inventory/bag.h"
|
2019-08-16 02:24:32 +02:00
|
|
|
|
2019-10-06 00:25:12 +02:00
|
|
|
int Player::gets_seed() {
|
|
|
|
return _s_seed;
|
|
|
|
}
|
|
|
|
void Player::sets_seed(int value) {
|
|
|
|
_s_seed = value;
|
|
|
|
|
2019-10-28 14:45:38 +01:00
|
|
|
ORPC(setc_seed, value);
|
2019-10-06 00:25:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int Player::getc_seed() {
|
|
|
|
return _c_seed;
|
|
|
|
}
|
|
|
|
void Player::setc_seed(int value) {
|
|
|
|
_c_seed = value;
|
|
|
|
}
|
|
|
|
|
2019-10-14 19:49:40 +02:00
|
|
|
//Ref<InputProfile> Player::get_input_profile() {
|
|
|
|
// return _input_profile;
|
|
|
|
//}
|
|
|
|
|
2019-09-16 21:57:55 +02:00
|
|
|
void Player::_setup() {
|
|
|
|
Entity::_setup();
|
2019-08-16 02:24:32 +02:00
|
|
|
|
2019-10-15 18:34:19 +02:00
|
|
|
if (!gets_entity_data().is_valid())
|
|
|
|
return;
|
2019-10-14 19:49:40 +02:00
|
|
|
|
2019-10-15 18:34:19 +02:00
|
|
|
if (is_deserialized()) {
|
2019-10-14 19:49:40 +02:00
|
|
|
|
2019-10-15 18:34:19 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfileManager *pm = ProfileManager::get_instance();
|
|
|
|
|
|
|
|
if (pm != NULL) {
|
|
|
|
Ref<ClassProfile> cp = pm->get_class_profile(gets_entity_data()->get_id());
|
|
|
|
|
|
|
|
if (cp.is_valid()) {
|
|
|
|
set_actionbar_locked(cp->get_actionbar_locked());
|
2019-10-14 19:49:40 +02:00
|
|
|
|
2019-10-15 18:34:19 +02:00
|
|
|
get_action_bar_profile()->clear_action_bars();
|
2019-10-14 19:49:40 +02:00
|
|
|
|
2019-10-15 18:34:19 +02:00
|
|
|
Ref<ActionBarProfile> abp = cp->get_action_bar_profile();
|
2019-10-14 19:49:40 +02:00
|
|
|
|
2019-10-15 18:34:19 +02:00
|
|
|
get_action_bar_profile()->from_actionbar_profile(abp);
|
2019-10-14 19:49:40 +02:00
|
|
|
}
|
2019-10-15 18:34:19 +02:00
|
|
|
}
|
2019-10-14 19:49:40 +02:00
|
|
|
|
2019-10-15 18:34:19 +02:00
|
|
|
if (!gets_bag().is_valid()) {
|
2019-08-16 02:24:32 +02:00
|
|
|
|
2019-10-15 18:34:19 +02:00
|
|
|
Ref<Bag> bag;
|
|
|
|
bag.instance();
|
2019-08-16 02:24:32 +02:00
|
|
|
|
2019-10-15 18:34:19 +02:00
|
|
|
bag->set_size(gets_entity_data()->get_bag_size());
|
2019-10-14 19:49:40 +02:00
|
|
|
|
2019-10-15 18:34:19 +02:00
|
|
|
sets_bag(bag);
|
2019-09-16 21:57:55 +02:00
|
|
|
}
|
2019-08-16 02:24:32 +02:00
|
|
|
}
|
|
|
|
|
2019-10-06 00:25:12 +02:00
|
|
|
Dictionary Player::_to_dict() {
|
|
|
|
Dictionary dict = Entity::_to_dict();
|
|
|
|
|
|
|
|
dict["seed"] = _s_seed;
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Player::_from_dict(const Dictionary &dict) {
|
|
|
|
Entity::_from_dict(dict);
|
|
|
|
|
|
|
|
sets_seed(dict.get("seed", _s_seed));
|
|
|
|
}
|
|
|
|
|
2019-06-10 20:48:14 +02:00
|
|
|
Player::Player() {
|
2019-10-23 15:40:04 +02:00
|
|
|
_s_seed = 0;
|
2019-10-06 00:25:12 +02:00
|
|
|
_c_seed = _s_seed;
|
2019-10-14 19:49:40 +02:00
|
|
|
|
|
|
|
//_input_profile = Ref<InputProfile>(memnew(InputProfile()));
|
2019-10-28 21:48:50 +01:00
|
|
|
|
|
|
|
SET_RPC_REMOTE("setc_seed");
|
2019-10-14 19:49:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Player::~Player() {
|
|
|
|
//_input_profile.unref();
|
2019-04-20 14:02:55 +02:00
|
|
|
}
|
2019-08-16 02:24:32 +02:00
|
|
|
|
|
|
|
void Player::_bind_methods() {
|
2019-10-06 00:25:12 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("gets_seed"), &Player::gets_seed);
|
|
|
|
ClassDB::bind_method(D_METHOD("sets_seed", "value"), &Player::sets_seed);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "sseed"), "sets_seed", "gets_seed");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("getc_seed"), &Player::getc_seed);
|
|
|
|
ClassDB::bind_method(D_METHOD("setc_seed", "value"), &Player::setc_seed);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "cseed"), "setc_seed", "getc_seed");
|
2019-10-14 19:49:40 +02:00
|
|
|
|
|
|
|
//ClassDB::bind_method(D_METHOD("get_input_profile"), &Player::get_input_profile);
|
2019-08-16 02:24:32 +02:00
|
|
|
}
|