代码拉取完成,页面将自动刷新
const variable_homeSignal = require("variable.homeSignal");
const memory_Init = {
init:function (){
this.room_source_energyContainer()
this.room_mineral_mineralContainer()
},
room_source_energyContainer:function (){
let distance = Math.sqrt(5)
for (let r of variable_homeSignal.homeRooms){
let set = new Set();
for (let s of r.room.find(FIND_SOURCES)){
let data = {
sourceId:s.id,
containerId:''
}
let c = s.pos.findInRange(FIND_STRUCTURES,distance,{
filter: o => o.structureType == STRUCTURE_CONTAINER
})
if (c.length == 1){
data.containerId = c[0].id
set.add(data)
}
}
r.room.memory.energyAndEnergyContainer = Array.from(set)
}
},
room_mineral_mineralContainer:function (){
let distance = Math.sqrt(5)
for (let r of variable_homeSignal.homeRooms){
let set = new Set();
for (let m of r.room.find(FIND_MINERALS)){
let data = {
mineralId:m.id,
containerId: ''
}
let c = m.pos.findInRange(FIND_STRUCTURES,distance,{
filter: o => o.structureType == STRUCTURE_CONTAINER
})
if (c.length == 1){
data.containerId = c[0].id
set.add(data)
}
}
r.room.memory.mineralAndMineralContainer = Array.from(set)
}
}
}
module.exports = memory_Init
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。