Pyrogenesis
13997
|
Provides efficient range-based queries of the game world, and also LOS-based effects (fog of war). More...
#include <ICmpRangeManager.h>
Classes | |
class | CLosQuerier |
Object providing efficient abstracted access to the LOS state. More... | |
Public Types | |
enum | ELosState { LOS_UNEXPLORED = 0, LOS_EXPLORED = 1, LOS_VISIBLE = 2, LOS_MASK = 3 } |
enum | ELosVisibility { VIS_HIDDEN, VIS_FOGGED, VIS_VISIBLE } |
typedef u32 | tag_t |
External identifiers for active queries. More... | |
Public Member Functions | |
virtual void | SetBounds (entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, ssize_t vertices)=0 |
Set the bounds of the world. More... | |
virtual std::vector< entity_id_t > | ExecuteQuery (entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, std::vector< int > owners, int requiredInterface)=0 |
Execute a passive query. More... | |
virtual tag_t | CreateActiveQuery (entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, std::vector< int > owners, int requiredInterface, u8 flags)=0 |
Construct an active query. More... | |
virtual tag_t | CreateActiveParabolicQuery (entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, entity_pos_t elevationBonus, std::vector< int > owners, int requiredInterface, u8 flags)=0 |
Construct an active query of a paraboloic form around the unit. More... | |
virtual entity_pos_t | GetElevationAdaptedRange (CFixedVector3D pos, CFixedVector3D rot, entity_pos_t range, entity_pos_t elevationBonus, entity_pos_t angle)=0 |
Get the average elevation over 8 points on distance range around the entity. More... | |
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 std::vector< entity_id_t > | ResetActiveQuery (tag_t tag)=0 |
Immediately execute a query, and re-enable it if disabled. More... | |
virtual std::vector< entity_id_t > | GetEntitiesByPlayer (player_id_t player)=0 |
Returns list of all entities for specific player. More... | |
virtual void | SetDebugOverlay (bool enabled)=0 |
Toggle the rendering of debug info. More... | |
virtual u8 | GetEntityFlagMask (std::string identifier)=0 |
Returns the mask for the specified identifier. More... | |
virtual void | SetEntityFlag (entity_id_t ent, std::string identifier, bool value)=0 |
Set the flag specified by the identifier to the supplied value for the entity. More... | |
virtual CLosQuerier | GetLosQuerier (player_id_t player)=0 |
Returns a CLosQuerier for checking whether vertex positions are visible to the given player (or other players it shares LOS with). More... | |
virtual ELosVisibility | GetLosVisibility (CEntityHandle ent, player_id_t player, bool forceRetainInFog=false)=0 |
Returns the visibility status of the given entity, with respect to the given player. More... | |
virtual ELosVisibility | GetLosVisibility (entity_id_t ent, player_id_t player, bool forceRetainInFog=false)=0 |
std::string | GetLosVisibility_wrapper (entity_id_t ent, player_id_t player, bool forceRetainInFog) |
GetLosVisibility wrapped for script calls. More... | |
virtual void | SetLosRevealAll (player_id_t player, bool enabled)=0 |
Set whether the whole map should be made visible to the given player. More... | |
virtual bool | GetLosRevealAll (player_id_t player)=0 |
Returns whether the whole map has been made visible to the given player. More... | |
virtual void | SetLosCircular (bool enabled)=0 |
Set the LOS to be restricted to a circular map. More... | |
virtual bool | GetLosCircular ()=0 |
Returns whether the LOS is restricted to a circular map. More... | |
virtual void | SetSharedLos (player_id_t player, std::vector< player_id_t > players)=0 |
Sets shared LOS data for player to the given list of players. More... | |
virtual u32 | GetSharedLosMask (player_id_t player)=0 |
Returns shared LOS mask for player. More... | |
virtual u8 | GetPercentMapExplored (player_id_t player)=0 |
Get percent map explored statistics for specified player. More... | |
virtual void | Verify ()=0 |
Perform some internal consistency checks for testing/debugging. More... | |
![]() | |
virtual | ~IComponent () |
virtual void | Init (const CParamNode ¶mNode)=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 ¶mNode, IDeserializer &deserialize)=0 |
virtual JSClass * | GetJSClass () const |
virtual jsval | GetJSInstance () const |
Additional Inherited Members | |
![]() | |
static std::string | GetSchema () |
static u8 | GetSerializationVersion () |
Provides efficient range-based queries of the game world, and also LOS-based effects (fog of war).
(These are somewhat distinct concepts but they share a lot of the implementation, so for efficiency they're combined into this class.)
Possible use cases:
In most cases the users are event-based and want notifications when something has entered or left the range, and the query can be set up once and rarely changed. These queries have to be fast. It's fine to approximate an entity as a point.
Current design:
This class handles just the most common parts of range queries: distance, target interface, and player ownership. The caller can then apply any more complex filtering that it needs.
There are two types of query: Passive queries are performed by ExecuteQuery and immediately return the matching entities. Active queries are set up by CreateActiveQuery, and then a CMessageRangeUpdate message will be sent to the entity once per turn if anybody has entered or left the range since the last RangeUpdate. Queries can be disabled, in which case no message will be sent.
Definition at line 66 of file ICmpRangeManager.h.
typedef u32 ICmpRangeManager::tag_t |
External identifiers for active queries.
Definition at line 72 of file ICmpRangeManager.h.
Enumerator | |
---|---|
LOS_UNEXPLORED | |
LOS_EXPLORED | |
LOS_VISIBLE | |
LOS_MASK |
Definition at line 189 of file ICmpRangeManager.h.
Enumerator | |
---|---|
VIS_HIDDEN | |
VIS_FOGGED | |
VIS_VISIBLE |
Definition at line 197 of file ICmpRangeManager.h.
|
pure virtual |
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 elevation, a physical correct paraboloid with height=maxRange/2 above the unit is used to query them |
elevationBonus | 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. |
Implemented in CCmpRangeManager.
|
pure virtual |
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. |
Implemented in CCmpRangeManager.
|
pure virtual |
Destroy a query and clean up resources.
This must be called when an entity no longer needs its query (e.g. when the entity is destroyed).
tag | identifier of query. |
Implemented in CCmpRangeManager.
|
pure virtual |
Disable the processing of a query (no RangeUpdate messages will be sent).
tag | identifier of query. |
Implemented in CCmpRangeManager.
|
pure virtual |
Re-enable the processing of a query.
tag | identifier of query. |
Implemented in CCmpRangeManager.
|
pure virtual |
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. |
Implemented in CCmpRangeManager.
|
pure virtual |
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 |
Implemented in CCmpRangeManager.
|
pure virtual |
Returns list of all entities for 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.)
Implemented in CCmpRangeManager.
|
pure virtual |
Returns the mask for the specified identifier.
Implemented in CCmpRangeManager.
|
pure virtual |
Returns whether the LOS is restricted to a circular map.
Implemented in CCmpRangeManager.
|
pure virtual |
Returns a CLosQuerier for checking whether vertex positions are visible to the given player (or other players it shares LOS with).
Implemented in CCmpRangeManager.
|
pure virtual |
Returns whether the whole map has been made visible to the given player.
Implemented in CCmpRangeManager.
|
pure virtual |
Returns the visibility status of the given entity, with respect to the given player.
Returns VIS_HIDDEN if the entity doesn't exist or is not in the world. This respects the GetLosRevealAll flag. If forceRetainInFog is true, the visibility acts as if CCmpVision's RetainInFog flag were set. TODO: This is a hack to allow preview entities in FoW to return fogged instead of hidden, see http://trac.wildfiregames.com/ticket/958
Implemented in CCmpRangeManager.
|
pure virtual |
Implemented in CCmpRangeManager.
std::string ICmpRangeManager::GetLosVisibility_wrapper | ( | entity_id_t | ent, |
player_id_t | player, | ||
bool | forceRetainInFog | ||
) |
GetLosVisibility wrapped for script calls.
Returns "hidden", "fogged" or "visible".
Definition at line 24 of file ICmpRangeManager.cpp.
|
pure virtual |
Get percent map explored statistics for specified player.
Implemented in CCmpRangeManager.
|
pure virtual |
Returns shared LOS mask for player.
Implemented in CCmpRangeManager.
|
pure virtual |
Immediately execute a query, and re-enable it if disabled.
The next RangeUpdate message will say who has entered/left since this call, so you won't miss any notifications.
tag | identifier of query. |
Implemented in CCmpRangeManager.
|
pure virtual |
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 |
vertices | Number of terrain vertices per side |
Implemented in CCmpRangeManager.
|
pure virtual |
Toggle the rendering of debug info.
Implemented in CCmpRangeManager.
|
pure virtual |
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. |
Implemented in CCmpRangeManager.
|
pure virtual |
Set the LOS to be restricted to a circular map.
Implemented in CCmpRangeManager.
|
pure virtual |
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.
Implemented in CCmpRangeManager.
|
pure virtual |
Sets shared LOS data for player to the given list of players.
Implemented in CCmpRangeManager.
|
pure virtual |
Perform some internal consistency checks for testing/debugging.
Implemented in CCmpRangeManager.