13 std::shared_ptr<FieldParams> fieldParams_;
15 std::uint32_t unitsCount_;
24 UnitsParams(
double moveRadius,
const std::shared_ptr<FieldParams> &fieldParams, uint32_t unitsCount);
63class Unit :
public std::enable_shared_from_this<Unit> {
72 void setID(
const size_t id) { id_ = id; }
84 explicit Unit(
size_t id,
const std::shared_ptr<UnitsParams> ¶ms);
89 [[nodiscard]]
auto getCoord()
const {
return coord_; }
94 [[nodiscard]]
auto getID()
const {
return id_; }
99 virtual void updateState(
const std::shared_ptr<Unit> &another) = 0;
Represents a generic unit in the simulation.
Definition Unit.hpp:63
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 ~Unit()=default
Virtual destructor for Unit.
auto getCoord() const
Retrieves the current coordinates of the unit.
Definition Unit.hpp:89
Unit & operator=(const Unit &other)=default
void setID(const size_t id)
Sets the ID of the unit.
Definition Unit.hpp:72
Unit & operator=(Unit &&other)=default
Unit(const Unit &other)=default
auto getID() const
Retrieves the ID of the unit.
Definition Unit.hpp:94
virtual void die()=0
Executes the death behavior of the unit.
void setCoord(const Point coord)
Sets the coordinates of the unit.
Definition Unit.hpp:77
Unit(Unit &&other)=default
Configuration parameters shared among multiple units.
Definition Unit.hpp:12
void operator=(const UnitsParams &)=delete
virtual ~UnitsParams()=default
Virtual destructor for UnitsParams.
virtual Point generatePos(std::optional< Point > initialPoint)
Generates a position for a unit, optionally starting from an initial point.
Definition Unit.cpp:8
void operator=(UnitsParams &&)=delete
auto getFieldParams() const
Retrieves the shared field parameters.
Definition Unit.hpp:34
auto getUnitsCount() const
Retrieves the total number of units.
Definition Unit.hpp:39
UnitsParams(UnitsParams &&)=delete
UnitsParams(const UnitsParams &)=delete
auto getMoveRadius() const
Retrieves the movement radius of the units.
Definition Unit.hpp:29
Represents a 2D point with x and y coordinates.
Definition utils.hpp:10