Symphony Of Empires
Unit Class Reference

Roughly a batallion, consisting of approximately 500 soldiers each. More...

#include <unit.hpp>

Inheritance diagram for Unit:
Collaboration diagram for Unit:

Public Member Functions

float attack (Unit &enemy)
 
glm::vec2 get_pos () const
 
void set_target (const Province &province)
 
void stop_movement ()
 
float days_to_move_to (const Province &province) const
 
bool update_movement (UnitManager &unit_manager)
 
void set_owner (const Nation &nation)
 
bool can_move () const
 Checks if the unit can move (if it can set_province) More...
 
const std::vector< ProvinceIdget_path () const
 
void set_path (const Province &target)
 
bool has_target_province () const
 
ProvinceId get_target_province_id () const
 
float get_strength () const
 
ProvinceId province_id () const
 
- Public Member Functions inherited from Entity< UnitId >
constexpr Entity () noexcept=default
 
constexpr Entity (Entity &&) noexcept=default
 
constexpr Entity (const Entity &) noexcept=default
 
constexpr Entityoperator= (const Entity &) noexcept=default
 
constexpr ~Entity () noexcept=default
 
constexpr bool is_invalid () const
 Checks if the current id is invalid. More...
 
constexpr bool is_valid () const
 Checks if the current id is valid. More...
 
constexpr operator Id () const noexcept
 
constexpr operator size_t () const noexcept
 
constexpr Id get_id () const
 

Public Attributes

UnitTypeId type_id
 
NationId owner_id
 
PopId pop_id
 
float size = 0.f
 
float base = 0.f
 
float experience = 1.f
 
bool on_battle = false
 
- Public Attributes inherited from Entity< UnitId >
Id cached_id
 Id used to speed up Id lookups on any context. More...
 

Friends

class Client
 
class UnitManager
 
struct Eng3D::Deser::Serializer< Unit >
 

Additional Inherited Members

- Public Types inherited from Entity< UnitId >
using Id = UnitId
 
- Static Public Member Functions inherited from Entity< UnitId >
constexpr static Id invalid ()
 Returns an invalid id. More...
 
constexpr static bool is_invalid (Id id)
 Checks if the id is not valid. More...
 
constexpr static bool is_valid (Id id)
 Checks if the id is valid. More...
 

Detailed Description

Roughly a batallion, consisting of approximately 500 soldiers each.

Definition at line 80 of file unit.hpp.

Member Function Documentation

◆ attack()

float Unit::attack ( Unit enemy)
Todo:
Better attack algorithm

Definition at line 57 of file unit.cpp.

◆ can_move()

bool Unit::can_move ( ) const
inline

Checks if the unit can move (if it can set_province)

Returns
true
false

Definition at line 107 of file unit.hpp.

Here is the caller graph for this function:

◆ days_to_move_to()

float Unit::days_to_move_to ( const Province province) const

Definition at line 89 of file unit.cpp.

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

◆ get_path()

const std::vector<ProvinceId> Unit::get_path ( ) const
inline

Definition at line 111 of file unit.hpp.

Here is the caller graph for this function:

◆ get_pos()

glm::vec2 Unit::get_pos ( ) const

Definition at line 77 of file unit.cpp.

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

◆ get_strength()

float Unit::get_strength ( ) const

Definition at line 222 of file unit.cpp.

◆ get_target_province_id()

ProvinceId Unit::get_target_province_id ( ) const
inline

Definition at line 121 of file unit.hpp.

◆ has_target_province()

bool Unit::has_target_province ( ) const
inline

Definition at line 117 of file unit.hpp.

Here is the caller graph for this function:

◆ province_id()

ProvinceId Unit::province_id ( ) const

Definition at line 83 of file unit.cpp.

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

◆ set_owner()

void Unit::set_owner ( const Nation nation)

Definition at line 184 of file unit.cpp.

Here is the caller graph for this function:

◆ set_path()

void Unit::set_path ( const Province target)

Calculates the neighbors for a given province

Euclidean distance calculation

Definition at line 188 of file unit.cpp.

Here is the call graph for this function:

◆ set_target()

void Unit::set_target ( const Province province)

Definition at line 67 of file unit.cpp.

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

◆ stop_movement()

void Unit::stop_movement ( )
inline

Definition at line 95 of file unit.hpp.

Here is the caller graph for this function:

◆ update_movement()

bool Unit::update_movement ( UnitManager unit_manager)

Definition at line 99 of file unit.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ Client

friend class Client
friend

Definition at line 82 of file unit.hpp.

◆ Eng3D::Deser::Serializer< Unit >

friend struct Eng3D::Deser::Serializer< Unit >
friend

Definition at line 83 of file unit.hpp.

◆ UnitManager

friend class UnitManager
friend

Definition at line 83 of file unit.hpp.

Member Data Documentation

◆ base

float Unit::base = 0.f

Definition at line 133 of file unit.hpp.

◆ experience

float Unit::experience = 1.f

Definition at line 134 of file unit.hpp.

◆ on_battle

bool Unit::on_battle = false

Definition at line 135 of file unit.hpp.

◆ owner_id

NationId Unit::owner_id

Definition at line 128 of file unit.hpp.

◆ pop_id

PopId Unit::pop_id

Definition at line 129 of file unit.hpp.

◆ size

float Unit::size = 0.f

Definition at line 132 of file unit.hpp.

◆ type_id

UnitTypeId Unit::type_id

Definition at line 127 of file unit.hpp.


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