X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FUniverse.h;h=55b86f95122b3d51c2657ecce125bfcd6c20e865;hb=1129b8ac89f1e614f69793227ccec90157708aea;hp=29e4ecb92b726f6e97bf65e38d6ea4aafecdacd1;hpb=96ab5904b059e00e78b26a6527790c8dc951e324;p=space.git diff --git a/src/world/Universe.h b/src/world/Universe.h index 29e4ecb..55b86f9 100644 --- a/src/world/Universe.h +++ b/src/world/Universe.h @@ -1,26 +1,80 @@ #ifndef SPACE_UNIVERSE_H_ #define SPACE_UNIVERSE_H_ -namespace space { +#include "../entity/Entity.h" +#include "../graphics/Vector.h" + +#include -class Sector; + +namespace space { class Universe { public: - Universe(int w, int h, int sec_w, int sec_h, int numres); + Universe(Vector size, Vector secSize, Vector areaSize); ~Universe(); -private: - Universe(const Universe &); - Universe &operator =(const Universe &); + + Universe(const Universe &) = delete; + Universe &operator =(const Universe &) = delete; + +public: + const Vector size; + const Vector secSize; + const Vector areaSize; + +public: + class Area; + + class Sector { + + public: + Sector(const Universe &univ, Vector coords) + : univ(univ), coords(coords) { } + + public: + Vector SectorCoords() const { return coords; } + Vector AreaCoords() const { return univ.areaSize * coords; } + + Area AreaAt(Vector ac) const { return univ.AreaAt(AreaCoords() + ac); } + + private: + const Universe &univ; + Vector coords; + + }; + + class Area { + + public: + Area(const Universe &univ, Vector coords) + : univ(univ), coords(coords) { } + + public: + Vector SectorCoords() const { return coords / univ.areaSize; } + Vector AreaCoords() const { return coords; } + + Sector ParentSector() const { return univ.SectorAt(SectorCoords()); } + + private: + const Universe &univ; + Vector coords; + + }; + +public: + Sector SectorAt(Vector coords) const { return Sector(*this, coords); } + Area AreaAt(Vector coords) const { return Area(*this, coords); } + +public: + Entity *AddEntity(const Entity &); + const std::list &Entities() const { return entities; } + +public: + void Update(float deltaT); private: - int w; - int h; - int numres; - int total; - Sector *sec_begin; - Sector *sec_end; + std::list entities; };