fix error in enemy loading code.
enemy loading no longer assumes that the enemy-describing data it recieves has certain optional properties.
This commit is contained in:
parent
4de8228579
commit
d39c226046
1 changed files with 7 additions and 3 deletions
10
js/enemy.mjs
10
js/enemy.mjs
|
@ -68,11 +68,15 @@ Event.listen("level/load/enemy", enemies => {
|
|||
const {pos, size} = data;
|
||||
const enemy = create(pos[0], pos[1], size[0], size[1]);
|
||||
|
||||
set_behaviour(enemy, data.behaviour);
|
||||
if (data.hasOwnProperty("behaviour")) {
|
||||
set_behaviour(enemy, data.behaviour);
|
||||
}
|
||||
|
||||
const meta = Entity.get_meta(enemy);
|
||||
for (const [key, value] of data.meta) {
|
||||
meta.set(key, value);
|
||||
if (data.hasOwnProperty("meta")) {
|
||||
for (const [key, value] of data.meta) {
|
||||
meta.set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
add(enemy);
|
||||
|
|
Loading…
Reference in a new issue