1 #ifndef SPACE_UNIVERSE_H_
2 #define SPACE_UNIVERSE_H_
5 #include "../entity/Ship.h"
6 #include "../graphics/Vector.h"
18 Universe(Vector<int> size, Vector<int> secSize, Vector<int> areaSize);
21 Universe(const Universe &) = delete;
22 Universe &operator =(const Universe &) = delete;
25 const Vector<int> size;
26 const Vector<int> secSize;
27 const Vector<int> areaSize;
28 const Vector<int> bounds;
31 using Env = std::map<int, float>;
38 Sector(const Universe &univ, Vector<int> coords)
39 : univ(univ), coords(coords) { }
42 Vector<int> SectorCoords() const { return coords; }
43 Vector<int> AreaCoords() const { return univ.areaSize * coords; }
45 Area AreaAt(Vector<int> ac) const { return univ.AreaAt(AreaCoords() + ac); }
56 Area(const Universe &univ, Vector<int> coords)
57 : univ(univ), coords(coords) { }
60 Vector<int> SectorCoords() const { return coords / univ.areaSize; }
61 Vector<int> AreaCoords() const { return coords; }
63 Sector ParentSector() const { return univ.SectorAt(SectorCoords()); }
64 const Env &GetEnv() const { return univ.EnvAt(coords); }
73 Sector SectorAt(Vector<int> coords) const { return Sector(*this, coords); }
74 Area AreaAt(Vector<int> coords) const { return Area(*this, coords); }
75 const Env &EnvAt(Vector<int> coords) const { return env[coords.x * bounds.y + coords.y]; }
78 Ship *AddShip(const Ship &);
79 const std::list<Ship> &Ships() const { return ships; }
81 int AddResource(const Resource &);
82 const Resource &GetResource(int id) const { return resources[id]; }
84 void DumpEnv(int res, Vector<int> coords, float amount);
85 void DumpEnv(int res, Vector<float> coords, float amount) {
86 DumpEnv(res, Vector<int>(coords), amount);
90 void Update(float deltaT);
93 std::list<Ship> ships;
94 std::vector<Resource> resources;