From 87e9d5b2f5e6c4e64d455e7cf97913edae0d0203 Mon Sep 17 00:00:00 2001
From: DominicKarma <51094361+DominicKarma@users.noreply.github.com>
Date: Wed, 10 Nov 2021 20:08:36 -0600
Subject: [PATCH] Fixed Ares arms in the deathray phase
---
NPCs/ExoMechs/Ares/AresBody.cs | 27 +++++++++++++++++++++++----
Utilities/MiscUtils.cs | 17 +++++++++++++++++
2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs
index a115ce83bb..c052bbe542 100644
--- a/NPCs/ExoMechs/Ares/AresBody.cs
+++ b/NPCs/ExoMechs/Ares/AresBody.cs
@@ -835,14 +835,33 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
Color armGlowmaskColor = afterimageBaseColor;
armGlowmaskColor.A = 184;
+ (int, bool)[] armProperties = new (int, bool)[]
+ {
+ // Laser arm.
+ (-1, true),
+
+ // Gauss arm.
+ (1, true),
+
+ // Telsa arm.
+ (-1, false),
+
+ // Plasma arm.
+ (1, false),
+ };
+
+ // Swap out arm positions as necessary.
+ if (AIState == (int)Phase.Deathrays)
+ CalamityUtils.SwapArrayIndices(ref armProperties, 1, 3);
+
if (laserArm != -1)
- DrawArm(spriteBatch, Main.npc[laserArm].Center, armGlowmaskColor, -1, true);
+ DrawArm(spriteBatch, Main.npc[laserArm].Center, armGlowmaskColor, armProperties[0].Item1, armProperties[0].Item2);
if (gaussArm != -1)
- DrawArm(spriteBatch, Main.npc[gaussArm].Center, armGlowmaskColor, 1, true);
+ DrawArm(spriteBatch, Main.npc[gaussArm].Center, armGlowmaskColor, armProperties[1].Item1, armProperties[1].Item2);
if (teslaArm != -1)
- DrawArm(spriteBatch, Main.npc[teslaArm].Center, armGlowmaskColor, -1, false);
+ DrawArm(spriteBatch, Main.npc[teslaArm].Center, armGlowmaskColor, armProperties[2].Item1, armProperties[2].Item2);
if (plasmaArm != -1)
- DrawArm(spriteBatch, Main.npc[plasmaArm].Center, armGlowmaskColor, 1, false);
+ DrawArm(spriteBatch, Main.npc[plasmaArm].Center, armGlowmaskColor, armProperties[3].Item1, armProperties[3].Item2);
Texture2D texture = Main.npcTexture[npc.type];
Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height);
diff --git a/Utilities/MiscUtils.cs b/Utilities/MiscUtils.cs
index 0970db23c4..5ced6652fa 100644
--- a/Utilities/MiscUtils.cs
+++ b/Utilities/MiscUtils.cs
@@ -29,6 +29,23 @@ namespace CalamityMod
NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), textColor.Value);
}
+ // Yes, this method has a use that Utils.Swap does not; You cannot use refs on array indices.
+ // The CLR will not allow that. As such, a custom method must be used to achieve this.
+
+ ///
+ /// Swaps two array indices based on a temporary variable.
+ ///
+ /// The type of the array.
+ /// The array.
+ /// The first index to swap.
+ /// The second index to swap.
+ public static void SwapArrayIndices(ref T[] array, int index1, int index2)
+ {
+ T temp = array[index1];
+ array[index1] = array[index2];
+ array[index2] = temp;
+ }
+
public static T[] ShuffleArray(T[] array, Random rand = null)
{
if (rand is null)