blob: 9153a902261dfaa7fb7504887bb124355d01c87f (
plain) (
blame)
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
|
var app = app || {};
class ShellContainer {
constructor() {
this.shells = [];
}
add(shell) {
this.shells.push(shell);
}
remove(id) {
this.shells.remove(this.shells.find(shell => shell.id === id));
}
contains(id) {
return !!this.shells.find(shell => shell.id === id);
}
get(id) {
return this.shells.find(shell => shell.id === id);
}
each(action) {
this.shells.forEach(shell => action(shell));
}
find(predicate) {
return this.shells.find(predicate);
}
update() {
this.each(shell => {
if(shell.isDestroyed) {
shell.destroy();
}
});
this.shells = this.shells.filter(shell => !shell.isDestroyed);
this.each(shell => shell.update());
}
}
|