From 92de2f38d30d6f96b45eb7fd188b1a0f16d2d52d Mon Sep 17 00:00:00 2001 From: GinYuH <72181395+GinYuH@users.noreply.github.com> Date: Sun, 3 Mar 2024 01:32:37 -0800 Subject: [PATCH] golf balls now get launched by auric ore/repulsers --- Projectiles/CalamityGlobalProjectile.cs | 71 ++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 7a872d34c5..019c90b34e 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -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(); + int auricRepulserID = TileType(); + // 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 EdgeTiles = new List(); + 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;