Improved harvester behaviour, reworked the job register system and added auto roadbuilding.
This commit is contained in:
26
main.js
26
main.js
@@ -3,11 +3,10 @@
|
||||
// ########################################
|
||||
|
||||
|
||||
const Class = require("Class");
|
||||
const Job = require("Job");
|
||||
const Room = require("Room");
|
||||
const Structure = require("Structure");
|
||||
|
||||
const creepClass = require("ClassCreep");
|
||||
const roomClass = require("ClassRoom");
|
||||
const spawnClass = require("ClassSpawn");
|
||||
|
||||
module.exports.loop = function () {
|
||||
if(!global.compiled) onRecompile();
|
||||
else if (!global.started) onRestart();
|
||||
@@ -15,23 +14,24 @@ module.exports.loop = function () {
|
||||
}
|
||||
|
||||
function onRecompile(){
|
||||
Class.setup();
|
||||
Job.setup();
|
||||
creepClass.setup();
|
||||
roomClass.setup();
|
||||
spawnClass.setup();
|
||||
console.log("Script recompiled...");
|
||||
global.compiled = true;
|
||||
}
|
||||
|
||||
function onRestart(){
|
||||
Object.values(Game.rooms).forEach(room => Room.begin(room));
|
||||
Object.values(Game.spawns).forEach(spawn => Structure.begin(spawn));
|
||||
Object.values(Game.creeps).forEach(creep => Job.begin(creep));
|
||||
Object.values(Game.rooms).forEach(room => room.begin());
|
||||
Object.values(Game.spawns).forEach(spawn => spawn.begin());
|
||||
Object.values(Game.creeps).forEach(creep => creep.begin());
|
||||
global.started = true;
|
||||
}
|
||||
|
||||
function onTick(){
|
||||
Object.values(Game.rooms).forEach(room => Room.tick(room));
|
||||
Object.values(Game.spawns).forEach(spawn => Structure.tick(spawn));
|
||||
Object.values(Game.creeps).forEach(creep => Job.tick(creep));
|
||||
Object.values(Game.rooms).forEach(room => room.tick());
|
||||
Object.values(Game.spawns).forEach(spawn => spawn.tick());
|
||||
Object.values(Game.creeps).forEach(creep => creep.tick());
|
||||
if(!(Game.time % 100)) cleanUp();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user