]> git.localhorst.tv Git - space.git/blobdiff - src/world/Universe.h
added universe environmental resources
[space.git] / src / world / Universe.h
index 740592690fb86935f68fccb92eaadd9527fcda1d..c4754bd0c718b0100baddd9584a6fbe50eb50d5d 100644 (file)
@@ -1,10 +1,13 @@
 #ifndef SPACE_UNIVERSE_H_
 #define SPACE_UNIVERSE_H_
 
-#include "../entity/Entity.h"
-#include "../math/Vector.h"
+#include "Resource.h"
+#include "../entity/Ship.h"
+#include "../graphics/Vector.h"
 
 #include <list>
+#include <map>
+#include <vector>
 
 
 namespace space {
@@ -22,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 {
@@ -55,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;
@@ -65,16 +72,27 @@ 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:
-       Entity *AddEntity(const Entity &);
-       const std::list<Entity> &Entities() const { return entities; }
+       Ship *AddShip(const Ship &);
+       const std::list<Ship> &Ships() const { return ships; }
+
+       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<Entity> entities;
+       std::list<Ship> ships;
+       std::vector<Resource> resources;
+       std::vector<Env> env;
 
 };