]> git.localhorst.tv Git - space.git/blobdiff - src/world/Universe.h
force based movement
[space.git] / src / world / Universe.h
index 29e4ecb92b726f6e97bf65e38d6ea4aafecdacd1..18db4dc782f8dd1d26360f23def88f9eafc4511c 100644 (file)
@@ -1,26 +1,80 @@
 #ifndef SPACE_UNIVERSE_H_
 #define SPACE_UNIVERSE_H_
 
-namespace space {
+#include "../entity/Ship.h"
+#include "../graphics/Vector.h"
+
+#include <list>
 
-class Sector;
+
+namespace space {
 
 class Universe {
 
 public:
-       Universe(int w, int h, int sec_w, int sec_h, int numres);
+       Universe(Vector<int> size, Vector<int> secSize, Vector<int> areaSize);
        ~Universe();
-private:
-       Universe(const Universe &);
-       Universe &operator =(const Universe &);
+
+       Universe(const Universe &) = delete;
+       Universe &operator =(const Universe &) = delete;
+
+public:
+       const Vector<int> size;
+       const Vector<int> secSize;
+       const Vector<int> areaSize;
+
+public:
+       class Area;
+
+       class Sector {
+
+       public:
+               Sector(const Universe &univ, Vector<int> coords)
+               : univ(univ), coords(coords) { }
+
+       public:
+               Vector<int> SectorCoords() const { return coords; }
+               Vector<int> AreaCoords() const { return univ.areaSize * coords; }
+
+               Area AreaAt(Vector<int> ac) const { return univ.AreaAt(AreaCoords() + ac); }
+
+       private:
+               const Universe &univ;
+               Vector<int> coords;
+
+       };
+
+       class Area {
+
+       public:
+               Area(const Universe &univ, Vector<int> coords)
+               : univ(univ), coords(coords) { }
+
+       public:
+               Vector<int> SectorCoords() const { return coords / univ.areaSize; }
+               Vector<int> AreaCoords() const { return coords; }
+
+               Sector ParentSector() const { return univ.SectorAt(SectorCoords()); }
+
+       private:
+               const Universe &univ;
+               Vector<int> coords;
+
+       };
+
+public:
+       Sector SectorAt(Vector<int> coords) const { return Sector(*this, coords); }
+       Area AreaAt(Vector<int> coords) const { return Area(*this, coords); }
+
+public:
+       Ship *AddShip(const Ship &);
+       const std::list<Ship> &Ships() const { return ships; }
+
+public:
+       void Update(float deltaT);
 
 private:
-       int w;
-       int h;
-       int numres;
-       int total;
-       Sector *sec_begin;
-       Sector *sec_end;
+       std::list<Ship> ships;
 
 };