Changeset View
Standalone View
binaries/data/mods/public/gui/session/selection_panels_helpers.js
Show First 20 Lines • Show All 349 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "stop", | "type": "stop", | ||||
"entities": entities, | "entities": entities, | ||||
"queued": false | "queued": false | ||||
}); | }); | ||||
} | } | ||||
function assignIdleVillager(entities, all) | |||||
Freagarach: Should indeed be renamed. | |||||
{ | |||||
let workers = Engine.GuiInterfaceCall("FindIdleUnits", { | |||||
"idleClasses": g_WorkerTypes, | |||||
"excludeUnits": [] | |||||
}); | |||||
FreagarachAuthorUnsubmitted Done Inline ActionsCan be inlined below, is that desirable? Freagarach: Can be inlined below, is that desirable? | |||||
Engine.PostNetworkCommand({ | |||||
"type": "assign-idle-villager", | |||||
Done Inline Actionsperhaps entities -> targets in order to distinguish them from the other entities elexis: perhaps entities -> targets in order to distinguish them from the other entities | |||||
"entities": entities, | |||||
FreagarachAuthorUnsubmitted Done Inline ActionsShould be filtered to only include gatherable/repairable entities. Freagarach: Should be filtered to only include gatherable/repairable entities. | |||||
elexisUnsubmitted Done Inline ActionsIf Im not mistaken, it might be more consistent to use the name target (or perhaps there is a difference, I didnt check). elexis: If Im not mistaken, it might be more consistent to use the name `target` (or perhaps there is a… | |||||
"idlers": workers, | |||||
elexisUnsubmitted Done Inline ActionsIt looks like one can pass non-idle workers too. If there was a command having idlers in the name, it sounds like that simulation command would have the task to look up one. Notice also that an idle unit at turn N (command construction time) may be a unit processing a command at turn N+2 (command execution time). elexis: It looks like one can pass non-idle workers too. If there was a command having idlers in the… | |||||
"all": all | |||||
}); | |||||
} | |||||
function unloadTemplate(template, owner) | function unloadTemplate(template, owner) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "unload-template", | "type": "unload-template", | ||||
"all": Engine.HotkeyIsPressed("session.unloadtype"), | "all": Engine.HotkeyIsPressed("session.unloadtype"), | ||||
"template": template, | "template": template, | ||||
"owner": owner, | "owner": owner, | ||||
// Filter out all entities that aren't garrisonable. | // Filter out all entities that aren't garrisonable. | ||||
Done Inline ActionsThis repair/gather hardcoding looks like it might be replaced with some loop or arguments provided for the currently selected entity, so that one could add support for traders, healers or whatever without having to modify the function. elexis: This repair/gather hardcoding looks like it might be replaced with some loop or arguments… | |||||
"garrisonHolders": g_Selection.toList().filter(ent => { | "garrisonHolders": g_Selection.toList().filter(ent => { | ||||
let state = GetEntityState(ent); | let state = GetEntityState(ent); | ||||
return state && !!state.garrisonHolder; | return state && !!state.garrisonHolder; | ||||
}) | }) | ||||
}); | }); | ||||
} | } | ||||
function unloadSelection() | function unloadSelection() | ||||
{ | { | ||||
let parent = 0; | let parent = 0; | ||||
let ents = []; | let ents = []; | ||||
for (let ent in g_Selection.selected) | for (let ent in g_Selection.selected) | ||||
Done Inline ActionsOne can access the GUIInterface from the GUI too (PushNotification), but thats still unconventional. I suppose all the other commands already have a known and available source entity. The most comparable thing may be the idle worker button, which is just disabled if there are no available units. elexis: One can access the GUIInterface from the GUI too (PushNotification), but thats still… | |||||
{ | { | ||||
let state = GetEntityState(+ent); | let state = GetEntityState(+ent); | ||||
if (!state || !state.turretParent) | if (!state || !state.turretParent) | ||||
continue; | continue; | ||||
if (!parent) | if (!parent) | ||||
{ | { | ||||
parent = state.turretParent; | parent = state.turretParent; | ||||
ents.push(+ent); | ents.push(+ent); | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |
Should indeed be renamed.