-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanager.keeperRoom.js
73 lines (56 loc) · 2.47 KB
/
manager.keeperRoom.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Module code goes here. Use 'module.exports' to export things:
* module.exports.thing = 'a thing';
*
* You can import it from another modules like this:
* var mod = require('manager.keeperRoom');
* mod.thing == 'a thing'; // true
*/
var logger = require("screeps.logger");
logger = new logger("manager.keeperRoom");
var obj = function() {
}
var base = require('manager.baseRoom');
obj.prototype = new base();
global.utils.extendFunction(obj, "init", function(targetRoomName, homeRoomManager) {
this._init(targetRoomName, true);
this.homeRoomManager = homeRoomManager;
this.remoteEnergyTarget = true;
});
global.utils.extendFunction(obj, "tickInit", function() {
this._tickInit();
this.logEnergyInRoom();
if (!this.roleObjects["workerNextRoom"]) {
var roleClasses = global.utils.getRoleClasses();
//order here affects spawn order
this.roleObjects["workerNextRoom"] = new roleClasses.workerNextRoom();
this.roleObjects["workerNextRoom"].init("workerNextRoom", this, this.homeRoomManager);
this.roleObjects["workerNextRoom"].requiredCreeps = 2;
this.roleObjects["workerNextRoom"].dangerZone = true;
}
//logger.log('--------------------------', this.visibility && !this.room.memory.initDone , this.homeRoomManager.buildingManager.buildEnabledFlag)
if (this.visibility && !this.room.memory.initDone && this.homeRoomManager.buildingManager.buildEnabledFlag) {
var spawn = this.homeRoomManager.getAvailableSpawn();
if (spawn) {
var sourceFlags = global.utils.flagsByColor(this.roomFlags, COLOR_YELLOW, COLOR_YELLOW);
sourceFlags.concat(global.utils.flagsByColor(this.roomFlags, COLOR_YELLOW, COLOR_PURPLE))
if (sourceFlags.length) {
for(var f in sourceFlags) {
var flag = sourceFlags[f]
var path = global.utils.findPath(spawn, flag);
global.utils.drawPath(path.path, "white");
this.homeRoomManager.buildingManager.addRoadsToPath(path.path);
this.homeRoomManager.buildingManager.buildPlan.containers.push(path.path[path.path.length-1])
}
this.room.memory.initDone = true;
}
}
}
});
global.utils.extendFunction(obj, "tick", function() {
this._tick();
});
global.utils.extendFunction(obj, "tickEnd", function() {
this._tickEnd();
});
module.exports = obj;