53eb9c112bed59a0a56e429d2f6cb54990514a5c
[vrlugburz] / src / level.h
1 #ifndef LEVEL_H_
2 #define LEVEL_H_
3
4 #include "scenefile.h"
5
6 enum {
7         TILE_EMPTY,
8         TILE_STRAIGHT,
9         TILE_CORNER,
10         TILE_DOOR
11 };
12
13 enum {
14         CELL_SOLID,
15         CELL_WALK,
16         CELL_BLOCKED
17 };
18
19 struct tile {
20         char *name;
21         int type;
22         struct scenefile scn;
23         struct tile *next;
24 };
25
26 struct cell {
27         int type;
28         int wall[4];
29         int floor, ceil;
30
31         struct meshgroup *mgrp;
32         int num_mgrp;
33
34         struct cell *next;
35 };
36
37 struct level {
38         char *fname, *dirname;
39
40         int width, height;
41         struct cell *cells;
42
43         struct tile *tiles;
44
45         /* meshes owned by the level, constructed during geometry generation or
46          * loaded, excluding meshes in tiles scenefiles
47          */
48         struct mesh *meshlist;
49 };
50
51
52 int init_level(struct level *lvl, int xsz, int ysz);
53 void destroy_level(struct level *lvl);
54
55 int load_level(struct level *lvl, const char *fname);
56 int save_level(struct level *lvl, const char *fname);
57
58 struct tile *find_level_tile(struct level *lvl, const char *tname);
59
60 int gen_cell_geom(struct level *lvl, struct cell *cell);
61 int gen_level_geom(struct level *lvl);
62
63 #endif  /* LEVEL_H_ */