Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 345 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
"type": "repair", | "type": "repair", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"autocontinue": true, | "autocontinue": true, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_repair", | "name": action.foundation ? "order_build" : "order_repair", | ||||
"entity": selection[0] | "entity": selection[0] | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!entState.builder || | if (!entState.builder || | ||||
!targetState.needsRepair && !targetState.foundation || | !targetState.needsRepair && !targetState.foundation || | ||||
!playerCheck(entState, targetState, ["Player", "Ally"])) | !playerCheck(entState, targetState, ["Player", "Ally"])) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true, "foundation": targetState.foundation }; | ||||
Freagarach: Perhaps split in newlines? | |||||
}, | }, | ||||
"preSelectedActionCheck": function(target, selection) | "preSelectedActionCheck": function(target, selection) | ||||
{ | { | ||||
if (preSelectedAction != ACTION_REPAIR) | if (preSelectedAction != ACTION_REPAIR) | ||||
return false; | return false; | ||||
if (getActionInfo("repair", target, selection).possible) | let actionInfo = getActionInfo("repair", target, selection); | ||||
if (actionInfo.possible) | |||||
return { | return { | ||||
"type": "repair", | "type": "repair", | ||||
"cursor": "action-repair", | "cursor": "action-repair", | ||||
"target": target | "target": target, | ||||
"foundation": actionInfo.foundation | |||||
}; | }; | ||||
return { | return { | ||||
"type": "none", | "type": "none", | ||||
"cursor": "action-repair-disabled", | "cursor": "action-repair-disabled", | ||||
"target": null | "target": null | ||||
}; | }; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target, selection) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
let actionInfo = getActionInfo("repair", target, selection); | |||||
if (!Engine.HotkeyIsPressed("session.repair") || | if (!Engine.HotkeyIsPressed("session.repair") || | ||||
!getActionInfo("repair", target, selection).possible) | !actionInfo.possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "repair", | "type": "repair", | ||||
"cursor": "action-repair", | "cursor": "action-repair", | ||||
"target": target | "target": target, | ||||
"foundation": actionInfo.foundation | |||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target, selection) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (!getActionInfo("repair", target, selection).possible) | let actionInfo = getActionInfo("repair", target, selection); | ||||
if (!actionInfo.possible) | |||||
return false; | return false; | ||||
return { | return { | ||||
"type": "repair", | "type": "repair", | ||||
"cursor": "action-repair", | "cursor": "action-repair", | ||||
"target": target | "target": target, | ||||
"foundation": actionInfo.foundation | |||||
}; | }; | ||||
}, | }, | ||||
"specificness": 11, | "specificness": 11, | ||||
}, | }, | ||||
"gather": | "gather": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "gather", | "type": "gather", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_gather", | "name": "order_gather", | ||||
"entity": selection[0] | "entity": selection[0] | ||||
}); | }); | ||||
Not Done Inline ActionsI guess this is the only difference between the two objects, so it might be good to consider avoiding the duplication and checking for the target entity type instead. elexis: I guess this is the only difference between the two objects, so it might be good to consider… | |||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!targetState.resourceSupply) | if (!targetState.resourceSupply) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 1,118 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Perhaps split in newlines?