Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
Entity Class Referenceabstract

Base pure virtual Entity class. Different types of enities inherit this. More...

#include <Entity.hpp>

Inheritance diagram for Entity:
Inheritance graph
Collaboration diagram for Entity:
Collaboration graph

Public Member Functions

 Entity (GameWorld *pGameWorld, std::string name, int baseAccuracy, int baseDamage, SpawnCoordinateBounds spawnCoordinateBounds, unsigned int id=0, Coordinates location=Coordinates())
 
 ~Entity ()=default
 
unsigned int getId ()
 Get the type id of this entity. More...
 
unsigned int getInstanceId ()
 Get the unique id of this entity. More...
 
std::string getName ()
 Get the name of this entity. More...
 
CoordinatesgetLocation ()
 Get the current location of this entity. More...
 
void setLocation (Coordinates location)
 Set the location of this entity. More...
 
Coordinates getRespawnLocation ()
 Returns a random location within the spawn bounds. More...
 
std::shared_ptr< Action > & getCurrentAction ()
 Get the current action of this entity. More...
 
int getHp ()
 Get the current hp of this entity. More...
 
int getMaxHp ()
 Get the maximum hp of this entity. More...
 
InventorygetInventory ()
 Get the Inventory object of this entity. More...
 
EquipmentgetEquipment ()
 Get the Equipment object of this entity. More...
 
int getRange ()
 Get tha attack range of this entity. More...
 
int getAttackSpeed ()
 Get the attack speed of this entity in milliseconds. More...
 
std::chrono::milliseconds getMoveSpeed ()
 Get the movement speed of this entity. More...
 
GameWorldgetGameWorld ()
 Get pointer to the GameWorld that this entity resides in. More...
 
void changeHp (int amount)
 Change the hp of this entity by amount. More...
 
void setAction (std::shared_ptr< Action > action)
 Set the current action to parameter action. More...
 
bool move (Coordinates location)
 Move to a neighboring tile. More...
 
virtual void attack (Entity &target)
 Perform an attack on target entity. More...
 
void pickUpItem (int itemId, Coordinates itemLocation)
 Pick up an item. More...
 
void dropItem (int itemId)
 Drop an item. More...
 
SkillSetgetSkillSet ()
 Get the SkillSet of this entity. More...
 
virtual void update ()=0
 Pure virtual function that child classes need to implement. Updates the entity on server tick. More...
 
virtual void respawn ()=0
 Pure virtual function that child classes need to implement. Performs entity's respawning. More...
 
bool isDisconnected ()
 Returns whether entity is disconnected, only relevant for players. More...
 
void setDisconnected ()
 Sets entity as disconnected, only relevant for players. More...
 

Protected Attributes

unsigned int idM
 
unsigned int instanceIdM
 
std::string nameM
 
Coordinates locationM
 
SpawnCoordinateBounds spawnCoordinateBoundsM
 
std::shared_ptr< ActioncurrentActionM = nullptr
 
int maxHpM = 1000
 
int hpM = maxHpM
 
GameWorldpGameWorldM
 
Inventory inventoryM
 
Equipment equipmentM
 
SkillSet skillSetM
 
int baseDamageM
 
int baseAccuracyM
 
bool isDisconnectedM = false
 
std::chrono::milliseconds respawnTimeM {2000}
 
std::chrono::milliseconds moveSpeedM {1000}
 

Static Protected Attributes

static int nextInstanceIdM = 0
 

Detailed Description

Base pure virtual Entity class. Different types of enities inherit this.

Constructor & Destructor Documentation

◆ Entity()

Entity::Entity ( GameWorld pGameWorld,
std::string  name,
int  baseAccuracy,
int  baseDamage,
SpawnCoordinateBounds  spawnCoordinateBounds,
unsigned int  id = 0,
Coordinates  location = Coordinates() 
)

◆ ~Entity()

Entity::~Entity ( )
default

Member Function Documentation

◆ attack()

void Entity::attack ( Entity target)
virtual

Perform an attack on target entity.

Parameters
target

Reimplemented in PlayerCharacter.

Here is the call graph for this function:

◆ changeHp()

void Entity::changeHp ( int  amount)

Change the hp of this entity by amount.

Parameters
amount
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dropItem()

void Entity::dropItem ( int  itemId)

Drop an item.

Parameters
itemIdinstance id of item to be dropped
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAttackSpeed()

int Entity::getAttackSpeed ( )

Get the attack speed of this entity in milliseconds.

Returns
int
Here is the call graph for this function:

◆ getCurrentAction()

std::shared_ptr< Action > & Entity::getCurrentAction ( )

Get the current action of this entity.

Returns
std::shared_ptr<Action>&

◆ getEquipment()

Equipment & Entity::getEquipment ( )

Get the Equipment object of this entity.

Returns
Equipment&
Here is the caller graph for this function:

◆ getGameWorld()

GameWorld * Entity::getGameWorld ( )

Get pointer to the GameWorld that this entity resides in.

Returns
GameWorld*

◆ getHp()

int Entity::getHp ( )

Get the current hp of this entity.

Returns
int
Here is the caller graph for this function:

◆ getId()

unsigned int Entity::getId ( )

Get the type id of this entity.

Returns
unsigned int

◆ getInstanceId()

unsigned int Entity::getInstanceId ( )

Get the unique id of this entity.

Returns
unsigned int

◆ getInventory()

Inventory & Entity::getInventory ( )

Get the Inventory object of this entity.

Returns
Inventory&
Here is the caller graph for this function:

◆ getLocation()

Coordinates & Entity::getLocation ( )

Get the current location of this entity.

Returns
Coordinates&
Here is the caller graph for this function:

◆ getMaxHp()

int Entity::getMaxHp ( )

Get the maximum hp of this entity.

Returns
int

◆ getMoveSpeed()

std::chrono::milliseconds Entity::getMoveSpeed ( )

Get the movement speed of this entity.

Returns
std::chrono::milliseconds

◆ getName()

std::string Entity::getName ( )

Get the name of this entity.

Returns
std::string
Here is the caller graph for this function:

◆ getRange()

int Entity::getRange ( )

Get tha attack range of this entity.

Returns
int
Here is the call graph for this function:

◆ getRespawnLocation()

Coordinates Entity::getRespawnLocation ( )

Returns a random location within the spawn bounds.

Returns
Coordinates
Here is the call graph for this function:

◆ getSkillSet()

SkillSet & Entity::getSkillSet ( )

Get the SkillSet of this entity.

Returns
SkillSet&
Here is the caller graph for this function:

◆ isDisconnected()

bool Entity::isDisconnected ( )

Returns whether entity is disconnected, only relevant for players.

Returns
bool

◆ move()

bool Entity::move ( Coordinates  location)

Move to a neighboring tile.

Parameters
location
Returns
success
Here is the call graph for this function:

◆ pickUpItem()

void Entity::pickUpItem ( int  itemId,
Coordinates  itemLocation 
)

Pick up an item.

Parameters
itemIdinstance id of item to be picked up
Here is the call graph for this function:

◆ respawn()

virtual void Entity::respawn ( )
pure virtual

Pure virtual function that child classes need to implement. Performs entity's respawning.

Implemented in PlayerCharacter, and Npc.

Here is the caller graph for this function:

◆ setAction()

void Entity::setAction ( std::shared_ptr< Action action)

Set the current action to parameter action.

Parameters
action
Here is the caller graph for this function:

◆ setDisconnected()

void Entity::setDisconnected ( )

Sets entity as disconnected, only relevant for players.

◆ setLocation()

void Entity::setLocation ( Coordinates  location)

Set the location of this entity.

Parameters
location

◆ update()

virtual void Entity::update ( )
pure virtual

Pure virtual function that child classes need to implement. Updates the entity on server tick.

Implemented in PassiveNpc, AggressiveNpc, PlayerCharacter, and Npc.

Member Data Documentation

◆ baseAccuracyM

int Entity::baseAccuracyM
protected

◆ baseDamageM

int Entity::baseDamageM
protected

◆ currentActionM

std::shared_ptr<Action> Entity::currentActionM = nullptr
protected

◆ equipmentM

Equipment Entity::equipmentM
protected

◆ hpM

int Entity::hpM = maxHpM
protected

◆ idM

unsigned int Entity::idM
protected

◆ instanceIdM

unsigned int Entity::instanceIdM
protected

◆ inventoryM

Inventory Entity::inventoryM
protected

◆ isDisconnectedM

bool Entity::isDisconnectedM = false
protected

◆ locationM

Coordinates Entity::locationM
protected

◆ maxHpM

int Entity::maxHpM = 1000
protected

◆ moveSpeedM

std::chrono::milliseconds Entity::moveSpeedM {1000}
protected

◆ nameM

std::string Entity::nameM
protected

◆ nextInstanceIdM

int Entity::nextInstanceIdM = 0
inlinestaticprotected

◆ pGameWorldM

GameWorld* Entity::pGameWorldM
protected

◆ respawnTimeM

std::chrono::milliseconds Entity::respawnTimeM {2000}
protected

◆ skillSetM

SkillSet Entity::skillSetM
protected

◆ spawnCoordinateBoundsM

SpawnCoordinateBounds Entity::spawnCoordinateBoundsM
protected

The documentation for this class was generated from the following files: