Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/helpers/Position.js
Show All 16 Lines | PositionHelper.prototype.DistanceBetweenEntities = function(firstEntity, secondEntity) | ||||
if (!cmpSecondPosition || !cmpSecondPosition.IsInWorld()) | if (!cmpSecondPosition || !cmpSecondPosition.IsInWorld()) | ||||
return Infinity; | return Infinity; | ||||
return cmpFirstPosition.GetPosition2D().distanceTo(cmpSecondPosition.GetPosition2D()); | return cmpFirstPosition.GetPosition2D().distanceTo(cmpSecondPosition.GetPosition2D()); | ||||
}; | }; | ||||
/** | /** | ||||
* @param {Vector2D} origin - The point to check around. | * @param {Vector2D} origin - The point to check around. | ||||
* @param {number} radius - The radius around the point to check. | * @param {number} minRange - The minimum distance the entities must have from the point to check. | ||||
* @param {number} maxRange - The maximum distance the entities may have from the point to check. | |||||
* @param {number[]} players - The players of which we need to check entities. | * @param {number[]} players - The players of which we need to check entities. | ||||
* @param {number} iid - Interface IID that returned entities must implement. Defaults to none. | * @param {number} iid - Interface IID that returned entities must implement. Defaults to none. | ||||
* | * | ||||
* @return {number[]} The id's of the entities in range of the given point. | * @return {number[]} The id's of the entities in range of the given point. | ||||
*/ | */ | ||||
PositionHelper.prototype.EntitiesNearPoint = function(origin, radius, players, iid = 0) | PositionHelper.prototype.EntitiesNearPoint = function(origin, minRange, maxRange, players, iid = 0) | ||||
{ | { | ||||
if (!origin || !radius || !players || !players.length) | if (!origin || !maxRange || !players || !players.length) | ||||
return []; | return []; | ||||
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); | return Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager). | ||||
return cmpRangeManager.ExecuteQueryAroundPos(origin, 0, radius, players, iid, true); | ExecuteQueryAroundPos(origin, minRange, maxRange, players, iid, true); | ||||
}; | }; | ||||
/** | /** | ||||
* Gives the position of the given entity, taking the lateness into account. | * Gives the position of the given entity, taking the lateness into account. | ||||
* Note that vertical movement is ignored. | * Note that vertical movement is ignored. | ||||
* | * | ||||
* @param {number} ent - Entity id of the entity we are finding the location for. | * @param {number} ent - Entity id of the entity we are finding the location for. | ||||
* @param {number} lateness - The time passed since the expected time to fire the function. | * @param {number} lateness - The time passed since the expected time to fire the function. | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator