public static void DrawLine(SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color) { float num1 = Vector2.Distance(start, end); Vector2 v = (end - start) / num1; Vector2 vector2_1 = start; Vector2 vector2_2 = Main.screenPosition; float rotation = Utils.ToRotation(v); float num2 = 0.0f; while ((double)num2 <= (double)num1) { float num3 = num2 / num1; spriteBatch.Draw(Main.blackTileTexture, vector2_1 - vector2_2, new Rectangle?(), new Color(new Vector4(num3, num3, num3, 1f) * color.ToVector4()), rotation, Vector2.Zero, 0.25f, SpriteEffects.None, 0.0f); vector2_1 = start + num2 * v; num2 += 4f; } }
public static void DrawLaser(SpriteBatch sb, Texture2D tex, Vector2 start, Vector2 end, Vector2 scale, Utils.LaserLineFraming framing) { Vector2 vector2_1 = start; Vector2 vector2_2 = Vector2.Normalize(end - start); float distanceLeft1 = (end - start).Length(); float rotation = Utils.ToRotation(vector2_2) - 1.570796f; if (Utils.HasNaNs(vector2_2)) { return; } float distanceCovered; Rectangle frame; Vector2 origin; Color color; framing(0, vector2_1, distanceLeft1, new Rectangle(), out distanceCovered, out frame, out origin, out color); sb.Draw(tex, vector2_1, new Rectangle?(frame), color, rotation, Utils.Size(frame) / 2f, scale, SpriteEffects.None, 0.0f); float distanceLeft2 = distanceLeft1 - distanceCovered * scale.Y; Vector2 vector2_3 = vector2_1 + vector2_2 * ((float)frame.Height - origin.Y) * scale.Y; if ((double)distanceLeft2 > 0.0) { float num = 0.0f; while ((double)num + 1.0 < (double)distanceLeft2) { framing(1, vector2_3, distanceLeft2 - num, frame, out distanceCovered, out frame, out origin, out color); if ((double)distanceLeft2 - (double)num < (double)frame.Height) { distanceCovered *= (distanceLeft2 - num) / (float)frame.Height; frame.Height = (int)((double)distanceLeft2 - (double)num); } sb.Draw(tex, vector2_3, new Rectangle?(frame), color, rotation, origin, scale, SpriteEffects.None, 0.0f); num += distanceCovered * scale.Y; vector2_3 += vector2_2 * distanceCovered * scale.Y; } } framing(2, vector2_3, distanceLeft2, new Rectangle(), out distanceCovered, out frame, out origin, out color); sb.Draw(tex, vector2_3, new Rectangle?(frame), color, rotation, origin, scale, SpriteEffects.None, 0.0f); }
public void Update() { if (Main.netMode == 2 || !this.active) { return; } if (this.type >= 276 && this.type <= 282) { this.velocity.X *= 0.98f; this.velocity.Y *= 0.98f; if ((double)this.velocity.Y < (double)this.scale) { this.velocity.Y += 0.05f; } if ((double)this.velocity.Y > 0.1) { if ((double)this.velocity.X > 0.0) { this.rotation += 0.01f; } else { this.rotation -= 0.01f; } } } if (this.type >= 570 && this.type <= 572) { this.scale -= 1.0f / 1000.0f; if ((double)this.scale <= 0.01) { this.scale = 0.01f; Gore.goreTime = 0; } this.sticky = false; this.rotation = this.velocity.X * 0.1f; } else if (this.type >= 706 && this.type <= 717) { this.alpha = (double)this.position.Y >= Main.worldSurface * 16.0 + 8.0 ? 100 : 0; int num1 = 4; ++this.frameCounter; if ((int)this.frame <= 4) { int x = (int)((double)this.position.X / 16.0); int y = (int)((double)this.position.Y / 16.0) - 1; if (WorldGen.InWorld(x, y, 0) && !Main.tile[x, y].active()) { this.active = false; } if ((int)this.frame == 0) { num1 = 24 + Main.rand.Next(256); } if ((int)this.frame == 1) { num1 = 24 + Main.rand.Next(256); } if ((int)this.frame == 2) { num1 = 24 + Main.rand.Next(256); } if ((int)this.frame == 3) { num1 = 24 + Main.rand.Next(96); } if ((int)this.frame == 5) { num1 = 16 + Main.rand.Next(64); } if (this.type == 716) { num1 *= 2; } if (this.type == 717) { num1 *= 4; } if ((int)this.frameCounter >= num1) { this.frameCounter = (byte)0; ++this.frame; if ((int)this.frame == 5) { int index = Gore.NewGore(this.position, this.velocity, this.type, 1f); Main.gore[index].frame = (byte)9; Main.gore[index].velocity *= 0.0f; } } } else if ((int)this.frame <= 6) { int num2 = 8; if (this.type == 716) { num2 *= 2; } if (this.type == 717) { num2 *= 3; } if ((int)this.frameCounter >= num2) { this.frameCounter = (byte)0; ++this.frame; if ((int)this.frame == 7) { this.active = false; } } } else if ((int)this.frame <= 9) { int num2 = 6; if (this.type == 716) { num2 = (int)((double)num2 * 1.5); this.velocity.Y += 0.175f; } else if (this.type == 717) { num2 *= 2; this.velocity.Y += 0.15f; } else { this.velocity.Y += 0.2f; } if ((double)this.velocity.Y < 0.5) { this.velocity.Y = 0.5f; } if ((double)this.velocity.Y > 12.0) { this.velocity.Y = 12f; } if ((int)this.frameCounter >= num2) { this.frameCounter = (byte)0; ++this.frame; } if ((int)this.frame > 9) { this.frame = (byte)7; } } else { if (this.type == 716) { num1 *= 2; } else if (this.type == 717) { num1 *= 6; } this.velocity.Y += 0.1f; if ((int)this.frameCounter >= num1) { this.frameCounter = (byte)0; ++this.frame; } this.velocity *= 0.0f; if ((int)this.frame > 14) { this.active = false; } } } else if (this.type == 11 || this.type == 12 || (this.type == 13 || this.type == 61) || (this.type == 62 || this.type == 63 || (this.type == 99 || this.type == 220)) || (this.type == 221 || this.type == 222 || this.type >= 375 && this.type <= 377 || (this.type >= 435 && this.type <= 437 || this.type >= 861 && this.type <= 862))) { this.velocity.Y *= 0.98f; this.velocity.X *= 0.98f; this.scale -= 0.007f; if ((double)this.scale < 0.1) { this.scale = 0.1f; this.alpha = (int)byte.MaxValue; } } else if (this.type == 16 || this.type == 17) { this.velocity.Y *= 0.98f; this.velocity.X *= 0.98f; this.scale -= 0.01f; if ((double)this.scale < 0.1) { this.scale = 0.1f; this.alpha = (int)byte.MaxValue; } } else if (this.type == 331) { this.alpha += 5; this.velocity.Y *= 0.95f; this.velocity.X *= 0.95f; this.rotation = this.velocity.X * 0.1f; } else if (this.type != 860 && this.type != 892 && this.type != 893 && ((this.type < 825 || this.type > 827) && (this.type < 411 || this.type > 430))) { this.velocity.Y += 0.2f; } this.rotation += this.velocity.X * 0.1f; if (this.type >= 580 && this.type <= 582) { this.rotation = 0.0f; this.velocity.X *= 0.95f; } if (this.type >= 825 && this.type <= 827) { if (this.timeLeft < 60) { this.alpha += Main.rand.Next(1, 7); } else if (this.alpha > 100) { this.alpha -= Main.rand.Next(1, 4); } if (this.alpha < 0) { this.alpha = 0; } if (this.alpha > (int)byte.MaxValue) { this.timeLeft = 0; } this.velocity.X = (float)(((double)this.velocity.X * 50.0 + (double)Main.windSpeed * 2.0 + (double)Main.rand.Next(-10, 11) * 0.100000001490116) / 51.0); float num1 = 0.0f; if ((double)this.velocity.X < 0.0) { num1 = this.velocity.X * 0.2f; } this.velocity.Y = (float)(((double)this.velocity.Y * 50.0 - 0.349999994039536 + (double)num1 + (double)Main.rand.Next(-10, 11) * 0.200000002980232) / 51.0); this.rotation = this.velocity.X * 0.6f; float num2 = -1f; if (Main.goreLoaded[this.type]) { Rectangle rectangle1 = new Rectangle((int)this.position.X, (int)this.position.Y, (int)((double)Main.goreTexture[this.type].Width * (double)this.scale), (int)((double)Main.goreTexture[this.type].Height * (double)this.scale)); for (int index = 0; index < (int)byte.MaxValue; ++index) { if (Main.player[index].active && !Main.player[index].dead) { Rectangle rectangle2 = new Rectangle((int)Main.player[index].position.X, (int)Main.player[index].position.Y, Main.player[index].width, Main.player[index].height); if (rectangle1.Intersects(rectangle2)) { this.timeLeft = 0; num2 = Main.player[index].velocity.Length(); break; } } } } if (this.timeLeft > 0) { if (Main.rand.Next(2) == 0) { --this.timeLeft; } if (Main.rand.Next(50) == 0) { this.timeLeft -= 5; } if (Main.rand.Next(100) == 0) { this.timeLeft -= 10; } } else { this.alpha = (int)byte.MaxValue; if (Main.goreLoaded[this.type] && (double)num2 != -1.0) { float num3 = (float)((double)Main.goreTexture[this.type].Width * (double)this.scale * 0.800000011920929); float x = this.position.X; float y = this.position.Y; float num4 = (float)Main.goreTexture[this.type].Width * this.scale; float num5 = (float)Main.goreTexture[this.type].Height * this.scale; int Type = 31; for (int index1 = 0; (double)index1 < (double)num3; ++index1) { int index2 = Dust.NewDust(new Vector2(x, y), (int)num4, (int)num5, Type, 0.0f, 0.0f, 0, new Color(), 1f); Main.dust[index2].velocity *= (float)((1.0 + (double)num2) / 3.0); Main.dust[index2].noGravity = true; Main.dust[index2].alpha = 100; Main.dust[index2].scale = this.scale; } } } } if (this.type >= 411 && this.type <= 430) { this.alpha = 50; this.velocity.X = (float)(((double)this.velocity.X * 50.0 + (double)Main.windSpeed * 2.0 + (double)Main.rand.Next(-10, 11) * 0.100000001490116) / 51.0); this.velocity.Y = (float)(((double)this.velocity.Y * 50.0 - 0.25 + (double)Main.rand.Next(-10, 11) * 0.200000002980232) / 51.0); this.rotation = this.velocity.X * 0.3f; if (Main.goreLoaded[this.type]) { Rectangle rectangle1 = new Rectangle((int)this.position.X, (int)this.position.Y, (int)((double)Main.goreTexture[this.type].Width * (double)this.scale), (int)((double)Main.goreTexture[this.type].Height * (double)this.scale)); for (int index = 0; index < (int)byte.MaxValue; ++index) { if (Main.player[index].active && !Main.player[index].dead) { Rectangle rectangle2 = new Rectangle((int)Main.player[index].position.X, (int)Main.player[index].position.Y, Main.player[index].width, Main.player[index].height); if (rectangle1.Intersects(rectangle2)) { this.timeLeft = 0; } } } if (Collision.SolidCollision(this.position, (int)((double)Main.goreTexture[this.type].Width * (double)this.scale), (int)((double)Main.goreTexture[this.type].Height * (double)this.scale))) { this.timeLeft = 0; } } if (this.timeLeft > 0) { if (Main.rand.Next(2) == 0) { --this.timeLeft; } if (Main.rand.Next(50) == 0) { this.timeLeft -= 5; } if (Main.rand.Next(100) == 0) { this.timeLeft -= 10; } } else { this.alpha = (int)byte.MaxValue; if (Main.goreLoaded[this.type]) { float num1 = (float)((double)Main.goreTexture[this.type].Width * (double)this.scale * 0.800000011920929); float x = this.position.X; float y = this.position.Y; float num2 = (float)Main.goreTexture[this.type].Width * this.scale; float num3 = (float)Main.goreTexture[this.type].Height * this.scale; int Type = 176; if (this.type >= 416 && this.type <= 420) { Type = 177; } if (this.type >= 421 && this.type <= 425) { Type = 178; } if (this.type >= 426 && this.type <= 430) { Type = 179; } for (int index1 = 0; (double)index1 < (double)num1; ++index1) { int index2 = Dust.NewDust(new Vector2(x, y), (int)num2, (int)num3, Type, 0.0f, 0.0f, 0, new Color(), 1f); Main.dust[index2].noGravity = true; Main.dust[index2].alpha = 100; Main.dust[index2].scale = this.scale; } } } } else if (this.type != 860 && this.type != 892 && this.type != 893) { if (this.type >= 706 && this.type <= 717) { if (this.type == 716) { float num1 = 0.6f; float num2 = (int)this.frame != 0 ? ((int)this.frame != 1 ? ((int)this.frame != 2 ? ((int)this.frame != 3 ? ((int)this.frame != 4 ? ((int)this.frame != 5 ? ((int)this.frame != 6 ? ((int)this.frame > 9 ? ((int)this.frame != 10 ? ((int)this.frame != 11 ? ((int)this.frame != 12 ? ((int)this.frame != 13 ? ((int)this.frame != 14 ? 0.0f : num1 * 0.1f) : num1 * 0.2f) : num1 * 0.3f) : num1 * 0.4f) : num1 * 0.5f) : num1 * 0.5f) : num1 * 0.2f) : num1 * 0.4f) : num1 * 0.5f) : num1 * 0.4f) : num1 * 0.3f) : num1 * 0.2f) : num1 * 0.1f; Lighting.AddLight(this.position + new Vector2(8f, 8f), 1f * num2, 0.5f * num2, 0.1f * num2); } Vector2 vector2 = this.velocity; this.velocity = Collision.TileCollision(this.position, this.velocity, 16, 14, false, false, 1); if (this.velocity != vector2) { if ((int)this.frame < 10) { this.frame = (byte)10; this.frameCounter = (byte)0; if (this.type != 716 && this.type != 717) { Main.PlaySound(39, (int)this.position.X + 8, (int)this.position.Y + 8, Main.rand.Next(2)); } } } else if (Collision.WetCollision(this.position + this.velocity, 16, 14)) { if ((int)this.frame < 10) { this.frame = (byte)10; this.frameCounter = (byte)0; if (this.type != 716 && this.type != 717) { Main.PlaySound(39, (int)this.position.X + 8, (int)this.position.Y + 8, 2); } } int index1 = (int)((double)this.position.X + 8.0) / 16; int index2 = (int)((double)this.position.Y + 14.0) / 16; if (Main.tile[index1, index2] != null && (int)Main.tile[index1, index2].liquid > 0) { this.velocity *= 0.0f; this.position.Y = (float)(index2 * 16 - (int)Main.tile[index1, index2].liquid / 16); } } } else if (this.sticky) { int num1 = 32; if (Main.goreLoaded[this.type]) { num1 = Main.goreTexture[this.type].Width; if (Main.goreTexture[this.type].Height < num1) { num1 = Main.goreTexture[this.type].Height; } } int num2 = (int)((double)num1 * 0.899999976158142); this.velocity = Collision.TileCollision(this.position, this.velocity, (int)((double)num2 * (double)this.scale), (int)((double)num2 * (double)this.scale), false, false, 1); if ((double)this.velocity.Y == 0.0) { this.velocity.X *= 0.97f; if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01) { this.velocity.X = 0.0f; } } if (this.timeLeft > 0) { --this.timeLeft; } else { ++this.alpha; } } else { this.alpha += 2; } } if (this.type == 860 || this.type == 892 || this.type == 893) { if ((double)this.velocity.Y < 0.0) { Vector2 Velocity = new Vector2(this.velocity.X, 0.6f); int num1 = 32; if (Main.goreLoaded[this.type]) { num1 = Main.goreTexture[this.type].Width; if (Main.goreTexture[this.type].Height < num1) { num1 = Main.goreTexture[this.type].Height; } } int num2 = (int)((double)num1 * 0.899999976158142); Vector2 vector2 = Collision.TileCollision(this.position, Velocity, (int)((double)num2 * (double)this.scale), (int)((double)num2 * (double)this.scale), false, false, 1); vector2.X *= 0.97f; if ((double)vector2.X > -0.01 && (double)vector2.X < 0.01) { vector2.X = 0.0f; } if (this.timeLeft > 0) { --this.timeLeft; } else { ++this.alpha; } this.velocity.X = vector2.X; } else { this.velocity.Y += 0.05235988f; Vector2 Velocity = new Vector2(Utils.RotatedBy(Vector2.UnitY, (double)this.velocity.Y, new Vector2()).X * 2f, Math.Abs(Utils.RotatedBy(Vector2.UnitY, (double)this.velocity.Y, new Vector2()).Y) * 3f) * 2f; int num = 32; if (Main.goreLoaded[this.type]) { num = Main.goreTexture[this.type].Width; if (Main.goreTexture[this.type].Height < num) { num = Main.goreTexture[this.type].Height; } } Vector2 vector2 = Velocity; Vector2 v = Collision.TileCollision(this.position, Velocity, (int)((double)num * (double)this.scale), (int)((double)num * (double)this.scale), false, false, 1); if (v != vector2) { this.velocity.Y = -1f; } this.position += v; this.rotation = Utils.ToRotation(v) + 3.141593f; if (this.timeLeft > 0) { --this.timeLeft; } else { ++this.alpha; } } } else { this.position += this.velocity; } if (this.alpha >= (int)byte.MaxValue) { this.active = false; } if ((double)this.light <= 0.0) { return; } float R = this.light * this.scale; float G = this.light * this.scale; float B = this.light * this.scale; if (this.type == 16) { B *= 0.3f; G *= 0.8f; } else if (this.type == 17) { G *= 0.6f; R *= 0.3f; } if (Main.goreLoaded[this.type]) { Lighting.AddLight((int)(((double)this.position.X + (double)Main.goreTexture[this.type].Width * (double)this.scale / 2.0) / 16.0), (int)(((double)this.position.Y + (double)Main.goreTexture[this.type].Height * (double)this.scale / 2.0) / 16.0), R, G, B); } else { Lighting.AddLight((int)(((double)this.position.X + 32.0 * (double)this.scale / 2.0) / 16.0), (int)(((double)this.position.Y + 32.0 * (double)this.scale / 2.0) / 16.0), R, G, B); } }