Creepy-simulation
 
Loading...
Searching...
No Matches
Unit Class Referenceabstract

Represents a generic unit in the simulation. More...

#include <Unit.hpp>

Inheritance diagram for Unit:
Creeper Steve

Public Member Functions

 Unit (size_t id, const std::shared_ptr< UnitsParams > &params)
 Constructs a Unit object.
 
auto getCoord () const
 Retrieves the current coordinates of the unit.
 
auto getID () const
 Retrieves the ID of the unit.
 
virtual void updateState (const std::shared_ptr< Unit > &another)=0
 Updates the state of the unit based on interaction with another unit.
 
virtual void walk ()=0
 Executes the walking behavior of the unit.
 
virtual void die ()=0
 Executes the death behavior of the unit.
 
virtual ~Unit ()=default
 Virtual destructor for Unit.
 
 Unit (const Unit &other)=default
 
Unitoperator= (const Unit &other)=default
 
 Unit (Unit &&other)=default
 
Unitoperator= (Unit &&other)=default
 

Protected Member Functions

void setID (const size_t id)
 Sets the ID of the unit.
 
void setCoord (const Point coord)
 Sets the coordinates of the unit.
 

Detailed Description

Represents a generic unit in the simulation.

Constructor & Destructor Documentation

◆ Unit() [1/3]

Unit::Unit ( size_t  id,
const std::shared_ptr< UnitsParams > &  params 
)
explicit

Constructs a Unit object.

Parameters
idThe unique ID of the unit.

◆ ~Unit()

virtual Unit::~Unit ( )
virtualdefault

Virtual destructor for Unit.

◆ Unit() [2/3]

Unit::Unit ( const Unit other)
default

◆ Unit() [3/3]

Unit::Unit ( Unit &&  other)
default

Member Function Documentation

◆ die()

virtual void Unit::die ( )
pure virtual

Executes the death behavior of the unit.

Implemented in Creeper, and Steve.

◆ getCoord()

auto Unit::getCoord ( ) const
inline

Retrieves the current coordinates of the unit.

Returns
The current coordinates.

◆ getID()

auto Unit::getID ( ) const
inline

Retrieves the ID of the unit.

Returns
The unique ID of the unit.

◆ operator=() [1/2]

Unit & Unit::operator= ( const Unit other)
default

◆ operator=() [2/2]

Unit & Unit::operator= ( Unit &&  other)
default

◆ setCoord()

void Unit::setCoord ( const Point  coord)
inlineprotected

Sets the coordinates of the unit.

Parameters
coordThe new coordinates.

◆ setID()

void Unit::setID ( const size_t  id)
inlineprotected

Sets the ID of the unit.

Parameters
idThe unique ID.

◆ updateState()

virtual void Unit::updateState ( const std::shared_ptr< Unit > &  another)
pure virtual

Updates the state of the unit based on interaction with another unit.

Parameters
anotherShared pointer to another unit.

Implemented in Creeper, and Steve.

◆ walk()

virtual void Unit::walk ( )
pure virtual

Executes the walking behavior of the unit.

Implemented in Creeper, and Steve.


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