Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 240 Lines • ▼ Show 20 Lines | "actionCheck": function(target, selection) | ||||
"cursor": "action-attack", | "cursor": "action-attack", | ||||
"target": target, | "target": target, | ||||
"firstAbleEntity": actionInfo.entity | "firstAbleEntity": actionInfo.entity | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 10, | "specificness": 10, | ||||
}, | }, | ||||
"call-to-arms": { | |||||
"execute": function(target, action, selection, queued, pushFront) | |||||
{ | |||||
let targetClasses; | |||||
if (Engine.HotkeyIsPressed("session.attackmoveUnit")) | |||||
targetClasses = { "attack": ["Unit"] }; | |||||
else | |||||
targetClasses = { "attack": ["Unit", "Structure"] }; | |||||
Engine.PostNetworkCommand({ | |||||
"type": "call-to-arms", | |||||
"entities": selection, | |||||
"target": target, | |||||
"targetClasses": targetClasses, | |||||
"queued": queued, | |||||
"pushFront": pushFront, | |||||
"allowCapture": true, | |||||
"formation": g_AutoFormation.getNull() | |||||
}); | |||||
return true; | |||||
}, | |||||
"getActionInfo": function(entState, targetState) | |||||
{ | |||||
return { "possible": !!entState.unitAI }; | |||||
}, | |||||
"actionCheck": function(target, selection) | |||||
{ | |||||
const actionInfo = getActionInfo("call-to-arms", target, selection); | |||||
return actionInfo.possible && { | |||||
"type": "call-to-arms", | |||||
"cursor": "action-attack", | |||||
"target": target, | |||||
"firstAbleEntity": actionInfo.entity | |||||
}; | |||||
}, | |||||
"preSelectedActionCheck": function(target, selection) | |||||
{ | |||||
return preSelectedAction == ACTION_CALLTOARMS && | |||||
this.actionCheck(target, selection); | |||||
}, | |||||
"specificness": 50, | |||||
}, | |||||
"patrol": | "patrol": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued, pushFront) | "execute": function(target, action, selection, queued, pushFront) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "patrol", | "type": "patrol", | ||||
"entities": selection, | "entities": selection, | ||||
"x": target.x, | "x": target.x, | ||||
▲ Show 20 Lines • Show All 1,161 Lines • ▼ Show 20 Lines | "stop": { | ||||
"execute": function(entStates) | "execute": function(entStates) | ||||
{ | { | ||||
if (entStates.length) | if (entStates.length) | ||||
stopUnits(entStates.map(entState => entState.id)); | stopUnits(entStates.map(entState => entState.id)); | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | "allowedPlayers": ["Player"] | ||||
}, | }, | ||||
"call-to-arms": { | |||||
"getInfo": function(entStates) | |||||
{ | |||||
const classes = ["Soldier", "Warship", "Siege", "Healer"]; | |||||
if (entStates.every(entState => !MatchesClassList(entState.identity.classes, classes))) | |||||
return false; | |||||
return { | |||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.calltoarms") + | |||||
translate("Send the selected units on attack move to the specified location after dropping resources."), | |||||
"icon": "call-to-arms.png", | |||||
"enabled": true | |||||
}; | |||||
}, | |||||
"execute": function(entStates) | |||||
{ | |||||
inputState = INPUT_PRESELECTEDACTION; | |||||
preSelectedAction = ACTION_CALLTOARMS; | |||||
}, | |||||
"allowedPlayers": ["Player"] | |||||
}, | |||||
"garrison": { | "garrison": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.garrisonable || | if (entStates.every(entState => !entState.garrisonable || | ||||
entState.garrisonable.holder != INVALID_ENTITY)) | entState.garrisonable.holder != INVALID_ENTITY)) | ||||
return false; | return false; | ||||
return { | return { | ||||
▲ Show 20 Lines • Show All 456 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator