var energyUtils = require('util_energy'); var name = 'harvester'; function run(creep) { if(creep.store.getFreeCapacity() > 0) { if(typeof creep.memory.assignedSource === 'undefined') energyUtils.sourceDelegate(creep); var source = Game.getObjectById(creep.memory.assignedSource); if(creep.harvest(source) == ERR_NOT_IN_RANGE) { creep.moveTo(source, {visualizePathStyle: {stroke: '#ffaa00'}}); } } else { if(!energyUtils.depositEnergy(creep)){ creep.moveTo(Game.flags.IdleArea); } } } module.exports = {name,run};