Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
DrawTargetMarker(target); | DrawTargetMarker(target); | ||||
Engine.GuiInterfaceCall("PlaySound", { "name": "order_patrol", "entity": selection[0] }); | Engine.GuiInterfaceCall("PlaySound", { "name": "order_patrol", "entity": selection[0] }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!entState.unitAI || !entState.unitAI.canPatrol) | if (!entState.unitAI || !entState.patrol) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target, selection) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
if (!someCanPatrol(selection) || | if (!someCanPatrol(selection) || | ||||
!Engine.HotkeyIsPressed("session.patrol") || | !Engine.HotkeyIsPressed("session.patrol") || | ||||
▲ Show 20 Lines • Show All 438 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!targetState.guard || | if (!targetState.guard || | ||||
!playerCheck(entState, targetState, ["Player", "Ally"]) || | !playerCheck(entState, targetState, ["Player", "Ally"]) || | ||||
!entState.unitAI || !entState.unitAI.canGuard || | !entState.unitAI || !entState.guard || | ||||
targetState.unitAI && targetState.unitAI.isGuarding) | targetState.unitAI && targetState.unitAI.isGuarding) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"preSelectedActionCheck": function(target, selection) | "preSelectedActionCheck": function(target, selection) | ||||
{ | { | ||||
if (preSelectedAction != ACTION_GUARD) | if (preSelectedAction != ACTION_GUARD) | ||||
▲ Show 20 Lines • Show All 482 Lines • ▼ Show 20 Lines | "execute": function() | ||||
backToWork(); | backToWork(); | ||||
}, | }, | ||||
}, | }, | ||||
"add-guard": { | "add-guard": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => | if (entStates.every(entState => | ||||
!entState.unitAI || !entState.unitAI.canGuard || entState.unitAI.isGuarding)) | !entState.unitAI || !entState.guard || entState.unitAI.isGuarding)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.guard") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.guard") + | ||||
translate("Order the selected units to guard a building or unit."), | translate("Order the selected units to guard a building or unit."), | ||||
"icon": "add-guard.png" | "icon": "add-guard.png" | ||||
}; | }; | ||||
}, | }, | ||||
Show All 36 Lines | "select-trading-goods": { | ||||
{ | { | ||||
toggleTrade(); | toggleTrade(); | ||||
}, | }, | ||||
}, | }, | ||||
"patrol": { | "patrol": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (!entStates.some(entState => entState.unitAI && entState.unitAI.canPatrol)) | if (!entStates.some(entState => entState.unitAI && !!entState.patrol)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.patrol") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.patrol") + | ||||
translate("Patrol") + "\n" + | translate("Patrol") + "\n" + | ||||
translate("Attack all encountered enemy units while avoiding buildings."), | translate("Attack all encountered enemy units while avoiding buildings."), | ||||
"icon": "patrol.png" | "icon": "patrol.png" | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | return entities.some(ent => { | ||||
return entState && entState.unitAI && entState.unitAI.isGuarding; | return entState && entState.unitAI && entState.unitAI.isGuarding; | ||||
}); | }); | ||||
} | } | ||||
function someCanPatrol(entities) | function someCanPatrol(entities) | ||||
{ | { | ||||
return entities.some(ent => { | return entities.some(ent => { | ||||
let entState = GetEntityState(ent); | let entState = GetEntityState(ent); | ||||
return entState && entState.unitAI && entState.unitAI.canPatrol; | return entState && entState.unitAI && !!entState.patrol; | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Keep in sync with Commands.js. | * Keep in sync with Commands.js. | ||||
*/ | */ | ||||
function isUndeletable(entState) | function isUndeletable(entState) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator