Merge pull request #403 from Danacus/master

Fix preferred variant not getting saved when clicking on the hud
This commit is contained in:
tobspr 2020-07-07 09:15:33 +02:00 committed by GitHub
commit e46dd4e00b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -216,7 +216,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

@ -523,12 +523,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