From bb099da0350f38e6bd2b3883e62c64210db074f2 Mon Sep 17 00:00:00 2001 From: GinYuH <72181395+GinYuH@users.noreply.github.com> Date: Sat, 17 May 2025 18:09:55 -0700 Subject: [PATCH] bendy ray tail --- NPCs/SunkenSea/EutrophicRay.cs | 94 ++++++++++++++++++------ NPCs/SunkenSea/EutrophicRay.png | Bin 1777 -> 1643 bytes NPCs/SunkenSea/EutrophicRayGlow.png | Bin 1054 -> 833 bytes NPCs/SunkenSea/EutrophicRayTail.png | Bin 0 -> 243 bytes NPCs/SunkenSea/EutrophicRayTailGlow.png | Bin 0 -> 213 bytes 5 files changed, 72 insertions(+), 22 deletions(-) create mode 100644 NPCs/SunkenSea/EutrophicRayTail.png create mode 100644 NPCs/SunkenSea/EutrophicRayTailGlow.png diff --git a/NPCs/SunkenSea/EutrophicRay.cs b/NPCs/SunkenSea/EutrophicRay.cs index 125bdbc965..554774655a 100644 --- a/NPCs/SunkenSea/EutrophicRay.cs +++ b/NPCs/SunkenSea/EutrophicRay.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using CalamityMod.BiomeManagers; using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Melee; using Microsoft.Xna.Framework; @@ -20,6 +21,8 @@ namespace CalamityMod.NPCs.SunkenSea public class EutrophicRay : SunkenSeaNPC { public static Asset GlowTexture; + public static Asset TailTexture; + public static Asset TailGlowTexture; #region Fields protected override List PreyIDs => []; protected override List PredatorIDs => @@ -50,16 +53,18 @@ namespace CalamityMod.NPCs.SunkenSea private Action _previousBehavior; #endregion + public override void Load() + { + GlowTexture = ModContent.Request(Texture + "Glow"); + TailTexture = ModContent.Request(Texture + "Tail"); + TailGlowTexture = ModContent.Request(Texture + "TailGlow"); + } + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 7; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); - value.Position.X += 24f; - NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; - if (!Main.dedServ) - { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - } + NPCID.Sets.TrailingMode[Type] = 3; + NPCID.Sets.TrailCacheLength[Type] = 15; base.SetStaticDefaults(); } @@ -127,11 +132,6 @@ namespace CalamityMod.NPCs.SunkenSea { CurrentBehavior?.Invoke(); - if (NPC.velocity.X > 0.25f) - NPC.spriteDirection = 1; - else if (NPC.velocity.X < 0.25f) - NPC.spriteDirection = -1; - // If out of water, act like you're out of water. if ((NPC.noTileCollide ? !(Collision.WetCollision(NPC.position, NPC.width, NPC.height) || Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) : !NPC.wet) && CurrentBehavior != OutOfWaterBehavior) CurrentBehavior = OutOfWaterBehavior; @@ -141,7 +141,7 @@ namespace CalamityMod.NPCs.SunkenSea hasBeenHit = true; NPC.chaseable = hasBeenHit; - NPC.rotation = NPC.velocity.ToRotation() + (NPC.spriteDirection == -1 ? MathHelper.Pi : 0); + NPC.rotation = NPC.velocity.ToRotation() + MathHelper.Pi; } private void OnBehaviorChange(Action newBehavior) { @@ -198,12 +198,6 @@ namespace CalamityMod.NPCs.SunkenSea NPC.velocity.Y = maxSpeedY; if (NPC.velocity.Y < -maxSpeedY) NPC.velocity.Y = -maxSpeedY; - - NPC.rotation = NPC.velocity.Y * 0.05f; - if (NPC.rotation < -0.1f) - NPC.rotation = -0.1f; - if (NPC.rotation > 0.1f) - NPC.rotation = 0.1f; } private void FleeBehavior() { @@ -311,9 +305,65 @@ namespace CalamityMod.NPCs.SunkenSea Vector2 halfSizeTexture = new Vector2(tex.Width / 2, tex.Height / 2 / Main.npcFrameCount[Type]); Vector2 vector = NPC.Center - screenPos; Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0); - SpriteEffects sp = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Main.spriteBatch.Draw(tex, vector, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, sp, 0f); - Main.spriteBatch.Draw(GlowTexture.Value, vector, NPC.frame, color, NPC.rotation, halfSizeTexture, NPC.scale, sp, 0f); + spriteBatch.Draw(tex, vector, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, 0, 0f); + spriteBatch.Draw(GlowTexture.Value, vector, NPC.frame, color, NPC.rotation, halfSizeTexture, NPC.scale, 0, 0f); + + // Position where the tail starts + Vector2 tailOffset = Vector2.UnitX.RotatedBy(NPC.rotation) * (tex.Width / 2 - 4); + + if (NPC.IsABestiaryIconDummy) + { + for (int i = 0; i < NPC.oldRot.Length; i++) + { + NPC.oldRot[i] = 0; + } + for (int i = 0; i < NPC.oldPos.Length; i++) + { + NPC.oldPos[i] = Vector2.UnitX.RotatedBy(NPC.rotation) * ((tex.Width / 2 - 4) + i * 8); + } + } + + float currentSegmentRotation = NPC.rotation; + List tailDrawPositions = new List(); + int segAmt = 7; + int tailLength = 40; + for (int i = 0; i < segAmt; i++) + { + float tailCompletionRatio = i / (float)segAmt; + float wrappedAngularOffset = MathHelper.WrapAngle(NPC.oldRot[i + 1] - currentSegmentRotation) * 0.6f; + float segmentRotationOffset = MathHelper.Clamp(wrappedAngularOffset, -0.24f, 0.24f); + + Vector2 Offset = Vector2.UnitX.RotatedBy(NPC.rotation); + Vector2 tailSegmentOffset = Vector2.UnitX.RotatedBy(currentSegmentRotation) * tailCompletionRatio * tailLength + Offset; + tailDrawPositions.Add(NPC.Center + tailSegmentOffset + tailOffset); + + currentSegmentRotation += segmentRotationOffset; + } + for (int i = 0; i < tailDrawPositions.Count; i++) + { + Vector2 pos = tailDrawPositions[i]; + float rot = pos.DirectionTo(NPC.Center + Vector2.UnitX.RotatedBy(NPC.rotation)).ToRotation(); + if (i > 0) + { + Vector2 oldPos = tailDrawPositions[i - 1]; + rot = pos.DirectionTo(oldPos).ToRotation(); + } + int frame = i switch + { + 1 => 10, + 5 => 20, + 6 => 32, + _ => 0 + }; + int height = 8; + if (i == 6) + height = 10; + rot += MathHelper.PiOver2; + + spriteBatch.Draw(TailTexture.Value, pos - screenPos, new Rectangle(0, frame, 10, height), NPC.GetAlpha(drawColor), rot, new Vector2(6, 4), NPC.scale, 0, 0f); + spriteBatch.Draw(TailGlowTexture.Value, pos - screenPos, new Rectangle(0, frame, 10, height), color, rot, new Vector2(6, 4), NPC.scale, 0, 0f); + } + return false; } diff --git a/NPCs/SunkenSea/EutrophicRay.png b/NPCs/SunkenSea/EutrophicRay.png index 4c0f87cd5adf5b07b958af9774b891cef6e35af5..76f3c10590c7525c569d5c97456d855e3cd1c629 100644 GIT binary patch delta 1577 zcmai!dsNZ~6vuy%nHD(Ee1w#M&&(HSrae>;6m+O4R;b_$%`8nVOLGb;8I<8;OVLVH zq?v9xt+ZO&$roC_%2!1Xo2E{4&G|?r+~}O`pPikvKkoV7d;j{J@BN-T51oae1%5uB z(9MX=002NKWTL-HaR2~%rLjTPNuFzV6rfQcy8^;4I5R1!ysb^O%|=#lQVFaeQ-=eL z88f%32F(OA<0JrRwSFm(u7wvD05(=rh>t1f;mG_4dbV#71wnhw_;$vQx7SDWbisieCcLrCB4eq}+svDxI-D3qZd(&J3 z<}p~_j01Hi%@yt!Rr)D~lZ!@-DPEi1MrN@JvlU8tlROTRnx+E}OT9@m0{LOhSAmu8 z1ziNGLpHu}J+*sbbzN&^ojI*!@^Mn}ez9vt^)?K_Uc!Fi@D(BdDdE?&eTO8$K*=m>u33=P%QcNX7ZnG@eJ%tEfOLiq zl}?&_UbX2vQhyM)?%?w&6%U!)Z+4fTNwJQl_XiXT17~MKTNz@oUz?XpkwP zy96kO04>bftpi;caVXRPM{IfUy3x<%9pTZ^j}AmK+)!AUrDo z_DJ758hRhE{mIbCEup!4tsDOR#m~>%;0U(6Qr}$4OlrT;pNLG>*1Mpms2+5BJ;m9G zy}ckB!~A`YRjY%Akelf%IQmLXEH!I=MKbB@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tyA44XNDrtQ_F12r++26>@obi5pL}&;;5J~)1MObFN~~99 f%KiFYz0>-3DvE~Z@=85`d6U7@)z4*}Q$iB}cGn4h diff --git a/NPCs/SunkenSea/EutrophicRayTail.png b/NPCs/SunkenSea/EutrophicRayTail.png new file mode 100644 index 0000000000000000000000000000000000000000..f15d72f500d363460dc02fb5d1c605e1d61cdc15 GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0vp^JV30)!3-of#CiP#QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`MFV_7Tvc>*+Frj-$l5HRtr@rEwRw6LP-Y6#fd@c}y(Gvl_&*phNO?26 z0fjgVJR*x382Ao@Fyrz36)8Z$5KkA!5RKrqXAJocDDXI6oN;95|B2qy*mM*_wdx)A zC~osHPT*NR|G?e{b?kE=egEQK!u7r5Y1-k+U(bA(D>QNhIl3i;g)q#yx_dEO*0Nn{1`c>;VwT-#p1PRQCEx8yZY;C%1Jk05m=L4Lvi|Nm!j&|3Kg$mcBZh%9Dc z;5!V$jK}j=qyPn-JY5_^G=jIDiRNNZ;BdKEc<2AT>Iq*qIIMWrFB7oP(qYND^BZi| z#j__?PB?t4<@5IK=F`|6-Z?0R?_kQkx>&p^i|K_N%T}&ke*%G~F?hQAxvX