Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/components/ICmpRangeManager.h
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
* - units gathering from a resource that is exhausted need to find a new resource of the | * - units gathering from a resource that is exhausted need to find a new resource of the | ||||
* same type, near the old one and reachable. | * same type, near the old one and reachable. | ||||
* - projectile weapons with splash damage need to find all units within some distance | * - projectile weapons with splash damage need to find all units within some distance | ||||
* of the target point. | * of the target point. | ||||
* - ... | * - ... | ||||
* | * | ||||
* In most cases the users are event-based and want notifications when something | * 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. | * has entered or left the range, and the query can be set up once and rarely changed. | ||||
* These queries have to be fast. Entities are approximated as circles. | * These queries have to be fast. Entities are approximated as points or circles | ||||
* (queries can be set up to ignore sizes because LOS currently ignores it, and mismatches are problematic). | |||||
* | * | ||||
* Current design: | * Current design: | ||||
* | * | ||||
* This class handles just the most common parts of range queries: | * This class handles just the most common parts of range queries: | ||||
* distance, target interface, and player ownership. | * distance, target interface, and player ownership. | ||||
* The caller can then apply any more complex filtering that it needs. | * The caller can then apply any more complex filtering that it needs. | ||||
* | * | ||||
* There are two types of query: | * There are two types of query: | ||||
Show All 26 Lines | public: | ||||
/** | /** | ||||
* Execute a passive query. | * Execute a passive query. | ||||
* @param source the entity around which the range will be computed. | * @param source the entity around which the range will be computed. | ||||
* @param minRange non-negative minimum distance in metres (inclusive). | * @param minRange non-negative minimum distance in metres (inclusive). | ||||
* @param maxRange non-negative maximum distance in metres (inclusive); or -1.0 to ignore distance. | * @param maxRange non-negative maximum distance in metres (inclusive); or -1.0 to ignore distance. | ||||
* @param owners list of player IDs that matching entities may have; -1 matches entities with no owner. | * @param owners list of player IDs that matching entities may have; -1 matches entities with no owner. | ||||
* @param requiredInterface if non-zero, an interface ID that matching entities must implement. | * @param requiredInterface if non-zero, an interface ID that matching entities must implement. | ||||
* @param accountForSize if true, compensate for source/target entity sizes. | |||||
* @return list of entities matching the query, ordered by increasing distance from the source entity. | * @return list of entities matching the query, ordered by increasing distance from the source entity. | ||||
*/ | */ | ||||
virtual std::vector<entity_id_t> ExecuteQuery(entity_id_t source, | virtual std::vector<entity_id_t> ExecuteQuery(entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, | ||||
entity_pos_t minRange, entity_pos_t maxRange, const std::vector<int>& owners, int requiredInterface) = 0; | const std::vector<int>& owners, int requiredInterface, bool accountForSize) = 0; | ||||
/** | /** | ||||
* Execute a passive query. | * Execute a passive query. | ||||
* @param pos the position around which the range will be computed. | * @param pos the position around which the range will be computed. | ||||
* @param minRange non-negative minimum distance in metres (inclusive). | * @param minRange non-negative minimum distance in metres (inclusive). | ||||
* @param maxRange non-negative maximum distance in metres (inclusive); or -1.0 to ignore distance. | * @param maxRange non-negative maximum distance in metres (inclusive); or -1.0 to ignore distance. | ||||
* @param owners list of player IDs that matching entities may have; -1 matches entities with no owner. | * @param owners list of player IDs that matching entities may have; -1 matches entities with no owner. | ||||
* @param requiredInterface if non-zero, an interface ID that matching entities must implement. | * @param requiredInterface if non-zero, an interface ID that matching entities must implement. | ||||
* @param accountForSize if true, compensate for source/target entity sizes. | |||||
* @return list of entities matching the query, ordered by increasing distance from the source entity. | * @return list of entities matching the query, ordered by increasing distance from the source entity. | ||||
*/ | */ | ||||
virtual std::vector<entity_id_t> ExecuteQueryAroundPos(const CFixedVector2D& pos, | virtual std::vector<entity_id_t> ExecuteQueryAroundPos(const CFixedVector2D& pos, entity_pos_t minRange, entity_pos_t maxRange, | ||||
entity_pos_t minRange, entity_pos_t maxRange, const std::vector<int>& owners, int requiredInterface) = 0; | const std::vector<int>& owners, int requiredInterface, bool accountForSize) = 0; | ||||
/** | /** | ||||
* Construct an active query. The query will be disabled by default. | * Construct an active query. The query will be disabled by default. | ||||
* @param source the entity around which the range will be computed. | * @param source the entity around which the range will be computed. | ||||
* @param minRange non-negative minimum distance in metres (inclusive). | * @param minRange non-negative minimum distance in metres (inclusive). | ||||
* @param maxRange non-negative maximum distance in metres (inclusive); or -1.0 to ignore distance. | * @param maxRange non-negative maximum distance in metres (inclusive); or -1.0 to ignore distance. | ||||
* @param owners list of player IDs that matching entities may have; -1 matches entities with no owner. | * @param owners list of player IDs that matching entities may have; -1 matches entities with no owner. | ||||
* @param requiredInterface if non-zero, an interface ID that matching entities must implement. | * @param requiredInterface if non-zero, an interface ID that matching entities must implement. | ||||
* @param flags if a entity in range has one of the flags set it will show up. | * @param flags if a entity in range has one of the flags set it will show up. | ||||
* @param accountForSize if true, compensate for source/target entity sizes. | |||||
* @return unique non-zero identifier of query. | * @return unique non-zero identifier of query. | ||||
*/ | */ | ||||
virtual tag_t CreateActiveQuery(entity_id_t source, | virtual tag_t CreateActiveQuery(entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, | ||||
entity_pos_t minRange, entity_pos_t maxRange, const std::vector<int>& owners, int requiredInterface, u8 flags) = 0; | const std::vector<int>& owners, int requiredInterface, u8 flags, bool accountForSize) = 0; | ||||
/** | /** | ||||
* Construct an active query of a paraboloic form around the unit. | * Construct an active query of a paraboloic form around the unit. | ||||
* The query will be disabled by default. | * The query will be disabled by default. | ||||
* @param source the entity around which the range will be computed. | * @param source the entity around which the range will be computed. | ||||
* @param minRange non-negative minimum horizontal distance in metres (inclusive). MinRange doesn't do parabolic checks. | * @param minRange non-negative minimum horizontal distance in metres (inclusive). MinRange doesn't do parabolic checks. | ||||
* @param maxRange non-negative maximum distance in metres (inclusive) for units on the same elevation; | * @param maxRange non-negative maximum distance in metres (inclusive) for units on the same elevation; | ||||
* or -1.0 to ignore distance. | * 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 | * For units on a different elevation, a physical correct paraboloid with height=maxRange/2 above the unit is used to query them | ||||
* @param elevationBonus extra bonus so the source can be placed higher and shoot further | * @param elevationBonus extra bonus so the source can be placed higher and shoot further | ||||
* @param owners list of player IDs that matching entities may have; -1 matches entities with no owner. | * @param owners list of player IDs that matching entities may have; -1 matches entities with no owner. | ||||
* @param requiredInterface if non-zero, an interface ID that matching entities must implement. | * @param requiredInterface if non-zero, an interface ID that matching entities must implement. | ||||
* @param flags if a entity in range has one of the flags set it will show up. | * @param 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. | |||||
* @return unique non-zero identifier of query. | * @return unique non-zero identifier of query. | ||||
*/ | */ | ||||
virtual tag_t CreateActiveParabolicQuery(entity_id_t source, | virtual tag_t CreateActiveParabolicQuery(entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, entity_pos_t elevationBonus, | ||||
entity_pos_t minRange, entity_pos_t maxRange, entity_pos_t elevationBonus, const std::vector<int>& owners, int requiredInterface, u8 flags) = 0; | const std::vector<int>& owners, int requiredInterface, u8 flags) = 0; | ||||
/** | /** | ||||
* Get the average elevation over 8 points on distance range around the entity | * Get the average elevation over 8 points on distance range around the entity | ||||
* @param id the entity id to look around | * @param id the entity id to look around | ||||
* @param range the distance to compare terrain height with | * @param range the distance to compare terrain height with | ||||
* @return a fixed number representing the average difference. It's positive when the entity is on average higher than the terrain surrounding it. | * @return a fixed number representing the average difference. It's positive when the entity is on average higher than the terrain surrounding it. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 192 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator