Fetch the repository succeeded.
var B = require('behaviors');
module.exports = {
run: function(creep){
const room = creep.room.name;
const pos = new RoomPosition(Memory.rooms[room].Upgrade.x, Memory.rooms[room].Upgrade.y, room);
if(B.DetectResource(pos,'energy') > 2000 && room != 'W42N28') return;
if(creep.store.getUsedCapacity() == 0){
const pos1 = new RoomPosition(Memory.rooms[room].Source1.x, Memory.rooms[room].Source1.y, room);
const pos2 = new RoomPosition(Memory.rooms[room].Source2.x, Memory.rooms[room].Source2.y, room);
var target = pos1;
if(B.DetectResource(pos1,'energy') < B.DetectResource(pos2,'energy')) target = pos2;
if(B.DetectResource(target, 'energy') < 100 && Memory.rooms[room].storage) target = creep.room.storage.pos;
if(Memory.rooms[room].storage) target = creep.room.storage.pos;
if(creep.pos.isNearTo(target)) B.GetResource(creep, target, 'energy');
else creep.moveTo(target, {visualizePathStyle: {stroke: '#ffffff'},reuse:200});
}else{
const pos = new RoomPosition(Memory.rooms[room].Upgrade.x, Memory.rooms[room].Upgrade.y, room);
if(creep.pos.isNearTo(pos)) creep.transferResource(pos,'energy');
else creep.moveTo(pos, {visualizePathStyle: {stroke: '#ffff00'},reuse:200});
}
}
}
// global.sayHello = function() { console.log('Hello!'); };
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。