@ -0,0 +1,40 @@ | |||||
/* | |||||
* 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_ENTITY_COMPONENT_STEERING_HPP | |||||
#define ANTKEEPER_ENTITY_COMPONENT_STEERING_HPP | |||||
#include "utility/fundamental-types.hpp" | |||||
namespace entity { | |||||
namespace component { | |||||
struct steering | |||||
{ | |||||
float3 velocity; | |||||
float3 acceleration; | |||||
float max_force; | |||||
float max_speed; | |||||
}; | |||||
} // namespace component | |||||
} // namespace entity | |||||
#endif // ANTKEEPER_ENTITY_COMPONENT_STEERING_HPP | |||||
@ -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 "entity/systems/steering.hpp" | |||||
#include "entity/components/steering.hpp" | |||||
#include "entity/components/transform.hpp" | |||||
#include "entity/id.hpp" | |||||
namespace entity { | |||||
namespace system { | |||||
steering::steering(entity::registry& registry): | |||||
updatable(registry) | |||||
{} | |||||
void steering::update(double t, double dt) | |||||
{ | |||||
registry.view<component::transform, component::steering>().each( | |||||
[&](entity::id entity_id, auto& transform, auto& boid) | |||||
{ | |||||
// Accelerate | |||||
boid.velocity += boid.acceleration; | |||||
if (math::dot(boid.velocity, boid.velocity) > boid.max_speed * boid.max_speed) | |||||
{ | |||||
boid.velocity = math::normalize(boid.velocity) * boid.max_speed; | |||||
} | |||||
// Clear acceleration | |||||
boid.acceleration = {0, 0, 0}; | |||||
// Move | |||||
transform.local.translation += boid.velocity; | |||||
}); | |||||
} | |||||
void steering::wander() | |||||
{ | |||||
} | |||||
} // namespace system | |||||
} // namespace entity |
@ -0,0 +1,42 @@ | |||||
/* | |||||
* 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_ENTITY_SYSTEM_STEERING_HPP | |||||
#define ANTKEEPER_ENTITY_SYSTEM_STEERING_HPP | |||||
#include "entity/systems/updatable.hpp" | |||||
namespace entity { | |||||
namespace system { | |||||
class steering: | |||||
public updatable | |||||
{ | |||||
public: | |||||
steering(entity::registry& registry); | |||||
virtual void update(double t, double dt); | |||||
private: | |||||
void wander(); | |||||
}; | |||||
} // namespace system | |||||
} // namespace entity | |||||
#endif // ANTKEEPER_ENTITY_SYSTEM_STEERING_HPP |
@ -0,0 +1,82 @@ | |||||
/* | |||||
* 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_BREED_HPP | |||||
#define ANTKEEPER_GAME_ANT_BREED_HPP | |||||
#include "game/ant/trait/antennae.hpp" | |||||
#include "game/ant/trait/cocoon.hpp" | |||||
#include "game/ant/trait/diet.hpp" | |||||
#include "game/ant/trait/egg.hpp" | |||||
#include "game/ant/trait/eyes.hpp" | |||||
#include "game/ant/trait/foraging-time.hpp" | |||||
#include "game/ant/trait/forewings.hpp" | |||||
#include "game/ant/trait/gaster.hpp" | |||||
#include "game/ant/trait/head.hpp" | |||||
#include "game/ant/trait/hindwings.hpp" | |||||
#include "game/ant/trait/larva.hpp" | |||||
#include "game/ant/trait/legs.hpp" | |||||
#include "game/ant/trait/mandibles.hpp" | |||||
#include "game/ant/trait/mesosoma.hpp" | |||||
#include "game/ant/trait/nest.hpp" | |||||
#include "game/ant/trait/ocelli.hpp" | |||||
#include "game/ant/trait/pigmentation.hpp" | |||||
#include "game/ant/trait/pilosity.hpp" | |||||
#include "game/ant/trait/sculpturing.hpp" | |||||
#include "game/ant/trait/sting.hpp" | |||||
#include "game/ant/trait/waist.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
/** | |||||
* Set of all traits that describes an ant breed. | |||||
*/ | |||||
struct breed | |||||
{ | |||||
// Morphological traits | |||||
trait::antennae* antennae; | |||||
trait::eyes* eyes; | |||||
trait::forewings* forewings; | |||||
trait::gaster* gaster; | |||||
trait::waist* waist; | |||||
trait::head* head; | |||||
trait::hindwings* hindwings; | |||||
trait::legs* legs; | |||||
trait::mandibles* mandibles; | |||||
trait::mesosoma* mesosoma; | |||||
trait::ocelli* ocelli; | |||||
trait::sting* sting; | |||||
trait::sculpturing* sculpturing; | |||||
trait::pigmentation* pigmentation; | |||||
trait::pilosity* pilosity; | |||||
trait::egg* egg; | |||||
trait::larva* larva; | |||||
trait::cocoon* cocoon; | |||||
// Behavioral traits | |||||
trait::diet* diet; | |||||
trait::foraging_time* foraging_time; | |||||
trait::nest* nest; | |||||
}; | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_BREED_HPP |
@ -0,0 +1,40 @@ | |||||
/* | |||||
* 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_CASTE_HPP | |||||
#define ANTKEEPER_GAME_ANT_CASTE_HPP | |||||
namespace game { | |||||
namespace ant { | |||||
/** | |||||
* Caste type enumerations | |||||
*/ | |||||
enum class caste | |||||
{ | |||||
queen, | |||||
worker, | |||||
soldier, | |||||
male | |||||
}; | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_CASTE_HPP |
@ -0,0 +1,35 @@ | |||||
/* | |||||
* 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_FOUNDING_MODE_HPP | |||||
#define ANTKEEPER_GAME_ANT_FOUNDING_MODE_HPP | |||||
namespace game { | |||||
namespace ant { | |||||
enum class founding_mode | |||||
{ | |||||
semi_claustral, | |||||
claustral | |||||
}; | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_FOUNDING_MODE_HPP |
@ -0,0 +1,148 @@ | |||||
/* | |||||
* 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/morphogenesis.hpp" | |||||
#include "render/material.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
static render::model* generate_queen(const ant::breed& breed); | |||||
static render::model* generate_worker(const ant::breed& breed); | |||||
static render::model* generate_soldier(const ant::breed& breed); | |||||
static render::model* generate_male(const ant::breed& breed); | |||||
static render::material* build_material(const ant::breed& breed); | |||||
static render::model* build_model | |||||
( | |||||
render::material* material, | |||||
render::model* antennae, | |||||
render::model* eyes, | |||||
render::model* forewings, | |||||
render::model* gaster, | |||||
render::model* head, | |||||
render::model* hindwings, | |||||
render::model* legs, | |||||
render::model* mandibles, | |||||
render::model* mesosoma, | |||||
render::model* ocelli, | |||||
render::model* sting, | |||||
render::model* waist | |||||
); | |||||
render::model* morphogenesis(const ant::breed& breed, ant::caste caste) | |||||
{ | |||||
switch (caste) | |||||
{ | |||||
case ant::caste::queen: | |||||
return generate_queen(breed); | |||||
case ant::caste::worker: | |||||
return generate_worker(breed); | |||||
case ant::caste::soldier: | |||||
return generate_soldier(breed); | |||||
case ant::caste::male: | |||||
return generate_male(breed); | |||||
} | |||||
return nullptr; | |||||
} | |||||
render::model* generate_queen(const ant::breed& breed) | |||||
{ | |||||
return nullptr; | |||||
} | |||||
render::model* generate_worker(const ant::breed& breed) | |||||
{ | |||||
// Get material parameters | |||||
// Build material | |||||
render::material* material = build_material(breed); | |||||
// Get worker body part models | |||||
render::model* antennae_model = breed.antennae->model; | |||||
render::model* eyes_model = breed.eyes->model; | |||||
render::model* gaster_model = breed.gaster->model; | |||||
render::model* head_model = breed.head->model; | |||||
render::model* legs_model = breed.legs->model; | |||||
render::model* mandibles_model = breed.mandibles->model; | |||||
render::model* mesosoma_model = breed.mesosoma->model; | |||||
render::model* sting_model = breed.sting->model; | |||||
render::model* waist_model = breed.waist->model; | |||||
// Build worker model | |||||
render::model* model = build_model | |||||
( | |||||
material, | |||||
antennae_model, | |||||
eyes_model, | |||||
nullptr, | |||||
gaster_model, | |||||
head_model, | |||||
nullptr, | |||||
legs_model, | |||||
mandibles_model, | |||||
mesosoma_model, | |||||
nullptr, | |||||
sting_model, | |||||
waist_model | |||||
); | |||||
return model; | |||||
} | |||||
render::model* generate_soldier(const ant::breed& breed) | |||||
{ | |||||
return nullptr; | |||||
} | |||||
render::model* generate_male(const ant::breed& breed) | |||||
{ | |||||
return nullptr; | |||||
} | |||||
render::material* build_material(const ant::breed& breed) | |||||
{ | |||||
return nullptr; | |||||
} | |||||
render::model* build_model | |||||
( | |||||
render::material* material, | |||||
render::model* antennae, | |||||
render::model* eyes, | |||||
render::model* forewings, | |||||
render::model* gaster, | |||||
render::model* head, | |||||
render::model* hindwings, | |||||
render::model* legs, | |||||
render::model* mandibles, | |||||
render::model* mesosoma, | |||||
render::model* ocelli, | |||||
render::model* sting, | |||||
render::model* waist | |||||
) | |||||
{ | |||||
return nullptr; | |||||
} | |||||
} // namespace ant | |||||
} // namespace game |
@ -0,0 +1,42 @@ | |||||
/* | |||||
* 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_MORPHOGENESIS_HPP | |||||
#define ANTKEEPER_GAME_ANT_MORPHOGENESIS_HPP | |||||
#include "game/ant/breed.hpp" | |||||
#include "game/ant/caste.hpp" | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
/** | |||||
* Generates a 3D model of an ant. | |||||
* | |||||
* @param breed Breed of the ant. | |||||
* @param caste Caste to which the ant belongs. | |||||
* @return 3D model of an ant. | |||||
*/ | |||||
render::model* morphogenesis(const ant::breed& breed, ant::caste caste); | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_MORPHOGENESIS_HPP |
@ -0,0 +1,38 @@ | |||||
/* | |||||
* 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_NEST_SITE_HPP | |||||
#define ANTKEEPER_GAME_ANT_NEST_SITE_HPP | |||||
namespace game { | |||||
namespace ant { | |||||
/** | |||||
* Nest site enumerations. | |||||
*/ | |||||
enum class nest_site | |||||
{ | |||||
hypogeic, | |||||
arboreal | |||||
}; | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_NEST_SITE_HPP |
@ -0,0 +1,59 @@ | |||||
/* | |||||
* 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_SUBCASTE_HPP | |||||
#define ANTKEEPER_GAME_ANT_SUBCASTE_HPP | |||||
namespace game { | |||||
namespace ant { | |||||
/** | |||||
* Ant subcaste types. | |||||
*/ | |||||
enum class subcaste | |||||
{ | |||||
/// A worker from the queen's first batch of eggs, smaller than normal workers. | |||||
nanitic, | |||||
/// A small worker or soldier. | |||||
minor, | |||||
/// A normal-sized worker or soldier | |||||
media, | |||||
/// A large worker or soldier. | |||||
major, | |||||
/// A queen or male which still has its wings. | |||||
alate, | |||||
/// A queen or male which has shed its wings. | |||||
dealate, | |||||
/// A queen or male which does not develop wings. | |||||
ergatoid, | |||||
/// A queen or male with short, nonfunctional wings. | |||||
brachypterous | |||||
}; | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_SUBCASTE_HPP |
@ -0,0 +1,45 @@ | |||||
/* | |||||
* 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_ANTENNAE_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_ANTENNAE_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the antennae of an ant. | |||||
*/ | |||||
struct antennae | |||||
{ | |||||
/// Scape length (SL), measured in mesosomal lengths. | |||||
float scape_length; | |||||
/// 3D model of the antennae. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_ANTENNAE_HPP |
@ -0,0 +1,45 @@ | |||||
/* | |||||
* 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_COCOON_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_COCOON_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the cocoon of an ant species. | |||||
*/ | |||||
struct cocoon | |||||
{ | |||||
/// Indicates whether a cocoon is formed by the larvae or not. | |||||
bool present; | |||||
/// 3D model of the cocoon, if present. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_COCOON_HPP |
@ -0,0 +1,55 @@ | |||||
/* | |||||
* 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_DIET_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_DIET_HPP | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the diet of an ant. | |||||
*/ | |||||
struct diet | |||||
{ | |||||
/// Preference for eating seeds. | |||||
float seeds; | |||||
/// Preference for eating ant brood. | |||||
float ant_brood; | |||||
/// Preference for eating arthropod eggs. | |||||
float arthropod_eggs; | |||||
/// Preference for eating nectar. | |||||
float nectar; | |||||
/// Preference for eating fungi. | |||||
float fungi; | |||||
/// Preference for eating carrion. | |||||
float carrion; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_DIET_HPP |
@ -0,0 +1,42 @@ | |||||
/* | |||||
* 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_EGG_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_EGG_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the eggs of an ant species. | |||||
*/ | |||||
struct egg | |||||
{ | |||||
/// 3D model of the egg. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_EGG_HPP |
@ -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/>. | |||||
*/ | |||||
#ifndef ANTKEEPER_GAME_ANT_TRAIT_EYES_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_EYES_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the eyes of an ant. | |||||
*/ | |||||
struct eyes | |||||
{ | |||||
/// Eye length (EL), measured in mesosomal lengths. | |||||
float length; | |||||
/// Eye width (EW), measured in mesosomal lengths. | |||||
float width; | |||||
/// Number of ommatidia. | |||||
int ommatidia; | |||||
/// 3D model of the eyes. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_EYES_HPP |
@ -0,0 +1,45 @@ | |||||
/* | |||||
* 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_FORAGING_TIME_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_FORAGING_TIME_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the surface foraging time of an ant. | |||||
*/ | |||||
struct foraging_time | |||||
{ | |||||
/// Minimum solar altitude at which foraging occurs. | |||||
float solar_altitude_min; | |||||
/// Maximum solar alttiude at which foraging occurs. | |||||
float solar_altitude_max; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_FORAGING_TIME_HPP |
@ -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/>. | |||||
*/ | |||||
#ifndef ANTKEEPER_GAME_ANT_TRAIT_FOREWINGS_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_FOREWINGS_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the forewings of an ant. | |||||
*/ | |||||
struct forewings | |||||
{ | |||||
/// Wing length, measured in mesosomal lengths. | |||||
float length; | |||||
/// Wing width, measured in mesosomal lengths. | |||||
float width; | |||||
/// Degree of venation. A value of `1.0` indicates a highly-developed venation pattern, while `0.0` indicates a complete absence of visible venation. | |||||
float venation; | |||||
/// 3D model of the forewings. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_FOREWINGS_HPP |
@ -0,0 +1,42 @@ | |||||
/* | |||||
* 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_GASTER_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_GASTER_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the gaster of an ant. | |||||
*/ | |||||
struct gaster | |||||
{ | |||||
/// 3D model of the gaster. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_GASTER_HPP |
@ -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/>. | |||||
*/ | |||||
#ifndef ANTKEEPER_GAME_ANT_TRAIT_HEAD_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_HEAD_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the head of an ant. | |||||
*/ | |||||
struct head | |||||
{ | |||||
/// Head length in full face view (HL), measured in mesosomal lengths. | |||||
float length; | |||||
/// Head width in full face view (HW), measured in mesosomal lengths. | |||||
float width; | |||||
/// Indicates whether the head can be used to plug nest entrances. | |||||
bool phragmotic; | |||||
/// 3D model of the head. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_HEAD_HPP |
@ -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/>. | |||||
*/ | |||||
#ifndef ANTKEEPER_GAME_ANT_TRAIT_HINDWINGS_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_HINDWINGS_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the hindwings of an ant. | |||||
*/ | |||||
struct hindwings | |||||
{ | |||||
/// Wing length, measured in mesosomal lengths. | |||||
float length; | |||||
/// Wing width, measured in mesosomal lengths. | |||||
float width; | |||||
/// Degree of venation. A value of `1.0` indicates a highly-developed venation pattern, while `0.0` indicates a complete absence of visible venation. | |||||
float venation; | |||||
/// 3D model of the hindwings. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_HINDWINGS_HPP |
@ -0,0 +1,45 @@ | |||||
/* | |||||
* 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_LARVA_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_LARVA_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the larvae of an ant species. | |||||
*/ | |||||
struct larva | |||||
{ | |||||
/// Number of larval instars before pupation. | |||||
int instars; | |||||
/// 3D model of the larva. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_LARVA_HPP |
@ -0,0 +1,45 @@ | |||||
/* | |||||
* 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_LEGS_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_LEGS_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the legs of an ant. | |||||
*/ | |||||
struct legs | |||||
{ | |||||
/// Running speed, measured in mesosomal lengths per second (ML/s). | |||||
float speed; | |||||
/// 3D model of the legs. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_LEGS_HPP |
@ -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 "resources/resource-loader.hpp" | |||||
#include "resources/resource-manager.hpp" | |||||
#include "resources/json.hpp" | |||||
#include "game/ant/trait/antennae.hpp" | |||||
#include "render/model.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::antennae* resource_loader<trait::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 | |||||
auto antennae_element = data->find("antennae"); | |||||
if (antennae_element == data->end()) | |||||
throw std::runtime_error("Invalid antennae trait."); | |||||
// Allocate antennae trait | |||||
trait::antennae* antennae = new trait::antennae(); | |||||
// 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>()); | |||||
// Parse antennae scape length | |||||
antennae->scape_length = 0.0f; | |||||
if (auto scape_length_element = antennae_element->find("scape_length"); scape_length_element != antennae_element->end()) | |||||
antennae->scape_length = scape_length_element->get<float>(); | |||||
// Free JSON data | |||||
delete data; | |||||
return antennae; | |||||
} |
@ -0,0 +1,65 @@ | |||||
/* | |||||
* 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/cocoon.hpp" | |||||
#include "render/model.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::cocoon* resource_loader<trait::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 | |||||
auto cocoon_element = data->find("cocoon"); | |||||
if (cocoon_element == data->end()) | |||||
throw std::runtime_error("Invalid cocoon trait."); | |||||
// Allocate cocoon trait | |||||
trait::cocoon* cocoon = new trait::cocoon(); | |||||
// Parse cocoon present | |||||
cocoon->present = false; | |||||
if (auto present_element = cocoon_element->find("present"); present_element != cocoon_element->end()) | |||||
cocoon->present = present_element->get<bool>(); | |||||
// 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>()); | |||||
} | |||||
else | |||||
{ | |||||
cocoon->model = nullptr; | |||||
} | |||||
// Free JSON data | |||||
delete data; | |||||
return cocoon; | |||||
} |
@ -0,0 +1,53 @@ | |||||
/* | |||||
* 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/egg.hpp" | |||||
#include "render/model.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::egg* resource_loader<trait::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 | |||||
auto egg_element = data->find("egg"); | |||||
if (egg_element == data->end()) | |||||
throw std::runtime_error("Invalid egg trait."); | |||||
// Allocate egg trait | |||||
trait::egg* egg = new trait::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>()); | |||||
// Free JSON data | |||||
delete data; | |||||
return egg; | |||||
} |
@ -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 "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 eyes trait | |||||
trait::eyes* eyes = new trait::eyes(); | |||||
// Load eyes model (if not null) | |||||
auto model_element = eyes_element->find("model"); | |||||
if (model_element == eyes_element->end()) | |||||
throw std::runtime_error("Eyes trait doesn't specify eyes model."); | |||||
if (model_element->is_null()) | |||||
{ | |||||
eyes->model = nullptr; | |||||
} | |||||
else | |||||
{ | |||||
eyes->model = resource_manager->load<render::model>(model_element->get<std::string>()); | |||||
} | |||||
// Parse eyes length | |||||
eyes->length = 0.0f; | |||||
if (auto length_element = eyes_element->find("length"); length_element != eyes_element->end()) | |||||
eyes->length = length_element->get<float>(); | |||||
// Parse eyes width | |||||
eyes->width = 0.0f; | |||||
if (auto width_element = eyes_element->find("width"); width_element != eyes_element->end()) | |||||
eyes->width = width_element->get<float>(); | |||||
// Parse eyes ommatidia | |||||
eyes->ommatidia = 0; | |||||
if (auto ommatidia_element = eyes_element->find("ommatidia"); ommatidia_element != eyes_element->end()) | |||||
eyes->ommatidia = ommatidia_element->get<int>(); | |||||
// Free JSON data | |||||
delete data; | |||||
return eyes; | |||||
} |
@ -0,0 +1,54 @@ | |||||
/* | |||||
* 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/foraging-time.hpp" | |||||
#include "math/angles.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::foraging_time* resource_loader<trait::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); | |||||
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."); | |||||
if (!solar_altitude_element->is_array() || solar_altitude_element->size() != 2) | |||||
throw std::runtime_error("Foraging time trait solar altitude must contain two values."); | |||||
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>()); | |||||
// Free JSON data | |||||
delete data; | |||||
return foraging_time; | |||||
} |
@ -0,0 +1,53 @@ | |||||
/* | |||||
* 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/gaster.hpp" | |||||
#include "render/model.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::gaster* resource_loader<trait::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 | |||||
auto gaster_element = data->find("gaster"); | |||||
if (gaster_element == data->end()) | |||||
throw std::runtime_error("Invalid gaster trait."); | |||||
// Allocate gaster trait | |||||
trait::gaster* gaster = new trait::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>()); | |||||
// Free JSON data | |||||
delete data; | |||||
return gaster; | |||||
} |
@ -0,0 +1,68 @@ | |||||
/* | |||||
* 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/head.hpp" | |||||
#include "render/model.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::head* resource_loader<trait::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 | |||||
auto head_element = data->find("head"); | |||||
if (head_element == data->end()) | |||||
throw std::runtime_error("Invalid head trait."); | |||||
// Allocate head trait | |||||
trait::head* head = new trait::head(); | |||||
// Load head 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>()); | |||||
// Parse head length | |||||
head->length = 0.0f; | |||||
if (auto length_element = head_element->find("length"); length_element != head_element->end()) | |||||
head->length = length_element->get<float>(); | |||||
// Parse head width | |||||
head->width = 0.0f; | |||||
if (auto width_element = head_element->find("width"); width_element != head_element->end()) | |||||
head->width = width_element->get<float>(); | |||||
// Parse head phragmotic | |||||
head->phragmotic = false; | |||||
if (auto phragmotic_element = head_element->find("phragmotic"); phragmotic_element != head_element->end()) | |||||
head->phragmotic = phragmotic_element->get<bool>(); | |||||
// Free JSON data | |||||
delete data; | |||||
return head; | |||||
} |
@ -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 "resources/resource-loader.hpp" | |||||
#include "resources/resource-manager.hpp" | |||||
#include "resources/json.hpp" | |||||
#include "game/ant/trait/larva.hpp" | |||||
#include "render/model.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::larva* resource_loader<trait::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 | |||||
auto larva_element = data->find("larva"); | |||||
if (larva_element == data->end()) | |||||
throw std::runtime_error("Invalid larva trait."); | |||||
// Allocate larva trait | |||||
trait::larva* larva = new trait::larva(); | |||||
// Load larva 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>()); | |||||
// Parse larva instars | |||||
larva->instars = 0; | |||||
if (auto instars_element = larva_element->find("instars"); instars_element != larva_element->end()) | |||||
larva->instars = instars_element->get<int>(); | |||||
// Free JSON data | |||||
delete data; | |||||
return larva; | |||||
} |
@ -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 "resources/resource-loader.hpp" | |||||
#include "resources/resource-manager.hpp" | |||||
#include "resources/json.hpp" | |||||
#include "game/ant/trait/legs.hpp" | |||||
#include "render/model.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::legs* resource_loader<trait::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 | |||||
auto legs_element = data->find("legs"); | |||||
if (legs_element == data->end()) | |||||
throw std::runtime_error("Invalid legs trait."); | |||||
// Allocate legs trait | |||||
trait::legs* legs = new trait::legs(); | |||||
// Load legs 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>()); | |||||
// Parse legs speed | |||||
legs->speed = 0.0f; | |||||
if (auto speed_element = legs_element->find("speed"); speed_element != legs_element->end()) | |||||
legs->speed = speed_element->get<float>(); | |||||
// Free JSON data | |||||
delete data; | |||||
return legs; | |||||
} |
@ -0,0 +1,63 @@ | |||||
/* | |||||
* 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 mandibles trait | |||||
trait::mandibles* mandibles = new trait::mandibles(); | |||||
// Load mandibles 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 mandibles length | |||||
mandibles->length = 0.0f; | |||||
if (auto length_element = mandibles_element->find("length"); length_element != mandibles_element->end()) | |||||
mandibles->length = length_element->get<float>(); | |||||
// Parse mandibles locking | |||||
mandibles->locking = false; | |||||
if (auto locking_element = mandibles_element->find("locking"); locking_element != mandibles_element->end()) | |||||
mandibles->locking = locking_element->get<bool>(); | |||||
// Free JSON data | |||||
delete data; | |||||
return mandibles; | |||||
} |
@ -0,0 +1,68 @@ | |||||
/* | |||||
* 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 mesosoma trait | |||||
trait::mesosoma* mesosoma = new trait::mesosoma(); | |||||
// 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 mesosoma length | |||||
mesosoma->length = 0.0f; | |||||
if (auto length_element = mesosoma_element->find("length"); length_element != mesosoma_element->end()) | |||||
mesosoma->length = length_element->get<float>(); | |||||
// Parse mesosoma width | |||||
mesosoma->width = 0.0f; | |||||
if (auto width_element = mesosoma_element->find("width"); width_element != mesosoma_element->end()) | |||||
mesosoma->width = width_element->get<float>(); | |||||
// Parse mesosoma spinescence | |||||
mesosoma->spinescence = 0.0f; | |||||
if (auto spinescence_element = mesosoma_element->find("spinescence"); spinescence_element != mesosoma_element->end()) | |||||
mesosoma->spinescence = spinescence_element->get<float>(); | |||||
// Free JSON data | |||||
delete data; | |||||
return mesosoma; | |||||
} |
@ -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 "resources/resource-loader.hpp" | |||||
#include "resources/resource-manager.hpp" | |||||
#include "resources/json.hpp" | |||||
#include "game/ant/trait/nest.hpp" | |||||
#include "game/ant/nest-site.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::nest* resource_loader<trait::nest>::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 nest_element = data->find("nest"); | |||||
if (nest_element == data->end()) | |||||
throw std::runtime_error("Invalid nest trait."); | |||||
// Allocate nest trait | |||||
trait::nest* nest = new trait::nest(); | |||||
// Parse nest site | |||||
nest->site = nest_site::hypogeic; | |||||
if (auto site_element = nest_element->find("site"); site_element != nest_element->end()) | |||||
{ | |||||
std::string site = site_element->get<std::string>(); | |||||
if (site == "hypogeic") | |||||
nest->site = nest_site::hypogeic; | |||||
else if (site == "arboreal") | |||||
nest->site = nest_site::arboreal; | |||||
} | |||||
// Free JSON data | |||||
delete data; | |||||
return nest; | |||||
} |
@ -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 "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 ocelli trait | |||||
trait::ocelli* ocelli = new trait::ocelli(); | |||||
// Load ocelli model (if not null) | |||||
auto model_element = ocelli_element->find("model"); | |||||
if (model_element == ocelli_element->end()) | |||||
throw std::runtime_error("Ocelli trait doesn't specify ocelli model."); | |||||
if (model_element->is_null()) | |||||
{ | |||||
ocelli->model = nullptr; | |||||
} | |||||
else | |||||
{ | |||||
ocelli->model = resource_manager->load<render::model>(model_element->get<std::string>()); | |||||
} | |||||
// Parse median ocellus | |||||
ocelli->median_ocellus = false; | |||||
if (auto median_ocellus_element = ocelli_element->find("median_ocellus"); median_ocellus_element != ocelli_element->end()) | |||||
ocelli->median_ocellus = median_ocellus_element->get<bool>(); | |||||
// Parse lateral ocelli | |||||
ocelli->lateral_ocelli = false; | |||||
if (auto lateral_ocelli_element = ocelli_element->find("lateral_ocelli"); lateral_ocelli_element != ocelli_element->end()) | |||||
ocelli->lateral_ocelli = lateral_ocelli_element->get<bool>(); | |||||
// Parse ocelli width | |||||
ocelli->width = 0.0f; | |||||
if (auto width_element = ocelli_element->find("width"); width_element != ocelli_element->end()) | |||||
ocelli->width = width_element->get<float>(); | |||||
// Parse ocelli height | |||||
ocelli->height = 0.0f; | |||||
if (auto height_element = ocelli_element->find("height"); height_element != ocelli_element->end()) | |||||
ocelli->height = height_element->get<float>(); | |||||
// Free JSON data | |||||
delete data; | |||||
return ocelli; | |||||
} |
@ -0,0 +1,64 @@ | |||||
/* | |||||
* 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/pigmentation.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::pigmentation* resource_loader<trait::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 | |||||
auto pigmentation_element = data->find("pigmentation"); | |||||
if (pigmentation_element == data->end()) | |||||
throw std::runtime_error("Invalid pigmentation trait."); | |||||
// Allocate pigmentation trait | |||||
trait::pigmentation* pigmentation = new trait::pigmentation(); | |||||
// Parse pigmentation primary albedo | |||||
pigmentation->primary_albedo = {0.0, 0.0, 0.0}; | |||||
if (auto primary_albedo_element = pigmentation_element->find("primary_albedo"); primary_albedo_element != pigmentation_element->end()) | |||||
{ | |||||
pigmentation->primary_albedo.x = (*primary_albedo_element)[0].get<float>(); | |||||
pigmentation->primary_albedo.y = (*primary_albedo_element)[1].get<float>(); | |||||
pigmentation->primary_albedo.z = (*primary_albedo_element)[2].get<float>(); | |||||
} | |||||
// Parse pigmentation secondary albedo | |||||
pigmentation->secondary_albedo = {0.0, 0.0, 0.0}; | |||||
if (auto secondary_albedo_element = pigmentation_element->find("secondary_albedo"); secondary_albedo_element != pigmentation_element->end()) | |||||
{ | |||||
pigmentation->secondary_albedo.x = (*secondary_albedo_element)[0].get<float>(); | |||||
pigmentation->secondary_albedo.y = (*secondary_albedo_element)[1].get<float>(); | |||||
pigmentation->secondary_albedo.z = (*secondary_albedo_element)[2].get<float>(); | |||||
} | |||||
// Free JSON data | |||||
delete data; | |||||
return pigmentation; | |||||
} |
@ -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 "resources/resource-loader.hpp" | |||||
#include "resources/resource-manager.hpp" | |||||
#include "resources/json.hpp" | |||||
#include "game/ant/trait/pilosity.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::pilosity* resource_loader<trait::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 | |||||
auto pilosity_element = data->find("pilosity"); | |||||
if (pilosity_element == data->end()) | |||||
throw std::runtime_error("Invalid pilosity trait."); | |||||
// Allocate pilosity trait | |||||
trait::pilosity* pilosity = new trait::pilosity(); | |||||
// Parse pilosity density | |||||
pilosity->density = 0.0f; | |||||
if (auto density_element = pilosity_element->find("density"); density_element != pilosity_element->end()) | |||||
pilosity->density = density_element->get<float>(); | |||||
// Free JSON data | |||||
delete data; | |||||
return pilosity; | |||||
} |
@ -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 "resources/resource-loader.hpp" | |||||
#include "resources/resource-manager.hpp" | |||||
#include "resources/json.hpp" | |||||
#include "game/ant/trait/sculpturing.hpp" | |||||
#include "gl/texture-2d.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::sculpturing* resource_loader<trait::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 | |||||
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(); | |||||
// 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>()); | |||||
// 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>(); | |||||
// Free JSON data | |||||
delete data; | |||||
return sculpturing; | |||||
} |
@ -0,0 +1,65 @@ | |||||
/* | |||||
* 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/sting.hpp" | |||||
#include "render/model.hpp" | |||||
#include <stdexcept> | |||||
using namespace game::ant; | |||||
template <> | |||||
trait::sting* resource_loader<trait::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 | |||||
auto sting_element = data->find("sting"); | |||||
if (sting_element == data->end()) | |||||
throw std::runtime_error("Invalid sting trait."); | |||||
// Allocate sting trait | |||||
trait::sting* sting = new trait::sting(); | |||||
// Parse sting present | |||||
sting->present = false; | |||||
if (auto present_element = sting_element->find("present"); present_element != sting_element->end()) | |||||
sting->present = present_element->get<bool>(); | |||||
// 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>()); | |||||
} | |||||
else | |||||
{ | |||||
sting->model = nullptr; | |||||
} | |||||
// Free JSON data | |||||
delete data; | |||||
return sting; | |||||
} |
@ -0,0 +1,97 @@ | |||||
/* | |||||
* 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 waist trait | |||||
trait::waist* waist = new trait::waist(); | |||||
// 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>()); | |||||
// Parse waist spinescence | |||||
waist->spinescence = 0.0f; | |||||
if (auto spinescence_element = waist_element->find("spinescence"); spinescence_element != waist_element->end()) | |||||
waist->spinescence = spinescence_element->get<float>(); | |||||
// Parse waist petiole length | |||||
waist->petiole_length = 0.0f; | |||||
if (auto petiole_length_element = waist_element->find("petiole_length"); petiole_length_element != waist_element->end()) | |||||
waist->petiole_length = petiole_length_element->get<float>(); | |||||
// Parse waist petiole width | |||||
waist->petiole_width = 0.0f; | |||||
if (auto petiole_width_element = waist_element->find("petiole_width"); petiole_width_element != waist_element->end()) | |||||
waist->petiole_width = petiole_width_element->get<float>(); | |||||
// Parse waist petiole height | |||||
waist->petiole_height = 0.0f; | |||||
if (auto petiole_height_element = waist_element->find("petiole_height"); petiole_height_element != waist_element->end()) | |||||
waist->petiole_height = petiole_height_element->get<float>(); | |||||
// Parse waist postpetiole | |||||
waist->postpetiole = false; | |||||
if (auto postpetiole_element = waist_element->find("postpetiole"); postpetiole_element != waist_element->end()) | |||||
waist->postpetiole = postpetiole_element->get<bool>(); | |||||
waist->postpetiole_length = 0.0f; | |||||
waist->postpetiole_width = 0.0f; | |||||
waist->postpetiole_height = 0.0f; | |||||
if (waist->postpetiole) | |||||
{ | |||||
// Parse waist postpetiole length | |||||
if (auto postpetiole_length_element = waist_element->find("postpetiole_length"); postpetiole_length_element != waist_element->end()) | |||||
waist->postpetiole_length = postpetiole_length_element->get<float>(); | |||||
// Parse waist postpetiole width | |||||
if (auto postpetiole_width_element = waist_element->find("postpetiole_width"); postpetiole_width_element != waist_element->end()) | |||||
waist->postpetiole_width = postpetiole_width_element->get<float>(); | |||||
// Parse waist postpetiole height | |||||
if (auto postpetiole_height_element = waist_element->find("postpetiole_height"); postpetiole_height_element != waist_element->end()) | |||||
waist->postpetiole_height = postpetiole_height_element->get<float>(); | |||||
} | |||||
// Free JSON data | |||||
delete data; | |||||
return waist; | |||||
} |
@ -0,0 +1,48 @@ | |||||
/* | |||||
* 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_MANDIBLES_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_MANDIBLES_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the mandibles of an ant. | |||||
*/ | |||||
struct mandibles | |||||
{ | |||||
/// Length of the closed mandibles in full face view (MandL), measured in mesosomal lengths. | |||||
float length; | |||||
/// Indicates the mandibles are able to lock open, such as in trap-jaw ants. | |||||
bool locking; | |||||
/// 3D model of the mandibles. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_MANDIBLES_HPP |
@ -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/>. | |||||
*/ | |||||
#ifndef ANTKEEPER_GAME_ANT_TRAIT_MESOSOMA_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_MESOSOMA_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the mesosoma of an ant. | |||||
*/ | |||||
struct mesosoma | |||||
{ | |||||
/// Mesosoma length (ML), also known as the Weber's length (WL). | |||||
float length; | |||||
/// Pronotum width in dorsal view (PrW). | |||||
float width; | |||||
/// Degree of spinescence. | |||||
float spinescence; | |||||
/// 3D model of the mesosoma. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_MESOSOMA_HPP |
@ -0,0 +1,42 @@ | |||||
/* | |||||
* 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_NEST_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_NEST_HPP | |||||
#include "game/ant/nest-site.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the nest site of an ant. | |||||
*/ | |||||
struct nest | |||||
{ | |||||
/// Site of the nest. | |||||
game::ant::nest_site site; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_NEST_HPP |
@ -0,0 +1,54 @@ | |||||
/* | |||||
* 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_OCELLI_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_OCELLI_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the ocelli of an ant. | |||||
*/ | |||||
struct ocelli | |||||
{ | |||||
/// Median ocellus present. | |||||
bool median_ocellus; | |||||
/// Lateral ocelli present. | |||||
bool lateral_ocelli; | |||||
/// Ocellus width, in mesosomal lengths. | |||||
float width; | |||||
/// Ocellus height, in mesosomal lengths. | |||||
float height; | |||||
/// 3D model of the ocelli. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_OCELLI_HPP |
@ -0,0 +1,45 @@ | |||||
/* | |||||
* 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_PIGMENTATION_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_PIGMENTATION_HPP | |||||
#include "utility/fundamental-types.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the pigmentation of an ant. | |||||
*/ | |||||
struct pigmentation | |||||
{ | |||||
/// Primary albedo color. | |||||
float3 primary_albedo; | |||||
/// Secondary albedo color. | |||||
float3 secondary_albedo; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_PIGMENTATION_HPP |
@ -0,0 +1,40 @@ | |||||
/* | |||||
* 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_PILOSITY_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_PILOSITY_HPP | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the pilosity of an ant. | |||||
*/ | |||||
struct pilosity | |||||
{ | |||||
/// Hair density. | |||||
float density; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_PILOSITY_HPP |
@ -0,0 +1,45 @@ | |||||
/* | |||||
* 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_SCULPTURING_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_SCULPTURING_HPP | |||||
#include "gl/texture-2d.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the surface sculpturing of an ant. | |||||
*/ | |||||
struct sculpturing | |||||
{ | |||||
/// Surface roughness. | |||||
float roughness; | |||||
/// Surface culpturing normal map. | |||||
gl::texture_2d* normal_map; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_SCULPTURING_HPP |
@ -0,0 +1,40 @@ | |||||
/* | |||||
* 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_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_SIZE_HPP | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the sizes of an ant caste. | |||||
*/ | |||||
struct size | |||||
{ | |||||
/// Size-frequency distribution, with sizes measured in mesosomal lengths. | |||||
std::vector<std::tuple<float, float>> distribution; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_SIZE_HPP |
@ -0,0 +1,45 @@ | |||||
/* | |||||
* 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_STING_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_STING_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the sting of an ant. | |||||
*/ | |||||
struct sting | |||||
{ | |||||
/// Indicates whether a sting present or not. | |||||
bool present; | |||||
/// 3D model of the sting. | |||||
render::model* model; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_STING_HPP |
@ -0,0 +1,66 @@ | |||||
/* | |||||
* 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_WAIST_HPP | |||||
#define ANTKEEPER_GAME_ANT_TRAIT_WAIST_HPP | |||||
#include "render/model.hpp" | |||||
namespace game { | |||||
namespace ant { | |||||
namespace trait { | |||||
/** | |||||
* Trait that describes the waist (petiole plus postpetiole) of an ant. | |||||
*/ | |||||
struct waist | |||||
{ | |||||
/// 3D model of the waist. | |||||
render::model* model; | |||||
/// Degree of spinescence. | |||||
float spinescence; | |||||
/// Postpetiole presence. | |||||
bool postpetiole; | |||||
/// Petiole length in dorsal view (PetL). | |||||
float petiole_length; | |||||
/// Petiole width in dorsal view (PetW). | |||||
float petiole_width; | |||||
/// Petiole height in in lateral profile (PetH). | |||||
float petiole_height; | |||||
/// Postpetiole length in dorsal view (PPL). | |||||
float postpetiole_length; | |||||
/// Postpetiole width in dorsal view (PPW). | |||||
float postpetiole_width; | |||||
/// Postpetiole height in in lateral profile (PPH). | |||||
float postpetiole_height; | |||||
}; | |||||
} // namespace trait | |||||
} // namespace ant | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_ANT_TRAIT_WAIST_HPP |
@ -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/load.hpp" | |||||
#include "application.hpp" | |||||
#include "debug/logger.hpp" | |||||
#include "resources/json.hpp" | |||||
#include "resources/resource-manager.hpp" | |||||
#include "render/model.hpp" | |||||
#include "render/material.hpp" | |||||
#include "render/passes/sky-pass.hpp" | |||||
#include "render/passes/ground-pass.hpp" | |||||
#include "entity/systems/astronomy.hpp" | |||||
#include <fstream> | |||||
namespace game { | |||||
namespace load { | |||||
void biome(game::context& ctx, const std::filesystem::path& path) | |||||
{ | |||||
ctx.logger->push_task("Loading biome from \"" + path.string() + "\""); | |||||
try | |||||
{ | |||||
json* data = ctx.resource_manager->load<json>(path); | |||||
// Load location | |||||
if (auto location = data->find("location"); location != data->end()) | |||||
{ | |||||
double elevation = 0.0; | |||||
double latitude = 0.0; | |||||
double longitude = 0.0; | |||||
if (auto location_ele = location->find("elevation"); location_ele != location->end()) | |||||
elevation = location_ele->get<double>(); | |||||
else | |||||
ctx.logger->warning("Biome elevation undefined"); | |||||
if (auto location_lat = location->find("latitude"); location_lat != location->end()) | |||||
latitude = math::radians<double>(location_lat->get<double>()); | |||||
else | |||||
ctx.logger->warning("Biome latitude undefined"); | |||||
if (auto location_lon = location->find("longitude"); location_lon != location->end()) | |||||
longitude = math::radians<double>(location_lon->get<double>()); | |||||
else | |||||
ctx.logger->warning("Biome longitude undefined"); | |||||
ctx.astronomy_system->set_observer_location({elevation, latitude, longitude}); | |||||
} | |||||
else | |||||
{ | |||||
ctx.logger->warning("Biome location undefined"); | |||||
} | |||||
// Setup sky | |||||
ctx.sky_pass->set_sky_model(ctx.resource_manager->load<render::model>("celestial-hemisphere.mdl")); | |||||
// Load terrain | |||||
if (auto terrain = data->find("terrain"); terrain != data->end()) | |||||
{ | |||||
if (auto material = terrain->find("material"); material != terrain->end()) | |||||
{ | |||||
render::model* terrestrial_hemisphere_model = ctx.resource_manager->load<render::model>("terrestrial-hemisphere.mdl"); | |||||
(*terrestrial_hemisphere_model->get_groups())[0]->set_material(ctx.resource_manager->load<render::material>(material->get<std::string>())); | |||||
ctx.ground_pass->set_ground_model(terrestrial_hemisphere_model); | |||||
} | |||||
else | |||||
{ | |||||
ctx.logger->warning("Biome terrain material undefined"); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
ctx.logger->warning("Biome terrain undefined"); | |||||
} | |||||
} | |||||
catch (...) | |||||
{ | |||||
ctx.logger->pop_task(EXIT_FAILURE); | |||||
} | |||||
ctx.logger->pop_task(EXIT_SUCCESS); | |||||
} | |||||
void colony(game::context& ctx, const std::filesystem::path& path) | |||||
{ | |||||
ctx.logger->push_task("Loading colony from \"" + path.string() + "\""); | |||||
try | |||||
{ | |||||
json* data = ctx.resource_manager->load<json>(path); | |||||
} | |||||
catch (...) | |||||
{ | |||||
ctx.logger->pop_task(EXIT_FAILURE); | |||||
} | |||||
ctx.logger->pop_task(EXIT_SUCCESS); | |||||
} | |||||
} // namespace load | |||||
} // namespace game |
@ -0,0 +1,41 @@ | |||||
/* | |||||
* 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_LOAD_HPP | |||||
#define ANTKEEPER_GAME_LOAD_HPP | |||||
#include "game/context.hpp" | |||||
namespace game { | |||||
namespace load { | |||||
/** | |||||
* Loads a biome. | |||||
*/ | |||||
void biome(game::context& ctx, const std::filesystem::path& path); | |||||
/** | |||||
* Loads a colony | |||||
*/ | |||||
void colony(game::context& ctx, const std::filesystem::path& path); | |||||
} // namespace load | |||||
} // namespace game | |||||
#endif // ANTKEEPER_GAME_LOAD_HPP |