Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/GuiInterface.js
Show First 20 Lines • Show All 473 Lines • ▼ Show 20 Lines | for (let type of types) | ||||
let range = cmpAttack.GetRange(type); | let range = cmpAttack.GetRange(type); | ||||
ret.attack[type].minRange = range.min; | ret.attack[type].minRange = range.min; | ||||
ret.attack[type].maxRange = range.max; | ret.attack[type].maxRange = range.max; | ||||
let timers = cmpAttack.GetTimers(type); | let timers = cmpAttack.GetTimers(type); | ||||
ret.attack[type].prepareTime = timers.prepare; | ret.attack[type].prepareTime = timers.prepare; | ||||
ret.attack[type].repeatTime = timers.repeat; | ret.attack[type].repeatTime = timers.repeat; | ||||
if (type != "Ranged") | |||||
{ | |||||
// Not a ranged attack, set some defaults. | |||||
ret.attack[type].elevationBonus = 0; | |||||
ret.attack[type].elevationAdaptedRange = ret.attack.maxRange; | |||||
continue; | |||||
} | |||||
ret.attack[type].elevationBonus = range.elevationBonus; | ret.attack[type].elevationBonus = range.elevationBonus; | ||||
if (cmpPosition && cmpPosition.IsInWorld()) | if (cmpPosition && cmpPosition.IsInWorld()) | ||||
// For units, take the range in front of it, no spread, so angle = 0, | // For units, take the range in front of it, no spread, so angle = 0, | ||||
// else, take the average elevation around it: angle = 2 * pi. | // else, take the average elevation around it: angle = 2 * pi. | ||||
ret.attack[type].elevationAdaptedRange = cmpRangeManager.GetElevationAdaptedRange(cmpPosition.GetPosition(), cmpPosition.GetRotation(), range.max, range.elevationBonus, cmpUnitAI ? 0 : 2 * Math.PI); | ret.attack[type].elevationAdaptedRange = cmpRangeManager.GetElevationAdaptedRange(cmpPosition.GetPosition(), cmpPosition.GetRotation(), range.max, range.elevationBonus, cmpUnitAI ? 0 : 2 * Math.PI); | ||||
else | else | ||||
// Not in world, set a default? | // Not in world, set a default? | ||||
▲ Show 20 Lines • Show All 1,467 Lines • ▼ Show 20 Lines | else | ||||
result = { "type": "set first" }; | result = { "type": "set first" }; | ||||
return result; | return result; | ||||
}; | }; | ||||
GuiInterface.prototype.CanAttack = function(player, data) | GuiInterface.prototype.CanAttack = function(player, data) | ||||
{ | { | ||||
let cmpAttack = Engine.QueryInterface(data.entity, IID_Attack); | let cmpAttack = Engine.QueryInterface(data.entity, IID_Attack); | ||||
return cmpAttack && cmpAttack.CanAttack(data.target, data.types || undefined); | return cmpAttack && cmpAttack.CanAttack(data.target, data.mustBeInRange || false, data.ignoreAttackEffects || {}, data.wantedTypes || [], data.projectile || undefined); | ||||
}; | }; | ||||
/* | /* | ||||
* Returns batch build time. | * Returns batch build time. | ||||
*/ | */ | ||||
GuiInterface.prototype.GetBatchTime = function(player, data) | GuiInterface.prototype.GetBatchTime = function(player, data) | ||||
{ | { | ||||
let cmpProductionQueue = Engine.QueryInterface(data.entity, IID_ProductionQueue); | let cmpProductionQueue = Engine.QueryInterface(data.entity, IID_ProductionQueue); | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator