Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_panels_helpers.js
Show First 20 Lines • Show All 409 Lines • ▼ Show 20 Lines | Engine.PostNetworkCommand({ | ||||
// Filter out all entities that aren't garrisonable. | // Filter out all entities that aren't garrisonable. | ||||
"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() | |||||
{ | |||||
let parent = 0; | |||||
let ents = []; | |||||
for (let ent in g_Selection.selected) | |||||
{ | |||||
let state = GetEntityState(+ent); | |||||
if (!state || !state.turretParent) | |||||
continue; | |||||
if (!parent) | |||||
{ | |||||
parent = state.turretParent; | |||||
ents.push(+ent); | |||||
} | |||||
else if (state.turretParent == parent) | |||||
ents.push(+ent); | |||||
} | |||||
if (parent) | |||||
Engine.PostNetworkCommand({ | |||||
"type": "unload", | |||||
"entities": ents, | |||||
"garrisonHolder": parent | |||||
}); | |||||
} | |||||
function unloadAll() | function unloadAll() | ||||
{ | { | ||||
let garrisonHolders = g_Selection.toList().filter(e => { | let garrisonHolders = g_Selection.toList().filter(e => { | ||||
let state = GetEntityState(e); | let state = GetEntityState(e); | ||||
return state && !!state.garrisonHolder; | return state && !!state.garrisonHolder; | ||||
}); | }); | ||||
if (!garrisonHolders.length) | if (!garrisonHolders.length) | ||||
Show All 18 Lines | function unloadAll() | ||||
if (otherEnts.length) | if (otherEnts.length) | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "unload-all-by-owner", | "type": "unload-all-by-owner", | ||||
"garrisonHolders": otherEnts | "garrisonHolders": otherEnts | ||||
}); | }); | ||||
} | } | ||||
function unloadAllTurrets() | |||||
{ | |||||
let turretHolders = g_Selection.toList().filter(e => { | |||||
let state = GetEntityState(e); | |||||
return state && !!state.turretHolder; | |||||
}); | |||||
if (!turretHolders.length) | |||||
return; | |||||
let ownedHolders = []; | |||||
let ejectables = []; | |||||
for (let ent of turretHolders) | |||||
{ | |||||
let turretHolderState = GetEntityState(ent); | |||||
if (controlsPlayer(turretHolderState.player)) | |||||
ownedHolders.push(ent); | |||||
else | |||||
{ | |||||
for (let turret of turretHolderState.turretHolder.turretPoints.map(tp => tp.entity)) | |||||
if (turret && controlsPlayer(GetEntityState(turret).player)) | |||||
ejectables.push(turret); | |||||
} | |||||
} | |||||
if (ejectables.length) | |||||
Engine.PostNetworkCommand({ | |||||
"type": "leave-turret", | |||||
"entities": ejectables | |||||
}); | |||||
if (ownedHolders.length) | |||||
Engine.PostNetworkCommand({ | |||||
"type": "unload-turrets", | |||||
"entities": ownedHolders | |||||
}); | |||||
} | |||||
function backToWork() | function backToWork() | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "back-to-work", | "type": "back-to-work", | ||||
// Filter out all entities that can't go back to work. | // Filter out all entities that can't go back to work. | ||||
"entities": g_Selection.toList().filter(ent => { | "entities": g_Selection.toList().filter(ent => { | ||||
let state = GetEntityState(ent); | let state = GetEntityState(ent); | ||||
return state && state.unitAI && state.unitAI.hasWorkOrders; | return state && state.unitAI && state.unitAI.hasWorkOrders; | ||||
Show All 37 Lines |
Wildfire Games · Phabricator