| 1 |
// ____ _ __ |
| 2 |
// / __ )____ _____ | | / /___ ___________ |
| 3 |
// / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ |
| 4 |
// / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) |
| 5 |
// /_____/\____/____/ |__/|__/\__,_/_/ /____/ |
| 6 |
// |
| 7 |
// A futuristic real-time strategy game. |
| 8 |
// This file is part of Bos Wars. |
| 9 |
// |
| 10 |
/**@name unit_cache.h - The unit headerfile. */ |
| 11 |
// |
| 12 |
// (c) Copyright 2007 by Jimmy Salmon |
| 13 |
// |
| 14 |
// This program is free software; you can redistribute it and/or modify |
| 15 |
// it under the terms of the GNU General Public License as published by |
| 16 |
// the Free Software Foundation; only version 2 of the License. |
| 17 |
// |
| 18 |
// This program is distributed in the hope that it will be useful, |
| 19 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
// GNU General Public License for more details. |
| 22 |
// |
| 23 |
// You should have received a copy of the GNU General Public License |
| 24 |
// along with this program; if not, write to the Free Software |
| 25 |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 26 |
// 02111-1307, USA. |
| 27 |
|
| 28 |
#ifndef __UNIT_CACHE_H__ |
| 29 |
#define __UNIT_CACHE_H__ |
| 30 |
|
| 31 |
//@{ |
| 32 |
|
| 33 |
/*---------------------------------------------------------------------------- |
| 34 |
-- Includes |
| 35 |
----------------------------------------------------------------------------*/ |
| 36 |
|
| 37 |
#include <vector> |
| 38 |
|
| 39 |
|
| 40 |
/*---------------------------------------------------------------------------- |
| 41 |
-- Declarations |
| 42 |
----------------------------------------------------------------------------*/ |
| 43 |
|
| 44 |
class CUnit; |
| 45 |
|
| 46 |
/** |
| 47 |
** Unit cache |
| 48 |
*/ |
| 49 |
class CUnitCache |
| 50 |
{ |
| 51 |
public: |
| 52 |
/// Initialize unit cache |
| 53 |
void Init(int mapWidth, int mapHeight); |
| 54 |
|
| 55 |
/// Insert new unit into cache |
| 56 |
void Insert(CUnit *unit); |
| 57 |
|
| 58 |
/// Remove unit from cache |
| 59 |
void Remove(CUnit *unit); |
| 60 |
|
| 61 |
/// Select units in range |
| 62 |
int Select(int x1, int y1, int x2, int y2, CUnit **table, int tablesize); |
| 63 |
|
| 64 |
/// Select units on tile |
| 65 |
int Select(int x, int y, CUnit **table, int tablesize); |
| 66 |
|
| 67 |
private: |
| 68 |
int width; |
| 69 |
int height; |
| 70 |
std::vector<std::vector<std::vector<CUnit *> > > cache; |
| 71 |
}; |
| 72 |
|
| 73 |
extern CUnitCache UnitCache; |
| 74 |
|
| 75 |
|
| 76 |
//@} |
| 77 |
|
| 78 |
#endif // !__UNIT_CACHE_H__ |