#ifndef TILEBASE_HPP #define TILEBASE_HPP #include "../render/textures.hpp" #include #include #include #include "iostream" // Forward declarations struct Chunk; struct Layer; struct Map; struct Coordinate { int x, y; Coordinate(); Coordinate(int X, int Y); }; struct Tile { ID id; ID spriteid; int animationframe; std::vector inventory; Chunk* owner; // pointer instead of reference void Draw(); void Update(float deltatime); Tile(ID Id, ID spriteId, Chunk* owner); Tile(); // default constructor (needed for containers) }; struct Chunk { Coordinate position; std::vector tiles; // dynamic instead of fixed array Layer* owner; void Draw(raylib::Rectangle aera); Chunk(Coordinate pos, Layer* Owner); Chunk(); // default constructor }; struct CoordinateHash { std::size_t operator()(const Coordinate& c) const noexcept; }; struct CoordinateEq { bool operator()(const Coordinate& a, const Coordinate& b) const noexcept; }; struct Layer { std::unordered_map chunks; ID id; bool DEBUG; Map* owner; void Draw(raylib::Rectangle aera); Layer(ID Id, Map* Owner); Layer(); // default constructor }; enum Actions{ place, destroy, rotate, open, close, drop, }; struct packet { Actions action; Coordinate position; int data; }; struct Map { std::array layers; // ground/water/void/decoration int worldtime; bool DEBUG; Map(); void Draw(raylib::Rectangle aera); void Init(); void Update(float deltatime, packet datapacket); }; #endif // !TILEBASE_HPP