1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| public override bool PreDraw(ref Color lightColor) { int BodyLength = 12;
SpriteBatch spriteBatch = Main.spriteBatch;
Texture2D texture = (Texture2D)ModContent.Request<Texture2D>(Texture);
SpriteBatchState sBS = GraphicsUtils.GetState(spriteBatch).Value; spriteBatch.End(); spriteBatch.Begin( SpriteSortMode.Deferred, BlendState.NonPremultiplied, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullNone, null, Main.GameViewMatrix.TransformationMatrix);
List<Vertex2D> bars = new List<Vertex2D>(); Vector2 drawCenter = Projectile.Center - Main.screenPosition + new Vector2(BodyLength * 5f * 0.75f, 0).RotatedBy(Projectile.rotation) * Projectile.scale; for (int i = 0; i < BodyLength; i++) { Color drawColor = lightColor; float jointIndex = i / (float)BodyLength; int frameY = (int)(Projectile.frame + i) % Main.projFrames[Projectile.type]; float frameYValue = frameY / (float)Main.projFrames[Projectile.type]; float deltaYValue = 1 / (float)Main.projFrames[Projectile.type]; float jointScale = 0.5f + 0.5f * MathF.Sin(jointIndex * MathHelper.Pi);
bars.Add( drawCenter + new Vector2(-20, -20).RotatedBy(Projectile.rotation) * jointScale * Projectile.scale, drawColor, new Vector3(0, frameYValue, 0)); bars.Add( drawCenter + new Vector2(-20, 20).RotatedBy(Projectile.rotation) * jointScale * Projectile.scale, drawColor, new Vector3(0, frameYValue + deltaYValue, 0)); bars.Add( drawCenter + new Vector2(20, -20).RotatedBy(Projectile.rotation) * jointScale * Projectile.scale, drawColor, new Vector3(1, frameYValue, 0)); bars.Add( drawCenter + new Vector2(20, -20).RotatedBy(Projectile.rotation) * jointScale * Projectile.scale, drawColor, new Vector3(1, frameYValue, 0)); bars.Add( drawCenter + new Vector2(-20, 20).RotatedBy(Projectile.rotation) * jointScale * Projectile.scale, drawColor, new Vector3(0, frameYValue + deltaYValue, 0)); bars.Add( drawCenter + new Vector2(20, 20).RotatedBy(Projectile.rotation) * jointScale * Projectile.scale, drawColor, new Vector3(1, frameYValue + deltaYValue, 0));
drawCenter -= new Vector2(10, 0).RotatedBy(Projectile.rotation) * jointScale * Projectile.scale; }
Main.graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone; Main.graphics.GraphicsDevice.Textures[0] = texture; Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap; if (bars.Count > 3) { Main.graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, bars.ToArray(), 0, bars.Count / 3); }
spriteBatch.End(); spriteBatch.Begin(sBS);
Projectile.frame = ++Projectile.frame % Main.projFrames[Projectile.type];
return false; }
|