chore: helper
This commit is contained in:
parent
8105ad2ad3
commit
c08b32b68c
|
@ -56,6 +56,13 @@ export class Spawner extends decorate(Trait) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maySpawn() {
|
||||||
|
if (this.maxSpawns <= this.children.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
listeners() {
|
listeners() {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
@ -78,7 +85,7 @@ export class Spawner extends decorate(Trait) {
|
||||||
},
|
},
|
||||||
|
|
||||||
spawn: (key, json = {}) => {
|
spawn: (key, json = {}) => {
|
||||||
if (this.maxSpawns <= this.children.length) {
|
if (!this.maySpawn()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const spawnJSON = this.spawnJSONs[key];
|
const spawnJSON = this.spawnJSONs[key];
|
||||||
|
@ -105,7 +112,7 @@ export class Spawner extends decorate(Trait) {
|
||||||
},
|
},
|
||||||
|
|
||||||
spawnAt: (key, position, json = {}) => {
|
spawnAt: (key, position, json = {}) => {
|
||||||
if (this.maxSpawns <= this.children.length) {
|
if (true && !this.maySpawn()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!json.traits) {
|
if (!json.traits) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user