32 #include <type_traits>
33 #include <glm/vec2.hpp>
35 #include "eng3d/freelist.hpp"
54 std::vector<std::pair<CommodityId, float>>
req_goods;
61 template<
bool is_const>
63 template<
bool is_serialize>
65 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.cached_id);
66 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.name);
67 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.ref_name);
68 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.supply_consumption);
69 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.speed);
70 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.max_health);
71 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.defense);
72 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.attack);
73 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.is_ground);
74 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.is_naval);
81 Unit& operator=(
const Unit&) =
default;
85 std::vector<ProvinceId> path;
86 float days_left_until_move = 0;
87 bool has_target =
false;
96 this->has_target =
false;
97 this->days_left_until_move = 0;
118 return this->has_target;
122 return this->target_province_id;
139 template<
bool is_const>
141 template<
bool is_serialize>
143 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.cached_id);
144 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.type_id);
145 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.
size);
146 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.base);
147 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.experience);
148 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.target_province_id);
149 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.has_target);
150 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.owner_id);
151 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.days_left_until_move);
152 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.path);
153 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.on_battle);
180 template<
bool is_const>
182 template<
bool is_serialize>
184 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.units);
185 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.unit_province);
186 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.province_units);
A single province, which is used to simulate economy in a "bulk-tiles" way instead of doing economica...
Roughly a batallion, consisting of approximately 500 soldiers each.
float days_to_move_to(const Province &province) const
void set_owner(const Nation &nation)
const std::vector< ProvinceId > get_path() const
void set_target(const Province &province)
bool can_move() const
Checks if the unit can move (if it can set_province)
ProvinceId get_target_province_id() const
float get_strength() const
ProvinceId province_id() const
bool has_target_province() const
float attack(Unit &enemy)
glm::vec2 get_pos() const
void set_path(const Province &target)
bool update_movement(UnitManager &unit_manager)
void add_unit(Unit unit, ProvinceId unit_current_province)
Eng3D::Freelist< Unit > units
std::vector< std::vector< UnitId > > province_units
std::vector< ProvinceId > unit_province
ProvinceId get_unit_current_province(UnitId unit_id) const
void init(World &world)
Fill in the relationship vectors for each nation.
void move_unit(UnitId unit, ProvinceId target_province)
void remove_unit(UnitId unit)
std::vector< UnitId > get_province_units(ProvinceId province_id) const
std::string string_format(const std::string_view format, Args &&... args)
String formatter.
A commodity, mostly serves as a "product type".
Base class that serves as archiver, stores (in memory) the data required for serialization/deserializ...
typename Eng3D::Deser::CondConstType< is_const, Unit >::type type
static void deser_dynamic(Eng3D::Deser::Archive &ar, type< is_serialize > &obj)
typename Eng3D::Deser::CondConstType< is_const, UnitManager >::type type
static void deser_dynamic(Eng3D::Deser::Archive &ar, type< is_serialize > &obj)
typename Eng3D::Deser::CondConstType< is_const, UnitType >::type type
static void deser_dynamic(Eng3D::Deser::Archive &ar, type< is_serialize > &obj)
A serializer (base class) which can be used to serialize objects and create per-object optimized clas...
A reference to a string on the global string pool.
const char * c_str() const
An entity which can only be referenced by an (presumably) unique Id this is the base class for the ot...
An entity which can be referenced via a ref_name and also via id.
Eng3D::StringRef ref_name
Defines a type of unit, it can be a tank, garrison, infantry, etc this is moddable via a lua script a...
std::string get_icon_path() const
std::vector< std::pair< CommodityId, float > > req_goods