Pyrogenesis
trunk
|
Range manager implementation. More...
Public Types | |
using | LosRegion = std::pair< u16, u16 > |
Public Types inherited from ICmpRangeManager | |
typedef u32 | tag_t |
External identifiers for active queries. More... | |
Public Types inherited from IComponent | |
using | AllocFunc = IComponent *(*)(const ScriptInterface &scriptInterface, JS::HandleValue ctor) |
using | DeallocFunc = void(*)(IComponent *) |
Public Member Functions | |
int | GetComponentTypeId () const override |
void | Init (const CParamNode ¶mNode) override |
void | Deinit () override |
template<typename S > | |
void | SerializeCommon (S &serialize) |
void | Serialize (ISerializer &serialize) override |
void | Deserialize (const CParamNode ¶mNode, IDeserializer &deserialize) override |
void | HandleMessage (const CMessage &msg, bool global) override |
void | SetBounds (entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1) override |
Set the bounds of the world. More... | |
void | Verify () override |
Perform some internal consistency checks for testing/debugging. More... | |
FastSpatialSubdivision * | GetSubdivision () override |
Access the spatial subdivision kept by the range manager. More... | |
void | ResetDerivedData () |
void | ResetSubdivisions (entity_pos_t x1, entity_pos_t z1) |
tag_t | CreateActiveQuery (entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, const std::vector< int > &owners, int requiredInterface, u8 flags, bool accountForSize) override |
Construct an active query. More... | |
tag_t | CreateActiveParabolicQuery (entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, entity_pos_t yOrigin, const std::vector< int > &owners, int requiredInterface, u8 flags) override |
Construct an active query of a paraboloic form around the unit. More... | |
void | DestroyActiveQuery (tag_t tag) override |
void | EnableActiveQuery (tag_t tag) override |
void | DisableActiveQuery (tag_t tag) override |
bool | IsActiveQueryEnabled (tag_t tag) const override |
std::vector< entity_id_t > | ExecuteQueryAroundPos (const CFixedVector2D &pos, entity_pos_t minRange, entity_pos_t maxRange, const std::vector< int > &owners, int requiredInterface, bool accountForSize) override |
Execute a passive query. More... | |
std::vector< entity_id_t > | ExecuteQuery (entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, const std::vector< int > &owners, int requiredInterface, bool accountForSize) override |
Execute a passive query. More... | |
std::vector< entity_id_t > | ResetActiveQuery (tag_t tag) override |
std::vector< entity_id_t > | GetEntitiesByPlayer (player_id_t player) const override |
Returns a list of all entities for a specific player. More... | |
std::vector< entity_id_t > | GetNonGaiaEntities () const override |
Returns a list of all entities of all players except gaia. More... | |
std::vector< entity_id_t > | GetGaiaAndNonGaiaEntities () const override |
Returns a list of all entities owned by a player or gaia. More... | |
std::vector< entity_id_t > | GetEntitiesByMask (u32 ownerMask) const |
void | SetDebugOverlay (bool enabled) override |
Toggle the rendering of debug info. More... | |
void | ExecuteActiveQueries () |
Update all currently-enabled active queries. More... | |
bool | TestEntityQuery (const Query &q, entity_id_t id, const EntityData &entity) const |
Returns whether the given entity matches the given query (ignoring maxRange) More... | |
void | PerformQuery (const Query &q, std::vector< entity_id_t > &r, CFixedVector2D pos) |
Returns a list of distinct entity IDs that match the given query, sorted by ID. More... | |
entity_pos_t | GetEffectiveParabolicRange (entity_id_t source, entity_id_t target, entity_pos_t range, entity_pos_t yOrigin) const override |
Get the effective range in a parablic range query. More... | |
entity_pos_t | GetElevationAdaptedRange (const CFixedVector3D &pos1, const CFixedVector3D &rot, entity_pos_t range, entity_pos_t yOrigin, entity_pos_t angle) const override |
Get the average elevation over 8 points on distance range around the entity. More... | |
virtual std::vector< entity_pos_t > | getParabolicRangeForm (CFixedVector3D pos, entity_pos_t maxRange, entity_pos_t cutoff, entity_pos_t minAngle, entity_pos_t maxAngle, int numberOfSteps) const |
Query | ConstructQuery (entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, const std::vector< int > &owners, int requiredInterface, u8 flagsMask, bool accountForSize) const |
Query | ConstructParabolicQuery (entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, entity_pos_t yOrigin, const std::vector< int > &owners, int requiredInterface, u8 flagsMask, bool accountForSize) const |
void | RenderSubmit (SceneCollector &collector) |
u8 | GetEntityFlagMask (const std::string &identifier) const override |
Returns the mask for the specified identifier. More... | |
void | SetEntityFlag (entity_id_t ent, const std::string &identifier, bool value) override |
Set the flag specified by the identifier to the supplied value for the entity. More... | |
CLosQuerier | GetLosQuerier (player_id_t player) const override |
Returns a CLosQuerier for checking whether vertex positions are visible to the given player (or other players it shares LOS with). More... | |
void | ActivateScriptedVisibility (entity_id_t ent, bool status) override |
Toggle the scripted Visibility component activation for entity ent. More... | |
LosVisibility | ComputeLosVisibility (CEntityHandle ent, player_id_t player) const |
LosVisibility | ComputeLosVisibility (entity_id_t ent, player_id_t player) const |
LosVisibility | GetLosVisibility (CEntityHandle ent, player_id_t player) const override |
Returns the visibility status of the given entity, with respect to the given player. More... | |
LosVisibility | GetLosVisibility (entity_id_t ent, player_id_t player) const override |
LosVisibility | GetLosVisibilityPosition (entity_pos_t x, entity_pos_t z, player_id_t player) const override |
Returns the visibility status of the given position, with respect to the given player. More... | |
size_t | GetVerticesPerSide () const override |
LosRegion | LosVertexToLosRegionsHelper (u16 x, u16 z) const |
LosRegion | PosToLosRegionsHelper (entity_pos_t x, entity_pos_t z) const |
void | AddToRegion (LosRegion region, entity_id_t ent) |
void | RemoveFromRegion (LosRegion region, entity_id_t ent) |
void | UpdateVisibilityData () |
void | RequestVisibilityUpdate (entity_id_t ent) override |
Request the update of the visibility cache of ent at next turn. More... | |
void | UpdateVisibility (entity_id_t ent, player_id_t player) |
void | UpdateVisibility (entity_id_t ent) |
void | SetLosRevealAll (player_id_t player, bool enabled) override |
Set whether the whole map should be made visible to the given player. More... | |
bool | GetLosRevealAll (player_id_t player) const override |
Returns whether the whole map has been made visible to the given player. More... | |
void | SetLosCircular (bool enabled) override |
Set the LOS to be restricted to a circular map. More... | |
bool | GetLosCircular () const override |
Returns whether the LOS is restricted to a circular map. More... | |
void | SetSharedLos (player_id_t player, const std::vector< player_id_t > &players) override |
Sets shared LOS data for player to the given list of players. More... | |
u32 | GetSharedLosMask (player_id_t player) const override |
Returns shared LOS mask for player. More... | |
void | ExploreMap (player_id_t p) override |
Explore the map (but leave it in the FoW) for player p. More... | |
void | ExploreTerritories () override |
Explore the tiles inside each player's territory. More... | |
void | SeeExploredEntities (player_id_t p) const |
Force any entity in explored territory to appear for player p. More... | |
void | RevealShore (player_id_t p, bool enable) override |
Reveal the shore for specified player p. More... | |
bool | LosIsOffWorld (ssize_t i, ssize_t j) const |
Returns whether the given vertex is outside the normal bounds of the world (i.e. More... | |
void | LosAddStripHelper (u8 owner, i32 i0, i32 i1, i32 j, Grid< u16 > &counts) |
Update the LOS state of tiles within a given horizontal strip (i0,j) to (i1,j) (inclusive). More... | |
void | LosRemoveStripHelper (u8 owner, i32 i0, i32 i1, i32 j, Grid< u16 > &counts) |
Update the LOS state of tiles within a given horizontal strip (i0,j) to (i1,j) (inclusive). More... | |
void | MarkVisibilityDirtyAroundTile (u8 owner, i32 i, i32 j) |
template<bool adding> | |
void | LosUpdateHelper (u8 owner, entity_pos_t visionRange, CFixedVector2D pos) |
Update the LOS state of tiles within a given circular range, either adding or removing visibility depending on the template parameter. More... | |
void | LosUpdateHelperIncremental (u8 owner, entity_pos_t visionRange, CFixedVector2D from, CFixedVector2D to) |
Update the LOS state of tiles within a given circular range, by removing visibility around the 'from' position and then adding visibility around the 'to' position. More... | |
void | LosAdd (player_id_t owner, entity_pos_t visionRange, CFixedVector2D pos) |
void | SharingLosAdd (u16 visionSharing, entity_pos_t visionRange, CFixedVector2D pos) |
void | LosRemove (player_id_t owner, entity_pos_t visionRange, CFixedVector2D pos) |
void | SharingLosRemove (u16 visionSharing, entity_pos_t visionRange, CFixedVector2D pos) |
void | LosMove (player_id_t owner, entity_pos_t visionRange, CFixedVector2D from, CFixedVector2D to) |
void | SharingLosMove (u16 visionSharing, entity_pos_t visionRange, CFixedVector2D from, CFixedVector2D to) |
u8 | GetPercentMapExplored (player_id_t player) const override |
Get percent map explored statistics for specified player. More... | |
u8 | GetUnionPercentMapExplored (const std::vector< player_id_t > &players) const override |
Get percent map explored statistics for specified set of players. More... | |
Public Member Functions inherited from ICmpRangeManager | |
virtual void | DestroyActiveQuery (tag_t tag)=0 |
Destroy a query and clean up resources. More... | |
virtual void | EnableActiveQuery (tag_t tag)=0 |
Re-enable the processing of a query. More... | |
virtual void | DisableActiveQuery (tag_t tag)=0 |
Disable the processing of a query (no RangeUpdate messages will be sent). More... | |
virtual bool | IsActiveQueryEnabled (tag_t tag) const =0 |
Check if the processing of a query is enabled. More... | |
virtual std::vector< entity_id_t > | ResetActiveQuery (tag_t tag)=0 |
Immediately execute a query, and re-enable it if disabled. More... | |
std::string | GetLosVisibility_wrapper (entity_id_t ent, player_id_t player) const |
GetLosVisibility wrapped for script calls. More... | |
std::string | GetLosVisibilityPosition_wrapper (entity_pos_t x, entity_pos_t z, player_id_t player) const |
GetLosVisibilityPosition wrapped for script calls. More... | |
Public Member Functions inherited from IComponent | |
virtual | ~IComponent () |
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 bool | NewJSObject (const ScriptInterface &scriptInterface, JS::MutableHandleObject out) const |
Returns false by default, indicating that a scripted wrapper of this IComponent is not supported. More... | |
virtual JS::Value | GetJSInstance () const |
Static Public Member Functions | |
static void | ClassInit (CComponentManager &componentManager) |
static IComponent * | Allocate (const ScriptInterface &, 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) |
static u8 | GetSerializationVersion () |
Static Public Attributes | |
static const player_id_t | MAX_LOS_PLAYER_ID = 16 |
Range manager implementation.
Maintains a list of all entities (and their positions and owners), which is used for queries.
LOS implementation is based on the model described in GPG2. (TODO: would be nice to make it cleverer, so e.g. mountains and walls can block vision)
using CCmpRangeManager::LosRegion = std::pair<u16, u16> |
|
inlineoverridevirtual |
Toggle the scripted Visibility component activation for entity ent.
Implements ICmpRangeManager.
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Construct an active query of a paraboloic form around the unit.
The query will be disabled by default.
source | the entity around which the range will be computed. |
minRange | non-negative minimum horizontal distance in metres (inclusive). MinRange doesn't do parabolic checks. |
maxRange | non-negative maximum distance in metres (inclusive) for units on the same elevation; or -1.0 to ignore distance. For units on a different height positions, a physical correct paraboloid with height=maxRange/2 above the unit is used to query them |
yOrigin | extra bonus so the source can be placed higher and shoot further |
owners | list of player IDs that matching entities may have; -1 matches entities with no owner. |
requiredInterface | if non-zero, an interface ID that matching entities must implement. |
flags | if a entity in range has one of the flags set it will show up. NB: this one has no accountForSize parameter (assumed true), because we currently can only have 7 arguments for JS functions. |
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Construct an active query.
The query will be disabled by default.
source | the entity around which the range will be computed. |
minRange | non-negative minimum distance in metres (inclusive). |
maxRange | non-negative maximum distance in metres (inclusive); or -1.0 to ignore distance. |
owners | list of player IDs that matching entities may have; -1 matches entities with no owner. |
requiredInterface | if non-zero, an interface ID that matching entities must implement. |
flags | if a entity in range has one of the flags set it will show up. |
accountForSize | if true, compensate for source/target entity sizes. |
Implements ICmpRangeManager.
|
inlinestatic |
|
inlineoverridevirtual |
Implements IComponent.
|
inlineoverridevirtual |
Implements IComponent.
|
inlineoverride |
|
inlineoverride |
|
inlineoverride |
|
inline |
Update all currently-enabled active queries.
|
inlineoverridevirtual |
Execute a passive query.
source | the entity around which the range will be computed. |
minRange | non-negative minimum distance in metres (inclusive). |
maxRange | non-negative maximum distance in metres (inclusive); or -1.0 to ignore distance. |
owners | list of player IDs that matching entities may have; -1 matches entities with no owner. |
requiredInterface | if non-zero, an interface ID that matching entities must implement. |
accountForSize | if true, compensate for source/target entity sizes. |
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Execute a passive query.
pos | the position around which the range will be computed. |
minRange | non-negative minimum distance in metres (inclusive). |
maxRange | non-negative maximum distance in metres (inclusive); or -1.0 to ignore distance. |
owners | list of player IDs that matching entities may have; -1 matches entities with no owner. |
requiredInterface | if non-zero, an interface ID that matching entities must implement. |
accountForSize | if true, compensate for source/target entity sizes. |
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Explore the map (but leave it in the FoW) for player p.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Explore the tiles inside each player's territory.
This is done only at the beginning of the game.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Implements IComponent.
|
inlineoverridevirtual |
Get the effective range in a parablic range query.
source | The entity id at the origin of the query. |
target | A target entity id. |
range | The distance to compare terrain height with. |
yOrigin | Height the source gains over the target by default. |
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Get the average elevation over 8 points on distance range around the entity.
id | the entity id to look around |
range | the distance to compare terrain height with |
Implements ICmpRangeManager.
|
inline |
|
inlineoverridevirtual |
Returns a list of all entities for a specific player.
(This is on this interface because it shares a lot of the implementation. Maybe it should be extended to be more like ExecuteQuery without the range parameter.)
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Returns the mask for the specified identifier.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Returns a list of all entities owned by a player or gaia.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Returns whether the LOS is restricted to a circular map.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Returns a CLosQuerier for checking whether vertex positions are visible to the given player (or other players it shares LOS with).
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Returns whether the whole map has been made visible to the given player.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Returns the visibility status of the given entity, with respect to the given player.
Returns LosVisibility::HIDDEN if the entity doesn't exist or is not in the world. This respects the GetLosRevealAll flag.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Returns the visibility status of the given position, with respect to the given player.
This respects the GetLosRevealAll flag.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Returns a list of all entities of all players except gaia.
Implements ICmpRangeManager.
|
inlinevirtual |
|
inlineoverridevirtual |
Get percent map explored statistics for specified player.
Implements ICmpRangeManager.
|
inlinestatic |
|
inlineoverridevirtual |
Returns shared LOS mask for player.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Access the spatial subdivision kept by the range manager.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Get percent map explored statistics for specified set of players.
Note: this function computes statistics from scratch and should not be called too often.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Reimplemented from IComponent.
|
inlineoverridevirtual |
Implements IComponent.
|
inlineoverride |
|
inline |
|
inline |
Update the LOS state of tiles within a given horizontal strip (i0,j) to (i1,j) (inclusive).
Returns whether the given vertex is outside the normal bounds of the world (i.e.
outside the range of a circular map)
|
inline |
|
inline |
|
inline |
Update the LOS state of tiles within a given horizontal strip (i0,j) to (i1,j) (inclusive).
|
inline |
Update the LOS state of tiles within a given circular range, either adding or removing visibility depending on the template parameter.
Assumes owner is in the valid range.
|
inline |
Update the LOS state of tiles within a given circular range, by removing visibility around the 'from' position and then adding visibility around the 'to' position.
|
inline |
Returns a list of distinct entity IDs that match the given query, sorted by ID.
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Request the update of the visibility cache of ent at next turn.
Typically used for fogging.
Implements ICmpRangeManager.
|
inlineoverride |
|
inline |
|
inline |
|
inlineoverridevirtual |
Reveal the shore for specified player p.
This works like for entities: if RevealShore is called multiple times with enabled, it will be necessary to call it the same number of times with !enabled to make the shore fall back into the FoW.
Implements ICmpRangeManager.
|
inline |
Force any entity in explored territory to appear for player p.
This is useful for miraging entities inside the territory borders at the beginning of a game, or if the "Explore Map" option has been set.
|
inlineoverridevirtual |
Implements IComponent.
|
inline |
|
inlineoverridevirtual |
Set the bounds of the world.
Entities should not be outside the bounds (else efficiency will suffer).
x0,z0,x1,z1 | Coordinates of the corners of the world |
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Toggle the rendering of debug info.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Set the flag specified by the identifier to the supplied value for the entity.
ent | the entity whose flags will be modified. |
identifier | the flag to be modified. |
value | to which the flag will be set. |
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Set the LOS to be restricted to a circular map.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Set whether the whole map should be made visible to the given player.
If player is -1, the map will be made visible to all players.
Implements ICmpRangeManager.
|
inlineoverridevirtual |
Sets shared LOS data for player to the given list of players.
Implements ICmpRangeManager.
|
inline |
|
inline |
|
inline |
|
inline |
Returns whether the given entity matches the given query (ignoring maxRange)
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Perform some internal consistency checks for testing/debugging.
Implements ICmpRangeManager.
bool CCmpRangeManager::m_DebugOverlayDirty |
bool CCmpRangeManager::m_DebugOverlayEnabled |
std::vector<SOverlayLine> CCmpRangeManager::m_DebugOverlayLines |
bool CCmpRangeManager::m_Deserializing |
EntityMap<EntityData> CCmpRangeManager::m_EntityData |
std::vector<u32> CCmpRangeManager::m_ExploredVertices |
std::array<bool, MAX_LOS_PLAYER_ID> CCmpRangeManager::m_GlobalPlayerVisibilityUpdate |
bool CCmpRangeManager::m_GlobalVisibilityUpdate |
bool CCmpRangeManager::m_LosCircular |
std::array<Grid<u16>, MAX_LOS_PLAYER_ID> CCmpRangeManager::m_LosPlayerCounts |
Grid<std::set<entity_id_t> > CCmpRangeManager::m_LosRegions |
i32 CCmpRangeManager::m_LosRegionsPerSide |
std::array<bool, MAX_LOS_PLAYER_ID+2> CCmpRangeManager::m_LosRevealAll |
i32 CCmpRangeManager::m_LosVerticesPerSide |
std::vector<entity_id_t> CCmpRangeManager::m_ModifiedEntities |
std::map<tag_t, Query> CCmpRangeManager::m_Queries |
tag_t CCmpRangeManager::m_QueryNext |
std::array<u16, MAX_LOS_PLAYER_ID+2> CCmpRangeManager::m_SharedDirtyVisibilityMasks |
std::array<u32, MAX_LOS_PLAYER_ID+2> CCmpRangeManager::m_SharedLosMasks |
FastSpatialSubdivision CCmpRangeManager::m_Subdivision |
std::vector<entity_id_t> CCmpRangeManager::m_SubdivisionResults |
u32 CCmpRangeManager::m_TotalInworldVertices |
entity_pos_t CCmpRangeManager::m_WorldX0 |
entity_pos_t CCmpRangeManager::m_WorldX1 |
entity_pos_t CCmpRangeManager::m_WorldZ0 |
entity_pos_t CCmpRangeManager::m_WorldZ1 |
|
static |