diff --git a/js/enemy.mjs b/js/enemy.mjs index 5dced80..d088531 100644 --- a/js/enemy.mjs +++ b/js/enemy.mjs @@ -17,8 +17,7 @@ function tick_enemy (enemy, deltatime) { if (meta.has("behaviour")) { const b = meta.get("behaviour"); - if (behaviours.exists(b)) { - const callback = behaviours.get_tick(b); + if (behaviours.exists(b)) { const callback = behaviours.get_tick(b); callback(enemy, deltatime); } } @@ -47,10 +46,6 @@ export function create (...args) { return enemy; } -function set_behaviour (enemy, behaviour, params) { - behaviours.init(enemy, behaviour, params); -} - export function add (enemy) { enemies.push(enemy); } @@ -69,7 +64,7 @@ Event.listen("level/load/enemy", enemies => { const enemy = create(pos[0], pos[1], size[0], size[1]); if (data.hasOwnProperty("behaviour")) { - set_behaviour(enemy, data.behaviour); + behaviours.init(enemy, data.behaviour, Object.fromEntries(data.meta)); } const meta = Entity.get_meta(enemy);