]> git.localhorst.tv Git - blobs.git/blobdiff - src/creature/Creature.hpp
randomize creature properties a bit
[blobs.git] / src / creature / Creature.hpp
index 7c3d1ef0f924cad93614a7c8dba26a59d005fbf5..2a40d510407e4ff791a3e16c3d9b718066ca2d93 100644 (file)
@@ -1,10 +1,13 @@
 #ifndef BLOBS_CREATURE_CREATURE_HPP_
 #define BLOBS_CREATURE_CREATURE_HPP_
 
+#include "Genome.hpp"
+#include "Goal.hpp"
 #include "Need.hpp"
 #include "Situation.hpp"
-#include "../graphics/glm.hpp"
+#include "Steering.hpp"
 #include "../graphics/SimpleVAO.hpp"
+#include "../math/glm.hpp"
 
 #include <memory>
 #include <string>
@@ -21,13 +24,14 @@ namespace graphics {
 namespace world {
        class Body;
        class Planet;
+       class Simulation;
 }
 namespace creature {
 
 class Creature {
 
 public:
-       Creature();
+       explicit Creature(world::Simulation &);
        ~Creature();
 
        Creature(const Creature &) = delete;
@@ -37,9 +41,21 @@ public:
        Creature &operator =(Creature &&) = delete;
 
 public:
+       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;
@@ -47,22 +63,43 @@ public:
        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::Simulation &sim;
        std::string name;
+
+       Genome genome;
+
+       double mass;
+       double size;
        double health;
+
        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;