mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-02-13 19:39:20 +00:00
Fix Building Placer Sound Bug
Fixes the sound distortion when using the building placer caused by many buildings trying to play their sounds at once. This will only play 1 building sound. Includes checks for if building was actually placed.
This commit is contained in:
parent
80fa97976d
commit
2c620ba4fb
@ -366,8 +366,9 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
|||||||
/**
|
/**
|
||||||
* Tries to place the current building at the given tile
|
* Tries to place the current building at the given tile
|
||||||
* @param {Vector} tile
|
* @param {Vector} tile
|
||||||
|
* @param {Object} options
|
||||||
*/
|
*/
|
||||||
tryPlaceCurrentBuildingAt(tile) {
|
tryPlaceCurrentBuildingAt(tile, options = {}) {
|
||||||
if (this.root.camera.zoomLevel < globalConfig.mapChunkOverviewMinZoom) {
|
if (this.root.camera.zoomLevel < globalConfig.mapChunkOverviewMinZoom) {
|
||||||
// Dont allow placing in overview mode
|
// Dont allow placing in overview mode
|
||||||
return;
|
return;
|
||||||
@ -388,6 +389,7 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
|||||||
originalRotation: this.currentBaseRotation,
|
originalRotation: this.currentBaseRotation,
|
||||||
building: this.currentMetaBuilding.get(),
|
building: this.currentMetaBuilding.get(),
|
||||||
variant: this.currentVariant.get(),
|
variant: this.currentVariant.get(),
|
||||||
|
sound: ((options.supressSound!=null)? !options.supressSound : true)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (entity) {
|
if (entity) {
|
||||||
@ -447,12 +449,19 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
|||||||
*/
|
*/
|
||||||
executeDirectionLockedPlacement() {
|
executeDirectionLockedPlacement() {
|
||||||
const path = this.computeDirectionLockPath();
|
const path = this.computeDirectionLockPath();
|
||||||
|
let needSound = false;
|
||||||
this.root.logic.performBulkOperation(() => {
|
this.root.logic.performBulkOperation(() => {
|
||||||
for (let i = 0; i < path.length; ++i) {
|
for (let i = 0; i < path.length; ++i) {
|
||||||
const { rotation, tile } = path[i];
|
const { rotation, tile } = path[i];
|
||||||
|
|
||||||
this.currentBaseRotation = rotation;
|
this.currentBaseRotation = rotation;
|
||||||
this.tryPlaceCurrentBuildingAt(tile);
|
// Add supressSound flag
|
||||||
|
let addedBuilding = this.tryPlaceCurrentBuildingAt(tile, {supressSound: ((i==0||needSound)? false : true)});
|
||||||
|
if (!addedBuilding && (i==0 || needSound)){
|
||||||
|
needSound = true;
|
||||||
|
}else {
|
||||||
|
needSound = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -151,9 +151,11 @@ export class GameLogic {
|
|||||||
* @param {number} param0.rotationVariant
|
* @param {number} param0.rotationVariant
|
||||||
* @param {string} param0.variant
|
* @param {string} param0.variant
|
||||||
* @param {MetaBuilding} param0.building
|
* @param {MetaBuilding} param0.building
|
||||||
|
* @param {boolean} param0.sound
|
||||||
* @returns {Entity}
|
* @returns {Entity}
|
||||||
*/
|
*/
|
||||||
tryPlaceBuilding({ origin, rotation, rotationVariant, originalRotation, variant, building }) {
|
tryPlaceBuilding({ origin, rotation, rotationVariant, originalRotation, variant, building, sound }) {
|
||||||
|
sound = (sound!==null)? sound : true; // Check for sound argument
|
||||||
if (this.checkCanPlaceBuilding({ origin, rotation, rotationVariant, variant, building })) {
|
if (this.checkCanPlaceBuilding({ origin, rotation, rotationVariant, variant, building })) {
|
||||||
// Remove any removeable entities below
|
// Remove any removeable entities below
|
||||||
const checker = new StaticMapEntityComponent({
|
const checker = new StaticMapEntityComponent({
|
||||||
@ -186,7 +188,10 @@ export class GameLogic {
|
|||||||
variant,
|
variant,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.root.soundProxy.playUi(building.getPlacementSound());
|
// Play sound
|
||||||
|
if (sound){
|
||||||
|
this.root.soundProxy.playUi(building.getPlacementSound());
|
||||||
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user