Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CCmpTerritoryManager Class Reference
Inheritance diagram for CCmpTerritoryManager:
Collaboration diagram for CCmpTerritoryManager:

Classes

struct  SBoundaryLine
 

Public Member Functions

int GetComponentTypeId () const override
 
void Init (const CParamNode &) override
 
void Deinit () override
 
void Serialize (ISerializer &serialize) override
 
void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize) override
 
void HandleMessage (const CMessage &msg, bool) override
 
void MakeDirtyIfRelevantEntity (entity_id_t ent)
 
const Grid< std::uint8_t > & GetTerritoryGrid () override
 For each tile, the TERRITORY_PLAYER_MASK bits are player ID; TERRITORY_CONNECTED_MASK is set if the tile is connected to a root object (civ center etc). More...
 
player_id_t GetOwner (entity_pos_t x, entity_pos_t z) override
 Get owner of territory at given position. More...
 
std::vector< std::uint32_t > GetNeighbours (entity_pos_t x, entity_pos_t z, bool filterConnected) override
 get the number of neighbour tiles for per player for the selected position More...
 
bool IsConnected (entity_pos_t x, entity_pos_t z) override
 Get whether territory at given position is connected to a root object (civ center etc) owned by that territory's player. More...
 
void SetTerritoryBlinking (entity_pos_t x, entity_pos_t z, bool enable) override
 Set a piece of territory to blinking. More...
 
bool IsTerritoryBlinking (entity_pos_t x, entity_pos_t z) override
 Check if a piece of territory is blinking. More...
 
void MakeDirty ()
 
bool NeedUpdateTexture (size_t *dirtyID) override
 Returns whether the territory texture needs to be updated. More...
 
bool NeedUpdateAI (size_t *dirtyID, size_t *dirtyBlinkingID) const override
 Returns whether the AI territory map needs to be updated. More...
 
void CalculateCostGrid ()
 
void CalculateTerritories ()
 
std::uint8_t GetTerritoryPercentage (player_id_t player) override
 Returns the percentage of the world controlled by a given player as defined by the number of territory cells the given player owns. More...
 
std::vector< STerritoryBoundary > ComputeBoundaries ()
 
void UpdateBoundaryLines ()
 
void Interpolate (float frameTime, float frameOffset)
 
void RenderSubmit (SceneCollector &collector, const CFrustum &frustum, bool culling)
 
void SetVisibility (bool visible) override
 Enables or disables rendering of an territory borders. More...
 
bool IsVisible () const override
 Whether the territory lines are visible. More...
 
void UpdateColors () override
 Updates the boundary and territory colors. More...
 
virtual bool NeedUpdateTexture (size_t *dirtyID)=0
 Returns whether the territory texture needs to be updated. More...
 
virtual bool NeedUpdateAI (size_t *dirtyID, size_t *dirtyBlinkingID) const =0
 Returns whether the AI territory map needs to be updated. More...
 
virtual const Grid< std::uint8_t > & GetTerritoryGrid ()=0
 For each tile, the TERRITORY_PLAYER_MASK bits are player ID; TERRITORY_CONNECTED_MASK is set if the tile is connected to a root object (civ center etc). More...
 
virtual player_id_t GetOwner (entity_pos_t x, entity_pos_t z)=0
 Get owner of territory at given position. More...
 
virtual std::vector< std::uint32_t > 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 More...
 
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 territory's player. More...
 
virtual void SetTerritoryBlinking (entity_pos_t x, entity_pos_t z, bool enable)=0
 Set a piece of territory to blinking. More...
 
virtual bool IsTerritoryBlinking (entity_pos_t x, entity_pos_t z)=0
 Check if a piece of territory is blinking. More...
 
virtual std::uint8_t GetTerritoryPercentage (player_id_t player)=0
 Returns the percentage of the world controlled by a given player as defined by the number of territory cells the given player owns. More...
 
virtual void SetVisibility (bool visible)=0
 Enables or disables rendering of an territory borders. More...
 
virtual void UpdateColors ()=0
 Updates the boundary and territory colors. More...
 
virtual bool IsVisible () const =0
 Whether the territory lines are visible. More...
 
- Public Member Functions inherited from IComponent
virtual ~IComponent ()
 
virtual void Init (const CParamNode &paramNode)=0
 
virtual void Deinit ()=0
 
virtual void HandleMessage (const CMessage &msg, bool global)
 
CEntityHandle GetEntityHandle () const
 
void SetEntityHandle (CEntityHandle ent)
 
entity_id_t GetEntityId () const
 
CEntityHandle GetSystemEntity () const
 
const CSimContext & GetSimContext () const
 
void SetSimContext (const CSimContext &context)
 
virtual void Serialize (ISerializer &serialize)=0
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)=0
 
virtual JS::HandleValue GetJSInstance () const =0
 @Returns JS::NullHandleValue if a scripted wrapper of this IComponent is not supported, the wrapper otherwise. More...
 
virtual int GetComponentTypeId () const =0
 

Static Public Member Functions

static void ClassInit (CComponentManager &componentManager)
 
static IComponent * Allocate (const Script::Interface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static void RegisterComponentType (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static void RegisterComponentTypeScriptWrapper (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema, ClassInitFunc classInit)
 
static std::uint8_t GetSerializationVersion ()
 

Public Attributes

std::uint8_t m_ImpassableCost
 
float m_BorderThickness
 
float m_BorderSeparation
 
Grid< std::uint8_t > * m_Territories
 
std::vector< std::uint16_t > m_TerritoryCellCounts
 
std::uint16_t m_TerritoryTotalPassableCellCount
 
Grid< std::uint8_t > * m_CostGrid
 
bool m_TriggerEvent
 
std::vector< SBoundaryLine > m_BoundaryLines
 
bool m_BoundaryLinesDirty
 
double m_AnimTime
 
TerrainTextureOverlay * m_DebugOverlay
 
bool m_EnableLineDebugOverlays
 Enable node debugging overlays for boundary lines? More...
 
std::vector< SOverlayLine > m_DebugBoundaryLineNodes
 
size_t m_DirtyID
 
size_t m_DirtyBlinkingID
 
bool m_ColorChanged
 

Private Member Functions

void MarkFootprintTiles (entity_id_t ent, player_id_t owner, Grid< std::uint32_t > &bestWeightGrid, const std::uint16_t tilesW, const std::uint16_t tilesH, std::vector< std::pair< std::uint16_t, std::uint16_t > > &tiles)
 Mark the territory tiles covered by an entity's footprint with infinite weight. More...
 

Private Attributes

bool m_Visible
 
bool m_Enabled
 

Additional Inherited Members

- Public Types inherited from IComponent
using AllocFunc = IComponent *(*)(const Script::Interface &scriptInterface, JS::HandleValue ctor)
 
using DeallocFunc = void(*)(IComponent *)
 
using ClassInitFunc = void(*)(CComponentManager &componentManager)
 
- Static Public Attributes inherited from ICmpTerritoryManager
static const int NAVCELLS_PER_TERRITORY_TILE = 8
 Number of pathfinder navcells per territory tile. More...
 
static const int TERRITORY_PLAYER_MASK = 0x1F
 
static const int TERRITORY_CONNECTED_MASK = 0x20
 
static const int TERRITORY_BLINKING_MASK = 0x40
 
static const int TERRITORY_PROCESSED_MASK = 0x80
 

Member Function Documentation

◆ Allocate()

static IComponent * CCmpTerritoryManager::Allocate ( const Script::Interface &  ,
JS::HandleValue   
)
inlinestatic

◆ CalculateCostGrid()

void CCmpTerritoryManager::CalculateCostGrid ( )

◆ CalculateTerritories()

void CCmpTerritoryManager::CalculateTerritories ( )

◆ ClassInit()

static void CCmpTerritoryManager::ClassInit ( CComponentManager &  componentManager)
inlinestatic

◆ ComputeBoundaries()

std::vector< STerritoryBoundary > CCmpTerritoryManager::ComputeBoundaries ( )

◆ Deallocate()

static void CCmpTerritoryManager::Deallocate ( IComponent *  cmp)
inlinestatic

◆ Deinit()

void CCmpTerritoryManager::Deinit ( )
inlineoverridevirtual

Implements IComponent.

◆ Deserialize()

void CCmpTerritoryManager::Deserialize ( const CParamNode &  paramNode,
IDeserializer &  deserialize 
)
inlineoverridevirtual

Implements IComponent.

◆ GetComponentTypeId()

int CCmpTerritoryManager::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetNeighbours()

std::vector< std::uint32_t > CCmpTerritoryManager::GetNeighbours ( entity_pos_t  x,
entity_pos_t  z,
bool  filterConnected 
)
overridevirtual

get the number of neighbour tiles for per player for the selected position

Returns
A list with the number of neighbour tiles per player

Implements ICmpTerritoryManager.

◆ GetOwner()

player_id_t CCmpTerritoryManager::GetOwner ( entity_pos_t  x,
entity_pos_t  z 
)
overridevirtual

Get owner of territory at given position.

Returns
player ID of owner; 0 if neutral territory

Implements ICmpTerritoryManager.

◆ GetSchema()

static std::string CCmpTerritoryManager::GetSchema ( )
inlinestatic

◆ GetTerritoryGrid()

const Grid< std::uint8_t > & CCmpTerritoryManager::GetTerritoryGrid ( )
inlineoverridevirtual

For each tile, the TERRITORY_PLAYER_MASK bits are player ID; TERRITORY_CONNECTED_MASK is set if the tile is connected to a root object (civ center etc).

Implements ICmpTerritoryManager.

◆ GetTerritoryPercentage()

std::uint8_t CCmpTerritoryManager::GetTerritoryPercentage ( player_id_t  player)
overridevirtual

Returns the percentage of the world controlled by a given player as defined by the number of territory cells the given player owns.

Implements ICmpTerritoryManager.

◆ HandleMessage()

void CCmpTerritoryManager::HandleMessage ( const CMessage &  msg,
bool   
)
inlineoverridevirtual

Reimplemented from IComponent.

◆ Init()

void CCmpTerritoryManager::Init ( const CParamNode &  )
inlineoverridevirtual

Implements IComponent.

◆ Interpolate()

void CCmpTerritoryManager::Interpolate ( float  frameTime,
float  frameOffset 
)

◆ IsConnected()

bool CCmpTerritoryManager::IsConnected ( entity_pos_t  x,
entity_pos_t  z 
)
overridevirtual

Get whether territory at given position is connected to a root object (civ center etc) owned by that territory's player.

Implements ICmpTerritoryManager.

◆ IsTerritoryBlinking()

bool CCmpTerritoryManager::IsTerritoryBlinking ( entity_pos_t  x,
entity_pos_t  z 
)
overridevirtual

Check if a piece of territory is blinking.

Implements ICmpTerritoryManager.

◆ IsVisible()

bool CCmpTerritoryManager::IsVisible ( ) const
inlineoverridevirtual

Whether the territory lines are visible.

Implements ICmpTerritoryManager.

◆ MakeDirty()

void CCmpTerritoryManager::MakeDirty ( )
inline

◆ MakeDirtyIfRelevantEntity()

void CCmpTerritoryManager::MakeDirtyIfRelevantEntity ( entity_id_t  ent)
inline

◆ MarkFootprintTiles()

void CCmpTerritoryManager::MarkFootprintTiles ( entity_id_t  ent,
player_id_t  owner,
Grid< std::uint32_t > &  bestWeightGrid,
const std::uint16_t  tilesW,
const std::uint16_t  tilesH,
std::vector< std::pair< std::uint16_t, std::uint16_t > > &  tiles 
)
private

Mark the territory tiles covered by an entity's footprint with infinite weight.

This ensures that buildings always own the territory directly beneath them. Tiles already claimed by another footprint are left untouched, so when called in ascending entity ID order, the oldest building keeps contested tiles.

◆ NeedUpdateAI()

bool CCmpTerritoryManager::NeedUpdateAI ( size_t *  dirtyID,
size_t *  dirtyBlinkingID 
) const
inlineoverridevirtual

Returns whether the AI territory map needs to be updated.

Implements ICmpTerritoryManager.

◆ NeedUpdateTexture()

bool CCmpTerritoryManager::NeedUpdateTexture ( size_t *  dirtyID)
inlineoverridevirtual

Returns whether the territory texture needs to be updated.

Implements ICmpTerritoryManager.

◆ RenderSubmit()

void CCmpTerritoryManager::RenderSubmit ( SceneCollector &  collector,
const CFrustum &  frustum,
bool  culling 
)

◆ Serialize()

void CCmpTerritoryManager::Serialize ( ISerializer &  serialize)
inlineoverridevirtual

Implements IComponent.

◆ SetTerritoryBlinking()

void CCmpTerritoryManager::SetTerritoryBlinking ( entity_pos_t  x,
entity_pos_t  z,
bool  enable 
)
overridevirtual

Set a piece of territory to blinking.

Must be updated on every territory calculation

Implements ICmpTerritoryManager.

◆ SetVisibility()

void CCmpTerritoryManager::SetVisibility ( bool  visible)
inlineoverridevirtual

Enables or disables rendering of an territory borders.

Implements ICmpTerritoryManager.

◆ UpdateBoundaryLines()

void CCmpTerritoryManager::UpdateBoundaryLines ( )

◆ UpdateColors()

void CCmpTerritoryManager::UpdateColors ( )
overridevirtual

Updates the boundary and territory colors.

Implements ICmpTerritoryManager.

Member Data Documentation

◆ m_AnimTime

double CCmpTerritoryManager::m_AnimTime

◆ m_BorderSeparation

float CCmpTerritoryManager::m_BorderSeparation

◆ m_BorderThickness

float CCmpTerritoryManager::m_BorderThickness

◆ m_BoundaryLines

std::vector<SBoundaryLine> CCmpTerritoryManager::m_BoundaryLines

◆ m_BoundaryLinesDirty

bool CCmpTerritoryManager::m_BoundaryLinesDirty

◆ m_ColorChanged

bool CCmpTerritoryManager::m_ColorChanged

◆ m_CostGrid

Grid<std::uint8_t>* CCmpTerritoryManager::m_CostGrid

◆ m_DebugBoundaryLineNodes

std::vector<SOverlayLine> CCmpTerritoryManager::m_DebugBoundaryLineNodes

◆ m_DebugOverlay

TerrainTextureOverlay* CCmpTerritoryManager::m_DebugOverlay

◆ m_DirtyBlinkingID

size_t CCmpTerritoryManager::m_DirtyBlinkingID

◆ m_DirtyID

size_t CCmpTerritoryManager::m_DirtyID

◆ m_Enabled

bool CCmpTerritoryManager::m_Enabled
private

◆ m_EnableLineDebugOverlays

bool CCmpTerritoryManager::m_EnableLineDebugOverlays

Enable node debugging overlays for boundary lines?

◆ m_ImpassableCost

std::uint8_t CCmpTerritoryManager::m_ImpassableCost

◆ m_Territories

Grid<std::uint8_t>* CCmpTerritoryManager::m_Territories

◆ m_TerritoryCellCounts

std::vector<std::uint16_t> CCmpTerritoryManager::m_TerritoryCellCounts

◆ m_TerritoryTotalPassableCellCount

std::uint16_t CCmpTerritoryManager::m_TerritoryTotalPassableCellCount

◆ m_TriggerEvent

bool CCmpTerritoryManager::m_TriggerEvent

◆ m_Visible

bool CCmpTerritoryManager::m_Visible
private

The documentation for this class was generated from the following file: