diff --git a/Items/Accessories/ElementalGauntlet.cs b/Items/Accessories/ElementalGauntlet.cs index 2d1718db05..4aa2c078af 100644 --- a/Items/Accessories/ElementalGauntlet.cs +++ b/Items/Accessories/ElementalGauntlet.cs @@ -40,7 +40,6 @@ namespace CalamityMod.Items.Accessories AddIngredient(ItemID.FireGauntlet). AddIngredient(ItemID.LunarBar, 8). AddIngredient(4). - AddIngredient(4). AddTile(). Register(); } diff --git a/Items/Accessories/EtherealTalisman.cs b/Items/Accessories/EtherealTalisman.cs index c9f97d3110..f10b85a7bc 100644 --- a/Items/Accessories/EtherealTalisman.cs +++ b/Items/Accessories/EtherealTalisman.cs @@ -42,7 +42,6 @@ namespace CalamityMod.Items.Accessories AddRecipeGroup("AnyManaFlower"). //Any mana flower accessory AddIngredient(ItemID.LunarBar, 8). AddIngredient(4). - AddIngredient(4). AddTile(). Register(); } diff --git a/Items/Accessories/Nanotech.cs b/Items/Accessories/Nanotech.cs index 96db6c958a..21b56bcdeb 100644 --- a/Items/Accessories/Nanotech.cs +++ b/Items/Accessories/Nanotech.cs @@ -41,7 +41,6 @@ namespace CalamityMod.Items.Accessories AddIngredient(). AddIngredient(ItemID.LunarBar, 8). AddIngredient(4). - AddIngredient(4). AddTile(). Register(); } diff --git a/Items/Accessories/Nucleogenesis.cs b/Items/Accessories/Nucleogenesis.cs index 4d2b398086..75283170ae 100644 --- a/Items/Accessories/Nucleogenesis.cs +++ b/Items/Accessories/Nucleogenesis.cs @@ -50,7 +50,6 @@ namespace CalamityMod.Items.Accessories AddIngredient(). AddIngredient(ItemID.LunarBar, 8). AddIngredient(4). - AddIngredient(4). AddTile(). Register(); } diff --git a/Items/Accessories/PlanebreakersPouch.cs b/Items/Accessories/PlanebreakersPouch.cs index 33b979b883..0e65047093 100644 --- a/Items/Accessories/PlanebreakersPouch.cs +++ b/Items/Accessories/PlanebreakersPouch.cs @@ -38,7 +38,6 @@ namespace CalamityMod.Items.Accessories AddIngredient(). AddIngredient(ItemID.LunarBar, 8). AddIngredient(4). - AddIngredient(4). AddTile(). Register(); } diff --git a/Items/Potions/CeaselessHungerPotion.cs b/Items/Potions/CeaselessHungerPotion.cs index 63ceb3b079..78fb605f52 100644 --- a/Items/Potions/CeaselessHungerPotion.cs +++ b/Items/Potions/CeaselessHungerPotion.cs @@ -33,7 +33,6 @@ namespace CalamityMod.Items.Potions CreateRecipe(4). AddIngredient(ItemID.BottledWater, 4). AddIngredient(). - AddIngredient(). AddTile(TileID.AlchemyTable). AddConsumeItemCallback(Recipe.ConsumptionRules.Alchemy). Register(); diff --git a/Items/Weapons/Magic/AuguroftheVoid.cs b/Items/Weapons/Magic/AuguroftheVoid.cs index 6b863edfb4..d2ef2738fe 100644 --- a/Items/Weapons/Magic/AuguroftheVoid.cs +++ b/Items/Weapons/Magic/AuguroftheVoid.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(ItemID.FragmentNebula, 5). AddTile(TileID.Bookcases). Register(); } diff --git a/Items/Weapons/Magic/Nucleosynthesis.cs b/Items/Weapons/Magic/Nucleosynthesis.cs index e6792704f4..e718608ca1 100644 --- a/Items/Weapons/Magic/Nucleosynthesis.cs +++ b/Items/Weapons/Magic/Nucleosynthesis.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(ItemID.FragmentNebula, 5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Melee/ArkoftheElements.cs b/Items/Weapons/Melee/ArkoftheElements.cs index 348db4f9e6..ffe88ecae2 100644 --- a/Items/Weapons/Melee/ArkoftheElements.cs +++ b/Items/Weapons/Melee/ArkoftheElements.cs @@ -234,7 +234,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(ItemID.FragmentSolar, 5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Melee/SeashineSword.cs b/Items/Weapons/Melee/SeashineSword.cs index 465fa48b07..358b10aa53 100644 --- a/Items/Weapons/Melee/SeashineSword.cs +++ b/Items/Weapons/Melee/SeashineSword.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; @@ -27,7 +28,14 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item1; Item.shoot = ModContent.ProjectileType(); } - + public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 120); + } + public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) + { + target.AddBuff(ModContent.BuffType(), 120); + } public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Melee/StarburstShiv.cs b/Items/Weapons/Melee/StarburstShiv.cs index 333f89fb7d..5fdd6a0f4f 100644 --- a/Items/Weapons/Melee/StarburstShiv.cs +++ b/Items/Weapons/Melee/StarburstShiv.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.PiercingStarlight). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(ItemID.FragmentSolar, 5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Melee/VanishingPoint.cs b/Items/Weapons/Melee/VanishingPoint.cs index a02853841d..5aee60aefa 100644 --- a/Items/Weapons/Melee/VanishingPoint.cs +++ b/Items/Weapons/Melee/VanishingPoint.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(ItemID.FragmentSolar, 5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Ranged/ChromaticEruption.cs b/Items/Weapons/Ranged/ChromaticEruption.cs index 0e25bea27c..4577cc58f0 100644 --- a/Items/Weapons/Ranged/ChromaticEruption.cs +++ b/Items/Weapons/Ranged/ChromaticEruption.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(ItemID.FragmentVortex, 5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Ranged/PlanetaryAnnihilation.cs b/Items/Weapons/Ranged/PlanetaryAnnihilation.cs index d06d34e907..6838dd2b28 100644 --- a/Items/Weapons/Ranged/PlanetaryAnnihilation.cs +++ b/Items/Weapons/Ranged/PlanetaryAnnihilation.cs @@ -105,7 +105,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.DaedalusStormbow). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(ItemID.FragmentVortex, 5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Ranged/ReedBlowgun.cs b/Items/Weapons/Ranged/ReedBlowgun.cs index 34a55c9613..12c7774d84 100644 --- a/Items/Weapons/Ranged/ReedBlowgun.cs +++ b/Items/Weapons/Ranged/ReedBlowgun.cs @@ -12,8 +12,6 @@ namespace CalamityMod.Items.Weapons.Ranged public class ReedBlowgun : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - public static readonly SoundStyle BubbleBurstSound = new("CalamityMod/Sounds/Custom/PistolShrimpBubbleBurst") { PitchVariance = 0.15f, Volume = 0.2f }; - public override void SetStaticDefaults() { ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; @@ -23,10 +21,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 22; Item.height = 46; - Item.damage = 21; + Item.damage = 25; Item.DamageType = DamageClass.Ranged; - Item.useTime = 25; - Item.useAnimation = 25; + Item.useTime = 32; + Item.useAnimation = 32; Item.useStyle = ItemUseStyleID.Shoot; Item.holdStyle = 16; Item.noMelee = true; diff --git a/Items/Weapons/Ranged/Seadragon.cs b/Items/Weapons/Ranged/Seadragon.cs index 1e47e455af..31b9ce3d5b 100644 --- a/Items/Weapons/Ranged/Seadragon.cs +++ b/Items/Weapons/Ranged/Seadragon.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item11; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; Item.useAmmo = AmmoID.Bullet; Item.Calamity().canFirePointBlankShots = true; diff --git a/Items/Weapons/Ranged/SuperradiantSlaughterer.cs b/Items/Weapons/Ranged/SuperradiantSlaughterer.cs index b68329a75a..e0d0977f1c 100644 --- a/Items/Weapons/Ranged/SuperradiantSlaughterer.cs +++ b/Items/Weapons/Ranged/SuperradiantSlaughterer.cs @@ -122,7 +122,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(ItemID.FragmentVortex, 5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Rogue/ReboundingRainbow.cs b/Items/Weapons/Rogue/ReboundingRainbow.cs index a2d3549eef..a874f6347d 100644 --- a/Items/Weapons/Rogue/ReboundingRainbow.cs +++ b/Items/Weapons/Rogue/ReboundingRainbow.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Rogue AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Summon/FlowersOfMortality.cs b/Items/Weapons/Summon/FlowersOfMortality.cs index db13ad1385..2778b1c5a0 100644 --- a/Items/Weapons/Summon/FlowersOfMortality.cs +++ b/Items/Weapons/Summon/FlowersOfMortality.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Summon AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(ItemID.FragmentStardust, 5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Summon/LegionofCelestia.cs b/Items/Weapons/Summon/LegionofCelestia.cs index d0a6ef0c1e..fa94cdf36a 100644 --- a/Items/Weapons/Summon/LegionofCelestia.cs +++ b/Items/Weapons/Summon/LegionofCelestia.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Summon AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddIngredient(5). + AddIngredient(ItemID.FragmentStardust, 5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Projectiles/Magic/AquamarineBolt.cs b/Projectiles/Magic/AquamarineBolt.cs index 886ec7cabc..f426b89a09 100644 --- a/Projectiles/Magic/AquamarineBolt.cs +++ b/Projectiles/Magic/AquamarineBolt.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -39,7 +40,8 @@ namespace CalamityMod.Projectiles.Magic } Projectile.rotation += 0.3f * (float)Projectile.direction; } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Melee/AmidiasWhirlpool.cs b/Projectiles/Melee/AmidiasWhirlpool.cs index 4815d4d045..a381b0710a 100644 --- a/Projectiles/Melee/AmidiasWhirlpool.cs +++ b/Projectiles/Melee/AmidiasWhirlpool.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -139,7 +140,8 @@ namespace CalamityMod.Projectiles.Melee { return new Color(30, 255, 253); } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); diff --git a/Projectiles/Melee/RedtideWhirlpool.cs b/Projectiles/Melee/RedtideWhirlpool.cs index 1922176180..42d3b112e9 100644 --- a/Projectiles/Melee/RedtideWhirlpool.cs +++ b/Projectiles/Melee/RedtideWhirlpool.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -54,7 +55,8 @@ namespace CalamityMod.Projectiles.Melee return false; } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.NPCDeath19, Projectile.position); diff --git a/Projectiles/Melee/SeashineSwordProj.cs b/Projectiles/Melee/SeashineSwordProj.cs index 12e6aa9d77..00272dd585 100644 --- a/Projectiles/Melee/SeashineSwordProj.cs +++ b/Projectiles/Melee/SeashineSwordProj.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -92,9 +93,9 @@ namespace CalamityMod.Projectiles.Melee CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); return false; } - public override Color? GetAlpha(Color lightColor) => new Color(128, byte.MaxValue, byte.MaxValue); - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 60); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 60); public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); diff --git a/Projectiles/Ranged/ArcherfishShot.cs b/Projectiles/Ranged/ArcherfishShot.cs index 7b82e11a0f..918ebc8a95 100644 --- a/Projectiles/Ranged/ArcherfishShot.cs +++ b/Projectiles/Ranged/ArcherfishShot.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -59,6 +60,15 @@ namespace CalamityMod.Projectiles.Ranged } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Wet, 240); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.Wet, 120); + target.AddBuff(ModContent.BuffType(), 120); + } + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(BuffID.Wet, 120); + target.AddBuff(ModContent.BuffType(), 120); + } } } diff --git a/Projectiles/Ranged/MegalodonShot.cs b/Projectiles/Ranged/MegalodonShot.cs index 9d5fba397e..9ecee22bea 100644 --- a/Projectiles/Ranged/MegalodonShot.cs +++ b/Projectiles/Ranged/MegalodonShot.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged bubble.type = Main.rand.NextBool(3) ? 412 : 411; } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 240); } } diff --git a/Projectiles/Ranged/PressurizedBubbleStream.cs b/Projectiles/Ranged/PressurizedBubbleStream.cs index 54b78cc3e1..4b593181e5 100644 --- a/Projectiles/Ranged/PressurizedBubbleStream.cs +++ b/Projectiles/Ranged/PressurizedBubbleStream.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -32,9 +33,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 1; + Projectile.penetrate = 3; Projectile.extraUpdates = 4; Projectile.timeLeft = FireTime + ChargeupTime; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool ShouldUpdatePosition() @@ -80,7 +83,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 bubblePosition = Owner.MountedCenter - Vector2.UnitY * 4f + bubbleRotation.ToRotationVector2() * 55f; - SoundEngine.PlaySound(ReedBlowgun.BubbleBurstSound, bubblePosition); + SoundEngine.PlaySound(SoundID.Item64, bubblePosition); } Projectile.velocity *= 0.985f; @@ -130,7 +133,8 @@ namespace CalamityMod.Projectiles.Ranged waterDust.velocity -= Projectile.velocity * 0.1f; } } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item21, Projectile.position); diff --git a/Projectiles/Rogue/SeafoamBubble.cs b/Projectiles/Rogue/SeafoamBubble.cs index d33e0aa2b0..31a35ff41b 100644 --- a/Projectiles/Rogue/SeafoamBubble.cs +++ b/Projectiles/Rogue/SeafoamBubble.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -42,7 +43,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.damage *= 2; } } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item54, Projectile.position); diff --git a/Systems/TileMerging/TileBlendMergeSystem_TileFrame.cs b/Systems/TileMerging/TileBlendMergeSystem_TileFrame.cs index 242a68ffc7..5387070e05 100644 --- a/Systems/TileMerging/TileBlendMergeSystem_TileFrame.cs +++ b/Systems/TileMerging/TileBlendMergeSystem_TileFrame.cs @@ -336,6 +336,9 @@ namespace CalamityMod.Systems if (sideType < 0) return; + if (!_TileTypeToBlendTextureSlot.IndexInRange(sideType)) + return; + var blendTextureSlot = _TileTypeToBlendTextureSlot[sideType]; if (blendTextureSlot == TileBlendTextureLoader.EmptySlot) return; diff --git a/Tiles/AstralSnow/AstralIce.png b/Tiles/AstralSnow/AstralIce.png index 924cc4a6fc..86a8d74879 100644 Binary files a/Tiles/AstralSnow/AstralIce.png and b/Tiles/AstralSnow/AstralIce.png differ diff --git a/Tiles/AstralSnow/AstralSnow.png b/Tiles/AstralSnow/AstralSnow.png index ab1fff1134..a0333f7c80 100644 Binary files a/Tiles/AstralSnow/AstralSnow.png and b/Tiles/AstralSnow/AstralSnow.png differ diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index 09a581aac2..50442427ef 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -21,6 +21,7 @@ using CalamityMod.Tiles.SunkenSea; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -264,6 +265,45 @@ namespace CalamityMod return PaintID.DeepRedPaint >= paintType && paintType <= PaintID.DeepPinkPaint; } + /// + /// Draws placed wall with multiple variants, properly painted. + /// + /// The sprite batch. + /// The type of wall. + /// The x co-ordinate of the wall. + /// The y co-ordinate of the wall. + /// The offset within the spritesheet, similar to TileFrame. + /// Whether or not PreDraw is drawn + public static bool DrawMultiVariantWall(this SpriteBatch spriteBatch, int type, int i, int j, int[] sheetOffset) + { + if (spriteBatch is null) + return true; + + spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Main.GameViewMatrix.TransformationMatrix, () => + { + Tile tile = Main.tile[i, j]; + Effect tileShader = Main.tileShader; + TreePaintingSettings settings = TreePaintSystemData.GetWallSettings(type); + int paintColor = tile.WallColor; + tileShader.Parameters["leafHueTestOffset"]?.SetValue(settings.HueTestOffset); + tileShader.Parameters["leafMinHue"]?.SetValue(settings.SpecialGroupMinimalHueValue); + tileShader.Parameters["leafMaxHue"]?.SetValue(settings.SpecialGroupMaximumHueValue); + tileShader.Parameters["leafMinSat"]?.SetValue(settings.SpecialGroupMinimumSaturationValue); + tileShader.Parameters["leafMaxSat"]?.SetValue(settings.SpecialGroupMaximumSaturationValue); + tileShader.Parameters["invertSpecialGroupResult"]?.SetValue(settings.InvertSpecialGroupResult); + int index = Main.ConvertPaintIdToTileShaderIndex(paintColor, settings.UseSpecialGroups, settings.UseWallShaderHacks); + tileShader.CurrentTechnique.Passes[index].Apply(); + + Texture2D sprite = TextureAssets.Wall[type].Value; + Vector2 offset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange)) - Vector2.One * 8f; + Rectangle frame = new Rectangle(sheetOffset[0] + tile.WallFrameX, sheetOffset[1] + tile.WallFrameY, 32, 32); + Color lightColor = Lighting.GetColor(i, j); + + spriteBatch.Draw(sprite, offset, frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + }); + return false; + } + public static Tile ParanoidTileRetrieval(int x, int y) { if (!WorldGen.InWorld(x, y)) diff --git a/Walls/AshenSlabWall.cs b/Walls/AshenSlabWall.cs index a2d65f6c17..ba96f5121b 100644 --- a/Walls/AshenSlabWall.cs +++ b/Walls/AshenSlabWall.cs @@ -1,7 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -24,28 +23,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/AstralMonolithWall.cs b/Walls/AstralMonolithWall.cs index ab826e6ae2..4fb6c06ea1 100644 --- a/Walls/AstralMonolithWall.cs +++ b/Walls/AstralMonolithWall.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Walls @@ -23,28 +22,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/BrimstoneSlabWall.cs b/Walls/BrimstoneSlabWall.cs index 8aec81812a..3c0e87b7a2 100644 --- a/Walls/BrimstoneSlabWall.cs +++ b/Walls/BrimstoneSlabWall.cs @@ -1,7 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -29,28 +28,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/BrimstoneSlagWall.cs b/Walls/BrimstoneSlagWall.cs index 002fb585bb..8addfebb53 100644 --- a/Walls/BrimstoneSlagWall.cs +++ b/Walls/BrimstoneSlagWall.cs @@ -1,7 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -24,28 +23,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/BrimstoneSlagWallUnsafe.cs b/Walls/BrimstoneSlagWallUnsafe.cs index 5663da37f0..c861ce2802 100644 --- a/Walls/BrimstoneSlagWallUnsafe.cs +++ b/Walls/BrimstoneSlagWallUnsafe.cs @@ -1,7 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -24,28 +23,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/CryonicBrickWall.cs b/Walls/CryonicBrickWall.cs index 3d2baab04c..5f2c0ce425 100644 --- a/Walls/CryonicBrickWall.cs +++ b/Walls/CryonicBrickWall.cs @@ -24,28 +24,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/ExoPrismPanelWall.cs b/Walls/ExoPrismPanelWall.cs index ff117d1ffd..e12e5d695c 100644 --- a/Walls/ExoPrismPanelWall.cs +++ b/Walls/ExoPrismPanelWall.cs @@ -24,28 +24,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/FloralWall.cs b/Walls/FloralWall.cs index 0773f69e1d..fcd4af4b31 100644 --- a/Walls/FloralWall.cs +++ b/Walls/FloralWall.cs @@ -25,28 +25,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/PerennialBrickWall.cs b/Walls/PerennialBrickWall.cs index 292f5b34d7..8ad57d43b3 100644 --- a/Walls/PerennialBrickWall.cs +++ b/Walls/PerennialBrickWall.cs @@ -25,28 +25,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/ProfanedSlabWall.cs b/Walls/ProfanedSlabWall.cs index 4cc1a0982f..a8ca231d45 100644 --- a/Walls/ProfanedSlabWall.cs +++ b/Walls/ProfanedSlabWall.cs @@ -24,28 +24,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/RunicProfanedBrickWall.cs b/Walls/RunicProfanedBrickWall.cs index d69f38209a..abd86eace7 100644 --- a/Walls/RunicProfanedBrickWall.cs +++ b/Walls/RunicProfanedBrickWall.cs @@ -26,28 +26,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/ScorchedBoneWall.cs b/Walls/ScorchedBoneWall.cs index a8f7afb80d..65d8c1305b 100644 --- a/Walls/ScorchedBoneWall.cs +++ b/Walls/ScorchedBoneWall.cs @@ -18,28 +18,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { diff --git a/Walls/VoidstoneSlabWall.cs b/Walls/VoidstoneSlabWall.cs index 2a7e70cb03..4e8d696829 100644 --- a/Walls/VoidstoneSlabWall.cs +++ b/Walls/VoidstoneSlabWall.cs @@ -24,80 +24,13 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) { - int[] sheetOffset = new int[2] { i % 3, j % 3 }; int xPos = i % 3; int yPos = j % 3; - switch (yPos) - { - case 0: - switch (xPos) - { - case 0: - sheetOffset = new int[2] { 0, 0 }; - break; - case 1: - sheetOffset = new int[2] { 0, 1 }; - break; - case 2: - sheetOffset = new int[2] { 0, 2 }; - break; - } - break; - case 1: - switch (xPos) - { - case 0: - sheetOffset = new int[2] { 0, 3 }; - break; - case 1: - sheetOffset = new int[2] { 0, 4 }; - break; - case 2: - sheetOffset = new int[2] { 0, 0 }; - break; - } - break; - case 2: - switch (xPos) - { - case 0: - sheetOffset = new int[2] { 0, 1 }; - break; - case 1: - sheetOffset = new int[2] { 0, 2 }; - break; - case 2: - sheetOffset = new int[2] { 0, 3 }; - break; - } - break; - } - sheetOffset[0] = sheetOffset[0] * 468; + int[] sheetOffset = new int[2] { 0, (xPos + yPos * 3) % 5 }; sheetOffset[1] = sheetOffset[1] * 180; return sheetOffset; } diff --git a/Walls/VoidstoneWall.cs b/Walls/VoidstoneWall.cs index ebacecb708..3f9290c465 100644 --- a/Walls/VoidstoneWall.cs +++ b/Walls/VoidstoneWall.cs @@ -33,59 +33,46 @@ namespace CalamityMod.Walls return false; } - public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch) + public static bool DrawWallGlow(int type, int i, int j, SpriteBatch spriteBatch) { if (GlowMask.Texture is null) - return; + return true; - Tile tile = Main.tile[i, j]; - int xLength = 32; - int xOff = 0; - - int xPos = tile.WallFrameX + xOff; - int yPos = tile.WallFrameY; - - Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); - Color drawcolor; - drawcolor = WorldGen.paintColor(tile.WallColor); - drawcolor.A = 255; - Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); - - if (Main.drawToScreen) - zero = Vector2.Zero; - - Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero; - Color lightColor = Lighting.GetColor(i, j, Color.White); - - spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); - - if (GlowMask.HasContentInFramePos(xPos, yPos)) + spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Main.GameViewMatrix.TransformationMatrix, () => { - float brightness = 1f; - float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.007f; - brightness *= MathF.Sin(i / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - brightness *= MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - brightness *= MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - brightness *= MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - drawcolor *= brightness; - Color glowColor = drawcolor * 0.4f; + Tile tile = Main.tile[i, j]; + Effect tileShader = Main.tileShader; + TreePaintingSettings settings = TreePaintSystemData.GetWallSettings(type); + int paintColor = tile.WallColor; + tileShader.Parameters["leafHueTestOffset"]?.SetValue(settings.HueTestOffset); + tileShader.Parameters["leafMinHue"]?.SetValue(settings.SpecialGroupMinimalHueValue); + tileShader.Parameters["leafMaxHue"]?.SetValue(settings.SpecialGroupMaximumHueValue); + tileShader.Parameters["leafMinSat"]?.SetValue(settings.SpecialGroupMinimumSaturationValue); + tileShader.Parameters["leafMaxSat"]?.SetValue(settings.SpecialGroupMaximumSaturationValue); + tileShader.Parameters["invertSpecialGroupResult"]?.SetValue(settings.InvertSpecialGroupResult); + int index = Main.ConvertPaintIdToTileShaderIndex(paintColor, settings.UseSpecialGroups, settings.UseWallShaderHacks); + tileShader.CurrentTechnique.Passes[index].Apply(); - // For now checking for glowing frames greatly reducing the bottleneck - // But maybe we could squeeze bit more by removing the loop - for (int k = 0; k < 3; k++) + Texture2D sprite = TextureAssets.Wall[type].Value; + Vector2 offset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange)) - Vector2.One * 8f; + int yPos = tile.WallFrameY; + int xPos = tile.WallFrameX; + Rectangle frame = new Rectangle(xPos, yPos, 32, 32); + Color lightColor = Lighting.GetColor(i, j); + + spriteBatch.Draw(sprite, offset, frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + + if (GlowMask.HasContentInFramePos(xPos, yPos)) { - Vector2 offset = new Vector2(Main.rand.NextFloat(-1, 1f), Main.rand.NextFloat(-1, 1f)) * 0.2f * k; - spriteBatch.Draw(GlowMask.Texture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Color glowColor = Color.Lerp(lightColor, Color.White, 0.2f + MathF.Sin(Main.GameUpdateCount * 0.007f) * 0.1f); + spriteBatch.Draw(GlowMask.Texture, offset, frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } - } - } - - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - DrawWallGlow(Type, i, j, spriteBatch); + }); return false; } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => DrawWallGlow(Type, i, j, spriteBatch); + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; } } diff --git a/Walls/VoidstoneWallUnsafe.cs b/Walls/VoidstoneWallUnsafe.cs index ecb6dc0a0b..deee028dc4 100644 --- a/Walls/VoidstoneWallUnsafe.cs +++ b/Walls/VoidstoneWallUnsafe.cs @@ -42,59 +42,46 @@ namespace CalamityMod.Walls } } - public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch) + public static bool DrawWallGlow(int type, int i, int j, SpriteBatch spriteBatch) { if (GlowMask.Texture is null) - return; + return true; - Tile tile = Main.tile[i, j]; - int xLength = 32; - int xOff = 0; - - int xPos = tile.WallFrameX + xOff; - int yPos = tile.WallFrameY; - - Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); - Color drawcolor; - drawcolor = WorldGen.paintColor(tile.WallColor); - drawcolor.A = 255; - Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); - - if (Main.drawToScreen) - zero = Vector2.Zero; - - Vector2 pos = new Vector2((i * 16 - (int)Main.screenPosition.X), (j * 16 - (int)Main.screenPosition.Y)) + zero; - Color lightColor = Lighting.GetColor(i, j, Color.White); - - spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); - - if (GlowMask.HasContentInFramePos(xPos, yPos)) + spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Main.GameViewMatrix.TransformationMatrix, () => { - float brightness = 1f; - float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.007f; - brightness *= MathF.Sin(i / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - brightness *= MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - brightness *= MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - brightness *= MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - drawcolor *= brightness; - Color glowColor = drawcolor * 0.4f; + Tile tile = Main.tile[i, j]; + Effect tileShader = Main.tileShader; + TreePaintingSettings settings = TreePaintSystemData.GetWallSettings(type); + int paintColor = tile.WallColor; + tileShader.Parameters["leafHueTestOffset"]?.SetValue(settings.HueTestOffset); + tileShader.Parameters["leafMinHue"]?.SetValue(settings.SpecialGroupMinimalHueValue); + tileShader.Parameters["leafMaxHue"]?.SetValue(settings.SpecialGroupMaximumHueValue); + tileShader.Parameters["leafMinSat"]?.SetValue(settings.SpecialGroupMinimumSaturationValue); + tileShader.Parameters["leafMaxSat"]?.SetValue(settings.SpecialGroupMaximumSaturationValue); + tileShader.Parameters["invertSpecialGroupResult"]?.SetValue(settings.InvertSpecialGroupResult); + int index = Main.ConvertPaintIdToTileShaderIndex(paintColor, settings.UseSpecialGroups, settings.UseWallShaderHacks); + tileShader.CurrentTechnique.Passes[index].Apply(); - // For now checking for glowing frames greatly reducing the bottleneck - // But maybe we could squeeze bit more by removing the loop - for (int k = 0; k < 3; k++) + Texture2D sprite = TextureAssets.Wall[type].Value; + Vector2 offset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange)) - Vector2.One * 8f; + int yPos = tile.WallFrameY; + int xPos = tile.WallFrameX; + Rectangle frame = new Rectangle(xPos, yPos, 32, 32); + Color lightColor = Lighting.GetColor(i, j); + + spriteBatch.Draw(sprite, offset, frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + + if (GlowMask.HasContentInFramePos(xPos, yPos)) { - Vector2 offset = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)) * 0.2f * k; - spriteBatch.Draw(GlowMask.Texture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Color glowColor = Color.Lerp(lightColor, Color.White, 0.2f + MathF.Sin(Main.GameUpdateCount * 0.007f) * 0.1f); + spriteBatch.Draw(GlowMask.Texture, offset, frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } - } - } - - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - DrawWallGlow(Type, i, j, spriteBatch); + }); return false; } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => DrawWallGlow(Type, i, j, spriteBatch); + public override void KillWall(int i, int j, ref bool fail) => fail = true; public override bool CanExplode(int i, int j) => false; diff --git a/Walls/WulfrumPlatingWall.cs b/Walls/WulfrumPlatingWall.cs index 131ba934ea..32ed421549 100644 --- a/Walls/WulfrumPlatingWall.cs +++ b/Walls/WulfrumPlatingWall.cs @@ -23,28 +23,7 @@ namespace CalamityMod.Walls public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Texture2D sprite = TextureAssets.Wall[Type].Value; - Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - zero -= new Vector2(8, 8); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - int[] sheetOffset = CreatePattern(i, j); - spriteBatch.Draw - ( - sprite, - drawOffset, - new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32), - lightColor, - 0, - new Vector2(0f, 0f), - 1, - SpriteEffects.None, - 0f - ); - return false; - } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j)); private int[] CreatePattern(int i, int j) {