visibility determination
[vrlugburz] / src / level.h
1 #ifndef LEVEL_H_
2 #define LEVEL_H_
3
4 #include "scenefile.h"
5 #include "tileset.h"
6
7 #define DEF_CELL_SIZE   3.0f
8
9 enum {
10         TILE_OPEN,
11         TILE_STR,
12         TILE_CORNER,
13         TILE_OPENCORNER,
14         TILE_TEE,
15         TILE_CROSS,
16         TILE_STR2OPEN,
17         TILE_STROPEN
18 };
19
20 enum {
21         CELL_SOLID,
22         CELL_WALK,
23         CELL_BLOCKED
24 };
25
26 struct tile {
27         char *name;
28         int type;
29
30         struct meshgroup mgrp;
31
32         struct tile *next;
33 };
34
35 struct cell {
36         int x, y;
37         int type;
38         int tiletype, tilerot;
39         int wall[4];
40         int floor, ceil;
41
42         struct tile *tile;
43         struct meshgroup *mgrp;
44         int num_mgrp;
45
46         struct cell *next;
47 };
48
49 struct level {
50         char *fname, *dirname;
51
52         int width, height;
53         int px, py;                             /* player start position */
54         float cell_size;
55         struct cell *cells;
56
57         struct tileset *tset;
58
59         /* meshes owned by the level, constructed during geometry generation or
60          * loaded, excluding meshes in tiles scenefiles
61          */
62         struct mesh *meshlist;
63
64         int visdist;
65 };
66
67
68 int init_level(struct level *lvl, int xsz, int ysz);
69 void destroy_level(struct level *lvl);
70
71 int load_level(struct level *lvl, const char *fname);
72 int save_level(struct level *lvl, const char *fname);
73
74 struct tile *find_level_tile(struct level *lvl, int type);
75
76 int gen_cell_geom(struct level *lvl, struct cell *cell);
77 int gen_level_geom(struct level *lvl);
78
79 int get_cell_type(struct level *lvl, int x, int y);
80
81 #endif  /* LEVEL_H_ */