diff --git a/NPCs/CeaselessVoid/DarkEnergy.cs b/NPCs/CeaselessVoid/DarkEnergy.cs index 4041be347c..03f1a95580 100644 --- a/NPCs/CeaselessVoid/DarkEnergy.cs +++ b/NPCs/CeaselessVoid/DarkEnergy.cs @@ -182,24 +182,27 @@ namespace CalamityMod.NPCs.CeaselessVoid NPC.ai[3] += minRotationVelocity + rotationVelocityIncrease; // Flash and pulse effect - if (NPC.ai[2] == 0f) + if (!NPC.dontTakeDamage) { - NPC.scale -= 0.01f; - NPC.alpha += 15; - if (NPC.alpha >= 125) + if (NPC.ai[2] == 0f) { - NPC.alpha = 130; - NPC.ai[2] = 1f; + NPC.scale -= 0.01f; + NPC.Opacity -= 0.06f; + if (NPC.Opacity <= 0.5f) + { + NPC.Opacity = 0.5f; + NPC.ai[2] = 1f; + } } - } - else - { - NPC.scale += 0.01f; - NPC.alpha -= 15; - if (NPC.alpha <= 0) + else { - NPC.alpha = 0; - NPC.ai[2] = 0f; + NPC.scale += 0.01f; + NPC.Opacity += 0.06f; + if (NPC.Opacity >= 1f) + { + NPC.Opacity = 1f; + NPC.ai[2] = 0f; + } } } } diff --git a/NPCs/ProfanedGuardians/ProfanedRocks.cs b/NPCs/ProfanedGuardians/ProfanedRocks.cs index d9c3a53f02..812dfb2e09 100644 --- a/NPCs/ProfanedGuardians/ProfanedRocks.cs +++ b/NPCs/ProfanedGuardians/ProfanedRocks.cs @@ -297,7 +297,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians drawPos += drawOrigin * NPC.scale + new Vector2(0f, NPC.gfxOffY); Rectangle frame = new Rectangle(0, 0, texture.Width, texture.Height); - NPC.DrawBackglow(Color.Orange, 4f, SpriteEffects.None, frame, screenPos); + NPC.DrawBackglow(Color.Orange, 4f, SpriteEffects.None, frame, screenPos, texture); spriteBatch.Draw(texture, drawPos, frame, NPC.GetAlpha(drawColor), NPC.rotation, drawOrigin, NPC.scale, SpriteEffects.None, 0f); diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 669e617abe..23e57d524c 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -144,113 +144,116 @@ namespace CalamityMod.Tiles Tile tile = Main.tile[i, j]; // Fruit from trees upon tree destruction - GetTreeBottom(i, j, out int treeX, out int treeY); - TreeTypes treeType = WorldGen.GetTreeType(Main.tile[treeX, treeY].TileType); - if (treeType != TreeTypes.None) + if (!effectOnly && fail && Main.netMode != NetmodeID.MultiplayerClient && TileID.Sets.IsShakeable[type]) { - treeY--; - while (treeY > 10 && Main.tile[treeX, treeY].HasTile && TileID.Sets.IsShakeable[Main.tile[treeX, treeY].TileType]) - treeY--; - - treeY++; - - if (WorldGen.IsTileALeafyTreeTop(treeX, treeY) && !Collision.SolidTiles(treeX - 2, treeX + 2, treeY - 2, treeY + 2)) + GetTreeBottom(i, j, out int treeX, out int treeY); + TreeTypes treeType = WorldGen.GetTreeType(Main.tile[treeX, treeY].TileType); + if (treeType != TreeTypes.None) { - int randomAmt = WorldGen.genRand.Next(2, 4); - for (int z = 0; z < randomAmt; z++) + treeY--; + while (treeY > 10 && Main.tile[treeX, treeY].HasTile && TileID.Sets.IsShakeable[Main.tile[treeX, treeY].TileType]) + treeY--; + + treeY++; + + if (WorldGen.IsTileALeafyTreeTop(treeX, treeY) && !Collision.SolidTiles(treeX - 2, treeX + 2, treeY - 2, treeY + 2)) { - int treeDropItemType = 0; - switch (treeType) + int randomAmt = WorldGen.genRand.Next(2, 4); + for (int z = 0; z < randomAmt; z++) { - case TreeTypes.Forest: + int treeDropItemType = 0; + switch (treeType) + { + case TreeTypes.Forest: - switch (WorldGen.genRand.Next(5)) - { - case 0: - treeDropItemType = ItemID.Apple; - break; - case 1: - treeDropItemType = ItemID.Apricot; - break; - case 2: - treeDropItemType = ItemID.Peach; - break; - case 3: - treeDropItemType = ItemID.Grapefruit; - break; - default: - treeDropItemType = ItemID.Lemon; - break; - } + switch (WorldGen.genRand.Next(5)) + { + case 0: + treeDropItemType = ItemID.Apple; + break; + case 1: + treeDropItemType = ItemID.Apricot; + break; + case 2: + treeDropItemType = ItemID.Peach; + break; + case 3: + treeDropItemType = ItemID.Grapefruit; + break; + default: + treeDropItemType = ItemID.Lemon; + break; + } - break; + break; - case TreeTypes.Snow: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Cherry : ItemID.Plum; - break; + case TreeTypes.Snow: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Cherry : ItemID.Plum; + break; - case TreeTypes.Jungle: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Mango : ItemID.Pineapple; - break; + case TreeTypes.Jungle: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Mango : ItemID.Pineapple; + break; - case TreeTypes.Palm: + case TreeTypes.Palm: - if (WorldGen.IsPalmOasisTree(treeX)) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + if (WorldGen.IsPalmOasisTree(treeX)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; - break; + break; - case TreeTypes.PalmCorrupt: + case TreeTypes.PalmCorrupt: - if (WorldGen.genRand.NextBool()) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; - else if (WorldGen.IsPalmOasisTree(treeX)) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; - else + if (WorldGen.genRand.NextBool()) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; + else if (WorldGen.IsPalmOasisTree(treeX)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + else + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; + + break; + + case TreeTypes.Corrupt: treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; + break; - break; + case TreeTypes.PalmHallowed: - case TreeTypes.Corrupt: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; - break; + if (WorldGen.genRand.NextBool()) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; + else if (WorldGen.IsPalmOasisTree(treeX)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + else + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; - case TreeTypes.PalmHallowed: + break; - if (WorldGen.genRand.NextBool()) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; - else if (WorldGen.IsPalmOasisTree(treeX)) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; - else + case TreeTypes.Hallowed: treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; + break; - break; + case TreeTypes.PalmCrimson: - case TreeTypes.Hallowed: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; - break; + if (WorldGen.genRand.NextBool()) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; + else if (WorldGen.IsPalmOasisTree(treeX)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + else + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; - case TreeTypes.PalmCrimson: + break; - if (WorldGen.genRand.NextBool()) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; - else if (WorldGen.IsPalmOasisTree(treeX)) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; - else + case TreeTypes.Crimson: treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; + break; - break; + default: + break; + } - case TreeTypes.Crimson: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; - break; - - default: - break; + if (treeDropItemType != 0) + Item.NewItem(new EntitySource_TileBreak(treeX, treeY), treeX * 16, treeY * 16, 16, 16, treeDropItemType); } - - if (treeDropItemType != 0) - Item.NewItem(new EntitySource_TileBreak(treeX, treeY), treeX * 16, treeY * 16, 16, 16, treeDropItemType); } } } diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index d409cab4f6..8e0facbb62 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -422,9 +422,9 @@ namespace CalamityMod return null; } - public static void DrawBackglow(this NPC npc, Color backglowColor, float backglowArea, SpriteEffects spriteEffects, Rectangle frame, Vector2 screenPos) + public static void DrawBackglow(this NPC npc, Color backglowColor, float backglowArea, SpriteEffects spriteEffects, Rectangle frame, Vector2 screenPos, Texture2D overrideTexture = null) { - Texture2D texture = TextureAssets.Npc[npc.type].Value; + Texture2D texture = overrideTexture is null ? TextureAssets.Npc[npc.type].Value : overrideTexture; Vector2 drawPosition = npc.Center - screenPos; Vector2 origin = frame.Size() * 0.5f; Color backAfterimageColor = backglowColor * npc.Opacity;