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 1/2] 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; From 975cc5d05f653ac385b2d1c1d52a667518050257 Mon Sep 17 00:00:00 2001 From: GinYuH <72181395+GinYuH@users.noreply.github.com> Date: Sun, 3 Mar 2024 19:35:30 -0800 Subject: [PATCH 2/2] a few more Calamity blocks now have golf properties --- Tiles/Abyss/PlantyMush.cs | 2 ++ Tiles/Abyss/SulphurousSand.cs | 2 ++ Tiles/Abyss/ViperVines.cs | 3 ++- Tiles/Astral/NovaeSlag.cs | 2 ++ Tiles/FurnitureStatigel/StatigelBlock.cs | 2 ++ Tiles/GiantPlanteraBulb.cs | 3 +++ Tiles/SunkenSea/EutrophicSand.cs | 2 ++ Tiles/UelibloomBrick.cs | 2 ++ Tiles/VernalSoil.cs | 2 ++ 9 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Tiles/Abyss/PlantyMush.cs b/Tiles/Abyss/PlantyMush.cs index 6ba73b5bae..bb9c985a8a 100644 --- a/Tiles/Abyss/PlantyMush.cs +++ b/Tiles/Abyss/PlantyMush.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -25,6 +26,7 @@ namespace CalamityMod.Tiles.Abyss Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = true; Main.tileBlockLight[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Organic"]); CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithAbyss(Type); diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index f8732559ea..6fb2c179e3 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; @@ -25,6 +26,7 @@ namespace CalamityMod.Tiles.Abyss { Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Sand"]); CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithAbyss(Type); diff --git a/Tiles/Abyss/ViperVines.cs b/Tiles/Abyss/ViperVines.cs index d714aaedb5..3e26bd5505 100644 --- a/Tiles/Abyss/ViperVines.cs +++ b/Tiles/Abyss/ViperVines.cs @@ -1,8 +1,8 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Metadata; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss @@ -15,6 +15,7 @@ namespace CalamityMod.Tiles.Abyss Main.tileBlockLight[Type] = true; Main.tileLavaDeath[Type] = true; Main.tileNoFail[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Plant"]); AddMapEntry(new Color(0, 50, 0)); HitSound = SoundID.Grass; DustType = 2; diff --git a/Tiles/Astral/NovaeSlag.cs b/Tiles/Astral/NovaeSlag.cs index 01539703e5..51265047de 100644 --- a/Tiles/Astral/NovaeSlag.cs +++ b/Tiles/Astral/NovaeSlag.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -18,6 +19,7 @@ namespace CalamityMod.Tiles.Astral { Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Sand"]); CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeAstralTiles(Type); diff --git a/Tiles/FurnitureStatigel/StatigelBlock.cs b/Tiles/FurnitureStatigel/StatigelBlock.cs index 2764c90c12..29b9d1714f 100644 --- a/Tiles/FurnitureStatigel/StatigelBlock.cs +++ b/Tiles/FurnitureStatigel/StatigelBlock.cs @@ -1,6 +1,7 @@  using Microsoft.Xna.Framework; using Terraria; +using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; @@ -13,6 +14,7 @@ namespace CalamityMod.Tiles.FurnitureStatigel Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = true; Main.tileBlockLight[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["PinkSlime"]); CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeDecorativeTiles(Type); diff --git a/Tiles/GiantPlanteraBulb.cs b/Tiles/GiantPlanteraBulb.cs index c87d3d0ef4..4ab0491284 100644 --- a/Tiles/GiantPlanteraBulb.cs +++ b/Tiles/GiantPlanteraBulb.cs @@ -6,6 +6,7 @@ using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -31,6 +32,8 @@ namespace CalamityMod.Tiles Main.tileFrameImportant[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Plant"]); + // Various data sets to protect this tile from premature death TileID.Sets.PreventsTileRemovalIfOnTopOfIt[Type] = true; TileID.Sets.PreventsTileReplaceIfOnTopOfIt[Type] = true; diff --git a/Tiles/SunkenSea/EutrophicSand.cs b/Tiles/SunkenSea/EutrophicSand.cs index 0a58e326ce..9956357a86 100644 --- a/Tiles/SunkenSea/EutrophicSand.cs +++ b/Tiles/SunkenSea/EutrophicSand.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -18,6 +19,7 @@ namespace CalamityMod.Tiles.SunkenSea { Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Sand"]); CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); // Tile blends with sandstone, which it is set to merge with here diff --git a/Tiles/UelibloomBrick.cs b/Tiles/UelibloomBrick.cs index 138e79e700..654fb1b1b5 100644 --- a/Tiles/UelibloomBrick.cs +++ b/Tiles/UelibloomBrick.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; @@ -22,6 +23,7 @@ namespace CalamityMod.Tiles Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = false; Main.tileBlockLight[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Organic"]); CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeDecorativeTiles(Type); diff --git a/Tiles/VernalSoil.cs b/Tiles/VernalSoil.cs index 80eceb4814..145e6acf38 100644 --- a/Tiles/VernalSoil.cs +++ b/Tiles/VernalSoil.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; +using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -18,6 +19,7 @@ namespace CalamityMod.Tiles { Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Organic"]); CalamityUtils.MergeWithGeneral(Type);