28 using namespace ::
ant;
32 phene.lateral_ocelli_present =
false;
33 phene.median_ocellus_present =
false;
34 phene.lateral_ocelli_model =
nullptr;
35 phene.median_ocellus_model =
nullptr;
40 if (
auto element = phene_element.find(
"lateral_ocelli_present");
element != phene_element.end())
41 phene.lateral_ocelli_present =
element->get<
bool>();
44 if (
auto element = phene_element.find(
"median_ocellus_present");
element != phene_element.end())
45 phene.median_ocellus_present =
element->get<
bool>();
48 if (
auto element = phene_element.find(
"width");
element != phene_element.end())
49 phene.width =
element->get<
float>();
52 if (
auto element = phene_element.find(
"height");
element != phene_element.end())
53 phene.height =
element->get<
float>();
56 if (phene.lateral_ocelli_present)
58 if (
auto element = phene_element.find(
"lateral_ocelli_model");
element != phene_element.end())
63 if (phene.median_ocellus_present)
65 if (
auto element = phene_element.find(
"median_ocellus_model");
element != phene_element.end())
77 auto ocelli_element = data->find(
"ocelli");
78 if (ocelli_element == data->end())
79 throw std::runtime_error(
"Invalid ocelli 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.
polyphenic_gene< phene::ocelli > ocelli
Polyphenic ocelli gene.
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.