Browse Source

Split traits into genes and phenes. Add genome and phenome structs. Add cladogenesis function.

master
C. J. Howard 2 years ago
parent
commit
b38971c9a8
91 changed files with 2689 additions and 1166 deletions
  1. +1
    -0
      CMakeLists.txt
  2. +12
    -60
      src/game/ant/caste.hpp
  3. +58
    -0
      src/game/ant/cladogenesis.cpp
  4. +43
    -0
      src/game/ant/cladogenesis.hpp
  5. +62
    -0
      src/game/ant/gene-frequency-table.hpp
  6. +85
    -0
      src/game/ant/gene-pool.hpp
  7. +37
    -0
      src/game/ant/gene/antennae.hpp
  8. +37
    -0
      src/game/ant/gene/body-size.hpp
  9. +10
    -13
      src/game/ant/gene/cocoon.hpp
  10. +37
    -0
      src/game/ant/gene/diet.hpp
  11. +37
    -0
      src/game/ant/gene/egg.hpp
  12. +37
    -0
      src/game/ant/gene/eyes.hpp
  13. +37
    -0
      src/game/ant/gene/foraging-time.hpp
  14. +37
    -0
      src/game/ant/gene/founding-mode.hpp
  15. +37
    -0
      src/game/ant/gene/gaster.hpp
  16. +37
    -0
      src/game/ant/gene/head.hpp
  17. +37
    -0
      src/game/ant/gene/larva.hpp
  18. +37
    -0
      src/game/ant/gene/legs.hpp
  19. +28
    -22
      src/game/ant/gene/loader/antennae-loader.cpp
  20. +69
    -0
      src/game/ant/gene/loader/body-size-loader.cpp
  21. +26
    -20
      src/game/ant/gene/loader/cocoon-loader.cpp
  22. +18
    -12
      src/game/ant/gene/loader/egg-loader.cpp
  23. +88
    -0
      src/game/ant/gene/loader/eyes-loader.cpp
  24. +24
    -12
      src/game/ant/gene/loader/foraging-time-loader.cpp
  25. +23
    -17
      src/game/ant/gene/loader/gaster-loader.cpp
  26. +87
    -0
      src/game/ant/gene/loader/gene-loader.hpp
  27. +33
    -27
      src/game/ant/gene/loader/head-loader.cpp
  28. +23
    -17
      src/game/ant/gene/loader/larva-loader.cpp
  29. +28
    -22
      src/game/ant/gene/loader/legs-loader.cpp
  30. +75
    -0
      src/game/ant/gene/loader/mandibles-loader.cpp
  31. +80
    -0
      src/game/ant/gene/loader/mesosoma-loader.cpp
  32. +91
    -0
      src/game/ant/gene/loader/ocelli-loader.cpp
  33. +19
    -12
      src/game/ant/gene/loader/pigmentation-loader.cpp
  34. +18
    -10
      src/game/ant/gene/loader/pilosity-loader.cpp
  35. +23
    -16
      src/game/ant/gene/loader/sculpturing-loader.cpp
  36. +26
    -20
      src/game/ant/gene/loader/sting-loader.cpp
  37. +116
    -0
      src/game/ant/gene/loader/waist-loader.cpp
  38. +103
    -0
      src/game/ant/gene/loader/wings-loader.cpp
  39. +37
    -0
      src/game/ant/gene/mandibles.hpp
  40. +37
    -0
      src/game/ant/gene/mesosoma.hpp
  41. +15
    -16
      src/game/ant/gene/monophenic-gene.hpp
  42. +37
    -0
      src/game/ant/gene/nest-site.hpp
  43. +37
    -0
      src/game/ant/gene/ocelli.hpp
  44. +37
    -0
      src/game/ant/gene/pigmentation.hpp
  45. +37
    -0
      src/game/ant/gene/pilosity.hpp
  46. +52
    -0
      src/game/ant/gene/polyphenic-gene.hpp
  47. +37
    -0
      src/game/ant/gene/sculpturing.hpp
  48. +37
    -0
      src/game/ant/gene/sting.hpp
  49. +37
    -0
      src/game/ant/gene/waist.hpp
  50. +37
    -0
      src/game/ant/gene/wings.hpp
  51. +51
    -0
      src/game/ant/genome.cpp
  52. +84
    -0
      src/game/ant/genome.hpp
  53. +26
    -26
      src/game/ant/morphogenesis.cpp
  54. +5
    -5
      src/game/ant/morphogenesis.hpp
  55. +6
    -6
      src/game/ant/phene/antennae.hpp
  56. +50
    -0
      src/game/ant/phene/body-size.hpp
  57. +6
    -6
      src/game/ant/phene/cocoon.hpp
  58. +6
    -6
      src/game/ant/phene/diet.hpp
  59. +6
    -6
      src/game/ant/phene/egg.hpp
  60. +6
    -6
      src/game/ant/phene/eyes.hpp
  61. +8
    -8
      src/game/ant/phene/foraging-time.hpp
  62. +6
    -6
      src/game/ant/phene/founding-mode.hpp
  63. +6
    -6
      src/game/ant/phene/gaster.hpp
  64. +6
    -6
      src/game/ant/phene/head.hpp
  65. +7
    -7
      src/game/ant/phene/larva.hpp
  66. +6
    -6
      src/game/ant/phene/legs.hpp
  67. +6
    -6
      src/game/ant/phene/mandibles.hpp
  68. +6
    -6
      src/game/ant/phene/mesosoma.hpp
  69. +3
    -3
      src/game/ant/phene/nest-site.hpp
  70. +6
    -6
      src/game/ant/phene/ocelli.hpp
  71. +6
    -6
      src/game/ant/phene/pigmentation.hpp
  72. +6
    -6
      src/game/ant/phene/pilosity.hpp
  73. +6
    -6
      src/game/ant/phene/sculpturing.hpp
  74. +5
    -5
      src/game/ant/phene/sting.hpp
  75. +5
    -5
      src/game/ant/phene/waist.hpp
  76. +6
    -6
      src/game/ant/phene/wings.hpp
  77. +115
    -0
      src/game/ant/phenome.cpp
  78. +94
    -0
      src/game/ant/phenome.hpp
  79. +0
    -78
      src/game/ant/species.hpp
  80. +4
    -4
      src/game/ant/subcaste.hpp
  81. +0
    -51
      src/game/ant/trait/loader/body-size-loader.cpp
  82. +0
    -82
      src/game/ant/trait/loader/eyes-loader.cpp
  83. +0
    -69
      src/game/ant/trait/loader/mandibles-loader.cpp
  84. +0
    -74
      src/game/ant/trait/loader/mesosoma-loader.cpp
  85. +0
    -89
      src/game/ant/trait/loader/ocelli-loader.cpp
  86. +0
    -98
      src/game/ant/trait/loader/waist-loader.cpp
  87. +0
    -99
      src/game/ant/trait/loader/wings-loader.cpp
  88. +0
    -46
      src/game/ant/trait/size-variation.hpp
  89. +0
    -1
      src/game/load.cpp
  90. +23
    -23
      src/game/state/nest-selection.cpp
  91. +0
    -1
      src/math/math.hpp

+ 1
- 0
CMakeLists.txt View File

@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.7)
option(VERSION_STRING "Project version string" "0.0.0")
project(antkeeper VERSION ${VERSION_STRING} LANGUAGES CXX)

+ 12
- 60
src/game/ant/caste.hpp View File

@ -20,75 +20,27 @@
#ifndef ANTKEEPER_GAME_ANT_CASTE_HPP
#define ANTKEEPER_GAME_ANT_CASTE_HPP
#include "game/ant/caste-type.hpp"
#include "game/ant/trait/antennae.hpp"
#include "game/ant/trait/eyes.hpp"
#include "game/ant/trait/gaster.hpp"
#include "game/ant/trait/head.hpp"
#include "game/ant/trait/legs.hpp"
#include "game/ant/trait/mandibles.hpp"
#include "game/ant/trait/mesosoma.hpp"
#include "game/ant/trait/ocelli.hpp"
#include "game/ant/trait/pigmentation.hpp"
#include "game/ant/trait/sculpturing.hpp"
#include "game/ant/trait/size-variation.hpp"
#include "game/ant/trait/sting.hpp"
#include "game/ant/trait/waist.hpp"
#include "game/ant/trait/wings.hpp"
#include <optional>
namespace game {
namespace ant {
/**
* Ant caste description.
* Ant caste enumerations.
*
* @see https://www.antwiki.org/wiki/Caste_Terminology
*/
struct caste
enum class caste
{
/// Caste type.
caste_type type;
/// Antennae description.
const trait::antennae* antennae;
/// Eyes description.
const trait::eyes* eyes;
/// Gaster description.
const trait::gaster* gaster;
/// Head description.
const trait::head* head;
/// Legs description.
const trait::legs* legs;
/// Mandibles description.
const trait::mandibles* mandibles;
/// Mesosoma description.
const trait::mesosoma* mesosoma;
/// Ocelli description.
const trait::ocelli* ocelli;
/// Pigmentation description.
const trait::pigmentation* pigmentation;
/// Sculpturing description.
const trait::sculpturing* sculpturing;
/// Size variation description.
const trait::size_variation* size_variation;
/// Queen caste type.
queen,
/// Sting description.
const trait::sting* sting;
/// Worker caste type.
worker,
/// Waist description.
const trait::waist* waist;
/// Soldier caste type.
soldier,
/// Wings description.
const trait::wings* wings;
/// Male caste type.
male
};
} // namespace ant

+ 58
- 0
src/game/ant/cladogenesis.cpp View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/cladogenesis.hpp"
namespace game {
namespace ant {
genome* cladogenesis(gene_pool& pool, std::random_device& rng)
{
// Allocate genome
ant::genome* genome = new ant::genome();
// Randomly sample genes
genome->antennae = pool.antennae.sample(rng);
genome->body_size = pool.body_size.sample(rng);
genome->cocoon = pool.cocoon.sample(rng);
genome->diet = pool.diet.sample(rng);
genome->egg = pool.egg.sample(rng);
genome->eyes = pool.eyes.sample(rng);
genome->foraging_time = pool.foraging_time.sample(rng);
genome->founding_mode = pool.founding_mode.sample(rng);
genome->gaster = pool.gaster.sample(rng);
genome->head = pool.head.sample(rng);
genome->larva = pool.larva.sample(rng);
genome->legs = pool.legs.sample(rng);
genome->mandibles = pool.mandibles.sample(rng);
genome->mesosoma = pool.mesosoma.sample(rng);
genome->nest_site = pool.nest_site.sample(rng);
genome->ocelli = pool.ocelli.sample(rng);
genome->pigmentation = pool.pigmentation.sample(rng);
genome->pilosity = pool.pilosity.sample(rng);
genome->sculpturing = pool.sculpturing.sample(rng);
genome->sting = pool.sting.sample(rng);
genome->waist = pool.waist.sample(rng);
genome->wings = pool.wings.sample(rng);
return genome;
}
} // namespace ant
} // namespace game

+ 43
- 0
src/game/ant/cladogenesis.hpp View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_CLADOGENESIS_HPP
#define ANTKEEPER_GAME_ANT_CLADOGENESIS_HPP
#include "game/ant/genome.hpp"
#include "game/ant/gene-pool.hpp"
#include <random>
namespace game {
namespace ant {
/**
* Generates a genome from a gene pool.
*
* @param pool Gene pool.
* @param rng Random number generator.
*
* @return New genome.
*/
genome* cladogenesis(gene_pool& pool, std::random_device& rng);
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_CLADOGENESIS_HPP

+ 62
- 0
src/game/ant/gene-frequency-table.hpp View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_FREQUENCY_TABLE_HPP
#define ANTKEEPER_GAME_ANT_GENE_FREQUENCY_TABLE_HPP
#include <random>
#include <vector>
namespace game {
namespace ant {
/**
* Gene frequency table.
*
* @tparam T Gene type.
*/
template <class T>
struct gene_frequency_table
{
/// Gene array.
std::vector<const T*> genes;
/// Gene discrete probability distribution.
std::discrete_distribution<std::size_t> distribution;
/**
* Samples a gene from the frequency table.
*
* @tparam Generator Uniform random bit generator type.
*
* @param g Uniform random bit generator object.
*
* @return Randomly sampled gene.
*/
template <class Generator>
const T* sample(Generator& g)
{
return genes[distribution(g)];
}
};
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_FREQUENCY_TABLE_HPP

+ 85
- 0
src/game/ant/gene-pool.hpp View File

@ -0,0 +1,85 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_POOL_HPP
#define ANTKEEPER_GAME_ANT_GENE_POOL_HPP
#include "game/ant/gene-frequency-table.hpp"
#include "game/ant/gene/antennae.hpp"
#include "game/ant/gene/body-size.hpp"
#include "game/ant/gene/cocoon.hpp"
#include "game/ant/gene/diet.hpp"
#include "game/ant/gene/egg.hpp"
#include "game/ant/gene/eyes.hpp"
#include "game/ant/gene/foraging-time.hpp"
#include "game/ant/gene/founding-mode.hpp"
#include "game/ant/gene/gaster.hpp"
#include "game/ant/gene/head.hpp"
#include "game/ant/gene/larva.hpp"
#include "game/ant/gene/legs.hpp"
#include "game/ant/gene/mandibles.hpp"
#include "game/ant/gene/mesosoma.hpp"
#include "game/ant/gene/nest-site.hpp"
#include "game/ant/gene/ocelli.hpp"
#include "game/ant/gene/pigmentation.hpp"
#include "game/ant/gene/pilosity.hpp"
#include "game/ant/gene/sculpturing.hpp"
#include "game/ant/gene/sting.hpp"
#include "game/ant/gene/waist.hpp"
#include "game/ant/gene/wings.hpp"
namespace game {
namespace ant {
/**
* Pool of genes from which ant genomes can be generated.
*/
struct gene_pool
{
/// Gene pool name.
std::string name;
gene_frequency_table<gene::antennae> antennae;
gene_frequency_table<gene::body_size> body_size;
gene_frequency_table<gene::cocoon> cocoon;
gene_frequency_table<gene::diet> diet;
gene_frequency_table<gene::egg> egg;
gene_frequency_table<gene::eyes> eyes;
gene_frequency_table<gene::foraging_time> foraging_time;
gene_frequency_table<gene::founding_mode> founding_mode;
gene_frequency_table<gene::gaster> gaster;
gene_frequency_table<gene::head> head;
gene_frequency_table<gene::larva> larva;
gene_frequency_table<gene::legs> legs;
gene_frequency_table<gene::mandibles> mandibles;
gene_frequency_table<gene::mesosoma> mesosoma;
gene_frequency_table<gene::nest_site> nest_site;
gene_frequency_table<gene::ocelli> ocelli;
gene_frequency_table<gene::pigmentation> pigmentation;
gene_frequency_table<gene::pilosity> pilosity;
gene_frequency_table<gene::sculpturing> sculpturing;
gene_frequency_table<gene::sting> sting;
gene_frequency_table<gene::waist> waist;
gene_frequency_table<gene::wings> wings;
};
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_POOL_HPP

+ 37
- 0
src/game/ant/gene/antennae.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_ANTENNAE_HPP
#define ANTKEEPER_GAME_ANT_GENE_ANTENNAE_HPP
#include "game/ant/phene/antennae.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic antennae gene.
typedef polyphenic_gene<phene::antennae> antennae;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_ANTENNAE_HPP

+ 37
- 0
src/game/ant/gene/body-size.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_BODY_SIZE_HPP
#define ANTKEEPER_GAME_ANT_GENE_BODY_SIZE_HPP
#include "game/ant/phene/body-size.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic body size gene.
typedef polyphenic_gene<phene::body_size> body_size;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_BODY_SIZE_HPP

src/game/ant/trait/body-size.hpp → src/game/ant/gene/cocoon.hpp View File

@ -17,24 +17,21 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_BODY_SIZE_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_BODY_SIZE_HPP
#ifndef ANTKEEPER_GAME_ANT_GENE_COCOON_HPP
#define ANTKEEPER_GAME_ANT_GENE_COCOON_HPP
#include "game/ant/phene/cocoon.hpp"
#include "game/ant/gene/monophenic-gene.hpp"
namespace game {
namespace ant {
namespace trait {
namespace gene {
/**
* Ant body size description.
*/
struct body_size
{
/// Mesosoma length (Weber's length) of a media worker, in centimeters.
float mesosoma_length;
};
/// Monophenic cocoon gene.
typedef monophenic_gene<phene::cocoon> cocoon;
} // namespace trait
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_BODY_SIZE_HPP
#endif // ANTKEEPER_GAME_ANT_GENE_COCOON_HPP

+ 37
- 0
src/game/ant/gene/diet.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_DIET_HPP
#define ANTKEEPER_GAME_ANT_GENE_DIET_HPP
#include "game/ant/phene/diet.hpp"
#include "game/ant/gene/monophenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Monophenic diet gene.
typedef monophenic_gene<phene::diet> diet;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_DIET_HPP

+ 37
- 0
src/game/ant/gene/egg.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_EGG_HPP
#define ANTKEEPER_GAME_ANT_GENE_EGG_HPP
#include "game/ant/phene/egg.hpp"
#include "game/ant/gene/monophenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Monophenic egg gene.
typedef monophenic_gene<phene::egg> egg;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_EGG_HPP

+ 37
- 0
src/game/ant/gene/eyes.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_EYES_HPP
#define ANTKEEPER_GAME_ANT_GENE_EYES_HPP
#include "game/ant/phene/eyes.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic eyes gene.
typedef polyphenic_gene<phene::eyes> eyes;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_EYES_HPP

+ 37
- 0
src/game/ant/gene/foraging-time.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_FORAGING_TIME_HPP
#define ANTKEEPER_GAME_ANT_GENE_FORAGING_TIME_HPP
#include "game/ant/phene/foraging-time.hpp"
#include "game/ant/gene/monophenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Monophenic foraging time gene.
typedef monophenic_gene<phene::foraging_time> foraging_time;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_FORAGING_TIME_HPP

+ 37
- 0
src/game/ant/gene/founding-mode.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_FOUNDING_MODE_HPP
#define ANTKEEPER_GAME_ANT_GENE_FOUNDING_MODE_HPP
#include "game/ant/phene/founding-mode.hpp"
#include "game/ant/gene/monophenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Monophenic founding mode gene.
typedef monophenic_gene<phene::founding_mode> founding_mode;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_FOUNDING_MODE_HPP

+ 37
- 0
src/game/ant/gene/gaster.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_GASTER_HPP
#define ANTKEEPER_GAME_ANT_GENE_GASTER_HPP
#include "game/ant/phene/gaster.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic gaster gene.
typedef polyphenic_gene<phene::gaster> gaster;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_GASTER_HPP

+ 37
- 0
src/game/ant/gene/head.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_HEAD_HPP
#define ANTKEEPER_GAME_ANT_GENE_HEAD_HPP
#include "game/ant/phene/head.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic head gene.
typedef polyphenic_gene<phene::head> head;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_HEAD_HPP

+ 37
- 0
src/game/ant/gene/larva.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_LARVA_HPP
#define ANTKEEPER_GAME_ANT_GENE_LARVA_HPP
#include "game/ant/phene/larva.hpp"
#include "game/ant/gene/monophenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Monophenic larva gene.
typedef monophenic_gene<phene::larva> larva;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_LARVA_HPP

+ 37
- 0
src/game/ant/gene/legs.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_LEGS_HPP
#define ANTKEEPER_GAME_ANT_GENE_LEGS_HPP
#include "game/ant/phene/legs.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic legs gene.
typedef polyphenic_gene<phene::legs> legs;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_LEGS_HPP

src/game/ant/trait/loader/antennae-loader.cpp → src/game/ant/gene/loader/antennae-loader.cpp View File

@ -17,45 +17,51 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/antennae.hpp"
#include "game/ant/gene/antennae.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_antennae_phene(phene::antennae& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.model = nullptr;
phene.total_antennomere_count = 0;
phene.club_antennomere_count = 0;
// Load antennae model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
// Parse total antennomere count
if (auto element = phene_element.find("total_antennomere_count"); element != phene_element.end())
phene.total_antennomere_count = element->get<int>();
// Parse club antennomere count
if (auto element = phene_element.find("club_antennomere_count"); element != phene_element.end())
phene.club_antennomere_count = element->get<int>();
}
template <>
trait::antennae* resource_loader<trait::antennae>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::antennae* resource_loader<gene::antennae>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto antennae_element = data->find("antennae");
if (antennae_element == data->end())
throw std::runtime_error("Invalid antennae trait.");
throw std::runtime_error("Invalid antennae gene.");
// Allocate and init antennae trait
trait::antennae* antennae = new trait::antennae();
antennae->model = nullptr;
antennae->total_antennomere_count = 0;
antennae->club_antennomere_count = 0;
// Load antennae model
auto model_element = antennae_element->find("model");
if (model_element == antennae_element->end())
throw std::runtime_error("Antennae trait doesn't specify antennae model.");
antennae->model = resource_manager->load<render::model>(model_element->get<std::string>());
// Allocate gene
gene::antennae* antennae = new gene::antennae();
// Parse total antennomere count
if (auto element = antennae_element->find("total_antennomere_count"); element != antennae_element->end())
antennae->total_antennomere_count = element->get<int>();
// Parse club antennomere count
if (auto element = antennae_element->find("club_antennomere_count"); element != antennae_element->end())
antennae->club_antennomere_count = element->get<int>();
// Deserialize gene
gene::deserialize_gene(*antennae, &deserialize_antennae_phene, *antennae_element, resource_manager);
// Free JSON data
delete data;

+ 69
- 0
src/game/ant/gene/loader/body-size-loader.cpp View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/gene/body-size.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_body_size_phene(phene::body_size& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.min_mesosoma_length = 1.0f;
phene.max_mesosoma_length = 1.0f;
phene.mean_mesosoma_length = 1.0f;
// Parse min mesosoma length
if (auto element = phene_element.find("min_mesosoma_length"); element != phene_element.end())
phene.min_mesosoma_length = element->get<float>();
// Parse max mesosoma length
if (auto element = phene_element.find("max_mesosoma_length"); element != phene_element.end())
phene.max_mesosoma_length = element->get<float>();
// Parse mean mesosoma length
if (auto element = phene_element.find("mean_mesosoma_length"); element != phene_element.end())
phene.mean_mesosoma_length = element->get<float>();
}
template <>
gene::body_size* resource_loader<gene::body_size>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate gene file
auto body_size_element = data->find("body_size");
if (body_size_element == data->end())
throw std::runtime_error("Invalid body size gene.");
// Allocate gene
gene::body_size* body_size = new gene::body_size();
// Deserialize gene
gene::deserialize_gene(*body_size, &deserialize_body_size_phene, *body_size_element, resource_manager);
// Free JSON data
delete data;
return body_size;
}

src/game/ant/trait/loader/cocoon-loader.cpp → src/game/ant/gene/loader/cocoon-loader.cpp View File

@ -17,43 +17,49 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/cocoon.hpp"
#include "game/ant/gene/cocoon.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_cocoon_phene(phene::cocoon& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.present = false;
phene.model = nullptr;
// Parse cocoon present
if (auto element = phene_element.find("present"); element != phene_element.end())
phene.present = element->get<bool>();
// Load cocoon model
if (phene.present)
{
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
}
}
template <>
trait::cocoon* resource_loader<trait::cocoon>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::cocoon* resource_loader<gene::cocoon>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto cocoon_element = data->find("cocoon");
if (cocoon_element == data->end())
throw std::runtime_error("Invalid cocoon trait.");
// Allocate and init cocoon trait
trait::cocoon* cocoon = new trait::cocoon();
cocoon->present = false;
cocoon->model = nullptr;
throw std::runtime_error("Invalid cocoon gene.");
// Parse cocoon present
if (auto present_element = cocoon_element->find("present"); present_element != cocoon_element->end())
cocoon->present = present_element->get<bool>();
// Allocate gene
gene::cocoon* cocoon = new gene::cocoon();
// Load cocoon model (if present)
if (cocoon->present)
{
auto model_element = cocoon_element->find("model");
if (model_element == cocoon_element->end())
throw std::runtime_error("Cocoon trait doesn't specify cocoon model.");
cocoon->model = resource_manager->load<render::model>(model_element->get<std::string>());
}
// Deserialize gene
gene::deserialize_gene(*cocoon, &deserialize_cocoon_phene, *cocoon_element, resource_manager);
// Free JSON data
delete data;

src/game/ant/trait/loader/egg-loader.cpp → src/game/ant/gene/loader/egg-loader.cpp View File

@ -17,35 +17,41 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/egg.hpp"
#include "game/ant/gene/egg.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_egg_phene(phene::egg& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.model = nullptr;
// Load egg model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
}
template <>
trait::egg* resource_loader<trait::egg>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::egg* resource_loader<gene::egg>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto egg_element = data->find("egg");
if (egg_element == data->end())
throw std::runtime_error("Invalid egg trait.");
throw std::runtime_error("Invalid egg gene.");
// Allocate and init egg trait
trait::egg* egg = new trait::egg();
egg->model = nullptr;
// Allocate gene
gene::egg* egg = new gene::egg();
// Load egg model
auto model_element = egg_element->find("model");
if (model_element == egg_element->end())
throw std::runtime_error("Egg trait doesn't specify egg model.");
egg->model = resource_manager->load<render::model>(model_element->get<std::string>());
// Deserialize gene
gene::deserialize_gene(*egg, &deserialize_egg_phene, *egg_element, resource_manager);
// Free JSON data
delete data;

+ 88
- 0
src/game/ant/gene/loader/eyes-loader.cpp View File

@ -0,0 +1,88 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/gene/eyes.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_eyes_phene(phene::eyes& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.present = false;
phene.model = nullptr;
phene.length = 0.0f;
phene.width = 0.0f;
phene.height = 0.0f;
phene.ommatidia_count = 0;
// Parse present
if (auto element = phene_element.find("present"); element != phene_element.end())
phene.present = element->get<bool>();
if (phene.present)
{
// Load eyes model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
// Parse length
if (auto element = phene_element.find("length"); element != phene_element.end())
phene.length = element->get<float>();
// Parse width
if (auto element = phene_element.find("width"); element != phene_element.end())
phene.width = element->get<float>();
// Parse height
if (auto element = phene_element.find("height"); element != phene_element.end())
phene.height = element->get<float>();
// Parse ommatidia count
if (auto element = phene_element.find("ommatidia_count"); element != phene_element.end())
phene.ommatidia_count = element->get<int>();
}
}
template <>
gene::eyes* resource_loader<gene::eyes>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate gene file
auto eyes_element = data->find("eyes");
if (eyes_element == data->end())
throw std::runtime_error("Invalid eyes gene.");
// Allocate gene
gene::eyes* eyes = new gene::eyes();
// Deserialize gene
gene::deserialize_gene(*eyes, &deserialize_eyes_phene, *eyes_element, resource_manager);
// Free JSON data
delete data;
return eyes;
}

src/game/ant/trait/loader/foraging-time-loader.cpp → src/game/ant/gene/loader/foraging-time-loader.cpp View File

@ -17,35 +17,47 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/foraging-time.hpp"
#include "game/ant/gene/foraging-time.hpp"
#include "math/angles.hpp"
#include "math/constants.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_foraging_time_phene(phene::foraging_time& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.min_solar_altitude = -math::half_pi<float>;
phene.max_solar_altitude = math::half_pi<float>;
// Parse min solar altitude
if (auto element = phene_element.find("min_solar_altitude"); element != phene_element.end())
phene.min_solar_altitude = math::radians(element->get<float>());
// Parse max solar altitude
if (auto element = phene_element.find("max_solar_altitude"); element != phene_element.end())
phene.max_solar_altitude = math::radians(element->get<float>());
}
template <>
trait::foraging_time* resource_loader<trait::foraging_time>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::foraging_time* resource_loader<gene::foraging_time>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate gene file
auto foraging_time_element = data->find("foraging_time");
if (foraging_time_element == data->end())
throw std::runtime_error("Invalid foraging time trait.");
auto solar_altitude_element = foraging_time_element->find("solar_altitude");
if (solar_altitude_element == foraging_time_element->end())
throw std::runtime_error("Foraging time trait doesn't specify solar altitude.");
throw std::runtime_error("Invalid foraging time gene.");
if (!solar_altitude_element->is_array() || solar_altitude_element->size() != 2)
throw std::runtime_error("Foraging time trait solar altitude must contain two values.");
// Allocate gene
gene::foraging_time* foraging_time = new gene::foraging_time();
trait::foraging_time* foraging_time = new trait::foraging_time();
foraging_time->solar_altitude_min = math::radians<float>(solar_altitude_element->front().get<float>());
foraging_time->solar_altitude_max = math::radians<float>(solar_altitude_element->back().get<float>());
// Deserialize gene
gene::deserialize_gene(*foraging_time, &deserialize_foraging_time_phene, *foraging_time_element, resource_manager);
// Free JSON data
delete data;

src/game/ant/trait/loader/gaster-loader.cpp → src/game/ant/gene/loader/gaster-loader.cpp View File

@ -17,40 +17,46 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/gaster.hpp"
#include "game/ant/gene/gaster.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_gaster_phene(phene::gaster& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.model = nullptr;
phene.phragmosis = 0.0f;
// Load gaster model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
// Parse phragmosis
if (auto element = phene_element.find("phragmosis"); element != phene_element.end())
phene.phragmosis = element->get<float>();
}
template <>
trait::gaster* resource_loader<trait::gaster>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::gaster* resource_loader<gene::gaster>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto gaster_element = data->find("gaster");
if (gaster_element == data->end())
throw std::runtime_error("Invalid gaster trait.");
throw std::runtime_error("Invalid gaster gene.");
// Allocate and init gaster trait
trait::gaster* gaster = new trait::gaster();
gaster->model = nullptr;
gaster->phragmosis = 0.0;
// Allocate gene
gene::gaster* gaster = new gene::gaster();
// Load gaster model
auto model_element = gaster_element->find("model");
if (model_element == gaster_element->end())
throw std::runtime_error("Gaster trait doesn't specify gaster model.");
gaster->model = resource_manager->load<render::model>(model_element->get<std::string>());
// Parse phragmosis
if (auto element = gaster_element->find("phragmosis"); element != gaster_element->end())
gaster->phragmosis = element->get<float>();
// Deserialize gene
gene::deserialize_gene(*gaster, &deserialize_gaster_phene, *gaster_element, resource_manager);
// Free JSON data
delete data;

+ 87
- 0
src/game/ant/gene/loader/gene-loader.hpp View File

@ -0,0 +1,87 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_GENE_LOADER_HPP
#define ANTKEEPER_GAME_ANT_GENE_GENE_LOADER_HPP
#include "game/ant/gene/monophenic-gene.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
#include "resources/json.hpp"
#include "resources/resource-manager.hpp"
namespace game {
namespace ant {
namespace gene {
/**
* Deserializes a gene.
*
* @tparam T Phene type.
*
* @param gene Gene to deserialize.
* @param deserialize_phene Phene deserialization function.
* @param gene_element JSON element containing a gene definition.
* @param resource_manager Resource manager pointer.
*/
/// @{
template <class T>
void deserialize_gene(monophenic_gene<T>& gene, void (*deserialize_phene)(T&, const json&, resource_manager*), const json& gene_element, resource_manager* resource_manager)
{
// Read gene name
if (auto element = gene_element.find("name"); element != gene_element.end())
gene.name = element->get<std::string>();
// Deserialize phene
if (auto element = gene_element.find("phene"); element != gene_element.end())
deserialize_phene(gene.phene, *element, resource_manager);
}
template <class T>
void deserialize_gene(polyphenic_gene<T>& gene, void (*deserialize_phene)(T&, const json&, resource_manager*), const json& gene_element, resource_manager* resource_manager)
{
// Read gene name
if (auto element = gene_element.find("name"); element != gene_element.end())
gene.name = element->get<std::string>();
// Deserialize phenes
if (auto phenes_element = gene_element.find("phenes"); phenes_element != gene_element.end())
{
if (auto element = phenes_element->find("female"); element != phenes_element->end())
{
deserialize_phene(gene.phenes[caste::queen], *element, resource_manager);
deserialize_phene(gene.phenes[caste::worker], *element, resource_manager);
deserialize_phene(gene.phenes[caste::soldier], *element, resource_manager);
}
if (auto element = phenes_element->find("male"); element != phenes_element->end())
deserialize_phene(gene.phenes[caste::male], *element, resource_manager);
if (auto element = phenes_element->find("queen"); element != phenes_element->end())
deserialize_phene(gene.phenes[caste::queen], *element, resource_manager);
if (auto element = phenes_element->find("worker"); element != phenes_element->end())
deserialize_phene(gene.phenes[caste::worker], *element, resource_manager);
if (auto element = phenes_element->find("soldier"); element != phenes_element->end())
deserialize_phene(gene.phenes[caste::soldier], *element, resource_manager);
}
}
/// @}
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_GENE_LOADER_HPP

src/game/ant/trait/loader/head-loader.cpp → src/game/ant/gene/loader/head-loader.cpp View File

@ -17,50 +17,56 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/head.hpp"
#include "game/ant/gene/head.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_head_phene(phene::head& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.model = nullptr;
phene.length = 0.0f;
phene.width = 0.0f;
phene.phragmosis = 0.0f;
// Load head model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
// Parse length
if (auto element = phene_element.find("length"); element != phene_element.end())
phene.length = element->get<float>();
// Parse width
if (auto element = phene_element.find("width"); element != phene_element.end())
phene.width = element->get<float>();
// Parse phragmosis
if (auto element = phene_element.find("phragmosis"); element != phene_element.end())
phene.phragmosis = element->get<float>();
}
template <>
trait::head* resource_loader<trait::head>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::head* resource_loader<gene::head>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto head_element = data->find("head");
if (head_element == data->end())
throw std::runtime_error("Invalid head trait.");
// Allocate and init head trait
trait::head* head = new trait::head();
head->model = nullptr;
head->length = 0.0f;
head->width = 0.0f;
head->phragmosis = false;
// Load model
auto model_element = head_element->find("model");
if (model_element == head_element->end())
throw std::runtime_error("Head trait doesn't specify head model.");
head->model = resource_manager->load<render::model>(model_element->get<std::string>());
throw std::runtime_error("Invalid head gene.");
// Parse length
if (auto element = head_element->find("length"); element != head_element->end())
head->length = element->get<float>();
// Parse width
if (auto element = head_element->find("width"); element != head_element->end())
head->width = element->get<float>();
// Allocate gene
gene::head* head = new gene::head();
// Parse phragmosis
if (auto element = head_element->find("phragmosis"); element != head_element->end())
head->phragmosis = element->get<float>();
// Deserialize gene
gene::deserialize_gene(*head, &deserialize_head_phene, *head_element, resource_manager);
// Free JSON data
delete data;

src/game/ant/trait/loader/larva-loader.cpp → src/game/ant/gene/loader/larva-loader.cpp View File

@ -17,40 +17,46 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/larva.hpp"
#include "game/ant/gene/larva.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_larva_phene(phene::larva& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.model = nullptr;
phene.instar_count = 0;
// Load larva model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
// Parse instar count
if (auto element = phene_element.find("instar_count"); element != phene_element.end())
phene.instar_count = element->get<int>();
}
template <>
trait::larva* resource_loader<trait::larva>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::larva* resource_loader<gene::larva>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto larva_element = data->find("larva");
if (larva_element == data->end())
throw std::runtime_error("Invalid larva trait.");
// Allocate and init larva trait
trait::larva* larva = new trait::larva();
larva->model = nullptr;
larva->instars = 0;
throw std::runtime_error("Invalid larva gene.");
// Load model
auto model_element = larva_element->find("model");
if (model_element == larva_element->end())
throw std::runtime_error("Larva trait doesn't specify larva model.");
larva->model = resource_manager->load<render::model>(model_element->get<std::string>());
// Allocate gene
gene::larva* larva = new gene::larva();
// Parse instars
if (auto element = larva_element->find("instars"); element != larva_element->end())
larva->instars = element->get<int>();
// Deserialize gene
gene::deserialize_gene(*larva, &deserialize_larva_phene, *larva_element, resource_manager);
// Free JSON data
delete data;

src/game/ant/trait/loader/legs-loader.cpp → src/game/ant/gene/loader/legs-loader.cpp View File

@ -17,45 +17,51 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/legs.hpp"
#include "game/ant/gene/legs.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_legs_phene(phene::legs& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.model = nullptr;
phene.speed = 0.0f;
phene.grip = 0.0f;
// Load legs model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
// Parse speed
if (auto element = phene_element.find("speed"); element != phene_element.end())
phene.speed = element->get<float>();
// Parse grip
if (auto element = phene_element.find("grip"); element != phene_element.end())
phene.grip = element->get<float>();
}
template <>
trait::legs* resource_loader<trait::legs>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::legs* resource_loader<gene::legs>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto legs_element = data->find("legs");
if (legs_element == data->end())
throw std::runtime_error("Invalid legs trait.");
// Allocate and init legs trait
trait::legs* legs = new trait::legs();
legs->model = nullptr;
legs->speed = 1.0f;
legs->grip = 1.0f;
throw std::runtime_error("Invalid legs gene.");
// Load model
auto model_element = legs_element->find("model");
if (model_element == legs_element->end())
throw std::runtime_error("Legs trait doesn't specify legs model.");
legs->model = resource_manager->load<render::model>(model_element->get<std::string>());
// Allocate gene
gene::legs* legs = new gene::legs();
// Parse speed
if (auto element = legs_element->find("speed"); element != legs_element->end())
legs->speed = element->get<float>();
// Parse grip
if (auto element = legs_element->find("grip"); element != legs_element->end())
legs->grip = element->get<float>();
// Deserialize gene
gene::deserialize_gene(*legs, &deserialize_legs_phene, *legs_element, resource_manager);
// Free JSON data
delete data;

+ 75
- 0
src/game/ant/gene/loader/mandibles-loader.cpp View File

@ -0,0 +1,75 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/gene/mandibles.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_mandibles_phene(phene::mandibles& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.model = nullptr;
phene.length = 0.0f;
phene.apical_dental_count = 0;
phene.basal_dental_count = 0;
// Load mandibles model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
// Parse length
if (auto element = phene_element.find("length"); element != phene_element.end())
phene.length = element->get<float>();
// Parse apical dental count count
if (auto element = phene_element.find("apical_dental_count"); element != phene_element.end())
phene.apical_dental_count = element->get<int>();
// Parse basal dental count count
if (auto element = phene_element.find("basal_dental_count"); element != phene_element.end())
phene.basal_dental_count = element->get<int>();
}
template <>
gene::mandibles* resource_loader<gene::mandibles>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate gene file
auto mandibles_element = data->find("mandibles");
if (mandibles_element == data->end())
throw std::runtime_error("Invalid mandibles gene.");
// Allocate gene
gene::mandibles* mandibles = new gene::mandibles();
// Deserialize gene
gene::deserialize_gene(*mandibles, &deserialize_mandibles_phene, *mandibles_element, resource_manager);
// Free JSON data
delete data;
return mandibles;
}

+ 80
- 0
src/game/ant/gene/loader/mesosoma-loader.cpp View File

@ -0,0 +1,80 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/gene/mesosoma.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_mesosoma_phene(phene::mesosoma& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.model = nullptr;
phene.pronotum_width = 0.0f;
phene.pronotum_spinescence = 0.0f;
phene.mesonotum_spinescence = 0.0f;
phene.propodeum_spinescence = 0.0f;
// Load mesosoma model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
// Parse pronotum width
if (auto element = phene_element.find("pronotum_width"); element != phene_element.end())
phene.pronotum_width = element->get<float>();
// Parse pronotum spinescence
if (auto element = phene_element.find("pronotum_spinescence"); element != phene_element.end())
phene.pronotum_spinescence = element->get<float>();
// Parse mesonotum spinescence
if (auto element = phene_element.find("mesonotum_spinescence"); element != phene_element.end())
phene.mesonotum_spinescence = element->get<float>();
// Parse propodeum spinescence
if (auto element = phene_element.find("propodeum_spinescence"); element != phene_element.end())
phene.propodeum_spinescence = element->get<float>();
}
template <>
gene::mesosoma* resource_loader<gene::mesosoma>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate gene file
auto mesosoma_element = data->find("mesosoma");
if (mesosoma_element == data->end())
throw std::runtime_error("Invalid mesosoma gene.");
// Allocate gene
gene::mesosoma* mesosoma = new gene::mesosoma();
// Deserialize gene
gene::deserialize_gene(*mesosoma, &deserialize_mesosoma_phene, *mesosoma_element, resource_manager);
// Free JSON data
delete data;
return mesosoma;
}

+ 91
- 0
src/game/ant/gene/loader/ocelli-loader.cpp View File

@ -0,0 +1,91 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/gene/ocelli.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_ocelli_phene(phene::ocelli& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.lateral_ocelli_present = false;
phene.median_ocellus_present = false;
phene.lateral_ocelli_model = nullptr;
phene.median_ocellus_model = nullptr;
phene.width = 0.0f;
phene.height = 0.0f;
// Parse lateral ocelli present
if (auto element = phene_element.find("lateral_ocelli_present"); element != phene_element.end())
phene.lateral_ocelli_present = element->get<bool>();
// Parse median ocelli present
if (auto element = phene_element.find("median_ocellus_present"); element != phene_element.end())
phene.median_ocellus_present = element->get<bool>();
// Parse width
if (auto element = phene_element.find("width"); element != phene_element.end())
phene.width = element->get<float>();
// Parse height
if (auto element = phene_element.find("height"); element != phene_element.end())
phene.height = element->get<float>();
// Load lateral ocelli model, if present
if (phene.lateral_ocelli_present)
{
if (auto element = phene_element.find("lateral_ocelli_model"); element != phene_element.end())
phene.lateral_ocelli_model = resource_manager->load<render::model>(element->get<std::string>());
}
// Load median ocellus model, if present
if (phene.median_ocellus_present)
{
if (auto element = phene_element.find("median_ocellus_model"); element != phene_element.end())
phene.median_ocellus_model = resource_manager->load<render::model>(element->get<std::string>());
}
}
template <>
gene::ocelli* resource_loader<gene::ocelli>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate gene file
auto ocelli_element = data->find("ocelli");
if (ocelli_element == data->end())
throw std::runtime_error("Invalid ocelli gene.");
// Allocate gene
gene::ocelli* ocelli = new gene::ocelli();
// Deserialize gene
gene::deserialize_gene(*ocelli, &deserialize_ocelli_phene, *ocelli_element, resource_manager);
// Free JSON data
delete data;
return ocelli;
}

src/game/ant/trait/loader/pigmentation-loader.cpp → src/game/ant/gene/loader/pigmentation-loader.cpp View File

@ -17,34 +17,41 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/pigmentation.hpp"
#include "game/ant/gene/pigmentation.hpp"
#include "render/material.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_pigmentation_phene(phene::pigmentation& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.material = nullptr;
// Load pigmentation material
if (auto element = phene_element.find("material"); element != phene_element.end())
phene.material = resource_manager->load<render::material>(element->get<std::string>());
}
template <>
trait::pigmentation* resource_loader<trait::pigmentation>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::pigmentation* resource_loader<gene::pigmentation>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto pigmentation_element = data->find("pigmentation");
if (pigmentation_element == data->end())
throw std::runtime_error("Invalid pigmentation trait.");
throw std::runtime_error("Invalid pigmentation gene.");
// Allocate and init pigmentation trait
trait::pigmentation* pigmentation = new trait::pigmentation();
pigmentation->material = nullptr;
// Allocate gene
gene::pigmentation* pigmentation = new gene::pigmentation();
// Load pigmentation material
auto material_element = pigmentation_element->find("material");
if (material_element == pigmentation_element->end())
throw std::runtime_error("Pigmentation trait doesn't specify pigmentation material.");
pigmentation->material = resource_manager->load<render::material>(material_element->get<std::string>());
// Deserialize gene
gene::deserialize_gene(*pigmentation, &deserialize_pigmentation_phene, *pigmentation_element, resource_manager);
// Free JSON data
delete data;

src/game/ant/trait/loader/pilosity-loader.cpp → src/game/ant/gene/loader/pilosity-loader.cpp View File

@ -17,32 +17,40 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/pilosity.hpp"
#include "game/ant/gene/pilosity.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_pilosity_phene(phene::pilosity& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.density = 0.0f;
// Parse density
if (auto element = phene_element.find("density"); element != phene_element.end())
phene.density = element->get<float>();
}
template <>
trait::pilosity* resource_loader<trait::pilosity>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::pilosity* resource_loader<gene::pilosity>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto pilosity_element = data->find("pilosity");
if (pilosity_element == data->end())
throw std::runtime_error("Invalid pilosity trait.");
throw std::runtime_error("Invalid pilosity gene.");
// Allocate and init pilosity trait
trait::pilosity* pilosity = new trait::pilosity();
pilosity->density = 0.0f;
// Allocate gene
gene::pilosity* pilosity = new gene::pilosity();
// Parse pilosity density
if (auto density_element = pilosity_element->find("density"); density_element != pilosity_element->end())
pilosity->density = density_element->get<float>();
// Deserialize gene
gene::deserialize_gene(*pilosity, &deserialize_pilosity_phene, *pilosity_element, resource_manager);
// Free JSON data
delete data;

src/game/ant/trait/loader/sculpturing-loader.cpp → src/game/ant/gene/loader/sculpturing-loader.cpp View File

@ -17,39 +17,46 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/sculpturing.hpp"
#include "game/ant/gene/sculpturing.hpp"
#include "gl/texture-2d.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_sculpturing_phene(phene::sculpturing& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.normal_map = nullptr;
phene.roughness = 0.0f;
// Load normal map
if (auto element = phene_element.find("normal_map"); element != phene_element.end())
phene.normal_map = resource_manager->load<gl::texture_2d>(element->get<std::string>());
// Parse roughness
if (auto element = phene_element.find("roughness"); element != phene_element.end())
phene.roughness = element->get<float>();
}
template <>
trait::sculpturing* resource_loader<trait::sculpturing>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::sculpturing* resource_loader<gene::sculpturing>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto sculpturing_element = data->find("sculpturing");
if (sculpturing_element == data->end())
throw std::runtime_error("Invalid sculpturing trait.");
// Allocate sculpturing trait
trait::sculpturing* sculpturing = new trait::sculpturing();
throw std::runtime_error("Invalid sculpturing gene.");
// Load sculpturing normal map
auto normal_map_element = sculpturing_element->find("normal_map");
if (normal_map_element == sculpturing_element->end())
throw std::runtime_error("Sculpturing trait doesn't specify sculpturing normal map.");
sculpturing->normal_map = resource_manager->load<gl::texture_2d>(normal_map_element->get<std::string>());
// Allocate gene
gene::sculpturing* sculpturing = new gene::sculpturing();
// Parse sculpturing roughness
sculpturing->roughness = 0.0f;
if (auto roughness_element = sculpturing_element->find("roughness"); roughness_element != sculpturing_element->end())
sculpturing->roughness = roughness_element->get<float>();
// Deserialize gene
gene::deserialize_gene(*sculpturing, &deserialize_sculpturing_phene, *sculpturing_element, resource_manager);
// Free JSON data
delete data;

src/game/ant/trait/loader/sting-loader.cpp → src/game/ant/gene/loader/sting-loader.cpp View File

@ -17,43 +17,49 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/sting.hpp"
#include "game/ant/gene/sting.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_sting_phene(phene::sting& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.present = false;
phene.model = nullptr;
// Parse present
if (auto element = phene_element.find("present"); element != phene_element.end())
phene.present = element->get<bool>();
if (phene.present)
{
// Load sting model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
}
}
template <>
trait::sting* resource_loader<trait::sting>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
gene::sting* resource_loader<gene::sting>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
// Validate gene file
auto sting_element = data->find("sting");
if (sting_element == data->end())
throw std::runtime_error("Invalid sting trait.");
// Allocate and init sting trait
trait::sting* sting = new trait::sting();
sting->present = false;
sting->model = nullptr;
throw std::runtime_error("Invalid sting gene.");
// Parse sting present
if (auto element = sting_element->find("present"); element != sting_element->end())
sting->present = element->get<bool>();
// Allocate gene
gene::sting* sting = new gene::sting();
// Load sting model (if present)
if (sting->present)
{
auto model_element = sting_element->find("model");
if (model_element == sting_element->end())
throw std::runtime_error("Sting trait doesn't specify sting model.");
sting->model = resource_manager->load<render::model>(model_element->get<std::string>());
}
// Deserialize gene
gene::deserialize_gene(*sting, &deserialize_sting_phene, *sting_element, resource_manager);
// Free JSON data
delete data;

+ 116
- 0
src/game/ant/gene/loader/waist-loader.cpp View File

@ -0,0 +1,116 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/gene/waist.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_waist_phene(phene::waist& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.model = nullptr;
phene.petiole_present = false;
phene.petiole_length = 0.0f;
phene.petiole_width = 0.0f;
phene.petiole_height = 0.0f;
phene.petiole_spinescence = 0.0f;
phene.postpetiole_present = false;
phene.postpetiole_length = 0.0f;
phene.postpetiole_width = 0.0f;
phene.postpetiole_height = 0.0f;
phene.postpetiole_spinescence = 0.0f;
// Load waist model
if (auto element = phene_element.find("model"); element != phene_element.end())
phene.model = resource_manager->load<render::model>(element->get<std::string>());
// Parse petiole present
if (auto element = phene_element.find("petiole_present"); element != phene_element.end())
phene.petiole_present = element->get<bool>();
// Parse postpetiole present
if (auto element = phene_element.find("postpetiole_present"); element != phene_element.end())
phene.postpetiole_present = element->get<bool>();
if (phene.petiole_present)
{
// Parse petiole length
if (auto element = phene_element.find("petiole_length"); element != phene_element.end())
phene.petiole_length = element->get<float>();
// Parse petiole width
if (auto element = phene_element.find("petiole_width"); element != phene_element.end())
phene.petiole_width = element->get<float>();
// Parse petiole height
if (auto element = phene_element.find("petiole_height"); element != phene_element.end())
phene.petiole_height = element->get<float>();
// Parse petiole spinescence
if (auto element = phene_element.find("petiole_spinescence"); element != phene_element.end())
phene.petiole_spinescence = element->get<float>();
}
if (phene.postpetiole_present)
{
// Parse postpetiole length
if (auto element = phene_element.find("postpetiole_length"); element != phene_element.end())
phene.postpetiole_length = element->get<float>();
// Parse postpetiole width
if (auto element = phene_element.find("postpetiole_width"); element != phene_element.end())
phene.postpetiole_width = element->get<float>();
// Parse postpetiole height
if (auto element = phene_element.find("postpetiole_height"); element != phene_element.end())
phene.postpetiole_height = element->get<float>();
// Parse postpetiole spinescence
if (auto element = phene_element.find("postpetiole_spinescence"); element != phene_element.end())
phene.postpetiole_spinescence = element->get<float>();
}
}
template <>
gene::waist* resource_loader<gene::waist>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate gene file
auto waist_element = data->find("waist");
if (waist_element == data->end())
throw std::runtime_error("Invalid waist gene.");
// Allocate gene
gene::waist* waist = new gene::waist();
// Deserialize gene
gene::deserialize_gene(*waist, &deserialize_waist_phene, *waist_element, resource_manager);
// Free JSON data
delete data;
return waist;
}

+ 103
- 0
src/game/ant/gene/loader/wings-loader.cpp View File

@ -0,0 +1,103 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/gene/loader/gene-loader.hpp"
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/gene/wings.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
static void deserialize_wings_phene(phene::wings& phene, const json& phene_element, resource_manager* resource_manager)
{
phene.present = false;
phene.forewings_model = nullptr;
phene.hindwings_model = nullptr;
phene.forewing_length = 0.0f;
phene.forewing_width = 0.0f;
phene.forewing_venation = 0.0f;
phene.hindwing_length = 0.0f;
phene.hindwing_width = 0.0f;
phene.hindwing_venation = 0.0f;
// Parse present
if (auto element = phene_element.find("present"); element != phene_element.end())
phene.present = element->get<bool>();
if (phene.present)
{
// Load forewings model
if (auto element = phene_element.find("forewings_model"); element != phene_element.end())
phene.forewings_model = resource_manager->load<render::model>(element->get<std::string>());
// Load hindwings model
if (auto element = phene_element.find("hindwings_model"); element != phene_element.end())
phene.hindwings_model = resource_manager->load<render::model>(element->get<std::string>());
// Parse forewing length
if (auto element = phene_element.find("forewing_length"); element != phene_element.end())
phene.forewing_length = element->get<float>();
// Parse forewing width
if (auto element = phene_element.find("forewing_width"); element != phene_element.end())
phene.forewing_width = element->get<float>();
// Parse forewing venation
if (auto element = phene_element.find("forewing_venation"); element != phene_element.end())
phene.forewing_venation = element->get<float>();
// Parse hindwing length
if (auto element = phene_element.find("hindwing_length"); element != phene_element.end())
phene.hindwing_length = element->get<float>();
// Parse hindwing width
if (auto element = phene_element.find("hindwing_width"); element != phene_element.end())
phene.hindwing_width = element->get<float>();
// Parse hindwing venation
if (auto element = phene_element.find("hindwing_venation"); element != phene_element.end())
phene.hindwing_venation = element->get<float>();
}
}
template <>
gene::wings* resource_loader<gene::wings>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate gene file
auto wings_element = data->find("wings");
if (wings_element == data->end())
throw std::runtime_error("Invalid wings gene.");
// Allocate gene
gene::wings* wings = new gene::wings();
// Deserialize gene
gene::deserialize_gene(*wings, &deserialize_wings_phene, *wings_element, resource_manager);
// Free JSON data
delete data;
return wings;
}

+ 37
- 0
src/game/ant/gene/mandibles.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_MANDIBLES_HPP
#define ANTKEEPER_GAME_ANT_GENE_MANDIBLES_HPP
#include "game/ant/phene/mandibles.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic mandibles gene.
typedef polyphenic_gene<phene::mandibles> mandibles;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_MANDIBLES_HPP

+ 37
- 0
src/game/ant/gene/mesosoma.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_MESOSOMA_HPP
#define ANTKEEPER_GAME_ANT_GENE_MESOSOMA_HPP
#include "game/ant/phene/mesosoma.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic mesosoma gene.
typedef polyphenic_gene<phene::mesosoma> mesosoma;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_MESOSOMA_HPP

src/game/ant/caste-type.hpp → src/game/ant/gene/monophenic-gene.hpp View File

@ -17,33 +17,32 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_CASTE_TYPE_HPP
#define ANTKEEPER_GAME_ANT_CASTE_TYPE_HPP
#ifndef ANTKEEPER_GAME_ANT_GENE_MONOPHENIC_GENE_HPP
#define ANTKEEPER_GAME_ANT_GENE_MONOPHENIC_GENE_HPP
#include <string>
namespace game {
namespace ant {
namespace gene {
/**
* Ant caste type enumerations
* Gene with a single phene.
*
* @see https://www.antwiki.org/wiki/Caste_Terminology
* @tparam T Phene type.
*/
enum class caste_type
template <class T>
struct monophenic_gene
{
/// Queen caste type.
queen,
/// Worker caste type.
worker,
/// Soldier caste type.
soldier,
/// Gene name.
std::string name;
/// Male caste type.
male
/// Phene definition.
T phene;
};
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_CASTE_TYPE_HPP
#endif // ANTKEEPER_GAME_ANT_GENE_MONOPHENIC_GENE_HPP

+ 37
- 0
src/game/ant/gene/nest-site.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_NEST_SITE_HPP
#define ANTKEEPER_GAME_ANT_GENE_NEST_SITE_HPP
#include "game/ant/phene/nest-site.hpp"
#include "game/ant/gene/monophenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Monophenic nest site gene.
typedef monophenic_gene<phene::nest_site> nest_site;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_NEST_SITE_HPP

+ 37
- 0
src/game/ant/gene/ocelli.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_OCELLI_HPP
#define ANTKEEPER_GAME_ANT_GENE_OCELLI_HPP
#include "game/ant/phene/ocelli.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic ocelli gene.
typedef polyphenic_gene<phene::ocelli> ocelli;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_OCELLI_HPP

+ 37
- 0
src/game/ant/gene/pigmentation.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_PIGMENTATION_HPP
#define ANTKEEPER_GAME_ANT_GENE_PIGMENTATION_HPP
#include "game/ant/phene/pigmentation.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic pigmentation gene.
typedef polyphenic_gene<phene::pigmentation> pigmentation;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_PIGMENTATION_HPP

+ 37
- 0
src/game/ant/gene/pilosity.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_PILOSITY_HPP
#define ANTKEEPER_GAME_ANT_GENE_PILOSITY_HPP
#include "game/ant/phene/pilosity.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic pilosity gene.
typedef polyphenic_gene<phene::pilosity> pilosity;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_PILOSITY_HPP

+ 52
- 0
src/game/ant/gene/polyphenic-gene.hpp View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_POLYPHENIC_GENE_HPP
#define ANTKEEPER_GAME_ANT_GENE_POLYPHENIC_GENE_HPP
#include "game/ant/caste.hpp"
#include <string>
#include <unordered_map>
namespace game {
namespace ant {
namespace gene {
/**
* Gene with caste-specific phenes.
*
* @tparam T Phene type.
*
* @see https://en.wikipedia.org/wiki/Polyphenism
*/
template <class T>
struct polyphenic_gene
{
/// Gene name.
std::string name;
/// Caste-specific phene definitions.
std::unordered_map<caste, T> phenes;
};
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_POLYPHENIC_GENE_HPP

+ 37
- 0
src/game/ant/gene/sculpturing.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_SCULPTURING_HPP
#define ANTKEEPER_GAME_ANT_GENE_SCULPTURING_HPP
#include "game/ant/phene/sculpturing.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic sculpturing gene.
typedef polyphenic_gene<phene::sculpturing> sculpturing;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_SCULPTURING_HPP

+ 37
- 0
src/game/ant/gene/sting.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_STING_HPP
#define ANTKEEPER_GAME_ANT_GENE_STING_HPP
#include "game/ant/phene/sting.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic sting gene.
typedef polyphenic_gene<phene::sting> sting;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_STING_HPP

+ 37
- 0
src/game/ant/gene/waist.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_WAIST_HPP
#define ANTKEEPER_GAME_ANT_GENE_WAIST_HPP
#include "game/ant/phene/waist.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic waist gene.
typedef polyphenic_gene<phene::waist> waist;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_WAIST_HPP

+ 37
- 0
src/game/ant/gene/wings.hpp View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENE_WINGS_HPP
#define ANTKEEPER_GAME_ANT_GENE_WINGS_HPP
#include "game/ant/phene/wings.hpp"
#include "game/ant/gene/polyphenic-gene.hpp"
namespace game {
namespace ant {
namespace gene {
/// Polyphenic wings gene.
typedef polyphenic_gene<phene::wings> wings;
} // namespace gene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENE_WINGS_HPP

+ 51
- 0
src/game/ant/genome.cpp View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/genome.hpp"
namespace game {
namespace ant {
genome::genome():
antennae(nullptr),
body_size(nullptr),
cocoon(nullptr),
diet(nullptr),
egg(nullptr),
eyes(nullptr),
foraging_time(nullptr),
founding_mode(nullptr),
gaster(nullptr),
head(nullptr),
larva(nullptr),
legs(nullptr),
mandibles(nullptr),
mesosoma(nullptr),
nest_site(nullptr),
ocelli(nullptr),
pigmentation(nullptr),
pilosity(nullptr),
sculpturing(nullptr),
sting(nullptr),
waist(nullptr),
wings(nullptr)
{}
} // namespace ant
} // namespace game

+ 84
- 0
src/game/ant/genome.hpp View File

@ -0,0 +1,84 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_GENOME_HPP
#define ANTKEEPER_GAME_ANT_GENOME_HPP
#include "game/ant/gene/antennae.hpp"
#include "game/ant/gene/body-size.hpp"
#include "game/ant/gene/cocoon.hpp"
#include "game/ant/gene/diet.hpp"
#include "game/ant/gene/egg.hpp"
#include "game/ant/gene/eyes.hpp"
#include "game/ant/gene/foraging-time.hpp"
#include "game/ant/gene/founding-mode.hpp"
#include "game/ant/gene/gaster.hpp"
#include "game/ant/gene/head.hpp"
#include "game/ant/gene/larva.hpp"
#include "game/ant/gene/legs.hpp"
#include "game/ant/gene/mandibles.hpp"
#include "game/ant/gene/mesosoma.hpp"
#include "game/ant/gene/nest-site.hpp"
#include "game/ant/gene/ocelli.hpp"
#include "game/ant/gene/pigmentation.hpp"
#include "game/ant/gene/pilosity.hpp"
#include "game/ant/gene/sculpturing.hpp"
#include "game/ant/gene/sting.hpp"
#include "game/ant/gene/waist.hpp"
#include "game/ant/gene/wings.hpp"
namespace game {
namespace ant {
/**
* Complete set of ant genes.
*/
struct genome
{
/// Constructs an empty genome.
genome();
const gene::antennae* antennae;
const gene::body_size* body_size;
const gene::cocoon* cocoon;
const gene::diet* diet;
const gene::egg* egg;
const gene::eyes* eyes;
const gene::foraging_time* foraging_time;
const gene::founding_mode* founding_mode;
const gene::gaster* gaster;
const gene::head* head;
const gene::larva* larva;
const gene::legs* legs;
const gene::mandibles* mandibles;
const gene::mesosoma* mesosoma;
const gene::nest_site* nest_site;
const gene::ocelli* ocelli;
const gene::pigmentation* pigmentation;
const gene::pilosity* pilosity;
const gene::sculpturing* sculpturing;
const gene::sting* sting;
const gene::waist* waist;
const gene::wings* wings;
};
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_GENOME_HPP

+ 26
- 26
src/game/ant/morphogenesis.cpp View File

@ -30,8 +30,8 @@ namespace ant {
static render::material* build_exoskeleton_material
(
const ant::trait::pigmentation& pigmentation,
const ant::trait::sculpturing& sculpturing
const phene::pigmentation& pigmentation,
const phene::sculpturing& sculpturing
);
static void reskin_vertices
(
@ -66,8 +66,8 @@ static render::model* build_model
render::material* build_exoskeleton_material
(
const ant::trait::pigmentation& pigmentation,
const ant::trait::sculpturing& sculpturing
const phene::pigmentation& pigmentation,
const phene::sculpturing& sculpturing
)
{
// Allocate copy of pigmentation material
@ -96,34 +96,34 @@ render::material* build_exoskeleton_material
return exoskeleton_material;
}
render::model* morphogenesis(const ant::caste& caste)
render::model* morphogenesis(const phenome& phenome)
{
// Build exoskeleton material
render::material* exoskeleton_material = build_exoskeleton_material(*caste.pigmentation, *caste.sculpturing);
render::material* exoskeleton_material = build_exoskeleton_material(*phenome.pigmentation, *phenome.sculpturing);
// Determine presence of optional parts
bool eyes_present = caste.eyes->present;
bool lateral_ocelli_present = caste.ocelli->lateral_ocelli_present;
bool median_ocellus_present = caste.ocelli->median_ocellus_present;
bool petiole_present = caste.waist->petiole_present;
bool postpetiole_present = caste.waist->postpetiole_present;
bool sting_present = caste.sting->present;
bool wings_present = caste.wings->present;
bool eyes_present = phenome.eyes->present;
bool lateral_ocelli_present = phenome.ocelli->lateral_ocelli_present;
bool median_ocellus_present = phenome.ocelli->median_ocellus_present;
bool petiole_present = phenome.waist->petiole_present;
bool postpetiole_present = phenome.waist->postpetiole_present;
bool sting_present = phenome.sting->present;
bool wings_present = phenome.wings->present;
// Get body part models
render::model* antennae_model = caste.antennae->model;
render::model* eyes_model = caste.eyes->model;
render::model* forewings_model = caste.wings->forewings_model;
render::model* gaster_model = caste.gaster->model;
render::model* head_model = caste.head->model;
render::model* hindwings_model = caste.wings->hindwings_model;
render::model* lateral_ocelli_model = caste.ocelli->lateral_ocelli_model;
render::model* legs_model = caste.legs->model;
render::model* mandibles_model = caste.mandibles->model;
render::model* median_ocellus_model = caste.ocelli->median_ocellus_model;
render::model* mesosoma_model = caste.mesosoma->model;
render::model* sting_model = caste.sting->model;
render::model* waist_model = caste.waist->model;
render::model* antennae_model = phenome.antennae->model;
render::model* eyes_model = phenome.eyes->model;
render::model* forewings_model = phenome.wings->forewings_model;
render::model* gaster_model = phenome.gaster->model;
render::model* head_model = phenome.head->model;
render::model* hindwings_model = phenome.wings->hindwings_model;
render::model* lateral_ocelli_model = phenome.ocelli->lateral_ocelli_model;
render::model* legs_model = phenome.legs->model;
render::model* mandibles_model = phenome.mandibles->model;
render::model* median_ocellus_model = phenome.ocelli->median_ocellus_model;
render::model* mesosoma_model = phenome.mesosoma->model;
render::model* sting_model = phenome.sting->model;
render::model* waist_model = phenome.waist->model;
// Get body part vertex buffers
const gl::vertex_buffer* antennae_vbo = antennae_model->get_vertex_buffer();

+ 5
- 5
src/game/ant/morphogenesis.hpp View File

@ -20,20 +20,20 @@
#ifndef ANTKEEPER_GAME_ANT_MORPHOGENESIS_HPP
#define ANTKEEPER_GAME_ANT_MORPHOGENESIS_HPP
#include "game/ant/caste.hpp"
#include "game/ant/phenome.hpp"
#include "render/model.hpp"
namespace game {
namespace ant {
/**
* Generates a 3D model of an ant.
* Generates a 3D model of an ant given its phenome.
*
* @param caste Caste description.
* @param phenome Phenome of an ant.
*
* @return 3D model of an ant.
* @return 3D model of the given phenome.
*/
render::model* morphogenesis(const ant::caste& caste);
render::model* morphogenesis(const phenome& phenome);
} // namespace ant
} // namespace game

src/game/ant/trait/antennae.hpp → src/game/ant/phene/antennae.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_ANTENNAE_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_ANTENNAE_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_ANTENNAE_HPP
#define ANTKEEPER_GAME_ANT_PHENE_ANTENNAE_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant antennae description.
* Ant antennae phene.
*
* @see https://www.antwiki.org/wiki/Character_States_for_Extant_Ant_Genera_of_the_Formicidae
* @see https://www.antwiki.org/wiki/Morphological_Measurements
@ -44,8 +44,8 @@ struct antennae
int club_antennomere_count;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_ANTENNAE_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_ANTENNAE_HPP

+ 50
- 0
src/game/ant/phene/body-size.hpp View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_PHENE_BODY_SIZE_HPP
#define ANTKEEPER_GAME_ANT_PHENE_BODY_SIZE_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace phene {
/**
* Ant body size phene.
*
* @see https://www.antwiki.org/wiki/Morphological_Measurements
*/
struct body_size
{
/// Minimum mesosoma length (Weber's length), in centimeters.
float min_mesosoma_length;
/// Maximum mesosoma length (Weber's length), in centimeters.
float max_mesosoma_length;
/// Mean mesosoma length (Weber's length), in centimeters.
float mean_mesosoma_length;
};
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_PHENE_BODY_SIZE_HPP

src/game/ant/trait/cocoon.hpp → src/game/ant/phene/cocoon.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_COCOON_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_COCOON_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_COCOON_HPP
#define ANTKEEPER_GAME_ANT_PHENE_COCOON_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant cocoon description.
* Ant cocoon phene.
*/
struct cocoon
{
@ -38,8 +38,8 @@ struct cocoon
bool present;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_COCOON_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_COCOON_HPP

src/game/ant/trait/diet.hpp → src/game/ant/phene/diet.hpp View File

@ -17,15 +17,15 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_DIET_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_DIET_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_DIET_HPP
#define ANTKEEPER_GAME_ANT_PHENE_DIET_HPP
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant diet description.
* Ant diet phene.
*/
struct diet
{
@ -48,8 +48,8 @@ struct diet
float carrion;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_DIET_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_DIET_HPP

src/game/ant/trait/egg.hpp → src/game/ant/phene/egg.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_EGG_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_EGG_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_EGG_HPP
#define ANTKEEPER_GAME_ANT_PHENE_EGG_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant egg description.
* Ant egg phene.
*/
struct egg
{
@ -35,8 +35,8 @@ struct egg
render::model* model;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_EGG_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_EGG_HPP

src/game/ant/trait/eyes.hpp → src/game/ant/phene/eyes.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_EYES_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_EYES_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_EYES_HPP
#define ANTKEEPER_GAME_ANT_PHENE_EYES_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant eyes description.
* Ant eyes phene.
*
* @see https://www.antwiki.org/wiki/Morphological_Measurements
*/
@ -52,8 +52,8 @@ struct eyes
int ommatidia_count;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_EYES_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_EYES_HPP

src/game/ant/trait/foraging-time.hpp → src/game/ant/phene/foraging-time.hpp View File

@ -17,29 +17,29 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_FORAGING_TIME_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_FORAGING_TIME_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_FORAGING_TIME_HPP
#define ANTKEEPER_GAME_ANT_PHENE_FORAGING_TIME_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant foraging time description.
* Ant foraging time phene.
*/
struct foraging_time
{
/// Minimum solar altitude at which foraging occurs.
float solar_altitude_min;
float min_solar_altitude;
/// Maximum solar alttiude at which foraging occurs.
float solar_altitude_max;
float max_solar_altitude;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_FORAGING_TIME_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_FORAGING_TIME_HPP

src/game/ant/trait/founding-mode.hpp → src/game/ant/phene/founding-mode.hpp View File

@ -17,15 +17,15 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_FOUNDING_MODE_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_FOUNDING_MODE_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_FOUNDING_MODE_HPP
#define ANTKEEPER_GAME_ANT_PHENE_FOUNDING_MODE_HPP
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Colony founding mode.
* Colony founding mode phene.
*
* @see https://www.antwiki.org/wiki/Colony_Foundation
*/
@ -41,8 +41,8 @@ enum class founding_mode
fission
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_FOUNDING_MODE_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_FOUNDING_MODE_HPP

src/game/ant/trait/gaster.hpp → src/game/ant/phene/gaster.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_GASTER_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_GASTER_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_GASTER_HPP
#define ANTKEEPER_GAME_ANT_PHENE_GASTER_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant gaster description.
* Ant gaster phene.
*
* @see https://antwiki.org/wiki/Phragmosis
*/
@ -40,8 +40,8 @@ struct gaster
float phragmosis;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_GASTER_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_GASTER_HPP

src/game/ant/trait/head.hpp → src/game/ant/phene/head.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_HEAD_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_HEAD_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_HEAD_HPP
#define ANTKEEPER_GAME_ANT_PHENE_HEAD_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant head description.
* Ant head phene.
*
* @see https://www.antwiki.org/wiki/Morphological_Measurements
* @see https://antwiki.org/wiki/Phragmosis
@ -47,8 +47,8 @@ struct head
float phragmosis;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_HEAD_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_HEAD_HPP

src/game/ant/trait/larva.hpp → src/game/ant/phene/larva.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_LARVA_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_LARVA_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_LARVA_HPP
#define ANTKEEPER_GAME_ANT_PHENE_LARVA_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant larva description.
* Ant larva phene.
*/
struct larva
{
@ -35,11 +35,11 @@ struct larva
render::model* model;
/// Number of larval instars before pupation.
int instars;
int instar_count;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_LARVA_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_LARVA_HPP

src/game/ant/trait/legs.hpp → src/game/ant/phene/legs.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_LEGS_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_LEGS_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_LEGS_HPP
#define ANTKEEPER_GAME_ANT_PHENE_LEGS_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant legs description.
* Ant legs phene.
*
* @see https://www.antwiki.org/wiki/Morphological_Measurements
*/
@ -43,8 +43,8 @@ struct legs
float grip;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_LEGS_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_LEGS_HPP

src/game/ant/trait/mandibles.hpp → src/game/ant/phene/mandibles.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_MANDIBLES_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_MANDIBLES_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_MANDIBLES_HPP
#define ANTKEEPER_GAME_ANT_PHENE_MANDIBLES_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant mandibles description.
* Ant mandibles phene.
*
* @see https://www.antwiki.org/wiki/Character_States_for_Extant_Ant_Genera_of_the_Formicidae
* @see https://www.antwiki.org/wiki/Morphological_and_Functional_Diversity_of_Ant_Mandibles
@ -48,8 +48,8 @@ struct mandibles
int basal_dental_count;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_MANDIBLES_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_MANDIBLES_HPP

src/game/ant/trait/mesosoma.hpp → src/game/ant/phene/mesosoma.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_MESOSOMA_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_MESOSOMA_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_MESOSOMA_HPP
#define ANTKEEPER_GAME_ANT_PHENE_MESOSOMA_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant mesosoma description.
* Ant mesosoma phene.
*
* @see https://www.antwiki.org/wiki/Morphological_Measurements
*/
@ -49,8 +49,8 @@ struct mesosoma
float propodeum_spinescence;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_MESOSOMA_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_MESOSOMA_HPP

src/game/ant/trait/nest-site.hpp → src/game/ant/phene/nest-site.hpp View File

@ -22,10 +22,10 @@
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Colony nest site description.
* Colony nest site phene.
*/
enum class nest_site
{
@ -33,7 +33,7 @@ enum class nest_site
arboreal
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game

src/game/ant/trait/ocelli.hpp → src/game/ant/phene/ocelli.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_OCELLI_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_OCELLI_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_OCELLI_HPP
#define ANTKEEPER_GAME_ANT_PHENE_OCELLI_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant ocelli description.
* Ant ocelli phene.
*/
struct ocelli
{
@ -50,8 +50,8 @@ struct ocelli
float height;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_OCELLI_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_OCELLI_HPP

src/game/ant/trait/pigmentation.hpp → src/game/ant/phene/pigmentation.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_PIGMENTATION_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_PIGMENTATION_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_PIGMENTATION_HPP
#define ANTKEEPER_GAME_ANT_PHENE_PIGMENTATION_HPP
#include "render/material.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant pigmentation description.
* Ant pigmentation phene.
*/
struct pigmentation
{
@ -35,8 +35,8 @@ struct pigmentation
render::material* material;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_PIGMENTATION_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_PIGMENTATION_HPP

src/game/ant/trait/pilosity.hpp → src/game/ant/phene/pilosity.hpp View File

@ -17,15 +17,15 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_PILOSITY_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_PILOSITY_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_PILOSITY_HPP
#define ANTKEEPER_GAME_ANT_PHENE_PILOSITY_HPP
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant pilosity description.
* Ant pilosity phene.
*/
struct pilosity
{
@ -33,8 +33,8 @@ struct pilosity
float density;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_PILOSITY_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_PILOSITY_HPP

src/game/ant/trait/sculpturing.hpp → src/game/ant/phene/sculpturing.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_SCULPTURING_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_SCULPTURING_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_SCULPTURING_HPP
#define ANTKEEPER_GAME_ANT_PHENE_SCULPTURING_HPP
#include "gl/texture-2d.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant surface sculpturing description.
* Ant surface sculpturing phene.
*/
struct sculpturing
{
@ -38,8 +38,8 @@ struct sculpturing
gl::texture_2d* normal_map;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_SCULPTURING_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_SCULPTURING_HPP

src/game/ant/trait/sting.hpp → src/game/ant/phene/sting.hpp View File

@ -17,14 +17,14 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_STING_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_STING_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_STING_HPP
#define ANTKEEPER_GAME_ANT_PHENE_STING_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Trait that describes the sting of an ant.
@ -38,8 +38,8 @@ struct sting
render::model* model;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_STING_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_STING_HPP

src/game/ant/trait/waist.hpp → src/game/ant/phene/waist.hpp View File

@ -17,14 +17,14 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_WAIST_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_WAIST_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_WAIST_HPP
#define ANTKEEPER_GAME_ANT_PHENE_WAIST_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Trait that describes the waist (petiole plus postpetiole) of an ant.
@ -67,8 +67,8 @@ struct waist
float postpetiole_spinescence;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_WAIST_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_WAIST_HPP

src/game/ant/trait/wings.hpp → src/game/ant/phene/wings.hpp View File

@ -17,17 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_WINGS_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_WINGS_HPP
#ifndef ANTKEEPER_GAME_ANT_PHENE_WINGS_HPP
#define ANTKEEPER_GAME_ANT_PHENE_WINGS_HPP
#include "render/model.hpp"
namespace game {
namespace ant {
namespace trait {
namespace phene {
/**
* Ant wings description.
* Ant wings phene.
*/
struct wings
{
@ -59,8 +59,8 @@ struct wings
float hindwing_venation;
};
} // namespace trait
} // namespace phene
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_WINGS_HPP
#endif // ANTKEEPER_GAME_ANT_PHENE_WINGS_HPP

+ 115
- 0
src/game/ant/phenome.cpp View File

@ -0,0 +1,115 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/ant/phenome.hpp"
namespace game {
namespace ant {
phenome::phenome(const genome& genome, caste caste):
phenome()
{
if (genome.antennae)
if (auto it = genome.antennae->phenes.find(caste); it != genome.antennae->phenes.end())
antennae = &it->second;
if (genome.body_size)
if (auto it = genome.body_size->phenes.find(caste); it != genome.body_size->phenes.end())
body_size = &it->second;
if (genome.cocoon)
cocoon = &genome.cocoon->phene;
if (genome.diet)
diet = &genome.diet->phene;
if (genome.egg)
egg = &genome.egg->phene;
if (genome.eyes)
if (auto it = genome.eyes->phenes.find(caste); it != genome.eyes->phenes.end())
eyes = &it->second;
if (genome.foraging_time)
foraging_time = &genome.foraging_time->phene;
if (genome.founding_mode)
founding_mode = &genome.founding_mode->phene;
if (genome.gaster)
if (auto it = genome.gaster->phenes.find(caste); it != genome.gaster->phenes.end())
gaster = &it->second;
if (genome.head)
if (auto it = genome.head->phenes.find(caste); it != genome.head->phenes.end())
head = &it->second;
if (genome.larva)
larva = &genome.larva->phene;
if (genome.legs)
if (auto it = genome.legs->phenes.find(caste); it != genome.legs->phenes.end())
legs = &it->second;
if (genome.mandibles)
if (auto it = genome.mandibles->phenes.find(caste); it != genome.mandibles->phenes.end())
mandibles = &it->second;
if (genome.mesosoma)
if (auto it = genome.mesosoma->phenes.find(caste); it != genome.mesosoma->phenes.end())
mesosoma = &it->second;
if (genome.nest_site)
nest_site = &genome.nest_site->phene;
if (genome.ocelli)
if (auto it = genome.ocelli->phenes.find(caste); it != genome.ocelli->phenes.end())
ocelli = &it->second;
if (genome.pigmentation)
if (auto it = genome.pigmentation->phenes.find(caste); it != genome.pigmentation->phenes.end())
pigmentation = &it->second;
if (genome.pilosity)
if (auto it = genome.pilosity->phenes.find(caste); it != genome.pilosity->phenes.end())
pilosity = &it->second;
if (genome.sculpturing)
if (auto it = genome.sculpturing->phenes.find(caste); it != genome.sculpturing->phenes.end())
sculpturing = &it->second;
if (genome.sting)
if (auto it = genome.sting->phenes.find(caste); it != genome.sting->phenes.end())
sting = &it->second;
if (genome.waist)
if (auto it = genome.waist->phenes.find(caste); it != genome.waist->phenes.end())
waist = &it->second;
if (genome.wings)
if (auto it = genome.wings->phenes.find(caste); it != genome.wings->phenes.end())
wings = &it->second;
}
phenome::phenome():
antennae(nullptr),
body_size(nullptr),
cocoon(nullptr),
diet(nullptr),
egg(nullptr),
eyes(nullptr),
foraging_time(nullptr),
founding_mode(nullptr),
gaster(nullptr),
head(nullptr),
larva(nullptr),
legs(nullptr),
mandibles(nullptr),
mesosoma(nullptr),
nest_site(nullptr),
ocelli(nullptr),
pigmentation(nullptr),
pilosity(nullptr),
sculpturing(nullptr),
sting(nullptr),
waist(nullptr),
wings(nullptr)
{}
} // namespace ant
} // namespace game

+ 94
- 0
src/game/ant/phenome.hpp View File

@ -0,0 +1,94 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_PHENOME_HPP
#define ANTKEEPER_GAME_ANT_PHENOME_HPP
#include "game/ant/phene/antennae.hpp"
#include "game/ant/phene/body-size.hpp"
#include "game/ant/phene/cocoon.hpp"
#include "game/ant/phene/diet.hpp"
#include "game/ant/phene/egg.hpp"
#include "game/ant/phene/eyes.hpp"
#include "game/ant/phene/foraging-time.hpp"
#include "game/ant/phene/founding-mode.hpp"
#include "game/ant/phene/gaster.hpp"
#include "game/ant/phene/head.hpp"
#include "game/ant/phene/larva.hpp"
#include "game/ant/phene/legs.hpp"
#include "game/ant/phene/mandibles.hpp"
#include "game/ant/phene/mesosoma.hpp"
#include "game/ant/phene/nest-site.hpp"
#include "game/ant/phene/ocelli.hpp"
#include "game/ant/phene/pigmentation.hpp"
#include "game/ant/phene/pilosity.hpp"
#include "game/ant/phene/sculpturing.hpp"
#include "game/ant/phene/sting.hpp"
#include "game/ant/phene/waist.hpp"
#include "game/ant/phene/wings.hpp"
#include "game/ant/genome.hpp"
#include "game/ant/caste.hpp"
namespace game {
namespace ant {
/**
* Complete set of ant phenes.
*/
struct phenome
{
/**
* Constructs a phenome for a given caste.
*
* @param genome Ant genome.
* @param caste Ant caste.
*/
phenome(const genome& genome, caste caste);
/// Constructs an empty phenome.
phenome();
const phene::antennae* antennae;
const phene::body_size* body_size;
const phene::cocoon* cocoon;
const phene::diet* diet;
const phene::egg* egg;
const phene::eyes* eyes;
const phene::foraging_time* foraging_time;
const phene::founding_mode* founding_mode;
const phene::gaster* gaster;
const phene::head* head;
const phene::larva* larva;
const phene::legs* legs;
const phene::mandibles* mandibles;
const phene::mesosoma* mesosoma;
const phene::nest_site* nest_site;
const phene::ocelli* ocelli;
const phene::pigmentation* pigmentation;
const phene::pilosity* pilosity;
const phene::sculpturing* sculpturing;
const phene::sting* sting;
const phene::waist* waist;
const phene::wings* wings;
};
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_PHENOME_HPP

+ 0
- 78
src/game/ant/species.hpp View File

@ -1,78 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_SPECIES_HPP
#define ANTKEEPER_GAME_ANT_SPECIES_HPP
#include "game/ant/caste.hpp"
#include "game/ant/trait/body-size.hpp"
#include "game/ant/trait/cocoon.hpp"
#include "game/ant/trait/diet.hpp"
#include "game/ant/trait/egg.hpp"
#include "game/ant/trait/foraging-time.hpp"
#include "game/ant/trait/larva.hpp"
#include "game/ant/trait/nest-site.hpp"
#include <optional>
namespace game {
namespace ant {
/**
* Ant species description.
*/
struct species
{
/// Body size description.
const trait::body_size* body_size;
/// Egg description.
const trait::egg* egg;
/// Larva description.
const trait::larva* larva;
/// Cocoon description.
const trait::cocoon* cocoon;
/// Queen caste description.
std::optional<caste> queen_caste;
/// Worker caste description.
std::optional<caste> worker_caste;
/// Soldier caste description.
std::optional<caste> soldier_caste;
/// Male caste description.
std::optional<caste> male_caste;
/// Diet description.
const trait::diet* diet;
/// Foraging time description.
const trait::foraging_time* foraging_time;
/// Nest site description.
const trait::nest_site* nest_site;
};
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_SPECIES_HPP

src/game/ant/subcaste-type.hpp → src/game/ant/subcaste.hpp View File

@ -17,14 +17,14 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_SUBCASTE_TYPE_HPP
#define ANTKEEPER_GAME_ANT_SUBCASTE_TYPE_HPP
#ifndef ANTKEEPER_GAME_ANT_SUBCASTE_HPP
#define ANTKEEPER_GAME_ANT_SUBCASTE_HPP
namespace game {
namespace ant {
/**
* Ant subcaste type enumerations.
* Ant subcaste enumerations.
*/
enum class subcaste
{
@ -56,4 +56,4 @@ enum class subcaste
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_SUBCASTE_TYPE_HPP
#endif // ANTKEEPER_GAME_ANT_SUBCASTE_HPP

+ 0
- 51
src/game/ant/trait/loader/body-size-loader.cpp View File

@ -1,51 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/body-size.hpp"
#include <stdexcept>
using namespace game::ant;
template <>
trait::body_size* resource_loader<trait::body_size>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
auto body_size_element = data->find("body_size");
if (body_size_element == data->end())
throw std::runtime_error("Invalid body size trait.");
// Allocate and init body size trait
trait::body_size* body_size = new trait::body_size();
body_size->mesosoma_length = 1.0f;
// Parse mesosoma length
if (auto element = body_size_element->find("mesosoma_length"); element != body_size_element->end())
body_size->mesosoma_length = element->get<float>();
// Free JSON data
delete data;
return body_size;
}

+ 0
- 82
src/game/ant/trait/loader/eyes-loader.cpp View File

@ -1,82 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/eyes.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
template <>
trait::eyes* resource_loader<trait::eyes>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
auto eyes_element = data->find("eyes");
if (eyes_element == data->end())
throw std::runtime_error("Invalid eyes trait.");
// Allocate and init eyes trait
trait::eyes* eyes = new trait::eyes();
eyes->present = false;
eyes->model = nullptr;
eyes->length = 0.0f;
eyes->width = 0.0f;
eyes->height = 0.0f;
eyes->ommatidia_count = 0;
// Parse eyes present
if (auto present_element = eyes_element->find("present"); present_element != eyes_element->end())
eyes->present = present_element->get<bool>();
if (eyes->present)
{
// Load eyes model
auto model_element = eyes_element->find("model");
if (model_element == eyes_element->end())
throw std::runtime_error("Eyes trait doesn't specify eyes model.");
eyes->model = resource_manager->load<render::model>(model_element->get<std::string>());
// Parse length
if (auto element = eyes_element->find("length"); element != eyes_element->end())
eyes->length = element->get<float>();
// Parse width
if (auto element = eyes_element->find("width"); element != eyes_element->end())
eyes->width = element->get<float>();
// Parse height
if (auto element = eyes_element->find("height"); element != eyes_element->end())
eyes->height = element->get<float>();
// Parse ommatidia count
if (auto element = eyes_element->find("ommatidia_count"); element != eyes_element->end())
eyes->ommatidia_count = element->get<int>();
}
// Free JSON data
delete data;
return eyes;
}

+ 0
- 69
src/game/ant/trait/loader/mandibles-loader.cpp View File

@ -1,69 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/mandibles.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
template <>
trait::mandibles* resource_loader<trait::mandibles>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
auto mandibles_element = data->find("mandibles");
if (mandibles_element == data->end())
throw std::runtime_error("Invalid mandibles trait.");
// Allocate and init mandibles trait
trait::mandibles* mandibles = new trait::mandibles();
mandibles->model = nullptr;
mandibles->length = 0.0f;
mandibles->apical_dental_count = 0;
mandibles->basal_dental_count = 0;
// Load model
auto model_element = mandibles_element->find("model");
if (model_element == mandibles_element->end())
throw std::runtime_error("Mandibles trait doesn't specify mandibles model.");
mandibles->model = resource_manager->load<render::model>(model_element->get<std::string>());
// Parse length
if (auto element = mandibles_element->find("length"); element != mandibles_element->end())
mandibles->length = element->get<float>();
// Parse apical dental count
if (auto element = mandibles_element->find("apical_dental_count"); element != mandibles_element->end())
mandibles->apical_dental_count = element->get<int>();
// Parse basal dental count
if (auto element = mandibles_element->find("basal_dental_count"); element != mandibles_element->end())
mandibles->basal_dental_count = element->get<int>();
// Free JSON data
delete data;
return mandibles;
}

+ 0
- 74
src/game/ant/trait/loader/mesosoma-loader.cpp View File

@ -1,74 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/mesosoma.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
template <>
trait::mesosoma* resource_loader<trait::mesosoma>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
auto mesosoma_element = data->find("mesosoma");
if (mesosoma_element == data->end())
throw std::runtime_error("Invalid mesosoma trait.");
// Allocate and init mesosoma trait
trait::mesosoma* mesosoma = new trait::mesosoma();
mesosoma->model = nullptr;
mesosoma->pronotum_width = 0.0f;
mesosoma->pronotum_spinescence = 0.0f;
mesosoma->mesonotum_spinescence = 0.0f;
mesosoma->propodeum_spinescence = 0.0f;
// Load mesosoma model
auto model_element = mesosoma_element->find("model");
if (model_element == mesosoma_element->end())
throw std::runtime_error("Mesosoma trait doesn't specify mesosoma model.");
mesosoma->model = resource_manager->load<render::model>(model_element->get<std::string>());
// Parse pronotum width
if (auto element = mesosoma_element->find("pronotum_width"); element != mesosoma_element->end())
mesosoma->pronotum_width = element->get<float>();
// Parse pronotum spinescence
if (auto element = mesosoma_element->find("pronotum_spinescence"); element != mesosoma_element->end())
mesosoma->pronotum_spinescence = element->get<float>();
// Parse mesonotum spinescence
if (auto element = mesosoma_element->find("mesonotum_spinescence"); element != mesosoma_element->end())
mesosoma->mesonotum_spinescence = element->get<float>();
// Parse propodeum spinescence
if (auto element = mesosoma_element->find("propodeum_spinescence"); element != mesosoma_element->end())
mesosoma->propodeum_spinescence = element->get<float>();
// Free JSON data
delete data;
return mesosoma;
}

+ 0
- 89
src/game/ant/trait/loader/ocelli-loader.cpp View File

@ -1,89 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/ocelli.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
template <>
trait::ocelli* resource_loader<trait::ocelli>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
auto ocelli_element = data->find("ocelli");
if (ocelli_element == data->end())
throw std::runtime_error("Invalid ocelli trait.");
// Allocate and init ocelli trait
trait::ocelli* ocelli = new trait::ocelli();
ocelli->lateral_ocelli_model = nullptr;
ocelli->median_ocellus_model = nullptr;
ocelli->lateral_ocelli_present = false;
ocelli->median_ocellus_present = false;
ocelli->width = 0.0f;
ocelli->height = 0.0f;
// Parse lateral ocelli present
if (auto element = ocelli_element->find("lateral_ocelli_present"); element != ocelli_element->end())
ocelli->lateral_ocelli_present = element->get<bool>();
// Parse median ocellus present
if (auto element = ocelli_element->find("median_ocellus_present"); element != ocelli_element->end())
ocelli->median_ocellus_present = element->get<bool>();
// Parse width
if (auto element = ocelli_element->find("width"); element != ocelli_element->end())
ocelli->width = element->get<float>();
// Parse height
if (auto element = ocelli_element->find("height"); element != ocelli_element->end())
ocelli->height = element->get<float>();
// Load lateral ocelli model, if present
if (ocelli->lateral_ocelli_present)
{
auto lateral_ocelli_model_element = ocelli_element->find("lateral_ocelli_model");
if (lateral_ocelli_model_element == ocelli_element->end() || lateral_ocelli_model_element->is_null())
throw std::runtime_error("Ocelli trait doesn't specify lateral ocelli model.");
ocelli->lateral_ocelli_model = resource_manager->load<render::model>(lateral_ocelli_model_element->get<std::string>());
}
// Load median ocellus model, if present
if (ocelli->median_ocellus_present)
{
auto median_ocellus_model_element = ocelli_element->find("median_ocellus_model");
if (median_ocellus_model_element == ocelli_element->end() || median_ocellus_model_element->is_null())
throw std::runtime_error("Ocelli trait doesn't specify median ocellus model.");
ocelli->median_ocellus_model = resource_manager->load<render::model>(median_ocellus_model_element->get<std::string>());
}
// Free JSON data
delete data;
return ocelli;
}

+ 0
- 98
src/game/ant/trait/loader/waist-loader.cpp View File

@ -1,98 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/waist.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
template <>
trait::waist* resource_loader<trait::waist>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
auto waist_element = data->find("waist");
if (waist_element == data->end())
throw std::runtime_error("Invalid waist trait.");
// Allocate and init waist trait
trait::waist* waist = new trait::waist();
waist->model = nullptr;
waist->petiole_present = false;
waist->petiole_length = 0.0f;
waist->petiole_width = 0.0f;
waist->petiole_height = 0.0f;
waist->petiole_spinescence = 0.0f;
waist->postpetiole_present = false;
waist->postpetiole_length = 0.0f;
waist->postpetiole_width = 0.0f;
waist->postpetiole_height = 0.0f;
waist->postpetiole_spinescence = 0.0f;
// Parse petiole present
if (auto element = waist_element->find("petiole_present"); element != waist_element->end())
waist->petiole_present = element->get<bool>();
if (waist->petiole_present)
{
// Parse petiole properties
if (auto element = waist_element->find("petiole_length"); element != waist_element->end())
waist->petiole_length = element->get<float>();
if (auto element = waist_element->find("petiole_width"); element != waist_element->end())
waist->petiole_width = element->get<float>();
if (auto element = waist_element->find("petiole_height"); element != waist_element->end())
waist->petiole_height = element->get<float>();
if (auto element = waist_element->find("petiole_spinescence"); element != waist_element->end())
waist->petiole_spinescence = element->get<float>();
// Parse postpetiole present
if (auto element = waist_element->find("postpetiole_present"); element != waist_element->end())
waist->postpetiole_present = element->get<bool>();
if (waist->postpetiole_present)
{
// Parse postpetiole properties
if (auto element = waist_element->find("postpetiole_length"); element != waist_element->end())
waist->postpetiole_length = element->get<float>();
if (auto element = waist_element->find("postpetiole_width"); element != waist_element->end())
waist->postpetiole_width = element->get<float>();
if (auto element = waist_element->find("postpetiole_height"); element != waist_element->end())
waist->postpetiole_height = element->get<float>();
if (auto element = waist_element->find("postpetiole_spinescence"); element != waist_element->end())
waist->postpetiole_spinescence = element->get<float>();
}
// Load waist model
auto model_element = waist_element->find("model");
if (model_element == waist_element->end())
throw std::runtime_error("Waist trait doesn't specify waist model.");
waist->model = resource_manager->load<render::model>(model_element->get<std::string>());
}
// Free JSON data
delete data;
return waist;
}

+ 0
- 99
src/game/ant/trait/loader/wings-loader.cpp View File

@ -1,99 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/json.hpp"
#include "game/ant/trait/wings.hpp"
#include "render/model.hpp"
#include <stdexcept>
using namespace game::ant;
template <>
trait::wings* resource_loader<trait::wings>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
{
// Load JSON data
json* data = resource_loader<json>::load(resource_manager, file, path);
// Validate trait file
auto wings_element = data->find("wings");
if (wings_element == data->end())
throw std::runtime_error("Invalid wings trait.");
// Allocate and init wings trait
trait::wings* wings = new trait::wings();
wings->forewings_model = nullptr;
wings->hindwings_model = nullptr;
wings->present = false;
wings->forewing_length = 0.0f;
wings->forewing_width = 0.0f;
wings->forewing_venation = 0.0f;
wings->hindwing_length = 0.0f;
wings->hindwing_width = 0.0f;
wings->hindwing_venation = 0.0f;
// Parse wings present
if (auto present_element = wings_element->find("present"); present_element != wings_element->end())
wings->present = present_element->get<bool>();
if (wings->present)
{
// Load forewings model
auto forewings_model_element = wings_element->find("forewings_model");
if (forewings_model_element == wings_element->end())
throw std::runtime_error("Wings trait doesn't specify forewings model.");
wings->forewings_model = resource_manager->load<render::model>(forewings_model_element->get<std::string>());
// Load hindwings model
auto hindwings_model_element = wings_element->find("hindwings_model");
if (hindwings_model_element == wings_element->end())
throw std::runtime_error("Wings trait doesn't specify hindwings model.");
wings->hindwings_model = resource_manager->load<render::model>(hindwings_model_element->get<std::string>());
// Parse forewing length
if (auto element = wings_element->find("forewing_length"); element != wings_element->end())
wings->forewing_length = element->get<float>();
// Parse forewing width
if (auto element = wings_element->find("forewing_width"); element != wings_element->end())
wings->forewing_width = element->get<float>();
// Parse forewing venation
if (auto element = wings_element->find("forewing_venation"); element != wings_element->end())
wings->forewing_venation = element->get<float>();
// Parse hindwing length
if (auto element = wings_element->find("hindwing_length"); element != wings_element->end())
wings->hindwing_length = element->get<float>();
// Parse hindwing width
if (auto element = wings_element->find("hindwing_width"); element != wings_element->end())
wings->hindwing_width = element->get<float>();
// Parse hindwing venation
if (auto element = wings_element->find("hindwing_venation"); element != wings_element->end())
wings->hindwing_venation = element->get<float>();
}
// Free JSON data
delete data;
return wings;
}

+ 0
- 46
src/game/ant/trait/size-variation.hpp View File

@ -1,46 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_ANT_TRAIT_SIZE_VARIATION_HPP
#define ANTKEEPER_GAME_ANT_TRAIT_SIZE_VARIATION_HPP
namespace game {
namespace ant {
namespace trait {
/**
* Caste size variation description.
*/
struct size_variation
{
/// Minimum size factor.
float min_size;
/// Maximum size factor.
float max_size;
/// Mean size factor.
float mean_size;
};
} // namespace trait
} // namespace ant
} // namespace game
#endif // ANTKEEPER_GAME_ANT_TRAIT_SIZE_VARIATION_HPP

+ 0
- 1
src/game/load.cpp View File

@ -29,7 +29,6 @@
#include "render/passes/ground-pass.hpp"
#include "game/system/astronomy.hpp"
#include "game/system/terrain.hpp"
#include "math/random.hpp"
#include "math/noise/noise.hpp"
#include "math/hash/hash.hpp"
#include <fstream>

+ 23
- 23
src/game/state/nest-selection.cpp View File

@ -54,7 +54,8 @@
#include <iostream>
#include "game/ant/morphogenesis.hpp"
#include "game/ant/species.hpp"
#include "game/ant/phenome.hpp"
#include "game/ant/genome.hpp"
using namespace game::ant;
@ -67,31 +68,30 @@ nest_selection::nest_selection(game::context& ctx):
ctx.logger->push_task("Entering nest selection state");
ctx.logger->push_task("Loading worker caste");
ant::species species;
ant::caste& worker_caste = *species.worker_caste;
worker_caste.type = ant::caste_type::worker;
worker_caste.antennae = ctx.resource_manager->load<ant::trait::antennae>("pogonomyrmex-female-antennae.dna");
worker_caste.eyes = ctx.resource_manager->load<ant::trait::eyes>("pogonomyrmex-eyes.dna");
worker_caste.gaster = ctx.resource_manager->load<ant::trait::gaster>("pogonomyrmex-worker-gaster.dna");
worker_caste.head = ctx.resource_manager->load<ant::trait::head>("pogonomyrmex-head.dna");
worker_caste.legs = ctx.resource_manager->load<ant::trait::legs>("pogonomyrmex-legs.dna");
worker_caste.mandibles = ctx.resource_manager->load<ant::trait::mandibles>("pogonomyrmex-mandibles.dna");
worker_caste.mesosoma = ctx.resource_manager->load<ant::trait::mesosoma>("pogonomyrmex-worker-mesosoma.dna");
worker_caste.ocelli = ctx.resource_manager->load<ant::trait::ocelli>("ocelli-absent.dna");
worker_caste.pigmentation = ctx.resource_manager->load<ant::trait::pigmentation>("rust-pigmentation.dna");
worker_caste.sculpturing = ctx.resource_manager->load<ant::trait::sculpturing>("politus-sculpturing.dna");
//worker_caste.size_variation = ctx.resource_manager->load<ant::trait::size_variation>(...);
worker_caste.sting = ctx.resource_manager->load<ant::trait::sting>("pogonomyrmex-sting.dna");
worker_caste.waist = ctx.resource_manager->load<ant::trait::waist>("pogonomyrmex-waist.dna");
worker_caste.wings = ctx.resource_manager->load<ant::trait::wings>("wings-absent.dna");
render::model* worker_model = ant::morphogenesis(worker_caste);
ctx.logger->push_task("Loading genome");
ant::genome genome;
genome.antennae = ctx.resource_manager->load<ant::gene::antennae>("pogonomyrmex-antennae.dna");
genome.eyes = ctx.resource_manager->load<ant::gene::eyes>("pogonomyrmex-eyes.dna");
genome.gaster = ctx.resource_manager->load<ant::gene::gaster>("pogonomyrmex-gaster.dna");
genome.head = ctx.resource_manager->load<ant::gene::head>("pogonomyrmex-head.dna");
genome.legs = ctx.resource_manager->load<ant::gene::legs>("pogonomyrmex-legs.dna");
genome.mandibles = ctx.resource_manager->load<ant::gene::mandibles>("pogonomyrmex-mandibles.dna");
genome.mesosoma = ctx.resource_manager->load<ant::gene::mesosoma>("pogonomyrmex-mesosoma.dna");
genome.ocelli = ctx.resource_manager->load<ant::gene::ocelli>("ocelli-absent.dna");
genome.pigmentation = ctx.resource_manager->load<ant::gene::pigmentation>("rust-pigmentation.dna");
genome.sculpturing = ctx.resource_manager->load<ant::gene::sculpturing>("politus-sculpturing.dna");
genome.sting = ctx.resource_manager->load<ant::gene::sting>("pogonomyrmex-sting.dna");
genome.waist = ctx.resource_manager->load<ant::gene::waist>("pogonomyrmex-waist.dna");
genome.wings = ctx.resource_manager->load<ant::gene::wings>("wings-absent.dna");
ctx.logger->pop_task(EXIT_SUCCESS);
ctx.logger->push_task("Building worker phenome");
ant::phenome worker_phenome = ant::phenome(genome, ant::caste::worker);
ctx.logger->pop_task(EXIT_SUCCESS);
ctx.logger->push_task("Generating worker model");
render::model* worker_model = ant::morphogenesis(worker_phenome);
ctx.logger->pop_task(EXIT_SUCCESS);
// Create worker entity(s)
entity::id worker_eid = ctx.entity_registry->create();

+ 0
- 1
src/math/math.hpp View File

@ -36,7 +36,6 @@ namespace math {}
#include "math/constants.hpp"
#include "math/quadrature.hpp"
#include "math/interpolation.hpp"
#include "math/random.hpp"
#include "math/map.hpp"
#include "math/projection.hpp"

Loading…
Cancel
Save