Fix preferred variant not getting saved when clicking on the hud

This commit is contained in:
Daan Vanoverloop 2020-07-06 18:46:18 +02:00
parent 6c6ad6af22
commit 299b6c6302
2 changed files with 12 additions and 4 deletions

View File

@ -178,7 +178,7 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
consumeEvents: true, consumeEvents: true,
targetOnly: true, targetOnly: true,
}); });
detector.click.add(() => this.currentVariant.set(variant)); detector.click.add(() => this.setVariant(variant));
} }
} }

View File

@ -506,12 +506,20 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
); );
const newIndex = (index + 1) % availableVariants.length; const newIndex = (index + 1) % availableVariants.length;
const newVariant = availableVariants[newIndex]; const newVariant = availableVariants[newIndex];
this.currentVariant.set(newVariant); this.setVariant(newVariant);
this.preferredVariants[metaBuilding.getId()] = newVariant;
} }
} }
/**
* Sets the current variant to the given variant
*/
setVariant(variant) {
const metaBuilding = this.currentMetaBuilding.get();
this.currentVariant.set(variant);
this.preferredVariants[metaBuilding.getId()] = variant;
}
/** /**
* Performs the direction locked placement between two points after * Performs the direction locked placement between two points after
* releasing the mouse * releasing the mouse