-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.collect.js
37 lines (31 loc) · 898 Bytes
/
task.collect.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
/**
* Created by teeebor on 2016-07-24.
*/
let Task = require("task");
let types = [STRUCTURE_STORAGE, STRUCTURE_CONTAINER];
function Collect(ai) {
this.base = Task;
this.base(ai);
}
Collect.prototype = Object.create(Task.prototype);
Collect.prototype.constructor = Collect;
Collect.prototype.search = function () {
let dest = this.ai.findClosestByTypes(types);
if(dest != null){
this.ai.setDestination(dest.id)
}else{
this.ai.setDestination(null);
}
};
Collect.prototype.canDo = function () {
return false;
return this.ai.getFreeSource()!=null && (this.ai.creep.energy!=this.ai.creep.carryCapacity && this.ai.memory.task == "collect");
};
Collect.prototype.do = function () {
let destination = this.ai.getDestination();
if(destination!=null) {
if (this.ai.creep.harvest(destination)) {
}
}
};
module.exports = Collect;