module.exports = { setup: function () { Room.prototype = _Room.prototype; } } class _Room extends Room { begin(){ this.setJobQueue(); this.roomScan(); this.buildRoads(); this.memory.init = true; } tick(){ if(!this.memory.init) this.begin(); } setJobQueue(){ if(!this.memory.jobs) this.memory.jobs = [ { role: Role.HARVESTER }, { role: Role.HARVESTER }, { role: Role.HARVESTER }, { role: Role.HARVESTER }, { role: Role.HARVESTER } ] } roomScan(){ this.memory.layout = { sources: this.find(FIND_SOURCES).map(s=>s.id) }; } buildRoads(){ this.memory.layout.sources.forEach( sId => { const source = Game.getObjectById(sId); this.buildRoad(source, this.controller); this.buildRoad(source, this.find(FIND_MY_STRUCTURES, { filter:{ structureType:STRUCTURE_SPAWN }})[0]); } ) } buildRoad(from, to){ const path = from.pos.findPathTo(to); path.forEach(tile => this.createConstructionSite(tile.x, tile.y, STRUCTURE_ROAD)) } }