Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/input.js
Show First 20 Lines • Show All 1,515 Lines • ▼ Show 20 Lines | function addTrainingToQueue(selection, trainEntType, playerState) | ||||
{ | { | ||||
let buildingsForTraining = appropriateBuildings; | let buildingsForTraining = appropriateBuildings; | ||||
if (canBeAddedCount !== undefined) | if (canBeAddedCount !== undefined) | ||||
buildingsForTraining = buildingsForTraining.slice(0, canBeAddedCount); | buildingsForTraining = buildingsForTraining.slice(0, canBeAddedCount); | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "train", | "type": "train", | ||||
"template": trainEntType, | "template": trainEntType, | ||||
"count": 1, | "count": 1, | ||||
"entities": buildingsForTraining | "entities": buildingsForTraining, | ||||
"pushFront": Engine.HotkeyIsPressed("session.pushorderfront") | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Returns the number of units that will be present in a batch if the user clicks | * Returns the number of units that will be present in a batch if the user clicks | ||||
* the training button depending on the batch training modifier hotkey. | * the training button depending on the batch training modifier hotkey. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (g_BatchTrainingEntityAllowedCount !== undefined && | ||||
g_BatchTrainingEntityAllowedCount < batchedSize * appropriateBuildings.length) | g_BatchTrainingEntityAllowedCount < batchedSize * appropriateBuildings.length) | ||||
{ | { | ||||
// Train as many full batches as we can. | // Train as many full batches as we can. | ||||
let buildingsCountToTrainFullBatch = Math.floor(g_BatchTrainingEntityAllowedCount / batchedSize); | let buildingsCountToTrainFullBatch = Math.floor(g_BatchTrainingEntityAllowedCount / batchedSize); | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "train", | "type": "train", | ||||
"entities": appropriateBuildings.slice(0, buildingsCountToTrainFullBatch), | "entities": appropriateBuildings.slice(0, buildingsCountToTrainFullBatch), | ||||
"template": g_BatchTrainingType, | "template": g_BatchTrainingType, | ||||
"count": batchedSize | "count": batchedSize, | ||||
"pushFront": Engine.HotkeyIsPressed("session.pushorderfront") | |||||
}); | }); | ||||
// Train remainer in one more structure. | // Train remainer in one more structure. | ||||
let remainer = g_BatchTrainingEntityAllowedCount % batchedSize; | let remainer = g_BatchTrainingEntityAllowedCount % batchedSize; | ||||
if (remainer) | if (remainer) | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "train", | "type": "train", | ||||
"entities": [appropriateBuildings[buildingsCountToTrainFullBatch]], | "entities": [appropriateBuildings[buildingsCountToTrainFullBatch]], | ||||
"template": g_BatchTrainingType, | "template": g_BatchTrainingType, | ||||
"count": remainer | "count": remainer, | ||||
"pushFront": Engine.HotkeyIsPressed("session.pushorderfront") | |||||
}); | }); | ||||
} | } | ||||
else | else | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "train", | "type": "train", | ||||
"entities": appropriateBuildings, | "entities": appropriateBuildings, | ||||
"template": g_BatchTrainingType, | "template": g_BatchTrainingType, | ||||
"count": batchedSize | "count": batchedSize, | ||||
"pushFront": Engine.HotkeyIsPressed("session.pushorderfront") | |||||
}); | }); | ||||
} | } | ||||
function performGroup(action, groupId) | function performGroup(action, groupId) | ||||
{ | { | ||||
switch (action) | switch (action) | ||||
{ | { | ||||
case "snap": | case "snap": | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator