Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/GuiInterface.js
Show First 20 Lines • Show All 443 Lines • ▼ Show 20 Lines | GuiInterface.prototype.GetExtendedEntityState = function(player, ent) | ||||
let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | ||||
let cmpAttack = Engine.QueryInterface(ent, IID_Attack); | let cmpAttack = Engine.QueryInterface(ent, IID_Attack); | ||||
if (cmpAttack) | if (cmpAttack) | ||||
{ | { | ||||
let types = cmpAttack.GetAttackTypes(); | let types = cmpAttack.GetAttackTypes(); | ||||
if (types.length) | if (types.length) | ||||
ret.attack = {}; | ret.attack = {}; | ||||
for (let type of types) | for (let type of types) | ||||
{ | { | ||||
ret.attack[type] = cmpAttack.GetAttackStrengths(type); | ret.attack[type] = cmpAttack.GetAttackStrengths(type); | ||||
ret.attack[type].splash = cmpAttack.GetSplashDamage(type); | ret.attack[type].splash = cmpAttack.GetSplashDamage(type); | ||||
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; | ||||
▲ Show 20 Lines • Show All 1,367 Lines • ▼ Show 20 Lines | GuiInterface.prototype.GetTradingDetails = function(player, data) | ||||
else | else | ||||
{ | { | ||||
// Else both markets are not null and target is different from them | // Else both markets are not null and target is different from them | ||||
result = { "type": "set first" }; | result = { "type": "set first" }; | ||||
} | } | ||||
return result; | return result; | ||||
}; | }; | ||||
GuiInterface.prototype.CanCapture = function(player, data) | |||||
{ | |||||
let cmpAttack = Engine.QueryInterface(data.entity, IID_Attack); | |||||
if (!cmpAttack) | |||||
return false; | |||||
let owner = QueryOwnerInterface(data.entity).GetPlayerID(); | |||||
let cmpCapturable = QueryMiragedInterface(data.target, IID_Capturable); | |||||
if (cmpCapturable && cmpCapturable.CanCapture(owner) && cmpAttack.GetAttackTypes().indexOf("Capture") != -1) | |||||
return cmpAttack.CanAttack(data.target); | |||||
return false; | |||||
}; | |||||
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); | ||||
if (!cmpAttack) | return cmpAttack && cmpAttack.CanAttack(data.target, data.types || undefined); | ||||
fatherbushido: You choose on purpose to return undefined? | |||||
Not Done Inline ActionsDon't see anything better: when data.types is not existing, empty or undefined, all those should return cmpAttack.CanAttack(data.target, undefined). Putting an empty array here seems less self-explaining than undefined. (Also we don't return undefined the CanAttack function is called with undefined) bb: Don't see anything better: when `data.types` is not existing, empty or undefined, all those… | |||||
Not Done Inline Actionscould you forget my question :) I missed the ")" and so I didn't understand :) fatherbushido: could you forget my question :) I missed the ")" and so I didn't understand :) | |||||
return false; | |||||
let cmpEntityPlayer = QueryOwnerInterface(data.entity, IID_Player); | |||||
let cmpTargetPlayer = QueryOwnerInterface(data.target, IID_Player); | |||||
if (!cmpEntityPlayer || !cmpTargetPlayer) | |||||
return false; | |||||
// if the owner is an enemy, it's up to the attack component to decide | |||||
if (cmpEntityPlayer.IsEnemy(cmpTargetPlayer.GetPlayerID())) | |||||
return cmpAttack.CanAttack(data.target); | |||||
return false; | |||||
}; | }; | ||||
/* | /* | ||||
* 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 128 Lines • ▼ Show 20 Lines | let exposedFunctions = { | ||||
"SetBuildingPlacementPreview": 1, | "SetBuildingPlacementPreview": 1, | ||||
"SetWallPlacementPreview": 1, | "SetWallPlacementPreview": 1, | ||||
"GetFoundationSnapData": 1, | "GetFoundationSnapData": 1, | ||||
"PlaySound": 1, | "PlaySound": 1, | ||||
"FindIdleUnits": 1, | "FindIdleUnits": 1, | ||||
"HasIdleUnits": 1, | "HasIdleUnits": 1, | ||||
"GetTradingRouteGain": 1, | "GetTradingRouteGain": 1, | ||||
"GetTradingDetails": 1, | "GetTradingDetails": 1, | ||||
"CanCapture": 1, | |||||
"CanAttack": 1, | "CanAttack": 1, | ||||
"GetBatchTime": 1, | "GetBatchTime": 1, | ||||
"IsMapRevealed": 1, | "IsMapRevealed": 1, | ||||
"SetPathfinderDebugOverlay": 1, | "SetPathfinderDebugOverlay": 1, | ||||
"SetPathfinderHierDebugOverlay": 1, | "SetPathfinderHierDebugOverlay": 1, | ||||
"SetObstructionDebugOverlay": 1, | "SetObstructionDebugOverlay": 1, | ||||
"SetMotionDebugOverlay": 1, | "SetMotionDebugOverlay": 1, | ||||
Show All 15 Lines |
Wildfire Games · Phabricator
You choose on purpose to return undefined?