From 9070260e4d37f2c28a2fbdae3a104b5cedfac2a4 Mon Sep 17 00:00:00 2001 From: Dominic Date: Thu, 21 Jul 2022 01:10:14 -0500 Subject: [PATCH] Selection panel --- Items/Weapons/Summon/AresExoskeleton.cs | 3 - Projectiles/Summon/SmallAresArms/Arrow.png | Bin 0 -> 165 bytes .../Summon/SmallAresArms/ExoskeletonCannon.cs | 20 +- .../ExoskeletonGaussNukeCannon.cs | 11 +- .../SmallAresArms/ExoskeletonLaserCannon.cs | 18 +- .../Summon/SmallAresArms/ExoskeletonPanel.cs | 337 +++++++++++++----- .../Summon/SmallAresArms/ExoskeletonPanel.png | Bin 812 -> 801 bytes .../SmallAresArms/ExoskeletonPanelCancel.png | Bin 382 -> 0 bytes .../SmallAresArms/ExoskeletonPanelGauss.png | Bin 402 -> 1501 bytes .../SmallAresArms/ExoskeletonPanelLaser.png | Bin 387 -> 1433 bytes .../SmallAresArms/ExoskeletonPanelPlasma.png | Bin 401 -> 1450 bytes .../SmallAresArms/ExoskeletonPanelTesla.png | Bin 361 -> 1377 bytes .../SmallAresArms/ExoskeletonPlasmaCannon.cs | 9 +- .../SmallAresArms/ExoskeletonTeslaCannon.cs | 14 +- 14 files changed, 284 insertions(+), 128 deletions(-) create mode 100644 Projectiles/Summon/SmallAresArms/Arrow.png delete mode 100644 Projectiles/Summon/SmallAresArms/ExoskeletonPanelCancel.png diff --git a/Items/Weapons/Summon/AresExoskeleton.cs b/Items/Weapons/Summon/AresExoskeleton.cs index 6e43b2ae34..9ea4833428 100644 --- a/Items/Weapons/Summon/AresExoskeleton.cs +++ b/Items/Weapons/Summon/AresExoskeleton.cs @@ -1,7 +1,4 @@ using Terraria.DataStructures; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Projectiles/Summon/SmallAresArms/Arrow.png b/Projectiles/Summon/SmallAresArms/Arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..dd54c01276ce90556270a4811f833c5eae64e08b GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^5Nn{1`ISV`@iy0XB_Jc5^1#7ShP|(WL#WBRfKUqQiPdk%_xOzgUTpUBg2n+>0g^fPsjsJVeoYIb6Mw< G&;$Tao-H2$ literal 0 HcmV?d00001 diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs index acd2440206..e0f8ab3491 100644 --- a/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs @@ -11,17 +11,35 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms { public abstract class ExoskeletonCannon : ModProjectile { + public int HoverOffsetIndex => (int)Projectile.ai[0]; + public bool TargetingSomething => Projectile.ai[1] == 1f; public Player Owner => Main.player[Projectile.owner]; public LimbCollection Limbs = new(new CyclicCoordinateDescentUpdateRule(0.27f, MathHelper.PiOver2), 70f, 82f); + public static readonly Vector2[] HoverOffsetTable = new Vector2[] + { + new(300f, 96f), + new(-300f, 96f), + new(190f, -102f), + new(-190f, -102f) + }; + + public static readonly float[] RotationalClampTable = new float[] + { + 0.23f, + MathHelper.Pi - 0.23f, + 0.2f, + MathHelper.Pi - 0.2f + }; + public virtual bool UsesSuperpredictiveness => false; public virtual Vector2 DrawOffset => new((OwnerRestingOffset.X > 0f).ToDirectionInt() * 6f, -6f); - public virtual Vector2 ConnectOffset => Vector2.Zero; + public virtual Vector2 ConnectOffset => HoverOffsetIndex >= 2 ? new((OwnerRestingOffset.X > 0f).ToDirectionInt() * 14f, -30f) : Vector2.Zero; public abstract int ShootRate { get; } diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannon.cs index 3178aa9467..466e99c646 100644 --- a/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannon.cs +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannon.cs @@ -15,19 +15,14 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms public ref float RebuildTimer => ref Projectile.localAI[0]; - public override Vector2 ConnectOffset => new((OwnerRestingOffset.X > 0f).ToDirectionInt() * 14f, -30f); - public override int ShootRate => AresExoskeleton.GaussNukeShootRate; public override float ShootSpeed => 16f; - public override Vector2 OwnerRestingOffset => new(-190f, -102f); + public override Vector2 OwnerRestingOffset => HoverOffsetTable[HoverOffsetIndex]; + + public override void ClampFirstLimbRotation(ref double limbRotation) => limbRotation = RotationalClampTable[HoverOffsetIndex]; - public override void ClampFirstLimbRotation(ref double limbRotation) - { - limbRotation = MathHelper.Pi - 0.2f; - } - public override void SetStaticDefaults() { DisplayName.SetDefault("Gauss Nuke"); diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs index 14e989d831..ab8550bc4e 100644 --- a/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs @@ -5,28 +5,24 @@ using Terraria.Audio; using Microsoft.Xna.Framework.Graphics; using CalamityMod.Sounds; using CalamityMod.Items.Weapons.Summon; +using System.IO; namespace CalamityMod.Projectiles.Summon.SmallAresArms { public class ExoskeletonLaserCannon : ExoskeletonCannon { - public ref float ShootCounter => ref Projectile.ai[0]; + public ref float ShootCounter => ref Projectile.localAI[0]; // This is how many small, regular lasers will happen before the laser will charge up and prepare a laserbeam. public const int NormalLasersBeforeBeam = 6; - - public override Vector2 ConnectOffset => new((OwnerRestingOffset.X > 0f).ToDirectionInt() * 14f, -30f); - + public override int ShootRate => ShootCounter % NormalLasersBeforeBeam == 0f ? 150 : AresExoskeleton.LaserCannonNormalShootRate; public override float ShootSpeed => 13.5f; - public override Vector2 OwnerRestingOffset => new(190f, -102f); + public override Vector2 OwnerRestingOffset => HoverOffsetTable[HoverOffsetIndex]; - public override void ClampFirstLimbRotation(ref double limbRotation) - { - limbRotation = -0.2f; - } + public override void ClampFirstLimbRotation(ref double limbRotation) => limbRotation = RotationalClampTable[HoverOffsetIndex]; public override void SetStaticDefaults() { @@ -34,6 +30,10 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms Main.projFrames[Type] = 6; } + public override void SendExtraAI(BinaryWriter writer) => writer.Write(ShootCounter); + + public override void ReceiveExtraAI(BinaryReader reader) => ShootCounter = reader.ReadSingle(); + public override void ShootAtTarget(NPC target, Vector2 shootDirection) { // Play the laser cannon fire sound. diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs index 2f728a03e0..bf135dc300 100644 --- a/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs @@ -6,23 +6,118 @@ using Terraria.ID; using CalamityMod.Items.Weapons.Summon; using Terraria.GameContent; using Terraria.Audio; +using System.Linq; +using System; namespace CalamityMod.Projectiles.Summon.SmallAresArms { public class ExoskeletonPanel : ModProjectile { - public int ArmIDToDelete = -1; + public enum IconType + { + Inactive, + Plasma, + Tesla, + Laser, + Gauss + } + + public class IconState + { + public int PanelFlashTimer; + + public int MousePressFrameCountdown; + + public bool BeingHoveredOver; + + public bool PlacedInPanel; + + public IconType CurrentState; + + public Texture2D IconTexture + { + get + { + Texture2D plasmaTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelPlasma").Value; + Texture2D teslaTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelTesla").Value; + Texture2D laserTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelLaser").Value; + Texture2D gaussTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelGauss").Value; + return CurrentState switch + { + IconType.Plasma => plasmaTexture, + IconType.Tesla => teslaTexture, + IconType.Laser => laserTexture, + IconType.Gauss => gaussTexture, + _ => null, + }; + } + } + + public Rectangle Frame + { + get + { + int frame = 0; + if (BeingHoveredOver) + frame = PlacedInPanel ? 3 : 1; + if (MousePressFrameCountdown >= 1) + frame = 2; + if (PanelFlashTimer >= 1) + frame = (int)Math.Round(MathHelper.Lerp(4f, 6f, PanelFlashTimer / 24f)); + + return IconTexture?.Frame(1, 7, 0, frame) ?? default; + } + } + + public IconState(bool hover, bool panel, IconType state) + { + BeingHoveredOver = hover; + PlacedInPanel = panel; + CurrentState = state; + } + + public void Update() + { + if (PanelFlashTimer >= 1) + PanelFlashTimer++; + if (PanelFlashTimer >= 18) + PanelFlashTimer = 0; + + if (MousePressFrameCountdown > 0) + MousePressFrameCountdown--; + } + } + + public IconType ClickedIcon = IconType.Inactive; + + public IconState[] SelectionIcons = new IconState[] + { + new(false, false, IconType.Plasma), + new(false, false, IconType.Tesla), + new(false, false, IconType.Laser), + new(false, false, IconType.Gauss), + }; + + public IconState[] PanelIcons = new IconState[] + { + new(false, true, IconType.Inactive), + new(false, true, IconType.Inactive), + new(false, true, IconType.Inactive), + new(false, true, IconType.Inactive), + }; + + public bool ShouldDeleteArmIndex = false; public int ArmIDToSpawn = -1; + public int ArmIndex = -1; + public bool FadeOut => Projectile.ai[0] == 1f; public Vector2 PlayerOffset; public static Rectangle MouseRectangle => new((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 2, 2); - - public static readonly Color HoverColor = Color.Cyan; - + public override void SetStaticDefaults() { DisplayName.SetDefault("UI"); @@ -42,9 +137,42 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms public override void AI() { + int plasmaCannonID = ModContent.ProjectileType(); + int teslaCannonID = ModContent.ProjectileType(); + int laserCannonID = ModContent.ProjectileType(); + int gaussNukeID = ModContent.ProjectileType(); + int[] arms = new int[] + { + plasmaCannonID, + teslaCannonID, + laserCannonID, + gaussNukeID, + }; + + // Initialize things. if (PlayerOffset == Vector2.Zero) PlayerOffset = Main.MouseWorld - Main.LocalPlayer.Center; + for (int i = 0; i < 4; i++) + PanelIcons[i].CurrentState = IconType.Inactive; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (!arms.Contains(Main.projectile[i].type) || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].active) + continue; + + IconType stateFromID = IconType.Inactive; + if (Main.projectile[i].type == plasmaCannonID) + stateFromID = IconType.Plasma; + if (Main.projectile[i].type == teslaCannonID) + stateFromID = IconType.Tesla; + if (Main.projectile[i].type == laserCannonID) + stateFromID = IconType.Laser; + if (Main.projectile[i].type == gaussNukeID) + stateFromID = IconType.Gauss; + + PanelIcons[(int)Main.projectile[i].ai[0]].CurrentState = stateFromID; + } + // Handle fade effects. Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity - FadeOut.ToDirectionInt() * 0.0225f, 0f, 1f); if (FadeOut && Projectile.Opacity <= 0f) @@ -57,24 +185,25 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms if (ArmIDToSpawn >= 0) { SoundEngine.PlaySound(SoundID.Zombie66, Projectile.Center); - int cannon = Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, Vector2.Zero, ArmIDToSpawn, Projectile.damage, 0f, Projectile.owner); + int cannon = Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, Vector2.Zero, ArmIDToSpawn, Projectile.damage, 0f, Projectile.owner, ArmIndex); if (Main.projectile.IndexInRange(cannon)) Main.projectile[cannon].originalDamage = Projectile.originalDamage; } - if (ArmIDToDelete >= 0) + if (ShouldDeleteArmIndex) { SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); for (int i = 0; i < Main.maxProjectiles; i++) { - if (Main.projectile[i].type != ArmIDToDelete || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].active) + if (!arms.Contains(Main.projectile[i].type) || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].active || Main.projectile[i].ai[0] != ArmIndex) continue; - + Main.projectile[i].Kill(); } } - ArmIDToDelete = -1; + ShouldDeleteArmIndex = false; ArmIDToSpawn = -1; + ArmIndex = -1; } public override bool PreDraw(ref Color lightColor) @@ -83,108 +212,126 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms if (Main.myPlayer != Projectile.owner) return false; - int plasmaCannonID = ModContent.ProjectileType(); - int teslaCannonID = ModContent.ProjectileType(); - int laserCannonID = ModContent.ProjectileType(); - int gaussNukeID = ModContent.ProjectileType(); Texture2D panelTexture = ModContent.Request(Texture).Value; - Texture2D cancelTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelCancel").Value; Texture2D plasmaTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelPlasma").Value; - Texture2D teslaTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelTesla").Value; - Texture2D laserTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelLaser").Value; - Texture2D gaussTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelGauss").Value; + Texture2D arrowTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/Arrow").Value; + Vector2 area = plasmaTexture.Frame(1, 7, 0, 0).Size(); Vector2 drawPosition = (Main.LocalPlayer.Center + PlayerOffset - Main.screenPosition).Floor(); - if (Main.LocalPlayer.ownedProjectileCounts[plasmaCannonID] >= 1) - plasmaTexture = cancelTexture; - if (Main.LocalPlayer.ownedProjectileCounts[teslaCannonID] >= 1) - teslaTexture = cancelTexture; - if (Main.LocalPlayer.ownedProjectileCounts[laserCannonID] >= 1) - laserTexture = cancelTexture; - if (Main.LocalPlayer.ownedProjectileCounts[gaussNukeID] >= 1) - gaussTexture = cancelTexture; - Color plasmaColor = Color.White; - Color teslaColor = Color.White; - Color laserColor = Color.White; - Color gaussColor = Color.White; - Rectangle plasmaIconArea = Utils.CenteredRectangle(drawPosition + new Vector2(-66f, 10f) * Projectile.scale, plasmaTexture.Size() * Projectile.scale); - Rectangle teslaIconArea = Utils.CenteredRectangle(drawPosition + new Vector2(-26f, 10f) * Projectile.scale, plasmaTexture.Size() * Projectile.scale); - Rectangle laserIconArea = Utils.CenteredRectangle(drawPosition + new Vector2(26f, 10f) * Projectile.scale, plasmaTexture.Size() * Projectile.scale); - Rectangle gaussIconArea = Utils.CenteredRectangle(drawPosition + new Vector2(66f, 10f) * Projectile.scale, plasmaTexture.Size() * Projectile.scale); + Rectangle[] selectionIconAreas = new Rectangle[4] + { + Utils.CenteredRectangle(drawPosition + new Vector2(-62f, -70f) * Projectile.scale, area * Projectile.scale), + Utils.CenteredRectangle(drawPosition + new Vector2(-22f, -70f) * Projectile.scale, area * Projectile.scale), + Utils.CenteredRectangle(drawPosition + new Vector2(22f, -70f) * Projectile.scale, area * Projectile.scale), + Utils.CenteredRectangle(drawPosition + new Vector2(62f, -70f) * Projectile.scale, area * Projectile.scale) + }; - // Handle hover behaviors. If an arm needs to be destroyed or spawned, it will happen on the next frame. bool hoveringOverAnySlot = false; + bool clickedAnIconOnPanel = false; bool sufficientSlots = Main.LocalPlayer.maxMinions >= AresExoskeleton.MinionSlotsPerCannon; - if (MouseRectangle.Intersects(plasmaIconArea)) - { - Main.blockMouse = true; - hoveringOverAnySlot = true; - plasmaColor = HoverColor; - if (Main.mouseLeftRelease && Main.mouseLeft) - { - if (plasmaTexture == cancelTexture) - ArmIDToDelete = plasmaCannonID; - else if (sufficientSlots) - ArmIDToSpawn = plasmaCannonID; - } - } - if (MouseRectangle.Intersects(teslaIconArea)) - { - Main.blockMouse = true; - hoveringOverAnySlot = true; - teslaColor = HoverColor; - if (Main.mouseLeftRelease && Main.mouseLeft) - { - if (teslaTexture == cancelTexture) - ArmIDToDelete = teslaCannonID; - else if (sufficientSlots) - ArmIDToSpawn = teslaCannonID; - } - } - if (MouseRectangle.Intersects(laserIconArea)) - { - Main.blockMouse = true; - hoveringOverAnySlot = true; - laserColor = HoverColor; - if (Main.mouseLeftRelease && Main.mouseLeft) - { - if (laserTexture == cancelTexture) - ArmIDToDelete = laserCannonID; - else if (sufficientSlots) - ArmIDToSpawn = laserCannonID; - } - } - if (MouseRectangle.Intersects(gaussIconArea)) - { - Main.blockMouse = true; - hoveringOverAnySlot = true; - gaussColor = HoverColor; - if (Main.mouseLeftRelease && Main.mouseLeft) - { - if (gaussTexture == cancelTexture) - ArmIDToDelete = gaussNukeID; - else if (sufficientSlots) - ArmIDToSpawn = gaussNukeID; - } - } - plasmaColor = Projectile.GetAlpha(plasmaColor); - teslaColor = Projectile.GetAlpha(teslaColor); - laserColor = Projectile.GetAlpha(laserColor); - gaussColor = Projectile.GetAlpha(gaussColor); + // Draw icon and handle hover behaviors. + // If an arm needs to be destroyed or spawned, it will happen on the next frame in the AI update loop. + for (int i = 0; i < 4; i++) + { + Texture2D selectionIconTexture = SelectionIcons[i].IconTexture; + + // Handle selection icon click stuff. + SelectionIcons[i].BeingHoveredOver = false; + PanelIcons[i].BeingHoveredOver = false; + if (selectionIconAreas[i].Intersects(MouseRectangle)) + { + hoveringOverAnySlot = true; + SelectionIcons[i].BeingHoveredOver = true; + if (Main.mouseLeft && Main.mouseLeftRelease) + { + ClickedIcon = SelectionIcons[i].CurrentState; + SelectionIcons[i].MousePressFrameCountdown = 15; + } + } + + // Handle panel icon click stuff. + Rectangle panelArea = selectionIconAreas[i]; + panelArea.Y += (int)(Projectile.scale * 78f); + if (panelArea.Intersects(MouseRectangle)) + { + hoveringOverAnySlot = true; + PanelIcons[i].BeingHoveredOver = true; + if (Main.mouseLeft && Main.mouseLeftRelease && sufficientSlots) + { + clickedAnIconOnPanel = true; + PanelIcons[i].CurrentState = ClickedIcon; + PanelIcons[i].PanelFlashTimer = 1; + + switch (ClickedIcon) + { + case IconType.Plasma: + ArmIDToSpawn = ModContent.ProjectileType(); + break; + case IconType.Tesla: + ArmIDToSpawn = ModContent.ProjectileType(); + break; + case IconType.Laser: + ArmIDToSpawn = ModContent.ProjectileType(); + break; + case IconType.Gauss: + ArmIDToSpawn = ModContent.ProjectileType(); + break; + case IconType.Inactive: + ShouldDeleteArmIndex = true; + PanelIcons[i].PanelFlashTimer = 0; + break; + } + ArmIndex = i; + } + } + + Main.EntitySpriteDraw(selectionIconTexture, selectionIconAreas[i].Center.ToVector2(), SelectionIcons[i].Frame, Projectile.GetAlpha(Color.White), 0f, area * 0.5f, Projectile.scale, 0, 0); + } Main.EntitySpriteDraw(panelTexture, drawPosition, null, Projectile.GetAlpha(Color.White), 0f, panelTexture.Size() * 0.5f, Projectile.scale, 0, 0); - Main.EntitySpriteDraw(plasmaTexture, plasmaIconArea.Center.ToVector2(), null, plasmaColor, 0f, plasmaTexture.Size() * 0.5f, Projectile.scale, 0, 0); - Main.EntitySpriteDraw(teslaTexture, teslaIconArea.Center.ToVector2(), null, teslaColor, 0f, teslaTexture.Size() * 0.5f, Projectile.scale, 0, 0); - Main.EntitySpriteDraw(laserTexture, laserIconArea.Center.ToVector2(), null, laserColor, 0f, laserTexture.Size() * 0.5f, Projectile.scale, 0, 0); - Main.EntitySpriteDraw(gaussTexture, gaussIconArea.Center.ToVector2(), null, gaussColor, 0f, gaussTexture.Size() * 0.5f, Projectile.scale, 0, 0); + + // Draw panel icons. + for (int i = 0; i < 4; i++) + { + Rectangle panelArea = selectionIconAreas[i]; + panelArea.Y += (int)(Projectile.scale * 78f); + Texture2D panelIconTexture = PanelIcons[i].IconTexture; + if (panelIconTexture is not null) + Main.EntitySpriteDraw(panelIconTexture, panelArea.Center.ToVector2(), PanelIcons[i].Frame, Projectile.GetAlpha(Color.White), 0f, area * 0.5f, Projectile.scale, 0, 0); + + SelectionIcons[i].Update(); + PanelIcons[i].Update(); + } + + // Draw an arrow at the mouse from the selected icon if one has been selected. + if (ClickedIcon != IconType.Inactive) + { + Vector2 arrowDrawPosition = selectionIconAreas[(int)ClickedIcon - 1].Center.ToVector2(); + Vector2 arrowDirection = (Main.MouseScreen - arrowDrawPosition).SafeNormalize(Vector2.UnitY); + arrowDrawPosition += arrowDirection * Projectile.scale * 24f; + + Main.EntitySpriteDraw(arrowTexture, arrowDrawPosition, null, Projectile.GetAlpha(Color.White), arrowDirection.ToRotation(), arrowTexture.Size() * 0.5f, Projectile.scale, 0, 0); + } // Tell the player if they don't have enough summon slots. if (hoveringOverAnySlot && !sufficientSlots) - { Utils.DrawBorderStringFourWay(Main.spriteBatch, FontAssets.MouseText.Value, "Insufficient minion slots!", Main.MouseScreen.X + 20f, Main.MouseScreen.Y + 12f, Color.Cyan, Color.Black, new Vector2(0f, 0.5f)); + + // Reset the clicked icon if a click is made but not to a specific icon. + if (!hoveringOverAnySlot && Main.mouseLeft && Main.mouseLeftRelease) + ClickedIcon = IconType.Inactive; + + if (hoveringOverAnySlot) + { + Main.blockMouse = true; + Main.LocalPlayer.mouseInterface = true; } + // Reset the clicked icon and handle the arm creation/deletion if an icon was clicked on the panel. + if (clickedAnIconOnPanel) + ClickedIcon = IconType.Inactive; + return false; } diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.png index 29e7ece6964ec293789cc20eaee6dc7cca210322..d0d85a8a5756eab2709d8ebcbcdc18e95d8d0442 100644 GIT binary patch delta 646 zcmV;10(t$c2B8L!rhjHhL_t(&L+zN0a)TfcMM*`Pw#onhZarL9X@aKHYMdQ&XOiJ@ zS&ptE8m=oVj4BPQ>A0vNoCdwU@xM0gQBeWyMy(BdJXCI@82i5K@*S1cb$uTrrDFQ0 zj)odSKPV-BA-rdWpgKM4z#a<~&@_mY^M5{ne4Njqayihm4u9;CP`Q~>it+O^MngqH zRXeaTmH~g3XVkpTjAF5gi&EO_vWfJoy)Ms5bJZ$9qkN*udOGzzn++2+7M#Z--9VW* z03HLsQEOIc>dVF-s!c))H8{^UY&qs&LAeECe98WxDVC`<1{tX4RGV0Iz+&`lcGJpFI(SI)@NTuP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D;fUdcFPy)ky$Ag47*T01E&B07*qoM6N<$f(W2X5C8xG diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanelCancel.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelCancel.png deleted file mode 100644 index 4f1c1d8f5e521796512f5ba0027c9368c28ffa2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 382 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU3?z3ec*FxK#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6Ax8mT7-mv;x|P8{s2;(B|(0{|Dk{( z*uMfK$64SJS3^<@Z3eOm2&4W_vI=^NFLQx znR`?6iqC2LKR>ckgg+TqTn#yEDU-0&uEW`Jm)LRHRaUmMH<-_tWa<*^trZYy|7`t7 zaLCsj9f|SrzmW>|Ps$I*b`2Mi5pOz%1tJ?Z!9ngym Mp00i_>zopr00nE0MgRZ+ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanelGauss.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelGauss.png index 4d8202f8c94f64e69bafc3a26acf5b8f3b9bcc3e..399ca0170cf36181620c359772e8b791a5945c50 100644 GIT binary patch delta 1469 zcmV;u1w#6g1KkUd77GC;2m=5B04H4{n~@#DC|Y z8t9y+>vi7aW77;YTi5HA0bDM(+jWcHifIONn%6D!e7k|5^UPa-t}90w=)x|mXgHL2 z@f=(h59D^^ji{{Px-Lr%nyM%f`we6gf6#3x_8Z9KvKZ>93Uw0r2V@Y}E6>#`aUNAEH?viUM_U2{l%MP|CLO z2BK?A1rka+(G;n|ajKAu)rqD^1#)uUyKsV{YfB!^Go5WZ_&B=Lkmh-Q+>q2Nf02V~ zpp#2LCx=D(?XA%aG<&`wnPwoTndNP?A#v(6(1l%A(Qqj5;yFkO!Dk!NG}YjEL#jiX z=r(MvRjBR4(3?jMGG*2AY(tVb4>c)hCXmMs=`eeu?KRX()AVdZQg05Ls_bz?GRs0! zPc#0AG?s^=@9*A_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5uv*RxPdi9?t{hLd)oM+a4lL}4BHScvG) zL8-&}rU7VEQi=1B4?jbw8XvR@^MMp$YNot;Kc0l^;-bvfAau0Un0HJ^U{xrZw=9tDM>>#rEh8Rsx^SH?bkz|LIUT6>Wd75~%mV5by6W+smUHdt zGGvNUJTl@IDnV-y24Xp$pCVd;Dhu<>L$ss{q|MoqXPM5P6Hp6zzKn=O6?*JxI&i%Z z(t#dXqz+#fCROOGMVPO^$1g~K!zT3Z@yH^-@O5z&u0g0rf1d_cg|Dbs9YXJyq^n>Z z2tD~gIt|I#C60%jE?lPzU3J7mP6w(zng8@Lvw++}CNo?otwI>3^rcH-K}l;+1Nw@o zpF}ul1#-bxcKtap5t(TP(g=p<4I2?$Jh>K7Zy4kkfLc<9Lu|Y$Ljm2mnZ5%B)S`Lp z9Y`q7Sd6|4Vga-%sakfV388AdD1~bwX*^0p~U7cU?kFaQ7m z|Nrm+000nb;`0Ci00?waPE-H?|NsC0{{Y^Dy;+fd7k>cYNklL2!&zL zs_*~C>+gY~lg%d5Jr_FCZ-T|z^%a{ErN|02bKj=8&$tiGSTx%s`5en_NZD+RW6Bt+ zhKSocsKRlu9h#3P;G!K^?7YKoK~l5>88gLg1D>aQHdh#Z2WI0j_ydqF70u>7m}Q2e z4_8zlb9WVrYD7u@3-wI=P93;4$aUWVjH#$QBkMtqftVIFcu}_1gE|x<3QIHP`Z+ye zp8N^bJk*nfqBQQo-&7mOz`9VBQDmyQSRaalD>GYxP&Le^yh<$HS%D<>@+3-;m+-oN Y00kTsO%{sR8~^|S07*qoM6N<$g4@cEmH+?% diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanelPlasma.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelPlasma.png index 58027096c7dbcb9e8165f7233a944551c1d7c5a5..88bf8c292a846d66f163724f9b6c6646e07a0e0c 100644 GIT binary patch delta 1398 zcmV-+1&R8R1F8#<77GC;2m=5B04H4{n~@oz zNklaNTkK|NmXSo@7Fwwb}$P_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}J)d2qZmPJD!q!ixoNKwVy^HG`Q%)FnF!isy zrp(kO&TM|d(Tw%hDv_Y80lF4$DKF)w)j8ao<@!BfqrK2boFyt=akR{09&<^ Axc~qF diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanelTesla.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelTesla.png index 64dfbae70759bb0ad641636d34a812313176b7a1..77dde33046df3c7e47ce6e02b603fb1adae8094c 100644 GIT binary patch delta 1344 zcmV-G1;6^~0^tgf77GC;2m=5B04H4{n~@$6Vxuq&1fglK?f?JqG3+YBE#xe5^H6MQ5`l0`n&o?7 ze>vcg>4?j+u5Sm{^(fcHWg)pN4-<2z%Oc@rd4K;n@cyo-4Ik!21(X!)2J=)aVrX`D z5Ope{Rz%wD{1c@$ru7wZEX-oih~gZhcujmf_S^=yO<_(*FM2%gi-C&wM5!b>5);h& zq5_OX+=z}CX}u&tirYCaYEhu(3r2?3e={YFd}T<+>;-mqpB-E{lZO zs(54seDqVTi3%twD9b$6iWr)me;q`&lT@ps^G}r4xGE|Xg=w`$6z3SlYhomoCd`LF z;*9T#39+6i^_UVd>xl|57G%0&r1g>nDQ@Sys70X`9}6eMpR1=J^4FOGWox2Trp_G* zttv{Tyz?ftx+qn$^q4!{5K)y3m^-!65rJgjkm-uobVXO)amaK;n&a=6e>=x^cSL<% z&1DgDr^_PYvj6c4k1AQWH^W z?pfi`s-jfNJ8x2}i&AL>I?%M#IwGo)0WWfDqa%Xr?l@$+;x%2-Rd*aR9r1tnF>ayI z=KAtpi%SuWQu=Tre+8k|L^Lg0ZGt0GE27GxjYR`pQbpwSDSWQMuf50dU--$T#++S7 zz#CP?S6WZJz7Xh$j$BX|Ul;C(o?pNlRm9^Lq;t4fuO3G(c#5x!YZ2B&R7ZaiT2;JK zQ>%-p<0aAN)H)(6rIL${v>?L1N{mCMD_+wTU3JGH(-Hr7e;>JpBopSTRz);QvE>Ik zl~8LUnk08-Q;uKOtD?#tHHms@l&^>y9yK7QC~s2{H6S>m;u`78a!=&8si;m!qx)i@ z_#KgCj)3t!QAZJ%!&xu(Ly>X{Iu_?d`C;hHG*wN@3SMw5iv5?Wo9 ziYz3h))7%@D!q*jPQ|H>jtIVz9fwR;yk=7T{{9Q+%EF0;YGu^`0000n(000McQchF<|NsC0{{R|G14fa47k>cCNklNR!H6w=R&W%L25^6@&F?;@nm~S0@MqC@~G4Q448l!nmto6<=bZwNiAr{s8TnuP_ zCSjr~)TkP0b}mxTH^fDph!L}7ASteMU*u6p9Sc^L*Rv(Y9)24GX--7_-#E0ah^qFU yJ44HhsL1Fs_xM1Rs-qt~{o?|y!As7j*!u?{IuiA+!nN-J0000 13.5f; - public override Vector2 OwnerRestingOffset => new(300f, 96f); + public override Vector2 OwnerRestingOffset => HoverOffsetTable[HoverOffsetIndex]; + + public override void ClampFirstLimbRotation(ref double limbRotation) => limbRotation = RotationalClampTable[HoverOffsetIndex]; - public override void ClampFirstLimbRotation(ref double limbRotation) - { - limbRotation = 0.23f; - } - public override void SetStaticDefaults() { DisplayName.SetDefault("Plasma Cannon"); diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannon.cs index b40b40398d..97f718a2e1 100644 --- a/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannon.cs +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannon.cs @@ -5,12 +5,13 @@ using Terraria.ModLoader; using Terraria.Audio; using Microsoft.Xna.Framework.Graphics; using CalamityMod.Items.Weapons.Summon; +using System.IO; namespace CalamityMod.Projectiles.Summon.SmallAresArms { public class ExoskeletonTeslaCannon : ExoskeletonCannon { - public ref float TeslaOrbIndex => ref Projectile.ai[0]; + public ref float TeslaOrbIndex => ref Projectile.localAI[0]; public override int ShootRate => AresExoskeleton.TeslaCannonShootRate; @@ -18,12 +19,9 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms public override bool UsesSuperpredictiveness => true; - public override Vector2 OwnerRestingOffset => new(-300f, 96f); + public override Vector2 OwnerRestingOffset => HoverOffsetTable[HoverOffsetIndex]; - public override void ClampFirstLimbRotation(ref double limbRotation) - { - limbRotation = MathHelper.Pi - 0.23f; - } + public override void ClampFirstLimbRotation(ref double limbRotation) => limbRotation = RotationalClampTable[HoverOffsetIndex]; public override void SetStaticDefaults() { @@ -31,6 +29,10 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms Main.projFrames[Type] = 6; } + public override void SendExtraAI(BinaryWriter writer) => writer.Write(TeslaOrbIndex); + + public override void ReceiveExtraAI(BinaryReader reader) => TeslaOrbIndex = reader.ReadSingle(); + public override void PostAI() { Projectile.frameCounter++;