private void ChangeAnimations()
    {
        if (CurrentState.HasFlag(EAIState.ALIVE))
        {
            m_animator.animator.SetBool(IDliving, true);
        }
        if (CurrentState.HasFlag(EAIState.IDLE))
        {
            m_animator.animator.SetBool(IDmove, false);
            m_animator.animator.SetBool(IDattack, false);
            m_animator.animator.SetBool(IDdeath, false);
        }
        if (CurrentState.HasFlag(EAIState.MOVING))
        {
            m_animator.animator.SetBool(IDmove, true);
        }
        if (CurrentState.HasFlag(EAIState.ATTACKING))
        {
            m_animator.animator.SetBool(IDattack, true);
        }
        if (!CurrentState.HasFlag(EAIState.ATTACKING) && previousState.HasFlag(EAIState.ATTACKING))
        {
            m_animator.animator.SetBool(IDattack, false);
        }
        if (CurrentState.HasFlag(EAIState.DYING))
        {
            m_animator.animator.SetBool(IDliving, false);

            //now called via animation event
            //KillNPC();
        }
        if (CurrentState.HasFlag(EAIState.DEAD))
        {
            m_animator.animator.SetBool(IDdeath, true);
        }

        previousState = CurrentState;
    }
    protected override void NPCDecision()
    {
        if (CurrentState.HasFlag(EAIState.IDLE) && !CurrentState.HasFlag(EAIState.DEAD))
        {
            if (m_PlayerInRange)
            {
                List <RaycastHit> hits = new List <RaycastHit>();
                RaycastHit        hit;

                foreach (GameObject Player in m_TargetPlayers)
                {
                    if (Physics.Raycast(m_head.transform.position, (Player.transform.position - m_head.transform.position).normalized
                                        , out hit, m_aggroDistance * m_aggroDistance, LayerMask.GetMask(new string[] { "Walls", "Player" })
                                        , QueryTriggerInteraction.Ignore))
                    {
                        Vector3 playerAng = Player.transform.position;
                        playerAng.y = m_head.transform.position.y;
                        float angle = Vector3.SignedAngle((playerAng - m_head.transform.position), m_head.forward, Vector3.up);
                        if (angle >= -90 && angle <= 90)
                        {
                            hits.Add(hit);
                        }
                    }
                }
                if (hits.Count > 0)
                {
                    float distance = m_aggroDistance * m_aggroDistance + 1;
                    foreach (RaycastHit RHit in hits)
                    {
                        float dist = (RHit.transform.position - m_head.transform.position).sqrMagnitude;
                        if (dist < distance)
                        {
                            m_Target = RHit.transform.gameObject;
                            distance = dist;
                        }
                    }
                    CurrentState -= EAIState.IDLE;
                    CurrentState  = CurrentState | EAIState.MOVING;
                }
                else
                {
                    return;
                }
            }
        }
        if (CurrentState.HasFlag(EAIState.MOVING) && !CurrentState.HasFlag(EAIState.DEAD))
        {
            m_agent.destination = m_Target.transform.position;


            if (m_agent.remainingDistance < m_hitdistance &&
                !m_agent.pathPending)
            {
                Attack();

                return;
            }
            else
            {
                NotAttacking();
            }


            if ((m_agent.transform.position - m_Target.transform.position).sqrMagnitude >= m_deAggroDistance)
            {
                m_agent.SetDestination(m_Target.transform.position);

                if (CurrentState.HasFlag(EAIState.ATTACKING))
                {
                    CurrentState -= EAIState.ATTACKING;
                }

                CurrentState -= EAIState.MOVING;
                CurrentState  = CurrentState | EAIState.IDLE;
                return;
            }
        }
    }