mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Guards against undefined values/keys in base rotation logic.
One-lines setting check per tobspr's recommendation.
This commit is contained in:
parent
553ebb5ef6
commit
8ec646a8f6
@ -125,26 +125,30 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
||||
* @returns {number}
|
||||
*/
|
||||
get currentBaseRotation() {
|
||||
const rotationByBuilding = this.root.app.settings.getAllSettings().rotationByBuilding;
|
||||
if (!rotationByBuilding) {
|
||||
if (!this.root.app.settings.getAllSettings().rotationByBuilding) {
|
||||
return this.currentBaseRotationGeneral;
|
||||
}
|
||||
const building = this.currentMetaBuilding.get();
|
||||
if (building != undefined && this.preferredBaseRotations.hasOwnProperty(building.getId())) {
|
||||
return this.preferredBaseRotations[building.getId()];
|
||||
} else {
|
||||
return this.currentBaseRotationGeneral;
|
||||
}
|
||||
const id = this.currentMetaBuilding.get().getId();
|
||||
return this.preferredBaseRotations[id] == null
|
||||
? this.currentBaseRotationGeneral
|
||||
: this.preferredBaseRotations[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base rotation for the current meta-building.
|
||||
*/
|
||||
set currentBaseRotation(rotation) {
|
||||
const rotationByBuilding = this.root.app.settings.getAllSettings().rotationByBuilding;
|
||||
if (!rotationByBuilding) {
|
||||
if (!this.root.app.settings.getAllSettings().rotationByBuilding) {
|
||||
this.currentBaseRotationGeneral = rotation;
|
||||
} else {
|
||||
const id = this.currentMetaBuilding.get().getId();
|
||||
this.preferredBaseRotations[id] = rotation;
|
||||
const building = this.currentMetaBuilding.get();
|
||||
if (building != undefined) {
|
||||
this.preferredBaseRotations[building.getId()] = rotation;
|
||||
} else {
|
||||
this.currentBaseRotationGeneral = rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user