mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
Added seed to the player.
This commit is contained in:
parent
18cf024cc5
commit
529f8935d6
@ -582,8 +582,8 @@ public:
|
||||
Dictionary to_dict();
|
||||
void from_dict(const Dictionary &dict);
|
||||
|
||||
Dictionary _to_dict();
|
||||
void _from_dict(const Dictionary &dict);
|
||||
virtual Dictionary _to_dict();
|
||||
virtual void _from_dict(const Dictionary &dict);
|
||||
|
||||
Entity();
|
||||
~Entity();
|
||||
|
@ -2,6 +2,22 @@
|
||||
|
||||
#include "../inventory/bag.h"
|
||||
|
||||
int Player::gets_seed() {
|
||||
return _s_seed;
|
||||
}
|
||||
void Player::sets_seed(int value) {
|
||||
_s_seed = value;
|
||||
|
||||
SEND_RPC(rpc("setc_seed", value), setc_seed(value));
|
||||
}
|
||||
|
||||
int Player::getc_seed() {
|
||||
return _c_seed;
|
||||
}
|
||||
void Player::setc_seed(int value) {
|
||||
_c_seed = value;
|
||||
}
|
||||
|
||||
void Player::_setup() {
|
||||
Entity::_setup();
|
||||
|
||||
@ -15,8 +31,31 @@ void Player::_setup() {
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
Player::Player() {
|
||||
//_seed = 0; don't it will be random by default like this
|
||||
_c_seed = _s_seed;
|
||||
}
|
||||
|
||||
void Player::_bind_methods() {
|
||||
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");
|
||||
}
|
||||
|
@ -9,15 +9,25 @@ class Player : public Entity {
|
||||
GDCLASS(Player, Entity);
|
||||
|
||||
public:
|
||||
int gets_seed();
|
||||
void sets_seed(int value);
|
||||
|
||||
int getc_seed();
|
||||
void setc_seed(int value);
|
||||
|
||||
void _setup();
|
||||
|
||||
Dictionary _to_dict();
|
||||
void _from_dict(const Dictionary &dict);
|
||||
|
||||
Player();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
|
||||
int _s_seed;
|
||||
int _c_seed;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user