freg
0.3
Free-Roaming Elementary Game
|
This class contains information specific to player and interface for manipulating him. More...
#include <Player.h>
Signals | |
void | Moved (long x, long y, int z) const |
void | Notify (QString) const |
This is emitted when a notification is needed to be displayed. More... | |
void | OverstepBorder (int) |
This is emitted when player walks over shred border. More... | |
void | Updated () |
This is emitted when some player property is updated. More... | |
void | GetString (QString &) |
void | Destroyed () |
void | ShowFile (QString path) |
void | GetFocus (int *x, int *y, int *z) const |
Public Member Functions | |
Player () | |
Constructor creates or loads player. More... | |
~Player () | |
long | GlobalX () const |
long | GlobalY () const |
int | X () const |
int | Y () const |
dirs | GetDir () const |
This returns current player direction (see enum dirs in header.h) More... | |
int | HP () const |
This returns player hitpoints, also known as durability. More... | |
int | BreathPercent () const |
This returns player breath reserve. On error returns -100. More... | |
int | SatiationPercent () const |
Can be > 100 if player is gorged. On error returns -100. More... | |
const Block * | GetBlock () const |
bool | Visible (int x, int y, int z) const |
This returns true if block at (x, y, z) is visible to player. More... | |
int | UsingType () const |
This returns how player is using something now. More... | |
int | GetUsingInInventory () const |
void | SetUsingTypeNo () |
int | UsingSelfType () const |
This returns how player is using himself. More... | |
Inventory * | PlayerInventory () const |
Returns nullptr if there is no inventory, otherwise returns inventory. More... | |
long | GetLongitude () const |
long | GetLatitude () const |
bool | GetCreativeMode () const |
void | SetCreativeMode (bool turn) |
void | SetDir (dirs) |
void | Move (dirs) |
void | Jump () |
void | StopUseAll () |
Closes backpack, chests, etc. More... | |
void | Backpack () |
Tries to switch usingSelfType from NO to OPEN. More... | |
void | Inscribe () const |
void | Examine () |
void | Examine (int x, int y, int z) |
bool | Damage () const |
Returns true if xyz are in world bounds. More... | |
void | Use () |
void | Throw (int src, int dest=0, int num=1) |
Tries to throw (drop out) block number num from inventory. More... | |
usage_types | Use (int num) |
Tries to use block number num in inventory. More... | |
bool | Obtain (int src, int dest=0, int num=1) |
Tries to get block number num from outer inventory. More... | |
void | Inscribe (int num) |
void | Craft (int num) |
void | Build (int num) |
void | Wield (int num) |
void | MoveInsideInventory (int num_from, int num_to, int num=1) |
Can also wield appropriate things. More... | |
void | ProcessCommand (QString command) |
Static Public Member Functions | |
static constexpr quint64 | UniqueIntFromString (const char *const chars) |
Private Slots | |
void | CheckOverstep (int dir) |
Checks if player walked over the shred border. More... | |
void | BlockDestroy () |
This is called when player block is destroyed. More... | |
void | SetPlayer (int set_x, int set_y, int set_z) |
void | UpdateXYZ () |
Dir is not used, for slot signature compatibility only. More... | |
Private Member Functions | |
Player & | operator= (const Player &)=delete |
Player (const Player &)=delete | |
Animal * | NewPlayer () const |
Block * | ValidBlock (int num) const |
Checks player/inventory/block existence, size limits. More... | |
Shred * | GetShred () const |
World * | GetWorld () const |
bool | ForbiddenAdminCommands () const |
![]() | |
Xyz (short x, short y, short z) | |
Xyz () | |
short | Z () const |
void | SetXyz (short x, short y, short z) |
![]() | |
Xy (short x, short y) | |
Xy () | |
short | X () const |
short | Y () const |
Private Attributes | |
QSettings | settings |
long | homeLongi |
long | homeLati |
int | homeX |
int | homeY |
int | homeZ |
Animal * | player |
Animal * | creator |
int | usingType |
int | usingSelfType |
int | usingInInventory |
bool | creativeMode |
bool | cleaned = false |
![]() | |
short | z_self |
![]() | |
short | x_self |
short | y_self |
This class contains information specific to player and interface for manipulating him.
It receives input from screen, processes it, and dispatches actions to world.
It loads player from file and saves him to it.
Note: player block with its inventory is stored it shred file with all other blocks. player_save contains only coordinates where player is, his home coordinates and world player belongs to.
Also it does checks for player walking over the shred border.
Player::Player | ( | ) |
Constructor creates or loads player.
It puts player block to the world if there is no player block, and makes necessary connections.
Definition at line 497 of file Player.cpp.
Player::~Player | ( | ) |
Definition at line 531 of file Player.cpp.
|
privatedelete |
void Player::Backpack | ( | ) |
Tries to switch usingSelfType from NO to OPEN.
Definition at line 155 of file Player.cpp.
|
privateslot |
This is called when player block is destroyed.
Definition at line 439 of file Player.cpp.
int Player::BreathPercent | ( | ) | const |
This returns player breath reserve. On error returns -100.
Definition at line 72 of file Player.cpp.
void Player::Build | ( | int | num | ) |
Definition at line 298 of file Player.cpp.
|
privateslot |
Checks if player walked over the shred border.
This is connected to player's block signal Moved(int). It emits OverstepBorder(int) signal when player walks over the shred border.
Definition at line 427 of file Player.cpp.
void Player::Craft | ( | int | num | ) |
Definition at line 312 of file Player.cpp.
bool Player::Damage | ( | ) | const |
Returns true if xyz are in world bounds.
Definition at line 414 of file Player.cpp.
|
signal |
void Player::Examine | ( | ) |
Definition at line 95 of file Player.cpp.
void Player::Examine | ( | int | x, |
int | y, | ||
int | z | ||
) |
Definition at line 102 of file Player.cpp.
|
private |
Definition at line 320 of file Player.cpp.
const Block * Player::GetBlock | ( | ) | const |
Definition at line 58 of file Player.cpp.
bool Player::GetCreativeMode | ( | ) | const |
Definition at line 57 of file Player.cpp.
dirs Player::GetDir | ( | ) | const |
This returns current player direction (see enum dirs in header.h)
Definition at line 49 of file Player.cpp.
|
signal |
long Player::GetLatitude | ( | ) | const |
Definition at line 56 of file Player.cpp.
long Player::GetLongitude | ( | ) | const |
Definition at line 55 of file Player.cpp.
|
private |
Definition at line 46 of file Player.cpp.
|
signal |
int Player::GetUsingInInventory | ( | ) | const |
Definition at line 54 of file Player.cpp.
|
private |
Definition at line 47 of file Player.cpp.
long Player::GlobalX | ( | ) | const |
Definition at line 44 of file Player.cpp.
long Player::GlobalY | ( | ) | const |
Definition at line 45 of file Player.cpp.
int Player::HP | ( | ) | const |
This returns player hitpoints, also known as durability.
void Player::Inscribe | ( | ) | const |
Definition at line 180 of file Player.cpp.
void Player::Inscribe | ( | int | num | ) |
Definition at line 289 of file Player.cpp.
void Player::Jump | ( | ) |
Definition at line 133 of file Player.cpp.
void Player::Move | ( | dirs | direction | ) |
Definition at line 145 of file Player.cpp.
|
signal |
void Player::MoveInsideInventory | ( | int | num_from, |
int | num_to, | ||
int | num = 1 |
||
) |
Can also wield appropriate things.
Definition at line 281 of file Player.cpp.
|
private |
Definition at line 449 of file Player.cpp.
|
signal |
This is emitted when a notification is needed to be displayed.
It should be connected to screen::Notify(QString).
bool Player::Obtain | ( | int | src, |
int | dest = 0 , |
||
int | num = 1 |
||
) |
Tries to get block number num from outer inventory.
Definition at line 257 of file Player.cpp.
|
signal |
This is emitted when player walks over shred border.
It should be connected to World::ReloadShreds(int) signal.
Inventory * Player::PlayerInventory | ( | ) | const |
Returns nullptr if there is no inventory, otherwise returns inventory.
Definition at line 80 of file Player.cpp.
void Player::ProcessCommand | ( | QString | command | ) |
Definition at line 329 of file Player.cpp.
int Player::SatiationPercent | ( | ) | const |
Can be > 100 if player is gorged. On error returns -100.
Definition at line 74 of file Player.cpp.
void Player::SetCreativeMode | ( | bool | turn | ) |
Definition at line 60 of file Player.cpp.
void Player::SetDir | ( | dirs | direction | ) |
Definition at line 408 of file Player.cpp.
|
privateslot |
Definition at line 454 of file Player.cpp.
void Player::SetUsingTypeNo | ( | ) |
Definition at line 53 of file Player.cpp.
|
signal |
void Player::StopUseAll | ( | ) |
Closes backpack, chests, etc.
Definition at line 51 of file Player.cpp.
void Player::Throw | ( | int | src, |
int | dest = 0 , |
||
int | num = 1 |
||
) |
Tries to throw (drop out) block number num from inventory.
Definition at line 249 of file Player.cpp.
|
inlinestatic |
|
signal |
This is emitted when some player property is updated.
It shoul be connected to screen::UpdatePlayer() signal.
|
privateslot |
Dir is not used, for slot signature compatibility only.
Definition at line 90 of file Player.cpp.
void Player::Use | ( | ) |
Definition at line 163 of file Player.cpp.
usage_types Player::Use | ( | int | num | ) |
Tries to use block number num in inventory.
Definition at line 210 of file Player.cpp.
int Player::UsingSelfType | ( | ) | const |
This returns how player is using himself.
For example, OPEN means he is looking in his backpack. See enum usage_types in header.h.
Definition at line 52 of file Player.cpp.
int Player::UsingType | ( | ) | const |
This returns how player is using something now.
See enum usage_types in header.h.
Definition at line 50 of file Player.cpp.
|
private |
Checks player/inventory/block existence, size limits.
Definition at line 192 of file Player.cpp.
bool Player::Visible | ( | int | x, |
int | y, | ||
int | z | ||
) | const |
This returns true if block at (x, y, z) is visible to player.
Definition at line 402 of file Player.cpp.
void Player::Wield | ( | int | num | ) |
Definition at line 270 of file Player.cpp.
int Player::X | ( | ) | const |
Definition at line 36 of file Player.cpp.
int Player::Y | ( | ) | const |
Definition at line 40 of file Player.cpp.