#ifndef BLOBS_CREATURE_CREATURE_HPP_
#define BLOBS_CREATURE_CREATURE_HPP_
+#include "Genome.hpp"
+#include "Goal.hpp"
#include "Need.hpp"
-#include "../graphics/glm.hpp"
+#include "Situation.hpp"
+#include "Steering.hpp"
#include "../graphics/SimpleVAO.hpp"
+#include "../math/glm.hpp"
+#include <memory>
#include <string>
#include <vector>
namespace world {
class Body;
class Planet;
+ class Simulation;
}
namespace creature {
class Creature {
public:
- Creature();
+ explicit Creature(world::Simulation &);
~Creature();
Creature(const Creature &) = delete;
Creature &operator =(Creature &&) = delete;
public:
- void SetBody(world::Body &b) noexcept { body = &b; }
- world::Body &GetBody() noexcept { return *body; }
- const world::Body &GetBody() const noexcept { return *body; }
-
- void Surface(int s) noexcept { surface = s; }
- void Position(const glm::dvec3 &p) noexcept { position = p; }
+ world::Simulation &GetSimulation() noexcept { return sim; }
+ const world::Simulation &GetSimulation() const noexcept { return sim; }
void Name(const std::string &n) noexcept { name = n; }
const std::string &Name() const noexcept { return name; }
+ Genome &GetGenome() noexcept { return genome; }
+ const Genome &GetGenome() const noexcept { return genome; }
+
+ void Mass(double m) noexcept { mass = m; }
+ double Mass() const noexcept { return mass; }
+
+ void Size(double s) noexcept { size = s; }
+ double Size() const noexcept { return size; }
+
void Health(double h) noexcept { health = h; }
double Health() const noexcept { return health; }
+ void Hurt(double d) noexcept;
- void AddNeed(const Need &n) { needs.push_back(n); }
+ void AddNeed(std::unique_ptr<Need> &&n) { needs.emplace_back(std::move(n)); }
+ const std::vector<std::unique_ptr<Need>> &Needs() const noexcept { return needs; }
+
+ void AddGoal(std::unique_ptr<Goal> &&);
+ const std::vector<std::unique_ptr<Goal>> &Goals() const noexcept { return goals; }
void Tick(double dt);
+ Situation &GetSituation() noexcept { return situation; }
+ const Situation &GetSituation() const noexcept { return situation; }
+
+ Steering &GetSteering() noexcept { return steering; }
+ const Steering &GetSteering() const noexcept { return steering; }
+
+ void Velocity(const glm::dvec3 &v) noexcept { vel = v; }
+ const glm::dvec3 &Velocity() const noexcept { return vel; }
+ bool Moving() const noexcept { return glm::length2(vel) < 0.000001; }
+
glm::dmat4 LocalTransform() noexcept;
void BuildVAO();
void Draw(app::Assets &, graphics::Viewport &);
private:
- world::Body *body;
- int surface;
- glm::dvec3 position;
-
+ world::Simulation ∼
std::string name;
+
+ Genome genome;
+
+ double mass;
+ double size;
double health;
- std::vector<Need> needs;
+
+ std::vector<std::unique_ptr<Need>> needs;
+ std::vector<std::unique_ptr<Goal>> goals;
+
+ Situation situation;
+ Steering steering;
+
+ glm::dvec3 vel;
struct Attributes {
glm::vec3 position;