1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

use safeModulo

This commit is contained in:
EmeraldBlock 2020-10-08 20:16:58 -05:00 committed by GitHub
parent 4141c939d6
commit 39e360cc5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import { gMetaBuildingRegistry } from "../../../core/global_registries";
import { Signal, STOP_PROPAGATION } from "../../../core/signal";
import { TrackedState } from "../../../core/tracked_state";
import { Vector } from "../../../core/vector";
import { safeModulo } from "../../../core/utils";
import { enumMouseButton } from "../../camera";
import { StaticMapEntityComponent } from "../../components/static_map_entity";
import { Entity } from "../../entity";
@ -471,10 +472,7 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
.pressed
? -1
: 1;
let newIndex = (index + direction) % availableVariants.length;
if (newIndex < 0) {
newIndex += availableVariants.length;
}
let newIndex = safeModulo(index + direction, availableVariants.length);
const newVariant = availableVariants[newIndex];
this.setVariant(newVariant);
}