;; This file is part of Moonsters
;;  Copyright (C) 2021 Dam Studios
;;
;;     Moonsters is free software: you can redistribute it and/or modify
;;     it under the terms of the GNU General Public License as published by
;;     the Free Software Foundation, either version 3 of the License, or
;;     (at your option) any later version.
;; 
;;     SHOOT TO MOVE is distributed in the hope that it will be useful,
;;     but WITHOUT ANY WARRANTY; without even the implied warranty of
;;     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;     GNU General Public License for more details.
;; 
;;     You should have received a copy of the GNU General Public License
;;     along with Moonsters  If not, see <https://www.gnu.org/licenses/>.

.module Entity_Manager

.globl man_entity_create
.globl man_entity_forall
.globl man_entity_getArray
.globl man_entity_update
.globl man_entity_init

;;MACRO PARA CREAR ENTIDADES
.macro DefineEntityAnnonimous _type,_render, _x, _y, _w, _h, _vx, _vy, _pspr, _aist, _ai_dist
	.db _type
	.db _render ;;render or not ->> 0x02 == not render
	.db _x
	.db _y
	.db 0x00, 0x00 ;; old X, old Y
	.db _w
	.db _h
	.db _vx
	.db _vy
	.dw _pspr ;;sprite pointer
	.dw 0xC000
	.db 0x00, 0x00;; ai aim x, ai aim y
	.db _aist ;; AI status
	.db _ai_dist
.endm


.macro DefineEntity _name, _type,_render,_x, _y, _w, _h, _vx, _vy, _color, _aist, _ai_dist
_name::
	DefineEntityAnnonimous _type,_render, _x, _y, _w, _h, _vx, _vy, _color, _aist, _ai_dist
.endm


.macro saveSetBorder _color 
    push hl
   ; cpctm_setBorder_asm _color
    pop hl
.endm

e_type = 0
e_render = 1
e_x = 2
e_y = 3
e_oldX = 4
e_oldY = 5
e_w = 6
e_h = 7
e_vx = 8
e_vy = 9
e_pspr_l = 10
e_pspr_h = 11	
e_oldVideo_l = 12
e_oldVideo_h = 13
e_ai_aim_x = 14
e_ai_aim_y = 15
e_ai_st = 16
e_ai_dist = 17

entity_size = 18
max_entities = 30


e_render_visible = 0x01 ;; or anything except 2
e_render_notVisible = 0x02
e_render_notVisibleFirst = 0x20


e_type_default = 0x01
e_type_static = 0x02
e_type_enemy = 0x03
e_type_bullet = 0x04
e_type_bullet_enemy = 0x05 ;;bullet shot by the aliens
e_type_static_dmg = 0x06 ;;platform that does dmg
e_type_destroy = 0xFF


e_ai_noAI = 0
e_ai_stand_by = 1
e_ai_move_to = 2



.macro DefineEntityArray _N  ;;Ponemos un nombre aleatorio para la macro
	.rept _N
		DefineEntityAnnonimous 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0
	.endm
.endm

