mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
If cost is low, copy instead of cut
This commit is contained in:
parent
1837e72952
commit
6a279923e3
@ -13,6 +13,7 @@ import { T } from "../../../translations";
|
|||||||
import { KEYMAPPINGS } from "../../key_action_mapper";
|
import { KEYMAPPINGS } from "../../key_action_mapper";
|
||||||
import { THEME } from "../../theme";
|
import { THEME } from "../../theme";
|
||||||
import { enumHubGoalRewards } from "../../tutorial_goals";
|
import { enumHubGoalRewards } from "../../tutorial_goals";
|
||||||
|
import { enumNotificationType } from "./notifications";
|
||||||
|
|
||||||
const logger = createLogger("hud/mass_selector");
|
const logger = createLogger("hud/mass_selector");
|
||||||
|
|
||||||
@ -148,14 +149,30 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
// copy code relies on entities still existing, so must copy before deleting.
|
// copy code relies on entities still existing, so must copy before deleting.
|
||||||
this.root.hud.signals.buildingsSelectedForCopy.dispatch(entityUids);
|
this.root.hud.signals.buildingsSelectedForCopy.dispatch(entityUids);
|
||||||
|
|
||||||
for (let i = 0; i < entityUids.length; ++i) {
|
let canPaste = false;
|
||||||
const uid = entityUids[i];
|
const placer = this.root.hud.parts.blueprintPlacer;
|
||||||
const entity = this.root.entityMgr.findByUid(uid);
|
if (placer) {
|
||||||
if (!this.root.logic.tryDeleteBuilding(entity)) {
|
const blueprint = placer.currentBlueprint.get();
|
||||||
logger.error("Error in mass cut, could not remove building");
|
if (blueprint) {
|
||||||
this.selectedUids.delete(uid);
|
canPaste = blueprint.canAfford(this.root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (canPaste) {
|
||||||
|
for (let i = 0; i < entityUids.length; ++i) {
|
||||||
|
const uid = entityUids[i];
|
||||||
|
const entity = this.root.entityMgr.findByUid(uid);
|
||||||
|
if (!this.root.logic.tryDeleteBuilding(entity)) {
|
||||||
|
logger.error("Error in mass cut, could not remove building");
|
||||||
|
this.selectedUids.delete(uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.selectedUids = new Set();
|
||||||
|
this.root.hud.signals.notification.dispatch(
|
||||||
|
T.ingame.notifications.massCutInsufficient,
|
||||||
|
enumNotificationType.success
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
this.root.soundProxy.playUiClick();
|
this.root.soundProxy.playUiClick();
|
||||||
} else {
|
} else {
|
||||||
|
@ -337,6 +337,7 @@ ingame:
|
|||||||
notifications:
|
notifications:
|
||||||
newUpgrade: A new upgrade is available!
|
newUpgrade: A new upgrade is available!
|
||||||
gameSaved: Your game has been saved.
|
gameSaved: Your game has been saved.
|
||||||
|
massCutInsufficient: The cost for pasting is insufficient!
|
||||||
|
|
||||||
# The "Upgrades" window
|
# The "Upgrades" window
|
||||||
shop:
|
shop:
|
||||||
|
@ -325,6 +325,7 @@ ingame:
|
|||||||
notifications:
|
notifications:
|
||||||
newUpgrade: 新しいアップグレードが利用可能です!
|
newUpgrade: 新しいアップグレードが利用可能です!
|
||||||
gameSaved: ゲームをセーブしました。
|
gameSaved: ゲームをセーブしました。
|
||||||
|
massCutInsufficient: 設置コストが不足しています!
|
||||||
|
|
||||||
# The "Upgrades" window
|
# The "Upgrades" window
|
||||||
shop:
|
shop:
|
||||||
|
Loading…
Reference in New Issue
Block a user