;;-----------------------------LICENSE NOTICE------------------------------------
;;  This file is part of The Last Fungus: An Amstrad CPC Game 
;;  Copyright (C) 2021 Miguel Perez Tarruella / Antonio Jose Fernandez Belliure / 
;;                     David Martinez Garcia / Ocacho Games (@OcachoGames)
;;
;;  This program is free software: you can redistribute it and/or modify
;;  it under the terms of the GNU Lesser General Public License as published by
;;  the Free Software Foundation, either version 3 of the License, or
;;  (at your option) any later version.
;;
;;  This program 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 Lesser General Public License for more details.
;;
;;  You should have received a copy of the GNU Lesser General Public License
;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.
;;------------------------------------------------------------------------------

;;====================================================================
;; GLOBL INCLUDES
;;====================================================================

;;Managers
.include "man/entity.h.s"
.include "man/anim_states_machine/gravity_entity_sm.h.s"
.include "man/anim_states_machine/no_gravity_entity_sm.h.s"

;;Macros
.include "macros/math.h.s"

;;====================================================================
;; FUNCTIONS
;;====================================================================
man_state_machines_update::

    ;;The first one always gonna be the player 1
    ld ix, #m_entities
    call man_gravity_state_machine_update
    INCREMENT_REGISTER_2_BYTES ix, sizeof_e

    ;;Player 2 can be a Player or enemy
    
    ;;Check if the entity has the cmp_gravity to update or not the state machine with gravity
    ld c, #e_cmp_gravity
    IS_ENTITY_MATCHING_SIGNATURE
    jr nz, entity_sm_no_gravity

    call man_gravity_state_machine_update
    ret

    entity_sm_no_gravity:

    call man_no_gravity_state_machine_update

ret