-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpatch.room.js
48 lines (39 loc) · 1.35 KB
/
patch.room.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
const RoomAI = require('roomai.base');
Room.prototype.ai = function() {
if(this._ai === undefined) {
if(this.controller && this.controller.my) {
this._ai = new RoomAI(this);
} else {
this._ai = null;
}
}
return this._ai;
}
Room.prototype.powerSpawn = function() {
if(this._powerSpawn === undefined) {
if(this.controller && this.controller.my && this.controller.level >= 8) {
this._powerSpawn = this.find(FIND_MY_STRUCTURES, { filter: (s) => s.structureType == STRUCTURE_POWER_SPAWN })[0];
} else {
this._powerSpawn = null;
}
}
return this._powerSpawn;
}
Room.prototype.nuker = function() {
if(this._nuker === undefined) {
if(this.controller && this.controller.my && this.controller.level >= 8) {
this._nuker = this.find(FIND_MY_STRUCTURES, { filter: (s) => s.structureType == STRUCTURE_NUKER })[0];
} else {
this._nuker = null;
}
}
return this._nuker;
}
Room.prototype.storagePos = function() {
if(this.storage) return this.storage.pos;
let constructions = this.memory.constructions;
if(!constructions) return null;
let storageBuilding = constructions.storage[0];
if(!storageBuilding) return null;
return new RoomPosition(storageBuilding.x, storageBuilding.y, this.name);
}