Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/GuiInterface.js
Show First 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | GuiInterface.prototype.GetEntityState = function(player, ent) | ||||
let cmpRallyPoint = Engine.QueryInterface(ent, IID_RallyPoint); | let cmpRallyPoint = Engine.QueryInterface(ent, IID_RallyPoint); | ||||
if (cmpRallyPoint) | if (cmpRallyPoint) | ||||
ret.rallyPoint = { "position": cmpRallyPoint.GetPositions()[0] }; // undefined or {x,z} object | ret.rallyPoint = { "position": cmpRallyPoint.GetPositions()[0] }; // undefined or {x,z} object | ||||
let cmpGarrisonHolder = Engine.QueryInterface(ent, IID_GarrisonHolder); | let cmpGarrisonHolder = Engine.QueryInterface(ent, IID_GarrisonHolder); | ||||
if (cmpGarrisonHolder) | if (cmpGarrisonHolder) | ||||
ret.garrisonHolder = { | ret.garrisonHolder = { | ||||
"entities": cmpGarrisonHolder.GetEntities(), | "entities": cmpGarrisonHolder.GetEntities(), | ||||
"hiddenEntities": cmpGarrisonHolder.GetNonvisibleGarrisonedEntities(), | |||||
"buffHeal": cmpGarrisonHolder.GetHealRate(), | "buffHeal": cmpGarrisonHolder.GetHealRate(), | ||||
"allowedClasses": cmpGarrisonHolder.GetAllowedClasses(), | "allowedClasses": cmpGarrisonHolder.GetAllowedClasses(), | ||||
"capacity": cmpGarrisonHolder.GetCapacity(), | "capacity": cmpGarrisonHolder.GetCapacity(), | ||||
"garrisonedEntitiesCount": cmpGarrisonHolder.GetGarrisonedEntitiesCount() | "garrisonedEntitiesCount": cmpGarrisonHolder.GetGarrisonedEntitiesCount() | ||||
}; | }; | ||||
ret.canGarrison = !!Engine.QueryInterface(ent, IID_Garrisonable); | let cmpGarrisonable = Engine.QueryInterface(ent, IID_Garrisonable); | ||||
if (cmpGarrisonable) | |||||
ret.canGarrison = { | |||||
"unloadable": cmpGarrisonable.IsUnloadable() | |||||
} | |||||
let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); | let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); | ||||
if (cmpUnitAI) | if (cmpUnitAI) | ||||
ret.unitAI = { | ret.unitAI = { | ||||
"state": cmpUnitAI.GetCurrentState(), | "state": cmpUnitAI.GetCurrentState(), | ||||
"orders": cmpUnitAI.GetOrders(), | "orders": cmpUnitAI.GetOrders(), | ||||
"hasWorkOrders": cmpUnitAI.HasWorkOrders(), | "hasWorkOrders": cmpUnitAI.HasWorkOrders(), | ||||
"canGuard": cmpUnitAI.CanGuard(), | "canGuard": cmpUnitAI.CanGuard(), | ||||
▲ Show 20 Lines • Show All 1,447 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.CanAttack = function(player, data) | GuiInterface.prototype.CanAttack = function(player, data) | ||||
Stan: In antoher diff since player is unused I guess it could be removed ? | |||||
Done Inline ActionsNot really, the GUI always sends player first, even though it is often unused. Freagarach: Not really, the GUI always sends `player` first, even though it is often unused. | |||||
{ | { | ||||
let cmpAttack = Engine.QueryInterface(data.entity, IID_Attack); | let cmpUnitAI = Engine.QueryInterface(data.entity, IID_UnitAI); | ||||
return cmpAttack && cmpAttack.CanAttack(data.target, data.types || undefined); | return cmpUnitAI && cmpUnitAI.CanAttack(data.target, data.types || undefined); | ||||
Done Inline ActionsI'd reverse those two checks. The natural condition is having a cmpAttack, and then only check for UnitAI. wraitii: I'd reverse those two checks. The natural condition is having a cmpAttack, and then only check… | |||||
}; | }; | ||||
/* | /* | ||||
* Returns batch build time. | * Returns batch build time. | ||||
*/ | */ | ||||
GuiInterface.prototype.GetBatchTime = function(player, data) | GuiInterface.prototype.GetBatchTime = function(player, data) | ||||
Done Inline ActionsThese changes seem unrelated? wraitii: These changes seem unrelated? | |||||
Done Inline ActionsSame as above, we allow to have healers as turrets now. Freagarach: Same as above, we allow to have healers as turrets now. | |||||
{ | { | ||||
let cmpProductionQueue = Engine.QueryInterface(data.entity, IID_ProductionQueue); | let cmpProductionQueue = Engine.QueryInterface(data.entity, IID_ProductionQueue); | ||||
if (!cmpProductionQueue) | if (!cmpProductionQueue) | ||||
return 0; | return 0; | ||||
Done Inline ActionsSame here. wraitii: Same here. | |||||
return cmpProductionQueue.GetBatchTime(data.batchSize); | return cmpProductionQueue.GetBatchTime(data.batchSize); | ||||
}; | }; | ||||
GuiInterface.prototype.IsMapRevealed = function(player) | GuiInterface.prototype.IsMapRevealed = function(player) | ||||
{ | { | ||||
return Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetLosRevealAll(player); | return Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetLosRevealAll(player); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
In antoher diff since player is unused I guess it could be removed ?