示例#1
0
        public override bool PreAI()
        {
            if (!init)
            {
                float airRadius   = projectile.ai[0];
                float airDiameter = airRadius * 2;
                airRect = new Rectangle(
                    (int)(projectile.position.X - airRadius),
                    (int)(projectile.position.Y - airRadius),
                    (int)(airDiameter),
                    (int)(airDiameter));
                init = true;
            }

            for (int i = 0; i < Main.maxPlayers; i++)
            {
                Player player = Main.player[i];
                if (player.active && !player.dead)
                {
                    Rectangle playerRect = player.getRect();
                    if (playerRect.Intersects(airRect))
                    {
                        player.GetModPlayer <BuffPlayer>().AddChilledAirBuff(player, projectile.ai[1]);
                    }
                }
            }

            for (int i = 0; i < Main.maxNPCs; i++)
            {
                NPC npc = Main.npc[i];
                if (npc.active && (!npc.friendly || npc.townNPC) && !npc.dontTakeDamage)
                {
                    Rectangle npcRect = npc.getRect();
                    if (npcRect.Intersects(airRect))
                    {
                        BuffNPC pomNPC = npc.GetGlobalNPC <BuffNPC>();
                        pomNPC.AddChilledAirBuff(npc, projectile.ai[1]);
                    }
                }
            }

            Lighting.AddLight(projectile.Center, emittedLight);

            float dustsF = (airRect.Width * airRect.Height) / dustScarcity;
            int   dusts  = (int)Math.Ceiling(dustsF);

            if (Main.rand.NextFloat(1f) <= dustsF)
            {
                for (int i = 0; i < dusts; i++)
                {
                    Dust.NewDustPerfect(new Vector2(Main.rand.NextFloat(airRect.Left, airRect.Right), Main.rand.NextFloat(airRect.Bottom, airRect.Top)), ModContent.DustType <FrostCloud>(), Alpha: 150, Scale: Main.rand.NextFloat(1f, 6f));
                }
            }

            return(false);
        }