-
Notifications
You must be signed in to change notification settings - Fork 23
/
Building.h
50 lines (42 loc) · 1.11 KB
/
Building.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <cinttypes>
#include <vector>
#include <memory>
#include "Rendering/Renderer.h"
#include "Rendering/Tileset.h"
namespace Sourcehold {
namespace Parsers {
class Gm1File;
}
namespace Game {
using namespace Parsers;
class Building {
std::shared_ptr<Gm1File> gm1;
std::vector<uint32_t> walkableTiles;
uint32_t px, py, mapW, mapH;
bool loaded = false, placed = false;
public:
Building(uint32_t mw = 160, uint32_t mh = 160);
Building(std::weak_ptr<Gm1File> file, uint32_t x = 0, uint32_t y = 0,
uint32_t mw = 160, uint32_t mh = 160);
~Building();
/**
* Render the building preview before
* a building is placed
*/
void Preview(uint32_t x, uint32_t y);
/**
* Place the building at a certain
* point on the map (has to be a valid coord)
*/
void PlaceAt(uint32_t x, uint32_t y);
void MoveTo(uint32_t x, uint32_t y);
void Unload();
void Render();
bool CanWalkOn(uint32_t x, uint32_t y);
protected:
uint32_t CoordToGlobalIndex(uint32_t x, uint32_t y);
uint32_t CoordToLocalIndex(uint32_t x, uint32_t y);
};
} // namespace Game
} // namespace Sourcehold