Some of the projectile iterators
This commit is contained in:
1 parent
1a85f860e9
commit
e2c261e69e
19 files changed
+115
-119
No files matched your search
@@ -4715,23 +4715,23 @@ namespace CalamityMod.CalPlayer
|
||||
if (Player.whoAmI == Main.myPlayer && !endoCooper && randAmt > 0 && Main.rand.NextBool(randAmt) && chaseable)
|
||||
{
|
||||
int spearsFired = 0;
|
||||
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (spearsFired == 2)
|
||||
break;
|
||||
if (Main.projectile[i].owner == Player.whoAmI && Main.projectile[i].friendly)
|
||||
if (p.owner == Player.whoAmI && p.friendly)
|
||||
{
|
||||
bool attack = Main.projectile[i].owner == Player.whoAmI && Main.projectile[i].type == ModContent.ProjectileType<MiniGuardianAttack>();
|
||||
bool attack = p.type == ModContent.ProjectileType<MiniGuardianAttack>();
|
||||
if (attack)
|
||||
{
|
||||
int numSpears = profanedCrystalBuffs ? 12 : 6;
|
||||
int dam = (int)(Main.projectile[i].originalDamage * (profanedCrystalBuffs ? 1f : 0.25f));
|
||||
int dam = (int)(p.originalDamage * (profanedCrystalBuffs ? 1f : 0.25f));
|
||||
|
||||
for (int x = 0; x < numSpears; x++)
|
||||
{
|
||||
float angle = MathHelper.TwoPi / numSpears * x;
|
||||
int proj = Projectile.NewProjectile(source, Main.projectile[i].Center, angle.ToRotationVector2().RotatedBy(Math.Atan(-45f)) * 8f, ModContent.ProjectileType<MiniGuardianSpear>(), dam, 0f, Player.whoAmI, pscState, 0f);
|
||||
int proj = Projectile.NewProjectile(source, p.Center, angle.ToRotationVector2().RotatedBy(Math.Atan(-45f)) * 8f, ModContent.ProjectileType<MiniGuardianSpear>(), dam, 0f, Player.whoAmI, pscState, 0f);
|
||||
Main.projectile[proj].originalDamage = dam;
|
||||
}
|
||||
spearsFired++;
|
||||
|
||||
@@ -2307,11 +2307,11 @@ namespace CalamityMod.CalPlayer
|
||||
|
||||
if (Player.ownedProjectileCounts[ModContent.ProjectileType<DrataliornusBow>()] != 0)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach(Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType<DrataliornusBow>() && Main.projectile[i].owner == Player.whoAmI)
|
||||
if (p.type == ModContent.ProjectileType<DrataliornusBow>() && p.owner == Player.whoAmI)
|
||||
{
|
||||
Main.projectile[i].Kill();
|
||||
p.Kill();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,12 +858,12 @@ namespace CalamityMod.CalPlayer
|
||||
{
|
||||
int bullseyeType = ModContent.ProjectileType<SpiritOriginBullseye>();
|
||||
List<int> alreadyTargetedNPCs = new List<int>();
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].type != bullseyeType || !Main.projectile[i].active || Main.projectile[i].owner != Player.whoAmI)
|
||||
if (p.type != bullseyeType || p.owner != Player.whoAmI)
|
||||
continue;
|
||||
|
||||
alreadyTargetedNPCs.Add((int)Main.projectile[i].ai[0]);
|
||||
alreadyTargetedNPCs.Add((int)p.ai[0]);
|
||||
}
|
||||
|
||||
foreach (NPC target in Main.ActiveNPCs)
|
||||
@@ -1131,10 +1131,9 @@ namespace CalamityMod.CalPlayer
|
||||
if (Player.ownedProjectileCounts[ModContent.ProjectileType<OmegaBlueTentacle>()] < 6 && Main.myPlayer == Player.whoAmI)
|
||||
{
|
||||
bool[] tentaclesPresent = new bool[6];
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile projectile in Main.ActiveProjectiles)
|
||||
{
|
||||
Projectile projectile = Main.projectile[i];
|
||||
if (projectile.active && projectile.type == ModContent.ProjectileType<OmegaBlueTentacle>() && projectile.owner == Main.myPlayer && projectile.ai[1] >= 0f && projectile.ai[1] < 6f)
|
||||
if (projectile.type == ModContent.ProjectileType<OmegaBlueTentacle>() && projectile.owner == Main.myPlayer && projectile.ai[1] >= 0f && projectile.ai[1] < 6f)
|
||||
tentaclesPresent[(int)projectile.ai[1]] = true;
|
||||
}
|
||||
|
||||
@@ -3347,11 +3346,11 @@ namespace CalamityMod.CalPlayer
|
||||
{
|
||||
if (Player.whoAmI == Main.myPlayer)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType<BlunderBoosterAura>() && Main.projectile[i].owner == Player.whoAmI)
|
||||
if (p.type == ModContent.ProjectileType<BlunderBoosterAura>() && p.owner == Player.whoAmI)
|
||||
{
|
||||
Main.projectile[i].Kill();
|
||||
p.Kill();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3383,12 +3382,12 @@ namespace CalamityMod.CalPlayer
|
||||
if (Player.whoAmI == Main.myPlayer)
|
||||
{
|
||||
int auraType = ModContent.ProjectileType<TeslaAura>();
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].type != auraType || !Main.projectile[i].active || Main.projectile[i].owner != Player.whoAmI)
|
||||
if (p.type != auraType || p.owner != Player.whoAmI)
|
||||
continue;
|
||||
|
||||
Main.projectile[i].Kill();
|
||||
p.Kill();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3406,12 +3405,12 @@ namespace CalamityMod.CalPlayer
|
||||
else if (Player.whoAmI == Main.myPlayer)
|
||||
{
|
||||
int shieldType = ModContent.ProjectileType<CryonicShield>();
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].type != shieldType || !Main.projectile[i].active || Main.projectile[i].owner != Player.whoAmI)
|
||||
if (p.type != shieldType || p.owner != Player.whoAmI)
|
||||
continue;
|
||||
|
||||
Main.projectile[i].Kill();
|
||||
p.Kill();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace CalamityMod.CalPlayer.DrawLayers
|
||||
|
||||
int robot = -1;
|
||||
int andromedaMechID = ModContent.ProjectileType<GiantIbanRobotOfDoom>();
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == andromedaMechID && Main.projectile[i].owner == drawPlayer.whoAmI)
|
||||
if (p.type == andromedaMechID && p.owner == drawPlayer.whoAmI)
|
||||
{
|
||||
robot = i;
|
||||
break;
|
||||
|
||||
@@ -65,12 +65,10 @@ namespace CalamityMod.Graphics.Primitives
|
||||
var afterProjectiles = new List<IPixelatedPrimitiveRenderer>();
|
||||
|
||||
// Check every active projectile.
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile projectile in Main.ActiveProjectiles)
|
||||
{
|
||||
var projectile = Main.projectile[i];
|
||||
|
||||
// If the projectile is active, a mod projectile, and uses the interface, add it to the list of primitives to draw this frame.
|
||||
if (projectile.active && projectile.ModProjectile != null && projectile.ModProjectile is IPixelatedPrimitiveRenderer pixelPrimitiveProjectile)
|
||||
if (projectile.ModProjectile != null && projectile.ModProjectile is IPixelatedPrimitiveRenderer pixelPrimitiveProjectile)
|
||||
{
|
||||
var listToUse = pixelPrimitiveProjectile.LayerToRenderTo switch
|
||||
{
|
||||
|
||||
@@ -724,12 +724,9 @@ namespace CalamityMod.ILEditing
|
||||
Main.spriteBatch.SetBlendState(BlendState.Additive);
|
||||
|
||||
// Draw Projectiles.
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (!Main.projectile[i].active)
|
||||
continue;
|
||||
|
||||
if (Main.projectile[i].ModProjectile is IAdditiveDrawer d)
|
||||
if (p.ModProjectile is IAdditiveDrawer d)
|
||||
d.AdditiveDraw(Main.spriteBatch);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace CalamityMod.Items.Accessories
|
||||
if (Main.rand.NextBool(15))
|
||||
{
|
||||
int numProj = 0;
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].type == ModContent.ProjectileType<NebulaStar>())
|
||||
if (p.owner == player.whoAmI && p.type == ModContent.ProjectileType<NebulaStar>())
|
||||
{
|
||||
numProj++;
|
||||
}
|
||||
|
||||
@@ -361,10 +361,9 @@ namespace CalamityMod.Items.Accessories
|
||||
if (bestGrapplePos != Point.Zero)
|
||||
{
|
||||
//Clear any hooks that might have been flying before then.
|
||||
for (int i = 0; i < Main.maxProjectiles; ++i)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
Projectile p = Main.projectile[i];
|
||||
if (!p.active || p.owner != Player.whoAmI || p.type != ProjectileType<WulfrumHook>())
|
||||
if (p.owner != Player.whoAmI || p.type != ProjectileType<WulfrumHook>())
|
||||
continue;
|
||||
|
||||
if (p.ModProjectile is WulfrumHook)
|
||||
@@ -412,10 +411,9 @@ namespace CalamityMod.Items.Accessories
|
||||
if (triggersSet.Grapple && Player.releaseHook)
|
||||
{
|
||||
//Clear any previous non-wulfrum hooks / Any hooks that just got shot (should already be handled by the global proj
|
||||
for (int i = 0; i < Main.maxProjectiles; ++i)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
Projectile p = Main.projectile[i];
|
||||
if (!p.active || p.owner != Player.whoAmI || p.aiStyle != 7 || p.type == ProjectileType<WulfrumHook>())
|
||||
if (p.owner != Player.whoAmI || p.aiStyle != 7 || p.type == ProjectileType<WulfrumHook>())
|
||||
continue;
|
||||
|
||||
p.Kill();
|
||||
@@ -443,10 +441,9 @@ namespace CalamityMod.Items.Accessories
|
||||
//Jumping out of the hook
|
||||
if (triggersSet.Jump && Player.releaseJump)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; ++i)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
Projectile p = Main.projectile[i];
|
||||
if (!p.active || p.owner != Player.whoAmI || p.type != ProjectileType<WulfrumHook>())
|
||||
if (p.owner != Player.whoAmI || p.type != ProjectileType<WulfrumHook>())
|
||||
continue;
|
||||
|
||||
//Only clear hooks that are attached to stuff
|
||||
|
||||
+25
-25
@@ -531,11 +531,11 @@ namespace CalamityMod.Items
|
||||
}
|
||||
if (item.type == ItemID.PearlwoodBow)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].active && (Main.projectile[i].type == ModContent.ProjectileType<RainbowFront>() || Main.projectile[i].type == ModContent.ProjectileType<RainbowTrail>()) && Main.projectile[i].owner == player.whoAmI)
|
||||
if ((p.type == ModContent.ProjectileType<RainbowFront>() || p.type == ModContent.ProjectileType<RainbowTrail>()) && p.owner == player.whoAmI)
|
||||
{
|
||||
Main.projectile[i].Kill();
|
||||
p.Kill();
|
||||
}
|
||||
}
|
||||
for (int i = -8; i <= 8; i += 8)
|
||||
@@ -674,9 +674,9 @@ namespace CalamityMod.Items
|
||||
if (player.ActiveItem().type == ModContent.ItemType<IgneousExaltation>())
|
||||
{
|
||||
bool hasBlades = false;
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType<IgneousBlade>() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f)
|
||||
if (p.type == ModContent.ProjectileType<IgneousBlade>() && p.owner == player.whoAmI && p.localAI[1] == 0f)
|
||||
{
|
||||
hasBlades = true;
|
||||
break;
|
||||
@@ -684,22 +684,22 @@ namespace CalamityMod.Items
|
||||
}
|
||||
if (hasBlades)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].ModProjectile is IgneousBlade)
|
||||
if (p.ModProjectile is IgneousBlade)
|
||||
{
|
||||
if (Main.projectile[i].ModProjectile<IgneousBlade>().Firing)
|
||||
if (p.ModProjectile<IgneousBlade>().Firing)
|
||||
continue;
|
||||
}
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType<IgneousBlade>() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f)
|
||||
if (p.type == ModContent.ProjectileType<IgneousBlade>() && p.owner == player.whoAmI && p.localAI[1] == 0f)
|
||||
{
|
||||
Main.projectile[i].rotation = MathHelper.PiOver2 + MathHelper.PiOver4;
|
||||
Main.projectile[i].velocity = Main.projectile[i].SafeDirectionTo(Main.MouseWorld, Vector2.UnitY) * 22f;
|
||||
Main.projectile[i].rotation += Main.projectile[i].velocity.ToRotation();
|
||||
Main.projectile[i].ai[0] = 180f;
|
||||
Main.projectile[i].ModProjectile<IgneousBlade>().Firing = true;
|
||||
Main.projectile[i].tileCollide = true;
|
||||
Main.projectile[i].netUpdate = true;
|
||||
p.rotation = MathHelper.PiOver2 + MathHelper.PiOver4;
|
||||
p.velocity = p.SafeDirectionTo(Main.MouseWorld, Vector2.UnitY) * 22f;
|
||||
p.rotation += p.velocity.ToRotation();
|
||||
p.ai[0] = 180f;
|
||||
p.ModProjectile<IgneousBlade>().Firing = true;
|
||||
p.tileCollide = true;
|
||||
p.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -707,13 +707,13 @@ namespace CalamityMod.Items
|
||||
}
|
||||
if (player.ActiveItem().type == ModContent.ItemType<VoidConcentrationStaff>() && player.ownedProjectileCounts[ModContent.ProjectileType<VoidConcentrationBlackhole>()] == 0)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].ModProjectile is VoidConcentrationAura)
|
||||
if (p.ModProjectile is VoidConcentrationAura)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI)
|
||||
if (p.owner == player.whoAmI)
|
||||
{
|
||||
Main.projectile[i].ModProjectile<VoidConcentrationAura>().HandleRightClick();
|
||||
p.ModProjectile<VoidConcentrationAura>().HandleRightClick();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -724,18 +724,18 @@ namespace CalamityMod.Items
|
||||
{
|
||||
bool canContinue = true;
|
||||
int count = 0;
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType<GlacialEmbracePointyThing>() && Main.projectile[i].owner == player.whoAmI)
|
||||
if (p.type == ModContent.ProjectileType<GlacialEmbracePointyThing>() && p.owner == player.whoAmI)
|
||||
{
|
||||
if (Main.projectile[i].ai[1] > 1f)
|
||||
if (p.ai[1] > 1f)
|
||||
{
|
||||
canContinue = false;
|
||||
break;
|
||||
}
|
||||
else if (Main.projectile[i].ai[1] == 0f)
|
||||
else if (p.ai[1] == 0f)
|
||||
{
|
||||
if (((GlacialEmbracePointyThing)Main.projectile[i].ModProjectile).circlingPlayer)
|
||||
if (((GlacialEmbracePointyThing)p.ModProjectile).circlingPlayer)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +53,9 @@ namespace CalamityMod.Items.Tools
|
||||
{
|
||||
bool explodedAny = false;
|
||||
|
||||
for (int i = 0; i < Main.maxProjectiles; ++i)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
Projectile p = Main.projectile[i];
|
||||
if (!p.active || p.owner != player.whoAmI || p.type != Item.shoot)
|
||||
if (p.owner != player.whoAmI || p.type != Item.shoot)
|
||||
continue;
|
||||
|
||||
p.ai[1] = 1f;
|
||||
|
||||
@@ -56,9 +56,9 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal
|
||||
|
||||
float magnetCount = 0f;
|
||||
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI)
|
||||
if (p.type == type && p.owner == player.whoAmI)
|
||||
{
|
||||
magnetCount++;
|
||||
}
|
||||
@@ -67,12 +67,12 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal
|
||||
// Adjust the offset of all existing magnets such that they form a psuedo-circle.
|
||||
// This offset is used when determining where a magnet should move to relative to its true destination (such as the player or an enemy).
|
||||
int magnetIndex = 0;
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI)
|
||||
if (p.type == type && p.owner == player.whoAmI)
|
||||
{
|
||||
((PoleWarperSummon)Main.projectile[i].ModProjectile).Time = 0f;
|
||||
((PoleWarperSummon)Main.projectile[i].ModProjectile).AngularOffset = MathHelper.TwoPi * magnetIndex / magnetCount;
|
||||
((PoleWarperSummon)p.ModProjectile).Time = 0f;
|
||||
((PoleWarperSummon)p.ModProjectile).AngularOffset = MathHelper.TwoPi * magnetIndex / magnetCount;
|
||||
magnetIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,12 +35,12 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
public override bool CanUseItem(Player player)
|
||||
{
|
||||
int bladeProjID = ModContent.ProjectileType<BladecrestOathswordProj>();
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].type != bladeProjID || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI)
|
||||
if (p.type != bladeProjID || p.owner != player.whoAmI)
|
||||
continue;
|
||||
|
||||
return Main.projectile[i].ModProjectile<BladecrestOathswordProj>().PostSwingRepositionDelay <= 0f;
|
||||
return p.ModProjectile<BladecrestOathswordProj>().PostSwingRepositionDelay <= 0f;
|
||||
}
|
||||
|
||||
return base.CanUseItem(player);
|
||||
|
||||
@@ -100,15 +100,24 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
float state = 0;
|
||||
|
||||
//If there are any exoblades in "stasis" after a bonk, the attack should be an empowered slash instead
|
||||
if (Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ProjectileType<ExobladeProj>() && n.ai[0] == 1 && n.ai[1] == 1 && n.timeLeft > LungeCooldown))
|
||||
bool empoweredSlash = false;
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (p.owner == player.whoAmI && p.type == Item.shoot && p.ai[0] == 1 && p.ai[1] == 1 && p.timeLeft > LungeCooldown)
|
||||
{
|
||||
empoweredSlash = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empoweredSlash)
|
||||
{
|
||||
state = 2;
|
||||
|
||||
//Put all the "post bonk" stasised exoblades into regular cooldown for the right click ljunge
|
||||
for (int i = 0; i < Main.maxProjectiles; ++i)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
Projectile p = Main.projectile[i];
|
||||
if (!p.active || p.owner != player.whoAmI || p.type != Item.shoot || p.ai[0] != 1 || p.ai[1] != 1)
|
||||
if (p.owner != player.whoAmI || p.type != Item.shoot || p.ai[0] != 1 || p.ai[1] != 1)
|
||||
continue;
|
||||
|
||||
p.timeLeft = LungeCooldown;
|
||||
|
||||
@@ -66,10 +66,9 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
|
||||
private void DetonateRockets(Player player)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; ++i)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
Projectile p = Main.projectile[i];
|
||||
if (!p.active || p.owner != player.whoAmI || p.type != Item.shoot)
|
||||
if (p.owner != player.whoAmI || p.type != Item.shoot)
|
||||
continue;
|
||||
|
||||
// All rockets will instantly explode on the next frame and send packets to indicate as such.
|
||||
|
||||
@@ -68,11 +68,11 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
}
|
||||
else if (player.ActiveItem().type != Item.type || player.dead || !player.active)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
//Destroy all heads
|
||||
if (Main.projectile[i].type == HeadID && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].active)
|
||||
Main.projectile[i].Kill();
|
||||
if (p.type == HeadID && p.owner == player.whoAmI)
|
||||
p.Kill();
|
||||
}
|
||||
HeadSpawnTimer = 0;
|
||||
}
|
||||
@@ -111,11 +111,11 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
Projectile.NewProjectile(source, newPos, spreadVelocity * spreadDirection, Item.shoot, damage, knockback, player.whoAmI);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
//Force all heads to shoot
|
||||
if (Main.projectile[i].type == HeadID && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].active)
|
||||
Main.projectile[i].ai[1] = 1f;
|
||||
if (p.type == HeadID && p.owner == player.whoAmI)
|
||||
p.ai[1] = 1f;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -32,10 +32,9 @@ namespace CalamityMod.Items.Weapons.Rogue
|
||||
|
||||
public override bool AltFunctionUse(Player player)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
Projectile p = Main.projectile[i];
|
||||
if (p.type == ModContent.ProjectileType<NychthemeronProjectile>() && p.owner == player.whoAmI)
|
||||
if (p.type == Item.shoot && p.owner == player.whoAmI)
|
||||
{
|
||||
p.ai[0] = 1f;
|
||||
}
|
||||
@@ -93,12 +92,11 @@ namespace CalamityMod.Items.Weapons.Rogue
|
||||
|
||||
// Ideally new projectiles will fill in the most recently vacated spots in the pattern
|
||||
int[] activeSlots = new int[10] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile proj in Main.ActiveProjectiles)
|
||||
{
|
||||
Projectile proj = Main.projectile[i];
|
||||
if (proj.type == ModContent.ProjectileType<NychthemeronOrb>() && proj.owner == player.whoAmI && proj.active && proj.localAI[0] == 0f && activeSlots[(int)proj.localAI[1]] == -1)
|
||||
if (proj.type == ModContent.ProjectileType<NychthemeronOrb>() && proj.owner == player.whoAmI && proj.localAI[0] == 0f && activeSlots[(int)proj.localAI[1]] == -1)
|
||||
{
|
||||
activeSlots[(int)proj.localAI[1]] = i;
|
||||
activeSlots[(int)proj.localAI[1]] = proj.whoAmI;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,18 +39,18 @@ namespace CalamityMod.Items.Weapons.Rogue
|
||||
{
|
||||
if (player.altFunctionUse == 2)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].type != type || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI)
|
||||
if (p.type != type || p.owner != player.whoAmI)
|
||||
continue;
|
||||
|
||||
if (Main.projectile[i].ai[0] != 1f)
|
||||
if (p.ai[0] != 1f)
|
||||
continue;
|
||||
|
||||
NPC attachedNPC = Main.npc[(int)Main.projectile[i].ai[1]];
|
||||
Main.projectile[i].ai[0] = 2f;
|
||||
Main.projectile[i].ModProjectile<SacrificeProjectile>().AbleToHealOwner = attachedNPC.type != NPCID.TargetDummy && attachedNPC.type != ModContent.NPCType<SuperDummyNPC>();
|
||||
Main.projectile[i].netUpdate = true;
|
||||
NPC attachedNPC = Main.npc[(int)p.ai[1]];
|
||||
p.ai[0] = 2f;
|
||||
p.ModProjectile<SacrificeProjectile>().AbleToHealOwner = attachedNPC.type != NPCID.TargetDummy && attachedNPC.type != ModContent.NPCType<SuperDummyNPC>();
|
||||
p.netUpdate = true;
|
||||
}
|
||||
//TODO: Add something here to avoid stealth being consumed
|
||||
return false;
|
||||
|
||||
@@ -113,13 +113,13 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
// If the player owns a panel, make it fade away.
|
||||
if (player.ownedProjectileCounts[panelID] >= 1)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].type != panelID || Main.projectile[i].owner != player.whoAmI || !Main.projectile[i].active)
|
||||
if (p.type != panelID || p.owner != player.whoAmI)
|
||||
continue;
|
||||
|
||||
Main.projectile[i].ai[0] = 1f;
|
||||
Main.projectile[i].netUpdate = true;
|
||||
p.ai[0] = 1f;
|
||||
p.netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,13 +53,13 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
Item.noUseGraphic = true;
|
||||
}
|
||||
int bladeIndex = 0;
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI)
|
||||
if (p.type == type && p.owner == player.whoAmI)
|
||||
{
|
||||
Main.projectile[i].ModProjectile<BrittleStarMinion>().StarIndex = bladeIndex++;
|
||||
Main.projectile[i].ModProjectile<BrittleStarMinion>().AITimer = 0f;
|
||||
Main.projectile[i].netUpdate = true;
|
||||
p.ModProjectile<BrittleStarMinion>().StarIndex = bladeIndex++;
|
||||
p.ModProjectile<BrittleStarMinion>().AITimer = 0f;
|
||||
p.netUpdate = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user