From f2c13839e7caecf8778369bf4cd8237c968ba724 Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sun, 9 Nov 2025 12:14:23 +0700 Subject: [PATCH] Ported Astral Solution conversions --- Items/Ammo/AstralSolution.cs | 5 -- Projectiles/Typeless/AstralSpray.cs | 78 +++++++++--------------- World/AstralConversion.cs | 94 +++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 53 deletions(-) create mode 100644 World/AstralConversion.cs diff --git a/Items/Ammo/AstralSolution.cs b/Items/Ammo/AstralSolution.cs index 4026fbb514..68a557445e 100644 --- a/Items/Ammo/AstralSolution.cs +++ b/Items/Ammo/AstralSolution.cs @@ -20,10 +20,5 @@ namespace CalamityMod.Items.Ammo { itemGroup = ContentSamples.CreativeHelper.ItemGroup.Solutions; } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - return !(player.itemAnimation < player.ActiveItem().useAnimation - 3); - } } } diff --git a/Projectiles/Typeless/AstralSpray.cs b/Projectiles/Typeless/AstralSpray.cs index d2354f3dd6..f1b18aff04 100644 --- a/Projectiles/Typeless/AstralSpray.cs +++ b/Projectiles/Typeless/AstralSpray.cs @@ -1,4 +1,5 @@ using CalamityMod.World; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,69 +11,50 @@ namespace CalamityMod.Projectiles.Typeless public new string LocalizationCategory => "Projectiles.Typeless"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float Time => ref Projectile.ai[0]; + public bool ShotFromTerraformer => Projectile.ai[1] == 1f; + + public static int ConversionType; + public override void SetStaticDefaults() => ConversionType = ModContent.GetInstance().Type; + public override void SetDefaults() { - Projectile.width = 16; - Projectile.height = 16; - Projectile.aiStyle = -1; - Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.penetrate = -1; - Projectile.extraUpdates = 2; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; + Projectile.DefaultToSpray(); + Projectile.aiStyle = 0; } public override bool? CanDamage() => false; - public override bool PreAI() + public override void AI() { + if (Projectile.timeLeft > 133) + Projectile.timeLeft = 133; + if (Main.myPlayer == Projectile.owner) { - int x = (int)(Projectile.Center.X / 16f); - int y = (int)(Projectile.Center.Y / 16f); + int size = ShotFromTerraformer ? 3 : 2; + Point tileCenter = Projectile.Center.ToTileCoordinates(); + WorldGen.Convert(tileCenter.X, tileCenter.Y, ConversionType, size); + } - AstralBiome.ConvertToAstral(x - 1, x + 1, y - 1, y + 1); - } - if (Projectile.timeLeft > 133) + float dustStart = ShotFromTerraformer ? 3f : 7f; + if (Time > dustStart) { - Projectile.timeLeft = 133; - } - if (Projectile.ai[0] > 7f) - { - float scalar = 1f; - if (Projectile.ai[0] == 8f) + float dustScale = Utils.Remap(Time, dustStart + 1f, dustStart + 5f, 0.2f, 1f); + int dustArea = 0; + if (ShotFromTerraformer) { - scalar = 0.2f; + dustScale *= 1.2f; + dustArea = (int)(12f * dustScale); } - else if (Projectile.ai[0] == 9f) - { - scalar = 0.4f; - } - else if (Projectile.ai[0] == 10f) - { - scalar = 0.6f; - } - else if (Projectile.ai[0] == 11f) - { - scalar = 0.8f; - } - Projectile.ai[0]++; - for (int i = 0; i < 1; i++) - { - int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Ice_Purple, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100); - Main.dust[d].noGravity = true; - Main.dust[d].scale *= 1.75f * scalar; - Main.dust[d].velocity.X *= 2f; - Main.dust[d].velocity.Y *= 2f; - } - } - else - { - Projectile.ai[0]++; + + Dust spray = Dust.NewDustDirect(Projectile.position - Vector2.One * dustArea, Projectile.width + dustArea * 2, Projectile.height + dustArea * 2, DustID.Ice_Purple, Projectile.velocity.X * 0.4f, Projectile.velocity.Y * 0.4f, 100); + spray.noGravity = true; + spray.scale *= 1.75f * dustScale; } + + Time++; Projectile.rotation += 0.3f * Projectile.direction; - return false; } } } diff --git a/World/AstralConversion.cs b/World/AstralConversion.cs new file mode 100644 index 0000000000..c7eb220400 --- /dev/null +++ b/World/AstralConversion.cs @@ -0,0 +1,94 @@ +using CalamityMod.Systems.Collections; +using CalamityMod.Tiles.Astral; +using CalamityMod.Tiles.AstralDesert; +using CalamityMod.Tiles.AstralSnow; +using CalamityMod.Tiles.FurnitureMonolith; +using CalamityMod.Tiles.Ores; +using CalamityMod.Walls; +using CalamityMod.Walls.UnsafeWalls; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.World +{ + public class AstralConversion : ModBiomeConversion + { + public static int GrassType; + public static int DirtType; + public static int StoneType; + public static int SandType; + public static int SandstoneType; + public static int HardenedSandType; + public static int SnowType; + public static int IceType; + public static int ClayType; + public static int SiltType; + public static int FossilType; + public static int WoodType; + public static int OreType; + + public static int GrassWallType; + public static int DirtWallType; + public static int StoneWallType; + public static int SnowWallType; + public static int IceWallType; + public static int SandstoneWallType; + public static int HardenedSandWallType; + public static int FossilWallType; + public static int WoodWallType; + + public override void PostSetupContent() + { + GrassType = TileType(); + DirtType = TileType(); + StoneType = TileType(); + SnowType = TileType(); + IceType = TileType(); + SandType = TileType(); + SandstoneType = TileType(); + HardenedSandType = TileType(); + ClayType = TileType(); + SiltType = TileType(); + FossilType = TileType(); + WoodType = TileType(); + OreType = TileType(); + + DirtWallType = WallType(); + GrassWallType = WallType(); + StoneWallType = WallType(); + SnowWallType = WallType(); + IceWallType = WallType(); + SandstoneWallType = WallType(); + HardenedSandWallType = WallType(); + FossilWallType = WallType(); + WoodWallType = WallType(); + + TileLoader.RegisterSimpleConversion(TileID.Grass, Type, GrassType); + TileLoader.RegisterSimpleConversion(TileID.Dirt, Type, DirtType); + TileLoader.RegisterSimpleConversion(TileID.Stone, Type, StoneType); + TileLoader.RegisterSimpleConversion(TileID.SnowBlock, Type, SnowType); + TileLoader.RegisterSimpleConversion(TileID.IceBlock, Type, IceType); + TileLoader.RegisterSimpleConversion(TileID.Sand, Type, SandType); + TileLoader.RegisterSimpleConversion(TileID.Sandstone, Type, SandstoneType); + TileLoader.RegisterSimpleConversion(TileID.HardenedSand, Type, HardenedSandType); + TileLoader.RegisterSimpleConversion(TileID.ClayBlock, Type, ClayType); + TileLoader.RegisterSimpleConversion(TileID.Silt, Type, SiltType); + TileLoader.RegisterSimpleConversion(TileID.DesertFossil, Type, FossilType); + TileLoader.RegisterSimpleConversion(TileID.LivingWood, Type, WoodType); + TileLoader.RegisterSimpleConversion(TileID.Meteorite, Type, OreType); + + WallLoader.RegisterSimpleConversion(WallID.GrassUnsafe, Type, GrassWallType); + WallLoader.RegisterSimpleConversion(WallID.DirtUnsafe, Type, DirtWallType); + WallLoader.RegisterSimpleConversion(WallID.Stone, Type, StoneWallType); + WallLoader.RegisterSimpleConversion(WallID.SnowWallUnsafe, Type, SnowWallType); + WallLoader.RegisterSimpleConversion(WallID.IceUnsafe, Type, IceWallType); + WallLoader.RegisterSimpleConversion(WallID.Sandstone, Type, SandstoneWallType); + WallLoader.RegisterSimpleConversion(WallID.HardenedSand, Type, HardenedSandWallType); + WallLoader.RegisterSimpleConversion(WallID.DesertFossil, Type, FossilWallType); + WallLoader.RegisterSimpleConversion(WallID.LivingWoodUnsafe, Type, WoodWallType); + } + } +}