| 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 |
#pragma once |
| 50 |
|
| 51 |
#include <stdbool.h> |
| 52 |
|
| 53 |
#include "map_object.h" |
| 54 |
#include "pic.h" |
| 55 |
#include "thing.h" |
| 56 |
#include "tile.h" |
| 57 |
#include "triggers.h" |
| 58 |
#include "vector.h" |
| 59 |
|
| 60 |
|
| 61 |
typedef enum |
| 62 |
{ |
| 63 |
MAP_FLOOR, |
| 64 |
MAP_WALL, |
| 65 |
MAP_DOOR, |
| 66 |
MAP_ROOM, |
| 67 |
MAP_NOTHING, |
| 68 |
MAP_SQUARE |
| 69 |
} IMapType; |
| 70 |
const char *IMapTypeStr(IMapType t); |
| 71 |
IMapType StrIMapType(const char *s); |
| 72 |
|
| 73 |
#define MAP_ACCESS_RED 0x800 |
| 74 |
#define MAP_ACCESS_BLUE 0x400 |
| 75 |
#define MAP_ACCESS_GREEN 0x200 |
| 76 |
#define MAP_ACCESS_YELLOW 0x100 |
| 77 |
|
| 78 |
#define MAP_MASKACCESS 0xFF |
| 79 |
#define MAP_ACCESSBITS 0x0F00 |
| 80 |
|
| 81 |
typedef struct |
| 82 |
{ |
| 83 |
|
| 84 |
CArray LOS; |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
CArray Explored; |
| 89 |
} LineOfSight; |
| 90 |
|
| 91 |
typedef struct |
| 92 |
{ |
| 93 |
Rect2i R; |
| 94 |
int Mission; |
| 95 |
bool Hidden; |
| 96 |
} Exit; |
| 97 |
|
| 98 |
typedef struct |
| 99 |
{ |
| 100 |
map_t TileClasses; |
| 101 |
CArray Tiles; |
| 102 |
struct vec2i Size; |
| 103 |
|
| 104 |
LineOfSight LOS; |
| 105 |
CArray access; |
| 106 |
|
| 107 |
CArray triggers; |
| 108 |
int triggerId; |
| 109 |
|
| 110 |
int tilesSeen; |
| 111 |
int keyAccessCount; |
| 112 |
|
| 113 |
struct vec2i start; |
| 114 |
CArray exits; |
| 115 |
|
| 116 |
int NumExplorableTiles; |
| 117 |
} Map; |
| 118 |
|
| 119 |
extern Map gMap; |
| 120 |
|
| 121 |
uint16_t GetAccessMask(const int k); |
| 122 |
|
| 123 |
Tile *MapGetTile(const Map *map, const struct vec2i pos); |
| 124 |
bool MapIsTileIn(const Map *map, const struct vec2i pos); |
| 125 |
int MapIsTileInExit(const Map *map, const Thing *ti, const int exit); |
| 126 |
|
| 127 |
|
| 128 |
uint16_t MapGetAccessLevel(const Map *map, const struct vec2i pos); |
| 129 |
uint16_t AccessCodeToFlags(const uint16_t code); |
| 130 |
bool MapHasLockedRooms(const Map *map); |
| 131 |
bool MapPosIsInLockedRoom(const Map *map, const struct vec2 pos); |
| 132 |
int MapGetDoorKeycardFlag(Map *map, struct vec2i pos); |
| 133 |
|
| 134 |
|
| 135 |
bool MapTryMoveThing(Map *map, Thing *t, const struct vec2 pos); |
| 136 |
void MapRemoveThing(Map *map, Thing *t); |
| 137 |
|
| 138 |
void MapTerminate(Map *map); |
| 139 |
void MapInit(Map *map, const struct vec2i size); |
| 140 |
void MapPrintDebug(const Map *m); |
| 141 |
bool MapIsPosOKForPlayer( |
| 142 |
const Map *map, const struct vec2 pos, const bool allowAllTiles); |
| 143 |
bool MapIsTileAreaClear( |
| 144 |
const Map *map, const struct vec2 pos, const struct vec2i size); |
| 145 |
bool MapHasExits(const Map *m); |
| 146 |
void MapShowExitArea(Map *map, const int i); |
| 147 |
|
| 148 |
struct vec2 MapGetExitPos(const Map *m, const int i); |
| 149 |
struct vec2i MapGetRandomTile(const Map *map); |
| 150 |
struct vec2 MapGetRandomPos(const Map *map); |
| 151 |
bool MapPlaceRandomPos( |
| 152 |
const Map *map, const PlacementAccessFlags paFlags, |
| 153 |
bool (*tryPlaceFunc)(const Map *, const struct vec2, void *), void *data); |
| 154 |
|
| 155 |
void MapMarkAsVisited(Map *map, struct vec2i pos); |
| 156 |
void MapMarkAllAsVisited(Map *map); |
| 157 |
int MapGetExploredPercentage(Map *map); |
| 158 |
void MapUpdate(Map *map); |
| 159 |
|
| 160 |
typedef bool (*TileSelectFunc)(Map *, struct vec2i); |
| 161 |
|
| 162 |
struct vec2i MapSearchTileAround( |
| 163 |
Map *map, struct vec2i start, TileSelectFunc func); |
| 164 |
bool MapTileIsUnexplored(Map *map, struct vec2i tile); |
| 165 |
|
| 166 |
|
| 167 |
struct vec2 MapGenerateFreePosition(Map *map, const struct vec2i size); |
| 168 |
|
| 169 |
Trigger *MapNewTrigger(Map *map); |