Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/unit_actions.js
Property | Old Value | New Value |
---|---|---|
svn:mime-type | null | text/plain \ No newline at end of property |
Show First 20 Lines • Show All 1,126 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
var g_EntityCommands = | var g_EntityCommands = | ||||
{ | { | ||||
"unload-all": { | "unload-all": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
let count = 0; | let count = 0; | ||||
for (let entState of entStates) | for (let entState of entStates) | ||||
if (entState.garrisonHolder) | { | ||||
if (!entState.garrisonHolder) | |||||
continue; | |||||
if (allowedPlayersCheck([entState], ["Player"])) | |||||
count += entState.garrisonHolder.entities.length; | count += entState.garrisonHolder.entities.length; | ||||
else | |||||
for (let entity of entState.garrisonHolder.entities) | |||||
if (allowedPlayersCheck([GetEntityState(entity)], ["Player"])) | |||||
++count; | |||||
} | |||||
if (!count) | if (!count) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.unload") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.unload") + | ||||
translate("Unload All."), | translate("Unload All."), | ||||
"icon": "garrison-out.png", | "icon": "garrison-out.png", | ||||
"count": count, | "count": count, | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
unloadAll(); | unloadAll(); | ||||
}, | }, | ||||
"allowedPlayers": ["Player", "Ally"] | |||||
}, | }, | ||||
"delete": { | "delete": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
return entStates.some(entState => !isUndeletable(entState)) ? | return entStates.some(entState => !isUndeletable(entState)) ? | ||||
{ | { | ||||
"tooltip": | "tooltip": | ||||
colorizeHotkey("%(hotkey)s" + " ", "session.kill") + | colorizeHotkey("%(hotkey)s" + " ", "session.kill") + | ||||
translate("Destroy the selected units or structures.") + "\n" + | translate("Destroy the selected units or structures.") + "\n" + | ||||
colorizeHotkey( | colorizeHotkey( | ||||
translate("Use %(hotkey)s to avoid the confirmation dialog."), | translate("Use %(hotkey)s to avoid the confirmation dialog."), | ||||
"session.noconfirmation" | "session.noconfirmation" | ||||
), | ), | ||||
"icon": "kill_small.png" | "icon": "kill_small.png", | ||||
"enabled": true | |||||
} : | } : | ||||
{ | { | ||||
// Get all delete reasons and remove duplications | // Get all delete reasons and remove duplications | ||||
"tooltip": entStates.map(entState => isUndeletable(entState)) | "tooltip": entStates.map(entState => isUndeletable(entState)) | ||||
.filter((reason, pos, self) => | .filter((reason, pos, self) => | ||||
self.indexOf(reason) == pos && reason | self.indexOf(reason) == pos && reason | ||||
).join("\n"), | ).join("\n"), | ||||
"icon": "kill_small_disabled.png" | "icon": "kill_small_disabled.png", | ||||
"enabled": false | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function(entStates) | "execute": function(entStates) | ||||
{ | { | ||||
let entityIDs = entStates.reduce( | let entityIDs = entStates.reduce( | ||||
(ids, entState) => { | (ids, entState) => { | ||||
if (!isUndeletable(entState)) | if (!isUndeletable(entState)) | ||||
ids.push(entState.id); | ids.push(entState.id); | ||||
Show All 9 Lines | "execute": function(entStates) | ||||
"entities": entityIDs | "entities": entityIDs | ||||
}); | }); | ||||
if (Engine.HotkeyIsPressed("session.noconfirmation")) | if (Engine.HotkeyIsPressed("session.noconfirmation")) | ||||
deleteSelection(); | deleteSelection(); | ||||
else | else | ||||
(new DeleteSelectionConfirmation(deleteSelection)).display(); | (new DeleteSelectionConfirmation(deleteSelection)).display(); | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | |||||
}, | }, | ||||
"stop": { | "stop": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.unitAI)) | if (entStates.every(entState => !entState.unitAI)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.stop") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.stop") + | ||||
translate("Abort the current order."), | translate("Abort the current order."), | ||||
"icon": "stop.png" | "icon": "stop.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"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"] | |||||
}, | }, | ||||
"garrison": { | "garrison": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.unitAI || entState.turretParent || false)) | if (entStates.every(entState => !entState.unitAI || entState.turretParent || false)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.garrison") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.garrison") + | ||||
translate("Order the selected units to garrison in a structure or unit."), | translate("Order the selected units to garrison in a structure or unit."), | ||||
"icon": "garrison.png" | "icon": "garrison.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
inputState = INPUT_PRESELECTEDACTION; | inputState = INPUT_PRESELECTEDACTION; | ||||
preSelectedAction = ACTION_GARRISON; | preSelectedAction = ACTION_GARRISON; | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | |||||
}, | }, | ||||
"unload": { | "unload": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => { | if (entStates.every(entState => { | ||||
if (!entState.unitAI || !entState.turretParent) | if (!entState.unitAI || !entState.turretParent) | ||||
return true; | return true; | ||||
let parent = GetEntityState(entState.turretParent); | let parent = GetEntityState(entState.turretParent); | ||||
return !parent || !parent.garrisonHolder || parent.garrisonHolder.entities.indexOf(entState.id) == -1; | return !parent || !parent.garrisonHolder || parent.garrisonHolder.entities.indexOf(entState.id) == -1; | ||||
})) | })) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": translate("Unload"), | "tooltip": translate("Unload"), | ||||
"icon": "garrison-out.png" | "icon": "garrison-out.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
unloadSelection(); | unloadSelection(); | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | |||||
}, | }, | ||||
"repair": { | "repair": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.builder)) | if (entStates.every(entState => !entState.builder)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.repair") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.repair") + | ||||
translate("Order the selected units to repair a structure, ship, or siege engine."), | translate("Order the selected units to repair a structure, ship, or siege engine."), | ||||
"icon": "repair.png" | "icon": "repair.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
inputState = INPUT_PRESELECTEDACTION; | inputState = INPUT_PRESELECTEDACTION; | ||||
preSelectedAction = ACTION_REPAIR; | preSelectedAction = ACTION_REPAIR; | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | |||||
}, | }, | ||||
"focus-rally": { | "focus-rally": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.rallyPoint)) | if (entStates.every(entState => !entState.rallyPoint)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "camera.rallypointfocus") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "camera.rallypointfocus") + | ||||
translate("Focus on Rally Point."), | translate("Focus on Rally Point."), | ||||
"icon": "focus-rally.png" | "icon": "focus-rally.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function(entStates) | "execute": function(entStates) | ||||
{ | { | ||||
// TODO: Would be nicer to cycle between the rallypoints of multiple entities instead of just using the first | // TODO: Would be nicer to cycle between the rallypoints of multiple entities instead of just using the first | ||||
let focusTarget; | let focusTarget; | ||||
for (let entState of entStates) | for (let entState of entStates) | ||||
if (entState.rallyPoint && entState.rallyPoint.position) | if (entState.rallyPoint && entState.rallyPoint.position) | ||||
{ | { | ||||
focusTarget = entState.rallyPoint.position; | focusTarget = entState.rallyPoint.position; | ||||
break; | break; | ||||
} | } | ||||
if (!focusTarget) | if (!focusTarget) | ||||
for (let entState of entStates) | for (let entState of entStates) | ||||
if (entState.position) | if (entState.position) | ||||
{ | { | ||||
focusTarget = entState.position; | focusTarget = entState.position; | ||||
break; | break; | ||||
} | } | ||||
if (focusTarget) | if (focusTarget) | ||||
Engine.CameraMoveTo(focusTarget.x, focusTarget.z); | Engine.CameraMoveTo(focusTarget.x, focusTarget.z); | ||||
}, | }, | ||||
"allowedPlayers": ["Player", "Observer"] | |||||
}, | }, | ||||
"back-to-work": { | "back-to-work": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.unitAI || !entState.unitAI.hasWorkOrders)) | if (entStates.every(entState => !entState.unitAI || !entState.unitAI.hasWorkOrders)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.backtowork") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.backtowork") + | ||||
translate("Back to Work"), | translate("Back to Work"), | ||||
"icon": "back-to-work.png" | "icon": "back-to-work.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
backToWork(); | backToWork(); | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | |||||
}, | }, | ||||
"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.unitAI.canGuard || 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 structure or unit."), | translate("Order the selected units to guard a structure or unit."), | ||||
"icon": "add-guard.png" | "icon": "add-guard.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
inputState = INPUT_PRESELECTEDACTION; | inputState = INPUT_PRESELECTEDACTION; | ||||
preSelectedAction = ACTION_GUARD; | preSelectedAction = ACTION_GUARD; | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | |||||
}, | }, | ||||
"remove-guard": { | "remove-guard": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.unitAI || !entState.unitAI.isGuarding)) | if (entStates.every(entState => !entState.unitAI || !entState.unitAI.isGuarding)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": translate("Remove guard"), | "tooltip": translate("Remove guard"), | ||||
"icon": "remove-guard.png" | "icon": "remove-guard.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
removeGuard(); | removeGuard(); | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | |||||
}, | }, | ||||
"select-trading-goods": { | "select-trading-goods": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.market)) | if (entStates.every(entState => !entState.market)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": translate("Barter & Trade"), | "tooltip": translate("Barter & Trade"), | ||||
"icon": "economics.png" | "icon": "economics.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
g_TradeDialog.toggle(); | g_TradeDialog.toggle(); | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | |||||
}, | }, | ||||
"patrol": { | "patrol": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (!entStates.some(entState => entState.unitAI && entState.unitAI.canPatrol)) | if (!entStates.some(entState => entState.unitAI && entState.unitAI.canPatrol)) | ||||
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 structures."), | translate("Attack all encountered enemy units while avoiding structures."), | ||||
"icon": "patrol.png" | "icon": "patrol.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
inputState = INPUT_PRESELECTEDACTION; | inputState = INPUT_PRESELECTEDACTION; | ||||
preSelectedAction = ACTION_PATROL; | preSelectedAction = ACTION_PATROL; | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | |||||
}, | }, | ||||
"share-dropsite": { | "share-dropsite": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
let sharableEntities = entStates.filter( | let sharableEntities = entStates.filter( | ||||
entState => entState.resourceDropsite && entState.resourceDropsite.sharable); | entState => entState.resourceDropsite && entState.resourceDropsite.sharable); | ||||
if (!sharableEntities.length) | if (!sharableEntities.length) | ||||
return false; | return false; | ||||
// Returns if none of the entities belong to a player with a mutual ally | // Returns if none of the entities belong to a player with a mutual ally. | ||||
if (entStates.every(entState => !GetSimState().players[entState.player].isMutualAlly.some( | if (entStates.every(entState => !GetSimState().players[entState.player].isMutualAlly.some( | ||||
(isAlly, playerId) => isAlly && playerId != entState.player))) | (isAlly, playerId) => isAlly && playerId != entState.player))) | ||||
return false; | return false; | ||||
return sharableEntities.some(entState => !entState.resourceDropsite.shared) ? | return sharableEntities.some(entState => !entState.resourceDropsite.shared) ? | ||||
{ | { | ||||
"tooltip": translate("Press to allow allies to use this dropsite"), | "tooltip": translate("Press to allow allies to use this dropsite"), | ||||
"icon": "locked_small.png" | "icon": "locked_small.png", | ||||
"enabled": true | |||||
} : | } : | ||||
{ | { | ||||
"tooltip": translate("Press to prevent allies from using this dropsite"), | "tooltip": translate("Press to prevent allies from using this dropsite"), | ||||
"icon": "unlocked_small.png" | "icon": "unlocked_small.png", | ||||
"enabled": true | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function(entStates) | "execute": function(entStates) | ||||
{ | { | ||||
let sharableEntities = entStates.filter( | let sharableEntities = entStates.filter( | ||||
entState => entState.resourceDropsite && entState.resourceDropsite.sharable); | entState => entState.resourceDropsite && entState.resourceDropsite.sharable); | ||||
if (sharableEntities) | |||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "set-dropsite-sharing", | "type": "set-dropsite-sharing", | ||||
"entities": sharableEntities.map(entState => entState.id), | "entities": sharableEntities.map(entState => entState.id), | ||||
"shared": sharableEntities.some(entState => !entState.resourceDropsite.shared) | "shared": sharableEntities.some(entState => !entState.resourceDropsite.shared) | ||||
}); | }); | ||||
}, | }, | ||||
} | "allowedPlayers": ["Player"] | ||||
}; | }, | ||||
var g_AllyEntityCommands = | "is-dropsite-shared": { | ||||
{ | "getInfo": function(entStates) | ||||
"unload-all": { | |||||
"getInfo": function(entState) | |||||
{ | { | ||||
if (!entState.garrisonHolder) | let sharableEntities = entStates.filter( | ||||
entState => entState.resourceDropsite && entState.resourceDropsite.sharable); | |||||
if (!sharableEntities.length) | |||||
return false; | return false; | ||||
let player = Engine.GetPlayerID(); | let player = Engine.GetPlayerID(); | ||||
let simState = GetSimState(); | |||||
let count = 0; | if (!g_IsObserver && !simState.players[player].hasSharedDropsites || | ||||
for (let ent in g_Selection.selected) | entStates.every(entState => controlsPlayer(entState.player))) | ||||
{ | |||||
let selectedEntState = GetEntityState(+ent); | |||||
if (!selectedEntState.garrisonHolder) | |||||
continue; | |||||
for (let entity of selectedEntState.garrisonHolder.entities) | |||||
{ | |||||
let state = GetEntityState(entity); | |||||
if (state.player == player) | |||||
++count; | |||||
} | |||||
} | |||||
return { | |||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.unload") + | |||||
translate("Unload All."), | |||||
"icon": "garrison-out.png", | |||||
"count": count, | |||||
}; | |||||
}, | |||||
"execute": function(entState) | |||||
{ | |||||
unloadAll(); | |||||
}, | |||||
}, | |||||
"share-dropsite": { | |||||
"getInfo": function(entState) | |||||
{ | |||||
if (Engine.GetPlayerID() == -1 || | |||||
!GetSimState().players[Engine.GetPlayerID()].hasSharedDropsites || | |||||
!entState.resourceDropsite || !entState.resourceDropsite.sharable) | |||||
return false; | return false; | ||||
if (entState.resourceDropsite.shared) | if (!entStates.every(entState => entState.resourceDropsite.shared)) | ||||
return { | return { | ||||
"tooltip": translate("You are allowed to use this dropsite"), | "tooltip": translate("The use of this dropsite is prohibited"), | ||||
"icon": "unlocked_small.png" | "icon": "locked_small.png", | ||||
"enabled": false | |||||
}; | }; | ||||
return { | return { | ||||
"tooltip": translate("The use of this dropsite is prohibited"), | "tooltip": g_IsObserver ? translate("Allies are allowed to use this dropsite.") : | ||||
"icon": "locked_small.png" | translate("You are allowed to use this dropsite"), | ||||
"icon": "unlocked_small.png", | |||||
"enabled": false | |||||
}; | }; | ||||
}, | }, | ||||
"execute": function(entState) | "execute": function(entState) | ||||
{ | { | ||||
// This command button is always disabled | // This command button is always disabled. | ||||
}, | }, | ||||
"allowedPlayers": ["Ally", "Observer"] | |||||
} | } | ||||
}; | }; | ||||
function playerCheck(entState, targetState, validPlayers) | function playerCheck(entState, targetState, validPlayers) | ||||
{ | { | ||||
let playerState = GetSimState().players[entState.player]; | let playerState = GetSimState().players[entState.player]; | ||||
for (let player of validPlayers) | for (let player of validPlayers) | ||||
if (player == "Gaia" && targetState.player == 0 || | if (player == "Gaia" && targetState.player == 0 || | ||||
player == "Player" && targetState.player == entState.player || | player == "Player" && targetState.player == entState.player || | ||||
playerState["is" + player] && playerState["is" + player][targetState.player]) | playerState["is" + player] && playerState["is" + player][targetState.player]) | ||||
return true; | return true; | ||||
return false; | return false; | ||||
} | } | ||||
/** | |||||
* Checks whether the entities have the right diplomatic status | |||||
* with respect to the currently active player. | |||||
* Also "Observer" can be used. | |||||
* | |||||
* @param {Object[]} entStates - An array containing the entity states to check. | |||||
* @param {string[]} validPlayers - An array containing the diplomatic statuses. | |||||
* | |||||
* @return {boolean} - Whether the currently active player is allowed. | |||||
*/ | |||||
function allowedPlayersCheck(entStates, validPlayers) | |||||
{ | |||||
// Assume we can only select entities from one player, | |||||
// or it does not matter (e.g. observer). | |||||
let targetState = entStates[0]; | |||||
let playerState = GetSimState().players[Engine.GetPlayerID()]; | |||||
return validPlayers.some(player => | |||||
player == "Observer" && g_IsObserver || | |||||
player == "Player" && controlsPlayer(targetState.player) || | |||||
playerState && playerState["is" + player] && playerState["is" + player][targetState.player]); | |||||
} | |||||
function hasClass(entState, className) | function hasClass(entState, className) | ||||
{ | { | ||||
// note: use the functions in globalscripts/Templates.js for more versatile matching | // note: use the functions in globalscripts/Templates.js for more versatile matching | ||||
return entState.identity && entState.identity.classes.indexOf(className) != -1; | return entState.identity && entState.identity.classes.indexOf(className) != -1; | ||||
} | } | ||||
/** | /** | ||||
* Keep in sync with Commands.js. | * Keep in sync with Commands.js. | ||||
Show All 20 Lines | |||||
{ | { | ||||
Engine.GuiInterfaceCall("AddTargetMarker", { | Engine.GuiInterfaceCall("AddTargetMarker", { | ||||
"template": g_TargetMarker.move, | "template": g_TargetMarker.move, | ||||
"x": target.x, | "x": target.x, | ||||
"z": target.z | "z": target.z | ||||
}); | }); | ||||
} | } | ||||
function getCommandInfo(command, entStates) | |||||
{ | |||||
return entStates && g_EntityCommands[command] && | |||||
allowedPlayersCheck(entStates, g_EntityCommands[command].allowedPlayers) && | |||||
g_EntityCommands[command].getInfo(entStates); | |||||
} | |||||
function getActionInfo(action, target, selection) | function getActionInfo(action, target, selection) | ||||
{ | { | ||||
if (!selection || !selection.length || !GetEntityState(selection[0])) | if (!selection || !selection.length || !GetEntityState(selection[0])) | ||||
return { "possible": false }; | return { "possible": false }; | ||||
// Look at the first targeted entity | // Look at the first targeted entity | ||||
// (TODO: maybe we eventually want to look at more, and be more context-sensitive? | // (TODO: maybe we eventually want to look at more, and be more context-sensitive? | ||||
// e.g. prefer to attack an enemy unit, even if some friendly units are closer to the mouse) | // e.g. prefer to attack an enemy unit, even if some friendly units are closer to the mouse) | ||||
Show All 27 Lines |
Wildfire Games · Phabricator