-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
35 lines (28 loc) · 802 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const WorldState = require("./worldState");
const Commander = require("./commander");
const CreepRunner = require("./creepRunner");
let commander = null;
let worldState = null;
module.exports.loop = function () {
//Clears out creep memory when they pass.
deleteNullCreeps();
if(worldState == null || commander == null) {
worldState = new WorldState();
commander = new Commander(worldState);
return;
}
//World State updates condition data.
worldState.process();
//Creeps run their tasks.
CreepRunner.run();
//Commander processes and looks for plans to execute.
commander.process();
}
function deleteNullCreeps()
{
for(var i in Memory.creeps) {
if(!Game.creeps[i]) {
delete Memory.creeps[i];
}
}
}