Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/GuiInterface.js
Show First 20 Lines • Show All 371 Lines • ▼ Show 20 Lines | ret.garrisonHolder = { | ||||
"allowedClasses": cmpGarrisonHolder.GetAllowedClasses(), | "allowedClasses": cmpGarrisonHolder.GetAllowedClasses(), | ||||
"capacity": cmpGarrisonHolder.GetCapacity(), | "capacity": cmpGarrisonHolder.GetCapacity(), | ||||
"garrisonedEntitiesCount": cmpGarrisonHolder.GetGarrisonedEntitiesCount() | "garrisonedEntitiesCount": cmpGarrisonHolder.GetGarrisonedEntitiesCount() | ||||
}; | }; | ||||
let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); | let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); | ||||
if (cmpUnitAI) | if (cmpUnitAI) | ||||
ret.unitAI = { | ret.unitAI = { | ||||
"formation": cmpUnitAI.GetFormationTemplate(), | |||||
"state": cmpUnitAI.GetCurrentState(), | "state": cmpUnitAI.GetCurrentState(), | ||||
"orders": cmpUnitAI.GetOrders(), | "orders": cmpUnitAI.GetOrders(), | ||||
"hasWorkOrders": cmpUnitAI.HasWorkOrders(), | "hasWorkOrders": cmpUnitAI.HasWorkOrders(), | ||||
"canGuard": cmpUnitAI.CanGuard(), | "canGuard": cmpUnitAI.CanGuard(), | ||||
"isGuarding": cmpUnitAI.IsGuardOf(), | "isGuarding": cmpUnitAI.IsGuardOf(), | ||||
"possibleStances": cmpUnitAI.GetPossibleStances(), | "possibleStances": cmpUnitAI.GetPossibleStances(), | ||||
"isIdle":cmpUnitAI.IsIdle(), | "isIdle":cmpUnitAI.IsIdle(), | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | ret.loot = { | ||||
"stone": resources.stone, | "stone": resources.stone, | ||||
"metal": resources.metal | "metal": resources.metal | ||||
}; | }; | ||||
} | } | ||||
let cmpUnitMotion = Engine.QueryInterface(ent, IID_UnitMotion); | let cmpUnitMotion = Engine.QueryInterface(ent, IID_UnitMotion); | ||||
if (cmpUnitMotion) | if (cmpUnitMotion) | ||||
ret.speed = { | ret.speed = { | ||||
"walk": cmpUnitMotion.GetWalkSpeed(), | "walk": cmpUnitMotion.GetBaseSpeed(), | ||||
"run": cmpUnitMotion.GetRunSpeed() | "run": cmpUnitMotion.GetBaseSpeed() * cmpUnitMotion.GetTopSpeedRatio(), | ||||
"current": cmpUnitMotion.GetSpeed(), | |||||
"tryingToMove" : cmpUnitMotion.IsTryingToMove() | |||||
}; | }; | ||||
return ret; | return ret; | ||||
}; | }; | ||||
GuiInterface.prototype.GetAverageRangeForBuildings = function(player, cmd) | GuiInterface.prototype.GetAverageRangeForBuildings = function(player, cmd) | ||||
{ | { | ||||
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); | let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); | ||||
▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | return { | ||||
"name": template.Formation.FormationName, | "name": template.Formation.FormationName, | ||||
"tooltip": template.Formation.DisabledTooltip || "", | "tooltip": template.Formation.DisabledTooltip || "", | ||||
"icon": template.Formation.Icon | "icon": template.Formation.Icon | ||||
}; | }; | ||||
}; | }; | ||||
GuiInterface.prototype.IsFormationSelected = function(player, data) | GuiInterface.prototype.IsFormationSelected = function(player, data) | ||||
{ | { | ||||
for (let ent of data.ents) | for (let ent of data.entities) | ||||
{ | { | ||||
let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); | let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); | ||||
// GetLastFormationName is named in a strange way as it (also) is | if (cmpUnitAI && cmpUnitAI.GetFormationTemplate() == data.formationTemplate) | ||||
// the value of the current formation (see Formation.js LoadFormation) | |||||
if (cmpUnitAI && cmpUnitAI.GetLastFormationTemplate() == data.formationTemplate) | |||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
}; | }; | ||||
GuiInterface.prototype.IsStanceSelected = function(player, data) | GuiInterface.prototype.IsStanceSelected = function(player, data) | ||||
{ | { | ||||
for (let ent of data.ents) | for (let ent of data.ents) | ||||
▲ Show 20 Lines • Show All 1,187 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator