.globl entity_create
.globl entity_copy
.globl entity_doForAll
.globl entity_doForAll_matching
.globl entity_doForAll_pairs_matching
.globl entity_update
.globl entity_vector
.globl entity_set4destruction
.globl entity_set4creation
.globl entity_register
.globl num_entities
.globl getEntity2


; Constantes
e_tipo            = 0
e_cmps            = 1
e_x               = 2
e_y               = 3
e_vx              = 4
e_vy              = 5
e_w               = 6
e_h               = 7
e_spriteL         = 8
e_spriteH         = 9
e_iaL             = 10
e_iaH             = 11
e_animL           = 12
e_animH           = 13
e_anim_st         = 14
e_animCounter     = 15
e_collidesAgainst = 16
e_last_dir        = 17
e_last_dirY       = 18
e_player_shot     = 19
e_actualizaMove   = 20
e_contMove        = 21
e_aim_X           = 22
e_aim_Y           = 23
e_hp              = 24
e_perteneceL      = 25
e_perteneceH      = 26
e_tablaAnimL      = 27
e_tablaAnimH      = 28
e_anim_especial   = 29
e_invencibilidad  = 30
e_atacando        = 31


;; Tipos
e_type_invalid  = 0x00 
e_type_player   = 0x01
e_type_zombie   = 0x02  ;; realmente no es para el zombie, es para todos los enemigos
e_type_shot     = 0x04
e_type_arcoiris = 0x08
e_type_vida     = 0x10
e_type_dead     = 0x80
e_type_default  = 0x7F

;; Components
e_cmp_render   = 0x01
e_cmp_movable  = 0x02
e_cmp_input    = 0x04
e_cmp_ia       = 0x08
e_cmp_animated = 0x10
e_cmp_collider = 0x20
e_cmp_vidaextra = 0x40

k_max_num_entities = 16
k_size_entity      = 32



;; Define an entity 
.macro DefineEntity _name, _tipo, _cmps, _x, _y, _vx, _vy, _w, _h, _sprite, _ia, _anim, _anim_st,_animCounter, _collides, _lastdir, _lastdirY , _playerShot, _actualizaMove, _contMove, _aimX, _aimY, _hp, _pertenece, _tablaAnim, _animEspecial, _invencible, _atacando
   _name:
      .db _tipo      ;; (Invalid 00, Player 01, Enemigo 02, Dead 80, Default 7F)
      .db _cmps      ;; ()
      .db _x,  _y    ;; x, y
      .db _vx, _vy   ;; Vx, Vy
      .db _w, _h     ;; Width, Height
      .dw _sprite    ;; sprite (puntero al sprite)
      .dw _ia        ;; IA     (puntero a funcion)
      .dw _anim      ;; puntero a la animacion
      .db _anim_st
      .db _animCounter  ;; contador de animacion
      .db _collides  ;; Collides Against
      .db _lastdir, _lastdirY   ;; Ultima direccion a la que apunta la entidad (solo para ver hacia donde dispara el player)
      .db _playerShot ;; 1 si la entidad ya ha disparado, 0 si no
      .db _actualizaMove
      .db _contMove
      .db _aimX, _aimY
      .db _hp
      .dw _pertenece
      .dw _tablaAnim    ;; puntero a la tabla que le corresponde de animaciones
      .db _animEspecial ;; indica si es normal (0) o especial (1)
      .db _invencible
      .db _atacando
.endm

;; Define an entity with default values
.macro DefineEntityDefault _name, _suf
                        ;;  Tipo  cmps  x     y      vx   vy   width height  sprite   ia     anim  status counter  collides  last_dir last_dir  player_shot actualizaMove contMove aimX, aimY    HP   pertenece tablaAnim especial invencibile atacando
   DefineEntity _name'_suf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00,    0x00,    0x00,    0x00,       0x00,       0x00,       0x00,     0x00, 0x00,  0x00,  0x0000,  0x0000,   0x00,        0xDE,     0xAD;;
.endm

;; Define N default entities (changing the names)
.macro DefineNEntities _name, _n
   _c = 0
   .rept _n
      DefineEntityDefault _name, \_c
      _c = _c + 1 
   .endm
.endm
