golf balls now get launched by auric ore/repulsers

This commit is contained in:
GinYuH authored and Cameron Ewell committed 2024-03-05 00:07:34 -05:00
1 parent 75304f170f
commit 92de2f38d3
1 file changed
+70 -1
+70 -1
View File
@@ -11,7 +11,6 @@ using CalamityMod.Items.Accessories;
using CalamityMod.Items.Potions.Alcohol;
using CalamityMod.NPCs;
using CalamityMod.Particles;
using CalamityMod.Projectiles;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Melee;
using CalamityMod.Projectiles.Ranged;
@@ -19,6 +18,8 @@ using CalamityMod.Projectiles.Rogue;
using CalamityMod.Projectiles.Summon;
using CalamityMod.Projectiles.Typeless;
using CalamityMod.Projectiles.VanillaProjectileOverrides;
using CalamityMod.Tiles.FurnitureAuric;
using CalamityMod.Tiles.Ores;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -2855,6 +2856,74 @@ namespace CalamityMod.Projectiles
projectile.velocity *= ((Main.masterMode || BossRushEvent.BossRushActive) ? 1.017078f : 1.015525f);
}
// Golf Balls go nyoom on touching Auric Ore/Repulsers
if (ProjectileID.Sets.IsAGolfBall[projectile.type])
{
int auricOreID = TileType<AuricOre>();
int auricRepulserID = TileType<AuricRepulserPanelTile>();
// Get a list of tiles that are colliding with the ball.
// This is just Collision.GetEntityTiles but with a larger detection square because golf balls are too small and dumb to get detected half the time apparently
List<Point> EdgeTiles = new List<Point>();
int extraDist = 8;
int left = (int)projectile.position.X - extraDist;
int up = (int)projectile.position.Y - extraDist;
int right = (int)projectile.Right.X + extraDist;
int down = (int)projectile.Bottom.Y + extraDist;
if (left % 16 == 0)
{
left--;
}
if (up % 16 == 0)
{
up--;
}
if (right % 16 == 0)
{
right++;
}
if (down % 16 == 0)
{
down++;
}
int width = right / 16 - left / 16;
int height = down / 16 - up / 16;
left /= 16;
up /= 16;
for (int i = left; i <= left + width; i++)
{
EdgeTiles.Add(new Point(i, up));
EdgeTiles.Add(new Point(i, up + height));
}
for (int j = up; j < up + height; j++)
{
EdgeTiles.Add(new Point(left, j));
EdgeTiles.Add(new Point(left + width, j));
}
foreach (Point touchedTile in EdgeTiles)
{
Tile tile = Framing.GetTileSafely(touchedTile);
if (!tile.HasTile || !tile.HasUnactuatedTile)
continue;
if (tile.TileType == auricOreID || tile.TileType == auricRepulserID)
{
// Force Auric Ore to animate with its crackling electricity
if (tile.TileType == auricOreID)
{
AuricOre.Animate = true;
}
var yeetVec = Vector2.Normalize(projectile.Center - touchedTile.ToWorldCoordinates());
projectile.velocity += yeetVec * 40f;
SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/ExoMechs/TeslaShoot1") with { Pitch = 0.4f });
}
}
}
if (projectile.type == ProjectileID.OrnamentFriendly && lineColor == 1) //spawned by Festive Wings
{
Vector2 center = projectile.Center;