forked from mrkite/TerraFirma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworldinfo.h
84 lines (72 loc) · 2.2 KB
/
worldinfo.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/** @Copyright 2015 seancode */
#ifndef WORLDINFO_H_
#define WORLDINFO_H_
#include <QObject>
#include <QHash>
#include <QSharedPointer>
#include <QJsonArray>
#include <QJsonObject>
class TileInfo : public QObject {
Q_OBJECT
public:
struct MergeBlend {
bool hasTile;
qint16 tile;
quint32 mask;
bool blend;
bool recursive;
quint8 direction;
};
explicit TileInfo(QJsonObject const &json);
TileInfo(QJsonObject const &json, TileInfo const &parent);
QString name;
quint32 color;
double lightR, lightG, lightB;
quint32 mask;
bool solid, transparent, dirt, stone, grass, pile, flip,
brick, merge, large;
QList<MergeBlend> blends;
int width, height, skipy, toppad;
int u, v, minu, maxu, minv, maxv;
bool isHilighting;
QList<QSharedPointer<TileInfo>> variants;
};
Q_DECLARE_METATYPE(QSharedPointer<TileInfo>)
class WorldInfo : public QObject {
Q_OBJECT
public:
class InitException {
public:
explicit InitException(QString const reason) : reason(reason) {}
QString reason;
};
struct WallInfo {
WallInfo(quint16 id, QJsonObject const &json);
QString name;
quint32 color;
quint16 blend;
quint8 large;
};
struct NPC {
explicit NPC(QJsonObject const &json);
QString title;
quint16 head;
qint16 id;
};
explicit WorldInfo(QObject *parent = 0);
void init();
QSharedPointer<TileInfo> operator[](int i) const;
QSharedPointer<TileInfo> operator[](class Tile const *tile) const;
QHash<int, QSharedPointer<TileInfo>> tiles;
QHash<int, QSharedPointer<WallInfo>> walls;
QHash<quint16, QString> prefixes;
QHash<quint16, QString> items;
QHash<int, QSharedPointer<NPC>> npcsByBanner;
QHash<QString, QSharedPointer<NPC>> npcsByName;
quint32 sky, earth, rock, hell, water, lava, honey;
private:
const QJsonArray load(QString const filename);
QSharedPointer<TileInfo> find(QSharedPointer<TileInfo> info,
quint16 u, quint16 v) const;
};
#endif // WORLDINFO_H_