Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DrawDust()

void Terraria.Main.DrawDust ( )
inlineprotected

Definition at line 35458 of file Main.cs.

35459 {
35461 rectangle = new Microsoft.Xna.Framework.Rectangle((int)screenPosition.X - 1000, (int)screenPosition.Y - 1050, screenWidth + 2000, screenHeight + 2100);
35465 for (int i = 0; i < maxDustToDraw; i++)
35466 {
35467 Dust dust = Main.dust[i];
35468 if (!dust.active)
35469 {
35470 continue;
35471 }
35472 if ((dust.type >= 130 && dust.type <= 134) || (dust.type >= 219 && dust.type <= 223) || dust.type == 226 || dust.type == 278)
35473 {
35475 }
35476 if (new Microsoft.Xna.Framework.Rectangle((int)dust.position.X, (int)dust.position.Y, 4, 4).Intersects(rectangle))
35477 {
35478 float scale = dust.GetVisualScale();
35479 if (dust.shader != armorShaderData)
35480 {
35481 spriteBatch.End();
35482 armorShaderData = dust.shader;
35483 if (armorShaderData == null)
35484 {
35486 }
35487 else
35488 {
35490 dust.shader.Apply(null);
35491 }
35492 }
35493 if (dust.type >= 130 && dust.type <= 134)
35494 {
35495 float num = Math.Abs(dust.velocity.X) + Math.Abs(dust.velocity.Y);
35496 num *= 0.3f;
35497 num *= 10f;
35498 if (num > 10f)
35499 {
35500 num = 10f;
35501 }
35502 for (int j = 0; (float)j < num; j++)
35503 {
35504 Vector2 velocity = dust.velocity;
35505 Vector2 vector = dust.position - velocity * j;
35506 float scale2 = dust.scale * (1f - (float)j / 10f);
35507 Microsoft.Xna.Framework.Color color = Lighting.GetColor((int)((double)dust.position.X + 4.0) / 16, (int)((double)dust.position.Y + 4.0) / 16);
35508 color = dust.GetAlpha(color);
35509 spriteBatch.Draw(TextureAssets.Dust.Value, vector - screenPosition, dust.frame, color, dust.rotation, new Vector2(4f, 4f), scale2, SpriteEffects.None, 0f);
35510 }
35511 }
35512 else if (dust.type == 278)
35513 {
35514 float num2 = Math.Abs(dust.velocity.X) + Math.Abs(dust.velocity.Y);
35515 num2 *= 0.3f;
35516 num2 *= 10f;
35517 if (num2 > 10f)
35518 {
35519 num2 = 10f;
35520 }
35521 Vector2 origin = new Vector2(4f, 4f);
35522 for (int k = 0; (float)k < num2; k++)
35523 {
35524 Vector2 velocity2 = dust.velocity;
35525 Vector2 vector2 = dust.position - velocity2 * k;
35526 float scale3 = dust.scale * (1f - (float)k / 10f);
35527 Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)(dust.position.X + 4f) / 16, (int)(dust.position.Y + 4f) / 16);
35528 color2 = dust.GetAlpha(color2);
35529 spriteBatch.Draw(TextureAssets.Dust.Value, vector2 - screenPosition, dust.frame, color2, dust.rotation, origin, scale3, SpriteEffects.None, 0f);
35530 }
35531 }
35532 else if (dust.type >= 219 && dust.type <= 223 && dust.fadeIn == 0f)
35533 {
35534 float num3 = Math.Abs(dust.velocity.X) + Math.Abs(dust.velocity.Y);
35535 num3 *= 0.3f;
35536 num3 *= 10f;
35537 if (num3 > 10f)
35538 {
35539 num3 = 10f;
35540 }
35541 for (int l = 0; (float)l < num3; l++)
35542 {
35543 Vector2 velocity3 = dust.velocity;
35544 Vector2 vector3 = dust.position - velocity3 * l;
35545 float scale4 = dust.scale * (1f - (float)l / 10f);
35546 Microsoft.Xna.Framework.Color color3 = Lighting.GetColor((int)((double)dust.position.X + 4.0) / 16, (int)((double)dust.position.Y + 4.0) / 16);
35547 color3 = dust.GetAlpha(color3);
35548 spriteBatch.Draw(TextureAssets.Dust.Value, vector3 - screenPosition, dust.frame, color3, dust.rotation, new Vector2(4f, 4f), scale4, SpriteEffects.None, 0f);
35549 }
35550 }
35551 else if (dust.type == 264 && dust.fadeIn == 0f)
35552 {
35553 float num4 = Math.Abs(dust.velocity.X) + Math.Abs(dust.velocity.Y);
35554 num4 *= 10f;
35555 if (num4 > 10f)
35556 {
35557 num4 = 10f;
35558 }
35559 for (int m = 0; (float)m < num4; m++)
35560 {
35561 Vector2 velocity4 = dust.velocity;
35562 Vector2 vector4 = dust.position - velocity4 * m;
35563 float scale5 = dust.scale * (1f - (float)m / 10f);
35564 Microsoft.Xna.Framework.Color color4 = Lighting.GetColor((int)((double)dust.position.X + 4.0) / 16, (int)((double)dust.position.Y + 4.0) / 16);
35565 color4 = dust.GetAlpha(color4) * 0.3f;
35566 spriteBatch.Draw(TextureAssets.Dust.Value, vector4 - screenPosition, dust.frame, color4, dust.rotation, new Vector2(5f), scale5, SpriteEffects.None, 0f);
35567 color4 = dust.GetColor(color4);
35568 spriteBatch.Draw(TextureAssets.Dust.Value, vector4 - screenPosition, dust.frame, color4, dust.rotation, new Vector2(5f), scale5, SpriteEffects.None, 0f);
35569 }
35570 }
35571 else if ((dust.type == 226 || dust.type == 272) && dust.fadeIn == 0f)
35572 {
35573 float num5 = Math.Abs(dust.velocity.X) + Math.Abs(dust.velocity.Y);
35574 num5 *= 0.3f;
35575 num5 *= 10f;
35576 if (num5 > 10f)
35577 {
35578 num5 = 10f;
35579 }
35580 for (int n = 0; (float)n < num5; n++)
35581 {
35582 Vector2 velocity5 = dust.velocity;
35583 Vector2 vector5 = dust.position - velocity5 * n;
35584 float scale6 = dust.scale * (1f - (float)n / 10f);
35585 Microsoft.Xna.Framework.Color color5 = Lighting.GetColor((int)((double)dust.position.X + 4.0) / 16, (int)((double)dust.position.Y + 4.0) / 16);
35586 color5 = dust.GetAlpha(color5);
35587 spriteBatch.Draw(TextureAssets.Dust.Value, vector5 - screenPosition, dust.frame, color5, dust.rotation, new Vector2(4f, 4f), scale6, SpriteEffects.None, 0f);
35588 }
35589 }
35590 Microsoft.Xna.Framework.Color newColor = Lighting.GetColor((int)((double)dust.position.X + 4.0) / 16, (int)((double)dust.position.Y + 4.0) / 16);
35591 if (dust.type == 6 || dust.type == 15 || (dust.type >= 59 && dust.type <= 64))
35592 {
35594 }
35595 newColor = dust.GetAlpha(newColor);
35596 if (dust.type == 213)
35597 {
35598 scale = 1f;
35599 }
35600 spriteBatch.Draw(TextureAssets.Dust.Value, dust.position - screenPosition, dust.frame, newColor, dust.GetVisualRotation(), new Vector2(4f, 4f), scale, SpriteEffects.None, 0f);
35601 if (dust.color.PackedValue != 0)
35602 {
35604 if (color6.PackedValue != 0)
35605 {
35606 spriteBatch.Draw(TextureAssets.Dust.Value, dust.position - screenPosition, dust.frame, color6, dust.GetVisualRotation(), new Vector2(4f, 4f), scale, SpriteEffects.None, 0f);
35607 }
35608 }
35610 {
35611 dust.active = false;
35612 }
35613 }
35614 else
35615 {
35616 dust.active = false;
35617 }
35618 }
35619 spriteBatch.End();
35620 pixelShader.CurrentTechnique.Passes[0].Apply();
35621 TimeLogger.DetailedDrawTime(25);
35622 }
static readonly BlendState AlphaBlend
Definition BlendState.cs:36
static readonly SamplerState PointClamp
static double Abs(double value)
static Asset< Texture2D > Dust
static int maxDustToDraw
Definition Main.cs:1128
static SpriteBatch spriteBatch
Definition Main.cs:974
static Effect pixelShader
Definition Main.cs:2764
static int screenHeight
Definition Main.cs:1721
static Vector2 screenPosition
Definition Main.cs:1715
static Matrix Transform
Definition Main.cs:2771
static int screenWidth
Definition Main.cs:1719
static Dust[] dust
Definition Main.cs:1677
bool Intersects(Rectangle value)
Definition Rectangle.cs:129

References System.Math.Abs(), Microsoft.Xna.Framework.Graphics.BlendState.AlphaBlend, Microsoft.Xna.Framework.Color.Black, Microsoft.Xna.Framework.Graphics.RasterizerState.CullNone, Terraria.TimeLogger.DetailedDrawTime(), Terraria.GameContent.TextureAssets.Dust, Terraria.Main.dust, Terraria.Lighting.GetColor(), System.Text.RegularExpressions.i, Microsoft.Xna.Framework.Rectangle.Intersects(), Terraria.Main.maxDustToDraw, Microsoft.Xna.Framework.Graphics.DepthStencilState.None, Terraria.Main.pixelShader, Microsoft.Xna.Framework.Graphics.SamplerState.PointClamp, Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Main.screenWidth, Terraria.Main.spriteBatch, Terraria.Main.Transform, Microsoft.Xna.Framework.Graphics.Vector2, and Microsoft.Xna.Framework.Color.White.

Referenced by Terraria.Main.DoDraw(), and Terraria.Main.DrawCapture().