1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-19 06:19:19 +00:00

Reverse cycle when pressing shift key

This commit is contained in:
isaisstillalive 2020-06-30 22:31:23 +09:00
parent 390135574d
commit e631c6a072
2 changed files with 17 additions and 2 deletions

View File

@ -108,9 +108,16 @@ export class HUDBaseToolbar extends BaseHUDPart {
return; return;
} }
let addIndex;
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed) {
addIndex = this.supportedBuildings.length - 1;
} else {
addIndex = 1;
}
let process = false; let process = false;
let newIndex = this.lastSelectedIndex; let newIndex = this.lastSelectedIndex;
for (let i = 0; i < this.supportedBuildings.length; ++i, ++newIndex) { for (let i = 0; i < this.supportedBuildings.length; ++i, newIndex += addIndex) {
newIndex %= this.supportedBuildings.length; newIndex %= this.supportedBuildings.length;
const metaBuilding = gMetaBuildingRegistry.findByClass(this.supportedBuildings[newIndex]); const metaBuilding = gMetaBuildingRegistry.findByClass(this.supportedBuildings[newIndex]);
const handle = this.buildingHandles[metaBuilding.id]; const handle = this.buildingHandles[metaBuilding.id];

View File

@ -504,7 +504,15 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
index >= 0, index >= 0,
"Current variant was invalid: " + this.currentVariant.get() + " out of " + availableVariants "Current variant was invalid: " + this.currentVariant.get() + " out of " + availableVariants
); );
const newIndex = (index + 1) % availableVariants.length;
let addIndex;
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed) {
addIndex = availableVariants.length - 1;
} else {
addIndex = 1;
}
const newIndex = (index + addIndex) % availableVariants.length;
const newVariant = availableVariants[newIndex]; const newVariant = availableVariants[newIndex];
this.currentVariant.set(newVariant); this.currentVariant.set(newVariant);