public void spawn(Vector2 position)
        {
            minionState = BroodLingState.Egg;
            eggTimer    = 0;

            this.position = position - (dimensions / 2);
            enemy_life    = 8;

            direction = (float)(Game1.rand.NextDouble() * Math.PI);
        }
        public void setTarget(Vector2 en)
        {
            target = en;

            if (minionState == BroodLingState.Idle && en != null)
            {
                minionState = BroodLingState.Chase;
            }
            else if (en == null && minionState == BroodLingState.Chase)
            {
                minionState = BroodLingState.Idle;
            }
        }
        public BroodLing(LevelState parentWorld, Vector2 position, BroodLord lord)
        {
            minionState      = BroodLingState.Dead;
            this.parentWorld = parentWorld;
            this.dimensions  = GlobalGameConstants.TileSize * 0.6f;
            this.lord        = lord;

            enemy_life = 0;
            enemy_type = EnemyType.Alien;

            animation_time = 0;

            anim    = AnimationLib.loadNewAnimationSet("broodling");
            eggAnim = AnimationLib.getFrameAnimationSet("broodEgg");
        }
        public override void knockBack(Vector2 direction, float magnitude, int damage, Entity attacker)
        {
            if (minionState == BroodLingState.KnockBack || minionState == BroodLingState.Dying || minionState == BroodLingState.Dead)
            {
                return;
            }

            parentWorld.Particles.pushBloodParticle(CenterPoint);
            parentWorld.Particles.pushBloodParticle(CenterPoint);
            parentWorld.Particles.pushBloodParticle(CenterPoint);

            direction.Normalize();

            magnitude /= 2.5f;
            velocity   = magnitude * direction;

            velocity = Vector2.Clamp(velocity, Vector2.Zero, new Vector2(0.3f));

            enemy_life -= damage;

            minionState    = BroodLingState.KnockBack;
            knockBackTimer = 0;
        }
        public override void update(GameTime currentTime)
        {
            animation_time += currentTime.ElapsedGameTime.Milliseconds / ((minionState == BroodLingState.Egg) ? 1 : 1000f);

            if (direction < 0)
            {
                direction += (float)(Math.PI * 2);
            }

            if (minionState == BroodLingState.Idle)
            {
                direction += 0.05f;

                velocity = new Vector2((float)(Math.Cos(direction) * minionSpeed), (float)(Math.Sin(direction) * minionSpeed));
            }
            else if (minionState == BroodLingState.Chase)
            {
                double dir = Math.Atan2(target.Y - CenterPoint.Y, target.X - CenterPoint.X);

                if (Math.Abs(dir - direction) > Math.PI)
                {
                    if (dir > direction)
                    {
                        dir -= Math.PI * 2;
                    }
                    else if (dir < direction)
                    {
                        dir += Math.PI * 2;
                    }
                }

                if (dir > direction)
                {
                    direction += 0.02f;
                }
                else if (dir < direction)
                {
                    direction -= 0.02f;
                }

                velocity = new Vector2((float)(Math.Cos(direction) * minionSpeed), (float)(Math.Sin(direction) * minionSpeed));

                foreach (Entity en in parentWorld.EntityList)
                {
                    if (!(en.Enemy_Type == EnemyType.Player || en.Enemy_Type == EnemyType.Guard || en.Enemy_Type == EnemyType.Prisoner || en.Enemy_Type == EnemyType.NoType))
                    {
                        continue;
                    }

                    if (Vector2.Distance(en.CenterPoint, CenterPoint) > 500)
                    {
                        continue;
                    }


                    if (hitTest(en))
                    {
                        en.knockBack(Vector2.Normalize(en.CenterPoint - CenterPoint), 8, 5, lord);

                        velocity    = Vector2.Normalize(en.CenterPoint - CenterPoint) * -0.2f;
                        biteTimer   = 0;
                        minionState = BroodLingState.Biting;
                    }
                }
            }
            else if (minionState == BroodLingState.Egg)
            {
                velocity = Vector2.Zero;

                eggTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (eggTimer > eggDuration)
                {
                    if (target == null)
                    {
                        minionState = BroodLingState.Idle;
                    }
                    else
                    {
                        minionState = BroodLingState.Chase;
                    }
                }
            }
            else if (minionState == BroodLingState.Dying)
            {
                velocity = Vector2.Zero;

                dyingTimer += currentTime.ElapsedGameTime.Milliseconds;
                if (dyingTimer > dyingDuration)
                {
                    minionState = BroodLingState.Dead;
                }
            }
            else if (minionState == BroodLingState.Dead)
            {
                position = new Vector2(float.MinValue, float.MaxValue);
                velocity = Vector2.Zero;

                return;
            }
            else if (minionState == BroodLingState.KnockBack)
            {
                knockBackTimer += currentTime.ElapsedGameTime.Milliseconds;

                direction += 0.1f;

                if (knockBackTimer > knockBackDuration)
                {
                    minionState = BroodLingState.Chase;

                    if (enemy_life < 1)
                    {
                        for (int i = 0; i < 11; i++)
                        {
                            parentWorld.Particles.pushExplosiveGib(CenterPoint);
                            AudioLib.playSoundEffect("fleshyKnockBack");
                        }

                        minionState = BroodLingState.Dying;
                        dyingTimer  = 0;
                    }
                }
            }
            else if (minionState == BroodLingState.Biting)
            {
                biteTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (biteTimer > biteDuration)
                {
                    minionState = BroodLingState.Chase;
                }
            }
            else
            {
                throw new NotImplementedException("Invalid broodling minion state");
            }

            direction = direction % (float)(Math.PI * 2);

            Vector2 newPos = position + (this.velocity * currentTime.ElapsedGameTime.Milliseconds);

            position = parentWorld.Map.reloactePosition(position, newPos, dimensions);

            anim.Animation.Apply(anim.Skeleton, animation_time, true);
        }