28 using namespace ::
ant;
32 phene.model =
nullptr;
33 phene.petiole_present =
false;
34 phene.petiole_length = 0.0f;
35 phene.petiole_width = 0.0f;
36 phene.petiole_height = 0.0f;
37 phene.petiole_spinescence = 0.0f;
38 phene.postpetiole_present =
false;
39 phene.postpetiole_length = 0.0f;
40 phene.postpetiole_width = 0.0f;
41 phene.postpetiole_height = 0.0f;
42 phene.postpetiole_spinescence = 0.0f;
45 if (
auto element = phene_element.find(
"model");
element != phene_element.end())
49 if (
auto element = phene_element.find(
"petiole_present");
element != phene_element.end())
50 phene.petiole_present =
element->get<
bool>();
53 if (
auto element = phene_element.find(
"postpetiole_present");
element != phene_element.end())
54 phene.postpetiole_present =
element->get<
bool>();
56 if (phene.petiole_present)
59 if (
auto element = phene_element.find(
"petiole_length");
element != phene_element.end())
60 phene.petiole_length =
element->get<
float>();
63 if (
auto element = phene_element.find(
"petiole_width");
element != phene_element.end())
64 phene.petiole_width =
element->get<
float>();
67 if (
auto element = phene_element.find(
"petiole_height");
element != phene_element.end())
68 phene.petiole_height =
element->get<
float>();
71 if (
auto element = phene_element.find(
"petiole_spinescence");
element != phene_element.end())
72 phene.petiole_spinescence =
element->get<
float>();
75 if (phene.postpetiole_present)
78 if (
auto element = phene_element.find(
"postpetiole_length");
element != phene_element.end())
79 phene.postpetiole_length =
element->get<
float>();
82 if (
auto element = phene_element.find(
"postpetiole_width");
element != phene_element.end())
83 phene.postpetiole_width =
element->get<
float>();
86 if (
auto element = phene_element.find(
"postpetiole_height");
element != phene_element.end())
87 phene.postpetiole_height =
element->get<
float>();
90 if (
auto element = phene_element.find(
"postpetiole_spinescence");
element != phene_element.end())
91 phene.postpetiole_spinescence =
element->get<
float>();
102 auto waist_element = data->find(
"waist");
103 if (waist_element == data->end())
104 throw std::runtime_error(
"Invalid waist gene.");
static T * load(resource_manager *resourceManager, PHYSFS_File *file, const std::filesystem::path &path)
Loads resource data.
T * load(const std::filesystem::path &path)
Loads the requested resource.
nlohmann::json json
JSON data.
void deserialize_gene(monophenic_gene< T > &gene, void(*deserialize_phene)(T &, const json &, resource_manager *), const json &gene_element, resource_manager *resource_manager)
Deserializes a gene.
polyphenic_gene< phene::waist > waist
Polyphenic waist gene.