From 7e755128be4c08dbce8631de18fcd5dc3e57627f Mon Sep 17 00:00:00 2001 From: DominicKarma42 <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 23 Jun 2020 01:22:16 -0500 Subject: [PATCH] Added the Astral Beacon Note: This will use a schematic, much like the arsenal structures, but a building is still required and the schematic handling code is not on the master branch yet. --- CalamityMod.cs | 1 - Items/Materials/TitanHeart.cs | 22 ++++ Items/Materials/TitanHeart.png | Bin 0 -> 450 bytes Items/SummonItems/Starcore.cs | 20 +-- Localization/CalamityLocalization.cs | 4 +- NPCs/Astral/Atlas.cs | 1 + NPCs/CalamityGlobalNPCLoot.cs | 49 ------- Projectiles/Boss/DeusRitualDrama.cs | 186 +++++++++++++++++++++++++++ Projectiles/Boss/DeusRitualDrama.png | Bin 0 -> 2873 bytes Tiles/Astral/AstralBeacon.cs | 103 +++++++++++++++ Tiles/CalamityGlobalTile.cs | 14 +- World/WorldGenerationMethods.cs | 42 ++++++ 12 files changed, 370 insertions(+), 72 deletions(-) create mode 100644 Items/Materials/TitanHeart.cs create mode 100644 Items/Materials/TitanHeart.png create mode 100644 Projectiles/Boss/DeusRitualDrama.cs create mode 100644 Projectiles/Boss/DeusRitualDrama.png create mode 100644 Tiles/Astral/AstralBeacon.cs diff --git a/CalamityMod.cs b/CalamityMod.cs index 0f0505464b..1aab1fb73b 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -109,7 +109,6 @@ namespace CalamityMod // Boss Spawners public static int ghostKillCount = 0; public static int sharkKillCount = 0; - public static int astralKillCount = 0; // Textures & Shaders public static Texture2D heartOriginal2; diff --git a/Items/Materials/TitanHeart.cs b/Items/Materials/TitanHeart.cs new file mode 100644 index 0000000000..246090f891 --- /dev/null +++ b/Items/Materials/TitanHeart.cs @@ -0,0 +1,22 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Materials +{ + public class TitanHeart : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Titan Heart"); + } + + public override void SetDefaults() + { + item.width = 10; + item.height = 10; + item.maxStack = 999; + item.value = Item.sellPrice(silver: 5); + item.rare = 4; + } + } +} diff --git a/Items/Materials/TitanHeart.png b/Items/Materials/TitanHeart.png new file mode 100644 index 0000000000000000000000000000000000000000..ad923c822449a62bfc6763b54d3fa43cc39f4ce4 GIT binary patch literal 450 zcmV;z0X_bSP)HWv1^~tMCjQEViD~V4d-7JJzB&KVM)jh8+p9YKL@+rwaq??5>i!$|HQG7Q2 z;%=-yrPzlwx6s^BIXxrOcVEVhD7?=)b62R(nbf4mkL%LZAvk2z$?*AXL z#!)FFKUSZiD~81}%%>PWq??7XM6pl@5=ZFZ1hYI=@wNXxponw6e+A~l;u@z9>1H9W zgbfLjQ2DJ&Jje6m{#5?2?V;x7$h`d~gnk9Z6p z(#=Aa$Z)V@qz|7!aa5B4J4#%l#}#^<)_wR1R)6%|W~@O0_aWUal$SxxXRv&PHS;kr zFrfP^S=SIHgb4bOZWh9P0Lvb*pcT4u55;q^+5lFvywgzv%cov@2c}{94wuhhhQT9t zz%7Ki2}Zax6LUMHx$zb}6P0000F8}}l literal 0 HcmV?d00001 diff --git a/Items/SummonItems/Starcore.cs b/Items/SummonItems/Starcore.cs index 62d7479652..343319cf87 100644 --- a/Items/SummonItems/Starcore.cs +++ b/Items/SummonItems/Starcore.cs @@ -1,8 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; using CalamityMod.Items.Potions; -using CalamityMod.NPCs.AstrumDeus; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,7 +12,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Starcore"); Tooltip.SetDefault("May the stars guide your way\n" + - "Summons Astrum Deus\n" + + "Summons Astrum Deus at the Astral Beacon\n" + "Not consumable"); } @@ -29,22 +27,6 @@ namespace CalamityMod.Items.SummonItems item.consumable = false; } - public override bool CanUseItem(Player player) - { - return !Main.dayTime && player.Calamity().ZoneAstral && !NPC.AnyNPCs(ModContent.NPCType()); - } - - public override bool UseItem(Player player) - { - Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - - return true; - } - public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); diff --git a/Localization/CalamityLocalization.cs b/Localization/CalamityLocalization.cs index 1d36e513ef..d883788023 100644 --- a/Localization/CalamityLocalization.cs +++ b/Localization/CalamityLocalization.cs @@ -95,8 +95,8 @@ namespace CalamityMod.Localization new [] { "AureusBossText2", "A faint ethereal click can be heard from the dungeon." }, new [] { "AstralBossText", "The seal of the stars has been broken! You can now mine Astral Ore." }, new [] { "DeusText", "A star-spawned horror tunnels through the astral infection." }, - new [] { "DeusText2", "The astral infection trembles..." }, - new [] { "DeusText3", "The god of the stars draws near..." }, + new [] { "DeusAltarRejectText", "The god of the stars rejects your offering. You must unleash the power of the lunar Cultist to perform the ritual." }, + new [] { "DeusAltarRejectNightText", "The god of the stars rejects your offering. The ritual can only be performed at night." }, new [] { "CalamitasBossText", "You underestimate my power..." }, new [] { "CalamitasBossText2", "The brothers have been reborn!" }, diff --git a/NPCs/Astral/Atlas.cs b/NPCs/Astral/Atlas.cs index 3ce951f053..dacfe4772d 100644 --- a/NPCs/Astral/Atlas.cs +++ b/NPCs/Astral/Atlas.cs @@ -635,6 +635,7 @@ namespace CalamityMod.NPCs.Astral int minStardust = Main.expertMode ? 7 : 6; int maxStardust = Main.expertMode ? 9 : 8; DropHelper.DropItem(npc, ModContent.ItemType(), minStardust, maxStardust); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 2, 1, 2); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedAstrageldon, 7, 1, 1); //not guarantee to prevent inventory spam } diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 741b64d5c7..855997ac8d 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -1296,55 +1296,6 @@ namespace CalamityMod.NPCs } } } - - if (NPC.downedAncientCultist && !CalamityWorld.downedStarGod && npc.type == ModContent.NPCType() && !NPC.AnyNPCs(ModContent.NPCType())) - { - CalamityMod.astralKillCount++; - if (CalamityMod.astralKillCount == 1) - { - string key = "Mods.CalamityMod.DeusText2"; - Color messageColor = Color.Gold; - - if (Main.netMode == NetmodeID.SinglePlayer) - { - Main.NewText(Language.GetTextValue(key), messageColor); - } - else if (Main.netMode == NetmodeID.Server) - { - NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor); - } - } - else if (CalamityMod.astralKillCount == 2) - { - string key = "Mods.CalamityMod.DeusText3"; - Color messageColor = Color.Gold; - - if (Main.netMode == NetmodeID.SinglePlayer) - { - Main.NewText(Language.GetTextValue(key), messageColor); - } - else if (Main.netMode == NetmodeID.Server) - { - NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor); - } - } - if (CalamityMod.astralKillCount >= 3 && Main.netMode != NetmodeID.MultiplayerClient) - { - int lastPlayer = npc.lastInteraction; - - if (!Main.player[lastPlayer].active || Main.player[lastPlayer].dead) - { - lastPlayer = npc.FindClosestPlayer(); - } - - if (lastPlayer >= 0) - { - CalamityWorld.ChangeTime(false); - NPC.SpawnOnPlayer(lastPlayer, ModContent.NPCType()); - CalamityMod.astralKillCount = 0; - } - } - } } #endregion diff --git a/Projectiles/Boss/DeusRitualDrama.cs b/Projectiles/Boss/DeusRitualDrama.cs new file mode 100644 index 0000000000..df72616b52 --- /dev/null +++ b/Projectiles/Boss/DeusRitualDrama.cs @@ -0,0 +1,186 @@ +using CalamityMod.Dusts; +using CalamityMod.NPCs.AstrumDeus; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class DeusRitualDrama : ModProjectile + { + public float Time + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } + public const int TotalSinePeriods = 6; + public const int PulseTime = 45; + public const int TotalRitualTime = 420; + public const float MaxUpwardRise = 540f; + public static readonly Point PulseSize = new Point(300, 300); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Deus Ritual Drama"); + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 2; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = TotalRitualTime; + } + + public override void AI() + { + Time++; + if (Time == TotalRitualTime - PulseTime) + { + int idx = NPC.NewNPC((int)projectile.Center.X, (int)projectile.Center.Y - (int)MaxUpwardRise, ModContent.NPCType(), 1); + if (idx != -1) + { + if (Main.netMode == NetmodeID.SinglePlayer) + { + Main.NewText(Language.GetTextValue("Announcement.HasAwoken", Main.npc[idx].TypeName), new Color(175, 75, 255)); + return; + } + + if (Main.netMode == NetmodeID.Server) + { + NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] + { + Main.npc[idx].GetTypeNetName() + }), new Color(175, 75, 255)); + return; + } + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, idx); + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + float upwardnessRatio = Utils.InverseLerp(60f, TotalRitualTime, Time, true); + float upwardness = MathHelper.Lerp(0f, MaxUpwardRise, upwardnessRatio); + if (Time >= TotalRitualTime - PulseTime) + { + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); + float pulseCompletionRatio = Utils.InverseLerp(TotalRitualTime - PulseTime, TotalRitualTime, Time, true); + Vector2 scale = projectile.scale * (3f + pulseCompletionRatio * 5f) * new Vector2(1.5f, 1f); + DrawData drawData = new DrawData(ModContent.GetTexture("Terraria/Misc/Perlin"), + projectile.Center - Main.screenPosition + PulseSize.ToVector2() * scale * 0.5f - Vector2.UnitY * upwardness, + new Rectangle(0, 0, PulseSize.X, PulseSize.Y), + new Color(new Vector4(1f - (float)Math.Sqrt(pulseCompletionRatio))) * 0.66f, + projectile.rotation, + PulseSize.ToVector2(), + scale, + SpriteEffects.None, 0); + + Color pulseColor = Color.Lerp(Color.Cyan * 1.5f, Color.OrangeRed, MathHelper.Clamp(pulseCompletionRatio * 1.5f, 0f, 1f)); + GameShaders.Misc["ForceField"].UseColor(pulseColor); + GameShaders.Misc["ForceField"].Apply(drawData); + drawData.Draw(spriteBatch); + return false; + } + float outwardnessRatio = Utils.InverseLerp(60f, 220f, Time, true); + if (Time > 250f) + outwardnessRatio = 1f - Utils.InverseLerp(250f, TotalRitualTime - PulseTime, Time, true); + float outwardness = MathHelper.Lerp(0f, 140f, outwardnessRatio); + + Vector2 offset = new Vector2((float)Math.Sin(Time / (TotalRitualTime - PulseTime) * MathHelper.TwoPi * TotalSinePeriods) * outwardness, -upwardness); + + // If the stars "collide", generate some small explosion dust. + if (!Main.dedServ && Math.Abs(offset.X) < 6f && Time > 60f) + { + for (int i = 0; i < 20; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + Vector2.UnitY * offset.Y, 261); + dust.color = Utils.SelectRandom(Main.rand, Color.Cyan, Color.OrangeRed); + dust.scale = 1.15f; + dust.velocity = Main.rand.NextVector2CircularEdge(3f, 3f) * Main.rand.NextFloat(0.7f, 1.4f); + dust.noGravity = true; + + float angle = MathHelper.TwoPi * i / 20f; + dust = Dust.NewDustPerfect(projectile.Center + Vector2.UnitY * offset.Y, 261); + dust.color = Utils.SelectRandom(Main.rand, Color.Cyan, Color.OrangeRed); + dust.scale = 1.15f; + dust.velocity = angle.ToRotationVector2() * 7f; + dust.noGravity = true; + } + } + + DrawStars(spriteBatch, offset); + + return false; + } + + public void DrawStars(SpriteBatch spriteBatch, Vector2 offset) + { + Texture2D starTexture = ModContent.GetTexture(Texture); + for (int i = 0; i < 6; i++) + { + float angle = MathHelper.TwoPi * i / 6f + Time / 15f; + Vector2 angularOffset = angle.ToRotationVector2() * 4f; + spriteBatch.Draw(starTexture, + projectile.Center + angularOffset + offset - Main.screenPosition, + null, + Color.Cyan * 0.5f, + 0f, + starTexture.Size() * 0.5f, + 0.6f, + SpriteEffects.None, + 0f); + spriteBatch.Draw(starTexture, + projectile.Center + angularOffset + offset * new Vector2(-1f, 1f) - Main.screenPosition, + null, + Color.OrangeRed * 0.5f, + 0f, + starTexture.Size() * 0.5f, + 0.6f, + SpriteEffects.None, + 0f); + } + spriteBatch.Draw(starTexture, + projectile.Center + offset - Main.screenPosition, + null, + Color.Cyan * 1.4f, + 0f, + starTexture.Size() * 0.5f, + 0.6f, + SpriteEffects.None, + 0f); + spriteBatch.Draw(starTexture, + projectile.Center + offset * new Vector2(-1f, 1f) - Main.screenPosition, + null, + Color.OrangeRed * 1.1f, + 0f, + starTexture.Size() * 0.5f, + 0.6f, + SpriteEffects.None, + 0f); + + // Generate dust at the star position. This gives them a trail effect. + if (!Main.dedServ) + { + Dust dust2 = Dust.NewDustPerfect(projectile.Center + offset, 261); + dust2.color = Color.Cyan; + dust2.scale = 1.15f; + dust2.velocity = Vector2.Zero; + dust2.noGravity = true; + + dust2 = Dust.NewDustPerfect(projectile.Center + offset * new Vector2(-1f, 1f), 261); + dust2.color = Color.OrangeRed; + dust2.scale = 1.15f; + dust2.velocity = Vector2.Zero; + dust2.noGravity = true; + } + } + } +} diff --git a/Projectiles/Boss/DeusRitualDrama.png b/Projectiles/Boss/DeusRitualDrama.png new file mode 100644 index 0000000000000000000000000000000000000000..306efb434ed8bc7034150cea9336014c3f0a9c80 GIT binary patch literal 2873 zcmV-93&!+`P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!2kdb!2!6DYwZ943eHJHK~!i%)tbAj zB})~?`?b&HlT2(R6Kg6OD2l=byKTUVb7>NDfab5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QtsQYQ&i^L~E1XOTd{gtEj~lGJT*GUzEva#`Z3 zr1cN_A74NwR_aJ7N-FuASA?PlazxNY-+)An=&Bu7wyWX2|MM9*PZCMy=|@>i_)!+R zL6mm1@)tUN+#QR;I_#8r z&6yM~TXE5CGjNfI%)cP;zWyhK47@}XIx?3{GV9b@xQ=P;M;j0@q)FkmT~AIgB%|QE zr3`Z2?bsdoJPJokr+3Iv;EyMc(+(ndXgTvAnJai~2}=Df$${O0Z%0YYSt^@c!qO%O z@jMEKi{nwX)+H_Q_T)gDb>EJXz{dGIMy

2xgQ-om~jo7F)+l!r*Si zGTzad+pr<_PGq;F!2O72JRrf09a85;*`@F>#4;X%V8(r?>cij>36?lV_Hjt9sH*=1 X{&cp?RbjFf00000NkvXXu0mjf7aM9S literal 0 HcmV?d00001 diff --git a/Tiles/Astral/AstralBeacon.cs b/Tiles/Astral/AstralBeacon.cs new file mode 100644 index 0000000000..2f867d9b18 --- /dev/null +++ b/Tiles/Astral/AstralBeacon.cs @@ -0,0 +1,103 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Items.SummonItems; +using CalamityMod.NPCs.AstrumDeus; +using CalamityMod.Projectiles.Boss; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralBeacon : ModTile + { + public const int Width = 5; + public const int Height = 4; + public static readonly Color FailColor = new Color(237, 93, 83); + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileSpelunker[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style5x4); + TileObjectData.addTile(Type); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Astral Beacon"); + AddMapEntry(new Color(128, 128, 158), name); + disableSmartCursor = true; + } + + public override bool CanExplode(int i, int j) => false; + + public override bool CanKillTile(int i, int j, ref bool blockDamaged) => false; + public override bool NewRightClick(int i, int j) + { + Tile tile = Main.tile[i, j]; + + int left = i - tile.frameX / 18; + int top = j - tile.frameY / 18; + + if (!Main.LocalPlayer.HasItem(ModContent.ItemType()) && + !Main.LocalPlayer.HasItem(ModContent.ItemType())) + return true; + + if (NPC.AnyNPCs(ModContent.NPCType())) + return true; + + if (CalamityUtils.CountProjectiles(ModContent.ProjectileType()) > 0) + return true; + + bool usingStarcore = Main.LocalPlayer.HasItem(ModContent.ItemType()); + + if (!NPC.downedAncientCultist) + { + string localizationKey = "Mods.CalamityMod.DeusAltarRejectText"; + if (Main.netMode == NetmodeID.SinglePlayer) + Main.NewText(Language.GetTextValue(localizationKey), FailColor); + else if (Main.netMode == NetmodeID.Server) + NetMessage.BroadcastChatMessage(NetworkText.FromKey(localizationKey), FailColor); + return true; + } + + if (Main.dayTime) + { + string localizationKey = "Mods.CalamityMod.DeusAltarRejectNightText"; + if (Main.netMode == NetmodeID.SinglePlayer) + Main.NewText(Language.GetTextValue(localizationKey), FailColor); + else if (Main.netMode == NetmodeID.Server) + NetMessage.BroadcastChatMessage(NetworkText.FromKey(localizationKey), FailColor); + return false; + } + + Vector2 ritualSpawnPosition = new Vector2(left + Width / 2, top).ToWorldCoordinates(); + ritualSpawnPosition += new Vector2(0f, -24f); + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyRay"), ritualSpawnPosition); + Projectile.NewProjectile(ritualSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + + if (!usingStarcore) + Main.LocalPlayer.ConsumeItem(ModContent.ItemType(), true); + + return true; + } + public override void MouseOver(int i, int j) + { + Main.LocalPlayer.showItemIcon2 = ModContent.ItemType(); + if (Main.LocalPlayer.HasItem(ModContent.ItemType())) + Main.LocalPlayer.showItemIcon2 = ModContent.ItemType(); + Main.LocalPlayer.noThrow = 2; + Main.LocalPlayer.showItemIcon = true; + } + + public override void MouseOverFar(int i, int j) + { + Main.LocalPlayer.showItemIcon2 = ModContent.ItemType(); + if (Main.LocalPlayer.HasItem(ModContent.ItemType())) + Main.LocalPlayer.showItemIcon2 = ModContent.ItemType(); + Main.LocalPlayer.noThrow = 2; + Main.LocalPlayer.showItemIcon = true; + } + } +} diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 1137bed448..2425c63be8 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -525,5 +525,17 @@ namespace CalamityMod.Tiles return new int[0]; } - } + public override bool CanKillTile(int i, int j, int type, ref bool blockDamaged) + { + // Prevent tiles below an astral beacon from being destroyed. + if (CalamityUtils.ParanoidTileRetrieval(i, j - 1).active() && + CalamityUtils.ParanoidTileRetrieval(i, j).type != + CalamityUtils.ParanoidTileRetrieval(i, j - 1).type && + CalamityUtils.ParanoidTileRetrieval(i, j - 1).type == ModContent.TileType()) + { + return false; + } + return base.CanKillTile(i, j, type, ref blockDamaged); + } + } } diff --git a/World/WorldGenerationMethods.cs b/World/WorldGenerationMethods.cs index 92e4bd7512..9535b5fb31 100644 --- a/World/WorldGenerationMethods.cs +++ b/World/WorldGenerationMethods.cs @@ -1598,15 +1598,57 @@ namespace CalamityMod.World } } } + if (Main.netMode != NetmodeID.MultiplayerClient) { NetMessage.SendTileSquare(-1, i, j, 40, TileChangeType.None); if (CanAstralBiomeSpawn()) + { DoAstralConversion(new Point(i, j)); + GenerateAstralBeacon(i, j - 120); + } } return true; } + public static void GenerateAstralBeacon(int roughX, int startY) + { + int x = roughX + WorldGen.genRand.Next(24, 72 + 1) * WorldGen.genRand.NextBool(2).ToDirectionInt(); + int radius = WorldGen.genRand.Next(10, 13 + 1); + + int y = startY; + while (!CalamityUtils.ParanoidTileRetrieval(x, y).active() || + CalamityUtils.ParanoidTileRetrieval(x, y).type == TileID.Trees || + CalamityUtils.ParanoidTileRetrieval(x, y).type == TileID.Cactus) + { + y++; + } + + // Shove the meteor a bit into the ground. + y += radius / 2; + + // Generate a base slime-shaped structure of astral stone. + WorldUtils.Gen(new Point(x, y), new Shapes.Slime(radius), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + // And give it some astral ore to signify that it's an actual meteor. + for (int i = 0; i < 3; i++) + { + int x2 = x + WorldGen.genRand.Next(-2, 2 + 1); + int y2 = y + WorldGen.genRand.Next(-3, 3 + 1); + WorldUtils.Gen(new Point(x2, y2), new Shapes.Circle(WorldGen.genRand.Next(2, 4 + 1)), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + } + + // TODO - Use a schematic to generate the beacon when this code and the arsenal structure code are both on the master branch. + // Delete these comments once this is finished. + WorldGen.PlaceTile(x - AstralBeacon.Width / 2, y - radius - 1, ModContent.TileType()); + } public static void DoAstralConversion(object obj) { //Pre-calculate all variables necessary for elliptical area checking