Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 694 Lines • ▼ Show 20 Lines | "actionCheck": function(target, selection) | ||||
"cursor": "action-setup-trade-route", | "cursor": "action-setup-trade-route", | ||||
"tooltip": actionInfo.tooltip, | "tooltip": actionInfo.tooltip, | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 0, | "specificness": 0, | ||||
}, | }, | ||||
"occupy-turret": | |||||
{ | |||||
"execute": function(target, action, selection, queued) | |||||
{ | |||||
Engine.PostNetworkCommand({ | |||||
"type": "occupy-turret", | |||||
"entities": selection, | |||||
"target": action.target, | |||||
"queued": queued | |||||
}); | |||||
Engine.GuiInterfaceCall("PlaySound", { | |||||
"name": "order_garrison", | |||||
"entity": selection[0] | |||||
}); | |||||
return true; | |||||
}, | |||||
"getActionInfo": function(entState, targetState) | |||||
{ | |||||
if (!entState.canGarrison || !targetState.turretHolder || | |||||
!playerCheck(entState, targetState, ["Player", "MutualAlly"])) | |||||
return false; | |||||
if (!targetState.turretHolder.turretPoints.find(point => | |||||
!point.allowedClasses || MatchesClassList(entState.identity.classes, point.allowedClasses))) | |||||
return false; | |||||
let occupiedTurrets = targetState.turretHolder.turretPoints.filter(point => point.entity != null); | |||||
let tooltip = sprintf(translate("Current turrets: %(occupied)s/%(capacity)s"), { | |||||
"occupied": occupiedTurrets.length, | |||||
"capacity": targetState.turretHolder.turretPoints.length | |||||
}); | |||||
if (occupiedTurrets == targetState.turretHolder.turretPoints.length) | |||||
tooltip = coloredText(tooltip, "orange"); | |||||
return { | |||||
"possible": true, | |||||
"tooltip": tooltip | |||||
}; | |||||
}, | |||||
"preSelectedActionCheck": function(target, selection) | |||||
{ | |||||
if (preSelectedAction != ACTION_GARRISON) | |||||
return false; | |||||
let actionInfo = getActionInfo("occupy-turret", target, selection); | |||||
if (!actionInfo.possible) | |||||
return { | |||||
"type": "none", | |||||
"cursor": "action-garrison-disabled", | |||||
"target": null | |||||
}; | |||||
return { | |||||
"type": "occupy-turret", | |||||
"cursor": "action-garrison", | |||||
"tooltip": actionInfo.tooltip, | |||||
"target": target | |||||
}; | |||||
}, | |||||
"hotkeyActionCheck": function(target, selection) | |||||
{ | |||||
let actionInfo = getActionInfo("occupy-turret", target, selection); | |||||
if (!Engine.HotkeyIsPressed("session.garrison") || !actionInfo.possible) | |||||
return false; | |||||
return { | |||||
"type": "occupy-turret", | |||||
"cursor": "action-garrison", | |||||
"tooltip": actionInfo.tooltip, | |||||
"target": target | |||||
}; | |||||
}, | |||||
"specificness": 20, | |||||
}, | |||||
"garrison": | "garrison": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "garrison", | "type": "garrison", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
▲ Show 20 Lines • Show All 990 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator