8000 fix: drawEnergyHarvestInfo() 在房间数据不存在时跳过 · LokiSharp/ScreepsScript@722a9c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 722a9c0

Browse files
committed
fix: drawEnergyHarvestInfo() 在房间数据不存在时跳过
< 8000 /div>
1 parent ee4621b commit 722a9c0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mount/StructureExtension/ControllerExtension/ControllerExtension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export default class ControllerExtension extends StructureController {
3838
* 临时 - 显示能量获取速率
3939
*/
4040
private drawEnergyHarvestInfo() {
41-
const { totalEnergy, energyGetRate } = getRoomStats(this.room.name);
41+
const roomStats = getRoomStats(this.room.name);
42+
if (!roomStats || !roomStats.totalEnergy || !roomStats.energyGetRate) return;
43+
const { totalEnergy, energyGetRate } = roomStats;
4244
const { x, y } = this.pos;
4345
this.room.visual.text(
4446
`可用能量 ${totalEnergy || 0} 获取速率 ${energyGetRate ? energyGetRate.toFixed(2) : 0}`,

0 commit comments

Comments
 (0)
0