]> git.localhorst.tv Git - space.git/blobdiff - src/world/Universe.h
added universe environmental resources
[space.git] / src / world / Universe.h
index 807c1cd18fe16444f214abe749afcf601ac587ea..c4754bd0c718b0100baddd9584a6fbe50eb50d5d 100644 (file)
@@ -6,6 +6,7 @@
 #include "../graphics/Vector.h"
 
 #include <list>
+#include <map>
 #include <vector>
 
 
@@ -24,8 +25,11 @@ public:
        const Vector<int> size;
        const Vector<int> secSize;
        const Vector<int> areaSize;
+       const Vector<int> bounds;
 
 public:
+       using Env = std::map<int, float>;
+
        class Area;
 
        class Sector {
@@ -57,6 +61,7 @@ public:
                Vector<int> AreaCoords() const { return coords; }
 
                Sector ParentSector() const { return univ.SectorAt(SectorCoords()); }
+               const Env &GetEnv() const { return univ.EnvAt(coords); }
 
        private:
                const Universe &univ;
@@ -67,6 +72,7 @@ public:
 public:
        Sector SectorAt(Vector<int> coords) const { return Sector(*this, coords); }
        Area AreaAt(Vector<int> coords) const { return Area(*this, coords); }
+       const Env &EnvAt(Vector<int> coords) const { return env[coords.x * bounds.y + coords.y]; }
 
 public:
        Ship *AddShip(const Ship &);
@@ -75,12 +81,18 @@ public:
        int AddResource(const Resource &);
        const Resource &GetResource(int id) const { return resources[id]; }
 
+       void DumpEnv(int res, Vector<int> coords, float amount);
+       void DumpEnv(int res, Vector<float> coords, float amount) {
+               DumpEnv(res, Vector<int>(coords), amount);
+       }
+
 public:
        void Update(float deltaT);
 
 private:
        std::list<Ship> ships;
        std::vector<Resource> resources;
+       std::vector<Env> env;
 
 };