Pyrogenesis  trunk
ICmpTerritoryManager.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_ICMPTERRITORYMANAGER
19 #define INCLUDED_ICMPTERRITORYMANAGER
20 
22 
26 
28 {
29 public:
30  virtual bool NeedUpdate(size_t* dirtyID) const = 0;
31 
32  /**
33  * Number of pathfinder navcells per territory tile.
34  * Passability data is stored per navcell, but we probably don't need that much
35  * resolution, and a lower resolution can make the boundary lines look prettier
36  * and will take less memory, so we downsample the passability data.
37  */
38  static const int NAVCELLS_PER_TERRITORY_TILE = 8;
39 
40  static const int TERRITORY_PLAYER_MASK = 0x1F;
41  static const int TERRITORY_CONNECTED_MASK = 0x20;
42  static const int TERRITORY_BLINKING_MASK = 0x40;
43  static const int TERRITORY_PROCESSED_MASK = 0x80; //< For internal use; marks a tile as processed.
44 
45  /**
46  * For each tile, the TERRITORY_PLAYER_MASK bits are player ID;
47  * TERRITORY_CONNECTED_MASK is set if the tile is connected to a root object
48  * (civ center etc).
49  */
50  virtual const Grid<u8>& GetTerritoryGrid() = 0;
51 
52  /**
53  * Get owner of territory at given position.
54  * @return player ID of owner; 0 if neutral territory
55  */
57 
58  /**
59  * get the number of neighbour tiles for per player for the selected position
60  * @return A list with the number of neighbour tiles per player
61  */
62  virtual std::vector<u32> GetNeighbours(entity_pos_t x, entity_pos_t z, bool filterConnected) = 0;
63 
64  /**
65  * Get whether territory at given position is connected to a root object
66  * (civ center etc) owned by that territory's player.
67  */
68  virtual bool IsConnected(entity_pos_t x, entity_pos_t z) = 0;
69 
70  /**
71  * Set a piece of territory to blinking. Must be updated on every territory calculation
72  */
73  virtual void SetTerritoryBlinking(entity_pos_t x, entity_pos_t z, bool enable) = 0;
74 
75  /**
76  * Check if a piece of territory is blinking.
77  */
78  virtual bool IsTerritoryBlinking(entity_pos_t x, entity_pos_t z) = 0;
79 
80  /**
81  * Returns the percentage of the world controlled by a given player as defined by
82  * the number of territory cells the given player owns
83  */
84  virtual u8 GetTerritoryPercentage(player_id_t player) = 0;
85 
86  /**
87  * Enables or disables rendering of an territory borders.
88  */
89  virtual void SetVisibility(bool visible) = 0;
90 
91  DECLARE_INTERFACE_TYPE(TerritoryManager)
92 };
93 
94 #endif // INCLUDED_ICMPTERRITORYMANAGER
Definition: IComponent.h:33
A simple fixed-point number class.
Definition: Fixed.h:115
virtual bool IsTerritoryBlinking(entity_pos_t x, entity_pos_t z)=0
Check if a piece of territory is blinking.
virtual void SetTerritoryBlinking(entity_pos_t x, entity_pos_t z, bool enable)=0
Set a piece of territory to blinking.
virtual u8 GetTerritoryPercentage(player_id_t player)=0
Returns the percentage of the world controlled by a given player as defined by the number of territor...
virtual const Grid< u8 > & GetTerritoryGrid()=0
For each tile, the TERRITORY_PLAYER_MASK bits are player ID; TERRITORY_CONNECTED_MASK is set if the t...
uint8_t u8
Definition: types.h:37
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
Definition: Player.h:24
static const int TERRITORY_BLINKING_MASK
Definition: ICmpTerritoryManager.h:42
virtual void SetVisibility(bool visible)=0
Enables or disables rendering of an territory borders.
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
virtual bool IsConnected(entity_pos_t x, entity_pos_t z)=0
Get whether territory at given position is connected to a root object (civ center etc) owned by that ...
static const int TERRITORY_CONNECTED_MASK
Definition: ICmpTerritoryManager.h:41
virtual std::vector< u32 > GetNeighbours(entity_pos_t x, entity_pos_t z, bool filterConnected)=0
get the number of neighbour tiles for per player for the selected position
static const int NAVCELLS_PER_TERRITORY_TILE
Number of pathfinder navcells per territory tile.
Definition: ICmpTerritoryManager.h:38
virtual bool NeedUpdate(size_t *dirtyID) const =0
static const int TERRITORY_PLAYER_MASK
Definition: ICmpTerritoryManager.h:40
static const int TERRITORY_PROCESSED_MASK
Definition: ICmpTerritoryManager.h:43
virtual player_id_t GetOwner(entity_pos_t x, entity_pos_t z)=0
Get owner of territory at given position.
Definition: ICmpTerritoryManager.h:27