add generic move support for enemies

This commit is contained in:
Andrei Alexeyev 2019-07-27 23:14:48 +03:00
parent 4e4224dc59
commit c3d7827b7c
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
2 changed files with 11 additions and 1 deletions

View file

@ -64,6 +64,11 @@ static inline int enemy_call_logic_rule(Enemy *e, int t) {
if(e->logic_rule) {
return e->logic_rule(e, t);
} else {
// TODO: backport unified left/right move animations from the obsolete `newart` branch
e->moving = cabs(e->move.velocity) >= 1;
e->dir = creal(e->move.velocity) < 0;
e->pos += move_update(&e->move);
}
return ACTION_NONE;

View file

@ -16,6 +16,7 @@
#include "objectpool.h"
#include "entity.h"
#include "coroutine.h"
#include "move.h"
#ifdef DEBUG
#define ENEMY_DEBUG
@ -40,7 +41,11 @@ struct Enemy {
cmplx pos;
cmplx pos0;
cmplx pos0_visual;
cmplx args[RULE_ARGC];
union {
cmplx args[RULE_ARGC];
MoveParams move;
};
EnemyLogicRule logic_rule;
EnemyVisualRule visual_rule;