]> git.localhorst.tv Git - blobs.git/blobdiff - src/creature/Creature.hpp
creature skin overhaul
[blobs.git] / src / creature / Creature.hpp
index 6c918270e540594bc18d0e19bd0240f80af50c80..f36a2db1f1172770855a9eebdfc6554202689b6f 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "Genome.hpp"
 #include "Goal.hpp"
+#include "Memory.hpp"
 #include "Need.hpp"
 #include "Situation.hpp"
 #include "Steering.hpp"
@@ -56,6 +57,15 @@ public:
        Genome::Properties<double> &GetProperties() noexcept { return properties; }
        const Genome::Properties<double> &GetProperties() const noexcept { return properties; }
 
+       const Genome::PropertySet<double> &CurProps() const noexcept { return properties.props[cur_prop]; }
+       const Genome::PropertySet<double> &NextProps() const noexcept { return properties.props[cur_prop + 1]; }
+
+       void BaseColor(const glm::dvec3 &c) noexcept { base_color = c; }
+       const glm::dvec3 &BaseColor() const noexcept { return base_color; }
+
+       void HighlightColor(const glm::dvec3 &c) noexcept { highlight_color = c; }
+       glm::dvec4 HighlightColor() const noexcept;
+
        void Mass(double m) noexcept { mass = m; size = std::cbrt(mass / density); }
        double Mass() const noexcept { return mass; }
        void Grow(double amount) noexcept;
@@ -65,6 +75,7 @@ public:
 
        double Size() const noexcept;
        double Age() const noexcept;
+       double AgeLerp(double from, double to) const noexcept;
        // change of giving birth per tick
        double Fertility() const noexcept;
 
@@ -76,6 +87,9 @@ public:
        void Remove() noexcept { removable = true; }
        bool Removable() const noexcept { return removable; }
 
+       Memory &GetMemory() noexcept { return memory; }
+       const Memory &GetMemory() const noexcept { return memory; }
+
        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; }
 
@@ -90,21 +104,24 @@ public:
        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.00000001; }
-
        glm::dmat4 LocalTransform() noexcept;
 
        void BuildVAO();
        void Draw(graphics::Viewport &);
 
+private:
+       Situation::Derivative Step(const Situation::Derivative &ds, double dt) const noexcept;
+
 private:
        world::Simulation &sim;
        std::string name;
 
        Genome genome;
        Genome::Properties<double> properties;
+       int cur_prop;
+
+       glm::dvec3 base_color;
+       glm::dvec3 highlight_color;
 
        double mass;
        double density;
@@ -115,14 +132,14 @@ private:
        Callback on_death;
        bool removable;
 
+       Memory memory;
+
        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;
                glm::vec3 normal;