30 #include <glm/glm.hpp>
31 #include <glm/gtx/compatibility.hpp>
43 template<
bool is_const>
45 template<
bool is_serialize>
47 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.cached_id);
48 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.name);
49 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.ref_name);
56 constexpr
auto price_elasticity = 1.f;
58 return -price_elasticity;
65 return price_elasticity * glm::clamp(ratio, -1.f, 1.f);
88 if(glm::epsilonEqual(this->
price, 0.f, glm::epsilon<float>()))
97 float buy(
float amount) {
98 assert(amount >= 0.f && amount <= this->
supply);
99 this->supply -= amount;
101 assert(this->supply >= 0.f);
102 return this->
price * amount;
109 assert(amount >= 0.f);
111 return this->
price * amount;
125 template<
bool is_const>
127 template<
bool is_serialize>
129 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.cached_id);
130 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.price);
131 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.price_delta);
132 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.supply);
133 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.demand);
134 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.global_demand);
135 Eng3D::Deser::deser_dynamic<is_serialize>(ar, obj.speculative_demand);
std::string string_format(const std::string_view format, Args &&... args)
String formatter.
A commodity, mostly serves as a "product type".
std::string get_icon_path() const
Base class that serves as archiver, stores (in memory) the data required for serialization/deserializ...
static void deser_dynamic(Eng3D::Deser::Archive &ar, type< is_serialize > &obj)
typename Eng3D::Deser::CondConstType< is_const, Commodity >::type type
typename Eng3D::Deser::CondConstType< is_const, Product >::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...
A product (based off a Commodity) which can be bought by POPs, converted by factories and transported...
float buy(float amount)
Buy a portion of the item.
float get_price_delta() const
float produce(float amount)
Produce the product.
An entity which can be referenced via a ref_name and also via id.
Eng3D::StringRef ref_name