public override bool PreDraw(SpriteBatch sb, Color drawColor) { Texture2D texTail = mod.GetTexture("NPCs/Serris/Serris_Tail"); Serris_Head serris_head = (Serris_Head)head.modNPC; float bRot = npc.rotation - 1.57f; int tailHeight = texTail.Height / 15; Vector2 tailOrig = new Vector2(28, 29); Color bodyColor = npc.GetAlpha(Lighting.GetColor((int)npc.Center.X / 16, (int)npc.Center.Y / 16)); SpriteEffects effects = SpriteEffects.None; if (head.spriteDirection == -1) { effects = SpriteEffects.FlipVertically; tailOrig.Y = tailHeight - tailOrig.Y; } int frame = serris_head.state - 1; if (serris_head.state == 4) { frame = serris_head.sbFrame + 3; } int yFrame = frame * (tailHeight * 3) + (tailHeight * tailType); sb.Draw(texTail, npc.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, yFrame, texTail.Width, tailHeight)), bodyColor, bRot, tailOrig, 1f, effects, 0f); return(false); }
public override bool PreDraw(SpriteBatch sb, Color drawColor) { Texture2D texBody = mod.GetTexture("NPCs/Serris/Serris_Body"), texFins = mod.GetTexture("NPCs/Serris/Serris_Fins"); Serris_Head serris_head = (Serris_Head)head.modNPC; Vector2 bodyOrig = new Vector2(32, 35), finsOrig = new Vector2(52, 31); int bodyHeight = texBody.Height / 10, finsHeight = texFins.Height / 15; float bodyRot = npc.rotation - 1.57f; float headRot = head.rotation - 1.57f; Color bodyColor = npc.GetAlpha(Lighting.GetColor((int)npc.Center.X / 16, (int)npc.Center.Y / 16)); SpriteEffects effects = SpriteEffects.None; if (head.spriteDirection == -1) { effects = SpriteEffects.FlipVertically; bodyOrig.Y = bodyHeight - bodyOrig.Y; finsOrig.Y = finsHeight - finsOrig.Y; } int frame = serris_head.state - 1; if (serris_head.state == 4) { frame = serris_head.sbFrame + 3; } // If it's the last body part before the head, draw the fins. int yFrame = frame * (bodyHeight * 2); if ((int)npc.ai[1] == head.whoAmI) { for (int j = 0; j < 3; j++) { int finFrame = finsHeight * j + frame * (finsHeight * 3); Vector2 finPos = new Vector2(4, -16); float bodyRot2 = bodyRot - (headRot - bodyRot); Vector2 finRotPos = bodyRot.ToRotationVector2(); if (float.IsNaN(finRotPos.X) || float.IsNaN(finRotPos.Y)) { finRotPos = -Vector2.UnitY; } if (j == 0) { finPos = new Vector2(-14, -14); finRotPos = Vector2.Normalize(Vector2.Lerp(finRotPos, bodyRot2.ToRotationVector2(), 0.5f)); } if (j == 2) { finPos = new Vector2(20, -16); finRotPos = Vector2.Normalize(Vector2.Lerp(finRotPos, headRot.ToRotationVector2(), 0.5f)); } if (head.spriteDirection == -1) { finPos.Y *= -1; } float finRot = finRotPos.ToRotation(); finRot += (((float)Math.PI / 16) - ((float)Math.PI / 8) * (1f - serris_head.mouthFrame)) * 0.5f * head.spriteDirection; float finPosRot = finPos.ToRotation() + bodyRot; Vector2 finalFinPos = npc.Center + finPosRot.ToRotationVector2() * finPos.Length(); sb.Draw(texFins, finalFinPos - Main.screenPosition, new Rectangle?(new Rectangle(0, finFrame, texFins.Width, finsHeight)), bodyColor, finRot, finsOrig, 1f, effects, 0f); } } else { yFrame += bodyHeight; } sb.Draw(texBody, npc.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, yFrame, texBody.Width, bodyHeight)), bodyColor, bodyRot, bodyOrig, 1f, effects, 0f); return(false); }