forked from mrkite/TerraFirma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworld.h
142 lines (118 loc) · 2.95 KB
/
world.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/** @Copyright 2015 seancode */
#ifndef WORLD_H_
#define WORLD_H_
#include <QObject>
#include <QRunnable>
#include "./worldinfo.h"
#include "./worldheader.h"
#include "./handle.h"
class Tile {
public:
qint16 u, v, wallu, wallv, type;
quint8 wall, liquid, color, wallColor, slope;
int load(QSharedPointer<Handle> handle, int version,
const QList<bool> &extra);
bool active() const;
bool lava() const;
bool honey() const;
bool seen() const;
void setSeen(bool seen);
bool redWire() const;
bool blueWire() const;
bool greenWire() const;
bool yellowWire() const;
bool half() const;
bool actuator() const;
bool inactive() const;
private:
quint16 flags;
};
class World : public QObject, public QRunnable {
static const int MinimumVersion = 88;
static const int HighestVersion = 193;
Q_OBJECT
public:
struct Chest {
struct Item {
qint16 stack;
QString name;
QString prefix;
};
qint32 x, y;
QString name;
QList<Item> items;
};
struct Sign {
qint32 x, y;
QString text;
};
struct NPC {
QString title;
QString name;
float x, y;
bool homeless;
qint32 homeX, homeY;
qint16 sprite;
qint16 head;
qint16 order;
};
struct Entity {
qint32 id;
qint16 x, y;
};
struct TrainingDummy : Entity {
qint16 npc;
};
struct ItemFrame : Entity {
qint16 itemid;
quint8 prefix;
qint16 stack;
};
struct LogicSensor : Entity {
quint8 type;
bool on;
};
class InitException {
public:
InitException(QString const title, QString const reason)
: title(title), reason(reason) {}
QString title, reason;
};
explicit World(QObject *parent = 0);
virtual ~World();
void init();
void setFilename(QString filename);
void setPlayer(QString filename);
Tile *tiles;
QList<Chest> chests;
QList<Sign> signs;
QList<NPC> npcs;
QList<Entity> entities;
int tilesWide, tilesHigh;
WorldHeader header;
WorldInfo info;
signals:
void loaded(bool loaded);
void status(QString msg);
void loadError(QString reason);
protected:
void run() override;
private:
void loadHeader(QSharedPointer<Handle> handle, int version);
void loadTiles(QSharedPointer<Handle> handle, int version,
const QList<bool> &extra);
void loadChests(QSharedPointer<Handle> handle, int version);
void loadSigns(QSharedPointer<Handle> handle, int version);
void loadNPCs(QSharedPointer<Handle> handle, int version);
void loadDummies(QSharedPointer<Handle> handle, int version);
void loadEntities(QSharedPointer<Handle> handle, int version);
void loadPressurePlates(QSharedPointer<Handle> handle, int version);
void loadTownManager(QSharedPointer<Handle> handle, int version);
void spreadLight();
void loadPlayer();
void loadPlayer1(QSharedPointer<Handle> handle, int version);
void loadPlayer2(QSharedPointer<Handle> handle, int version);
QString filename;
QString player;
};
#endif // WORLD_H_