Created miner, made harvester pick resources and added reset commands.
This commit is contained in:
30
main.js
30
main.js
@@ -1,11 +1,7 @@
|
||||
// ########################################
|
||||
// ########## MAIN ##########
|
||||
// ########################################
|
||||
|
||||
|
||||
const creepClass = require("ClassCreep");
|
||||
const roomClass = require("ClassRoom");
|
||||
const spawnClass = require("ClassSpawn");
|
||||
const Commands = require("Commands");
|
||||
const CreepClass = require("CreepClass");
|
||||
const RoomClass = require("RoomClass");
|
||||
const Structure = require("Structure");
|
||||
|
||||
module.exports.loop = function () {
|
||||
if(!global.compiled) onRecompile();
|
||||
@@ -13,28 +9,34 @@ module.exports.loop = function () {
|
||||
else onTick();
|
||||
}
|
||||
|
||||
function onRecompile(){
|
||||
creepClass.setup();
|
||||
roomClass.setup();
|
||||
spawnClass.setup();
|
||||
function onRecompile(){
|
||||
setupClasses();
|
||||
console.log("Script recompiled...");
|
||||
global.compiled = true;
|
||||
}
|
||||
|
||||
function onRestart(){
|
||||
Object.values(Game.rooms).forEach(room => room.begin());
|
||||
Object.values(Game.spawns).forEach(spawn => spawn.begin());
|
||||
Object.values(Game.creeps).forEach(creep => creep.begin());
|
||||
Object.values(Game.structures).forEach(structure => Structure.begin(structure));
|
||||
global.started = true;
|
||||
}
|
||||
|
||||
function onTick(){
|
||||
Object.values(Game.rooms).forEach(room => room.tick());
|
||||
Object.values(Game.spawns).forEach(spawn => spawn.tick());
|
||||
Object.values(Game.creeps).forEach(creep => creep.tick());
|
||||
Object.values(Game.structures).forEach(structure => Structure.tick(structure));
|
||||
if(!(Game.time % 100)) cleanUp();
|
||||
}
|
||||
|
||||
|
||||
function setupClasses(){
|
||||
Commands.setup();
|
||||
CreepClass.setup();
|
||||
RoomClass.setup();
|
||||
Structure.setup();
|
||||
}
|
||||
|
||||
function cleanUp(){
|
||||
Object.keys(Memory.rooms).forEach(roomName => { if(!Game.rooms[roomName]) Memory.rooms[roomName] = undefined; });
|
||||
Object.keys(Memory.creeps).forEach(creepName => { if(!Game.creeps[creepName]) Memory.creeps[creepName] = undefined; });
|
||||
|
||||
Reference in New Issue
Block a user