Lodestone.Level
Loading...
Searching...
No Matches
lodestone::level::entity::Entity Class Reference

#include <Entity.h>

Inheritance diagram for lodestone::level::entity::Entity:
Collaboration diagram for lodestone::level::entity::Entity:

Public Member Functions

 Entity ()=default
 ~Entity () override=default
int getHealth () const
void setHealth (int health)
bool isDead () const
virtual int getMaxHealth () const
const types::Vec3d & getMotion () const
virtual void setMotion (const types::Vec3d &motion)
 Sets the entity's motion.
void setMotion (double x, double y, double z)
void resetCoords ()
virtual const common::registry::Identifier * getType () const
std::string toString () const override
Public Member Functions inherited from lodestone::level::entity::WorldSpaceObject
 WorldSpaceObject ()
virtual ~WorldSpaceObject ()=default
types::Vec3f getFront () const
types::Vec3f getDirection () const
types::Vec3d getTarget () const
Public Member Functions inherited from lodestone::common::string::StringSerializable
constexpr StringSerializable ()=default
virtual constexpr ~StringSerializable ()=default

Static Public Attributes

static constexpr int MAX_HEALTH = 20

Protected Attributes

types::Vec3d m_motion {0, 0, 0}
 The motion that the entity has.
int m_health = MAX_HEALTH

Friends

class lodestone::level::world::World
class lodestone::level::chunk::Chunk

Additional Inherited Members

Public Attributes inherited from lodestone::level::entity::WorldSpaceObject
types::Vec3d position = types::VEC3_ZERO<double>
types::Vec2f rotation = types::VEC2_ZERO<float>

Constructor & Destructor Documentation

◆ Entity()

lodestone::level::entity::Entity::Entity ( )
default

◆ ~Entity()

lodestone::level::entity::Entity::~Entity ( )
overridedefault

Member Function Documentation

◆ getHealth()

int lodestone::level::entity::Entity::getHealth ( ) const
9{ return m_health; }
int m_health
Definition Entity.h:56

◆ getMaxHealth()

int lodestone::level::entity::Entity::getMaxHealth ( ) const
virtual
17 {
18 return MAX_HEALTH; // todo modifiers and such
19 }
static constexpr int MAX_HEALTH
Definition Entity.h:25

◆ getMotion()

const types::Vec3d & lodestone::level::entity::Entity::getMotion ( ) const
21{ return m_motion; }
types::Vec3d m_motion
The motion that the entity has.
Definition Entity.h:54

◆ getType()

const common::registry::Identifier * lodestone::level::entity::Entity::getType ( ) const
virtual

Reimplemented in lodestone::level::entity::Player.

37 {
38 return &ENTITY;
39 }
static constexpr lodestone::common::registry::Identifier ENTITY
Definition Entities.h:8

◆ isDead()

bool lodestone::level::entity::Entity::isDead ( ) const
15{ return m_health <= 0; }

◆ resetCoords()

void lodestone::level::entity::Entity::resetCoords ( )
31 {
35 }
virtual void setMotion(const types::Vec3d &motion)
Sets the entity's motion.
Definition Entity.cpp:23
types::Vec2f rotation
Definition WorldSpaceObject.h:21
types::Vec3d position
Definition WorldSpaceObject.h:20
constexpr Vec2< T > VEC2_ZERO
Definition Vec2.h:62
constexpr Vec3< T > VEC3_ZERO
Definition Vec3.h:170

◆ setHealth()

void lodestone::level::entity::Entity::setHealth ( int health)
11 {
12 this->m_health = std::min(health, getMaxHealth());
13 }
virtual int getMaxHealth() const
Definition Entity.cpp:17

◆ setMotion() [1/2]

void lodestone::level::entity::Entity::setMotion ( const types::Vec3d & motion)
virtual

Sets the entity's motion.

23 {
24 this->m_motion = motion;
25 }

◆ setMotion() [2/2]

void lodestone::level::entity::Entity::setMotion ( double x,
double y,
double z )
27 {
28 setMotion({x, y, z});
29 }

◆ toString()

std::string lodestone::level::entity::Entity::toString ( ) const
inlineoverridevirtual

Implements lodestone::common::string::StringSerializable.

Reimplemented in lodestone::level::entity::Player.

46 {
47 return std::format(
48 "Entity[type={}, health={}, pos={}]", getType()->getString(),
49 m_health, position.toString());
50 };
virtual const common::registry::Identifier * getType() const
Definition Entity.cpp:37

◆ lodestone::level::chunk::Chunk

friend class lodestone::level::chunk::Chunk
friend

◆ lodestone::level::world::World

friend class lodestone::level::world::World
friend

Member Data Documentation

◆ m_health

int lodestone::level::entity::Entity::m_health = MAX_HEALTH
protected

◆ m_motion

types::Vec3d lodestone::level::entity::Entity::m_motion {0, 0, 0}
protected

The motion that the entity has.

54{0, 0, 0};

◆ MAX_HEALTH

int lodestone::level::entity::Entity::MAX_HEALTH = 20
staticconstexpr

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