-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdignityStructure.js
45 lines (37 loc) · 1.17 KB
/
dignityStructure.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
function DignityStructure() {
DignityAIBase.call(this);
this.destroyable = true;
this.storeCapacity = 0;
this.storeObjects = [];
this.outputObject = null;
this.outputObjects = [];
this.outputTime = 0;
};
DignityStructure.prototype = Object.create(DignityAIBase.prototype);
DignityStructure.prototype.constructor = DignityStructure;
DignityStructure.prototype.destroy = function() {
if(this.destroyable) {
this.storeCapacity = 0;
this.storeObjects = [];
this.outputObjects = [];
this.outputTime = 0;
}
};
DignityStructure.prototype.store = function(_dignityObject) {
if(this.storeCapacity > 0 && this.storeCapacity < this.storeObjects.length) {
this.storeObjects.push(_dignityObject);
}
};
DignityStructure.prototype.generate = function(isStoreObject) {
if(this.outputTime > 0) {
window.setTimeout(this.pushOutput, this.outputTime, isStoreObject);
} else {
this.pushOutput(isStoreObject);
}
};
DignityStructure.prototype.pushOutput = function(isStoreObject) {
this.outputObjects.push(this.outputObject);
if(isStoreObject) {
this.store(this.outputObject);
}
};