47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
|
|
/* ######################
|
|
# Screeps 2022 #
|
|
######################*/
|
|
|
|
const system = require("system");
|
|
|
|
module.exports.loop = function () {
|
|
if (global.compiled == undefined) {
|
|
// Configure classes and constants
|
|
setupClasses();
|
|
setConstants();
|
|
console.log("Script recompiled...");
|
|
global.compiled = true;
|
|
} else {
|
|
if (global.started == undefined) {
|
|
// After one tick of configuration, restart the system.
|
|
system.start();
|
|
console.log("System started...");
|
|
global.started = true;
|
|
}
|
|
system.update();
|
|
}
|
|
}
|
|
|
|
const creepClass = require("ClassCreep");
|
|
const roomClass = require("ClassRoom");
|
|
const spawnClass = require("ClassSpawn");
|
|
|
|
// Overwrite all game defined classes by inherited ones.
|
|
function setupClasses() {
|
|
creepClass.setup();
|
|
roomClass.setup();
|
|
spawnClass.setup();
|
|
}
|
|
|
|
// Adds additional constants to global scope
|
|
function setConstants() {
|
|
// The states of a room.
|
|
global.ROOMSTATE_NEUTRAL = 0;
|
|
global.ROOMSTATE_CAPITAL = 1;
|
|
global.ROOMSTATE_COLONY = 2;
|
|
global.ROOMSTATE_OUTPOST = 3;
|
|
|
|
// The roles of creeps.
|
|
global.ROLE_HARVESTER = 0;
|
|
} |