ArmedEntity
The ArmedEntity class is the base class of all armed entities in the game. Armed entities are those who can fire some missiles.
This class is derived from the AEntity interface and add some methods to manage the missiles.
Public member functions
// Construct a new Armed Entity object
ArmedEntity(Room &room, u_int id, short x, short y, short w, short h);
// Construct a new Armed Entity object
ArmedEntity(Room &room, u_int id, const std::pair<short, short> &pos, const std::pair<short, short> &size);
// Refresh the entity (move, shoot, etc.)
virtual void refresh() = 0;
Protected member functions
// Refresh the missiles of the entity (move, delete, etc.)
virtual void refreshMissiles();
// Check if any missile of the entity collide with another entity
virtual bool missilesCollide(const IEntity &other);
// Fire a new missile
virtual void fireMissile(Missile::Type type);
Protected attributes
// Last time the entity fired a missile
std::chrono::system_clock::time_point _lastFire;
Member functions documentation
Constructor
The constructor of the ArmedEntity class.
ArmedEntity(Room &room, u_int id, short x, short y, short w, short h);
ArmedEntity(Room &room, u_int id, const std::pair<short, short> &pos, const std::pair<short, short> &size);
Parameters
room
: A reference to the room in which the entity is.id
: The id of the entity.x
: The x position of the entity.y
: The y position of the entity.w
: The width of the entity.h
: The height of the entity.pos
: A pair of short containing the position of the entity (x, y).size
: A pair of short containing the size of the entity (w, h).
refresh
See IEntity::refresh.
refreshMissiles
This method refreshes all the missiles of the entity (move, delete, etc.). It is principally called by the refresh
method.
virtual void refreshMissiles();
missilesCollide
This method checks if any missile of the entity collide with another entity. It is principally called by the collide
method.
virtual bool missilesCollide(const IEntity &other);
Parameters
other
: A reference to the other entity to check collision with.
Returns
A boolean which is true if any missile of the entity collide with the other entity, false otherwise.
fireMissile
This method fires a new missile. It is principally called by the refresh
method.
virtual void fireMissile(Missile::Type type);
Parameters
type
: The type of the missile to fire.
Attributes documentation
_lastFire
The last time the entity fired a missile. This attribute is used to manage the fire rate of the entity, and is principally used by the refresh
method.
std::chrono::system_clock::time_point _lastFire;