41 lines
807 B
JavaScript
41 lines
807 B
JavaScript
|
|
/* ######################
|
|
# Screeps 2022 #
|
|
######################*/
|
|
|
|
const spawns = require("spawns");
|
|
const creeps = require("creeps");
|
|
const towers = require("towers");
|
|
const ai_main = require("ai_main");
|
|
|
|
const system = require("system");
|
|
|
|
module.exports.loop = function () {
|
|
// New system
|
|
if (global.started == undefined) {
|
|
console.log("Recompiled...");
|
|
global.started = true;
|
|
system.start();
|
|
}
|
|
system.update();
|
|
|
|
|
|
|
|
// Old system
|
|
ai_main.run();
|
|
towers.run();
|
|
spawns.run();
|
|
if (Game.time % 60 == 0) {
|
|
clear_dead_creeps_from_memory();
|
|
}
|
|
}
|
|
|
|
|
|
function clear_dead_creeps_from_memory() {
|
|
for (var cr in Memory.creeps) {
|
|
if (Game.creeps[cr] == null) {
|
|
delete (Memory.creeps[cr]);
|
|
}
|
|
}
|
|
}
|