Improved harvester behaviour, reworked the job register system and added auto roadbuilding.

This commit is contained in:
Douwe Ravers
2023-08-25 17:30:27 +02:00
parent 8c3528419a
commit 76650e22ac
11 changed files with 113 additions and 111 deletions

26
main.js
View File

@@ -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();
}