////////////////

        public static Vector2?FindAmbushDestination(NPC ambusher, Entity target)
        {
            for (int i = 0; i < 64; i++)
            {
                Vector2?dest = PirateRuffianNPC.AttemptToFindAmbushDestination(ambusher, target);
                if (dest.HasValue)
                {
                    return(dest);
                }
            }

            return(null);
        }
        ////

        private void RunAmbushActionBuildup(Entity target)
        {
            this.npc.velocity.X *= 0.7f;
            this.npc.ai[0]       = 0f;
            this.npc.ai[1]       = 0f;
            this.npc.ai[2]       = 0f;
            this.npc.ai[3]       = 0f;

            if ((this.AmbushRunTimer % 5) == 0)
            {
                Vector2?smokePos = PirateRuffianNPC.FindAmbushDestination(this.npc, target);

                if (smokePos.HasValue)
                {
                    PirateRuffianNPC.EmitSmoke(smokePos.Value, true);
                }
            }
        }
        public static void EmitSmoke(Vector2 pos, bool fake)
        {
            ParticleFxHelpers.MakeDustCloud(
                position: fake
                                        ? pos
                                        : pos - new Vector2(16f),
                quantity: 1,
                sprayAmount: 0.3f,
                scale: fake
                                        ? 0.5f
                                        : 2f
                );

            if (!fake)
            {
                PirateRuffianNPC.EmitSmoke(pos, true);
            }
        }
        private bool EndAmbushAction(Entity target)
        {
            Vector2?ambushPos = PirateRuffianNPC.FindAmbushDestination(this.npc, target);

            if (!ambushPos.HasValue)
            {
                return(false);
            }

            this.npc.Center = ambushPos.Value;
            if (Main.netMode == NetmodeID.Server)
            {
                NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, this.npc.whoAmI);
            }

            PirateRuffianNPC.EmitSmoke(ambushPos.Value, false);

            return(true);
        }
        ////////////////

        private void BeginAmbushAction(Entity target)
        {
            this.AmbushRunTimer = PDYBConfig.Instance.PirateRuffianAmbushBuildupDurationTicks;
            PirateRuffianNPC.EmitSmoke(this.npc.Center, false);
        }