From d39c2260460cc3aaf935d70d99ea949a0ed8a0d3 Mon Sep 17 00:00:00 2001 From: trans_soup <> Date: Fri, 27 Oct 2023 13:12:10 +0200 Subject: [PATCH] fix error in enemy loading code. enemy loading no longer assumes that the enemy-describing data it recieves has certain optional properties. --- js/enemy.mjs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/enemy.mjs b/js/enemy.mjs index 15468a8..61a8ce6 100644 --- a/js/enemy.mjs +++ b/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);