|
|
|
@ -48,6 +48,9 @@ export class HUDMassSelector extends BaseHUDPart {
|
|
|
|
|
* @param {Entity} entity
|
|
|
|
|
*/
|
|
|
|
|
onEntityDestroyed(entity) {
|
|
|
|
|
if (this.root.bulkOperationRunning) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.selectedUids.delete(entity.uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -90,14 +93,30 @@ export class HUDMassSelector extends BaseHUDPart {
|
|
|
|
|
|
|
|
|
|
doDelete() {
|
|
|
|
|
const entityUids = Array.from(this.selectedUids);
|
|
|
|
|
for (let i = 0; i < entityUids.length; ++i) {
|
|
|
|
|
const uid = entityUids[i];
|
|
|
|
|
const entity = this.root.entityMgr.findByUid(uid);
|
|
|
|
|
if (!this.root.logic.tryDeleteBuilding(entity)) {
|
|
|
|
|
logger.error("Error in mass delete, could not remove building");
|
|
|
|
|
this.selectedUids.delete(uid);
|
|
|
|
|
|
|
|
|
|
// Build mapping from uid to entity
|
|
|
|
|
/**
|
|
|
|
|
* @type {Map<number, Entity>}
|
|
|
|
|
*/
|
|
|
|
|
const mapUidToEntity = this.root.entityMgr.getFrozenUidSearchMap();
|
|
|
|
|
|
|
|
|
|
this.root.logic.performBulkOperation(() => {
|
|
|
|
|
for (let i = 0; i < entityUids.length; ++i) {
|
|
|
|
|
const uid = entityUids[i];
|
|
|
|
|
const entity = mapUidToEntity.get(uid);
|
|
|
|
|
if (!entity) {
|
|
|
|
|
logger.error("Entity not found by uid:", uid);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.root.logic.tryDeleteBuilding(entity)) {
|
|
|
|
|
logger.error("Error in mass delete, could not remove building");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Clear uids later
|
|
|
|
|
this.selectedUids = new Set();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startCopy() {
|
|
|
|
|