| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
#ifndef SPATIALINDEX_HH |
|---|
| 22 |
#define SPATIALINDEX_HH |
|---|
| 23 |
|
|---|
| 24 |
#include <cassert> |
|---|
| 25 |
#include <cmath> |
|---|
| 26 |
#include <set> |
|---|
| 27 |
#include <vector> |
|---|
| 28 |
|
|---|
| 29 |
#include "item.hh" |
|---|
| 30 |
#include "resourceitem.hh" |
|---|
| 31 |
#include "utils.hh" |
|---|
| 32 |
|
|---|
| 33 |
using namespace std; |
|---|
| 34 |
|
|---|
| 35 |
class SpatialIndex |
|---|
| 36 |
{ |
|---|
| 37 |
|
|---|
| 38 |
private: |
|---|
| 39 |
static vector<vector<Item *> > items; |
|---|
| 40 |
static vector<vector<ResourceItem *> > resourceitems; |
|---|
| 41 |
static uint16 height; |
|---|
| 42 |
static uint16 width; |
|---|
| 43 |
|
|---|
| 44 |
private: |
|---|
| 45 |
SpatialIndex(); |
|---|
| 46 |
static bool matchGivenItemProfile(Item * item, Player * p, bool player_eq, GenderName g, bool gender_eq, SubGenderName sg, bool subgender_eq); |
|---|
| 47 |
static bool matchGivenResourceItemProfile(ResourceItem * resourceitem, ResourceName rn, bool resourcetype_eq); |
|---|
| 48 |
public: |
|---|
| 49 |
static void init(uint16 height, uint16 width); |
|---|
| 50 |
static void clear(); |
|---|
| 51 |
static void setTile(uint16 x, uint16 y, Item * item); |
|---|
| 52 |
static set<Item *> getItemTile(uint16 x, uint16 y, Player * p = NULL, bool player_eq = true, GenderName g = GNULL, bool gender_eq = true, SubGenderName sg = SGNULL, bool subgender_eq = true); |
|---|
| 53 |
static set<Item *> getItemRect(uint16 x1, uint16 y1, uint16 x2, uint16 y2, Player * p = NULL, bool player_eq = true, GenderName g = GNULL, bool gender_eq = true, SubGenderName sg = SGNULL, bool subgender_eq = true); |
|---|
| 54 |
static set<Item *> getItemSquare(uint16 x, uint16 y, uint16 side, Player * p = NULL, bool player_eq = true, GenderName g = GNULL, bool gender_eq = true, SubGenderName sg = SGNULL, bool subgender_eq = true); |
|---|
| 55 |
static set<Item *> getItemDisc(uint16 x, uint16 y, uint16 radius, Player * p = NULL, bool player_eq = true, GenderName g = GNULL, bool gender_eq = true, SubGenderName sg = SGNULL, bool subgender_eq = true); |
|---|
| 56 |
|
|---|
| 57 |
static void setTile(uint16 x, uint16 y, ResourceItem * resourceitem); |
|---|
| 58 |
static set<ResourceItem *> getResourceItemTile(uint16 x, uint16 y, ResourceName rn = RNULL, bool resourcetype_eq = true); |
|---|
| 59 |
static set<ResourceItem *> getResourceItemRect(uint16 x1, uint16 y1, uint16 x2, uint16 y2, ResourceName rn = RNULL, bool resourcetype_eq = true); |
|---|
| 60 |
static set<ResourceItem *> getResourceItemSquare(uint16 x, uint16 y, uint16 side, ResourceName rn = RNULL, bool resourcetype_eq = true); |
|---|
| 61 |
static set<ResourceItem *> getResourceItemDisc(uint16 x, uint16 y, uint16 radius, ResourceName rn = RNULL, bool resourcetype_eq = true); |
|---|
| 62 |
}; |
|---|
| 63 |
|
|---|
| 64 |
#endif |
|---|