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:
trans_soup 2023-10-27 13:12:10 +02:00
parent 4de8228579
commit d39c226046

View file

@ -68,12 +68,16 @@ Event.listen("level/load/enemy", enemies => {
const {pos, size} = data;
const enemy = create(pos[0], pos[1], size[0], size[1]);
if (data.hasOwnProperty("behaviour")) {
set_behaviour(enemy, data.behaviour);
}
const meta = Entity.get_meta(enemy);
if (data.hasOwnProperty("meta")) {
for (const [key, value] of data.meta) {
meta.set(key, value);
}
}
add(enemy);
}