diff --git a/Items/Accessories/PhantomicArtifact.cs b/Items/Accessories/PhantomicArtifact.cs index f1c8b09981..9814584b8f 100644 --- a/Items/Accessories/PhantomicArtifact.cs +++ b/Items/Accessories/PhantomicArtifact.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; +using CalamityMod.Items.Placeables.Plates; using CalamityMod.Rarities; using Terraria; using Terraria.DataStructures; @@ -39,6 +40,7 @@ namespace CalamityMod.Items.Accessories CreateRecipe(). AddIngredient(). AddIngredient(5). + AddIngredient(25). AddIngredient(20). AddTile(TileID.LunarCraftingStation). Register(); diff --git a/Items/Placeables/Plates/Onyxplate.cs b/Items/Placeables/Plates/Onyxplate.cs new file mode 100644 index 0000000000..be00ab10f2 --- /dev/null +++ b/Items/Placeables/Plates/Onyxplate.cs @@ -0,0 +1,46 @@ +using CalamityMod.Items.Placeables.Walls; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.Plates +{ + public class Onyxplate : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Onyxplate"); + Tooltip.SetDefault("It resonates with otherworldly energy."); + SacrificeTotal = 100; + } + + public override void SetDefaults() + { + Item.createTile = ModContent.TileType(); + Item.useStyle = ItemUseStyleID.Swing; + Item.useTurn = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.autoReuse = true; + Item.consumable = true; + Item.width = 13; + Item.height = 10; + Item.maxStack = 999; + Item.value = Item.sellPrice(silver: 3); + Item.rare = ItemRarityID.Orange; + } + + public override void AddRecipes() + { + CreateRecipe(25). + AddIngredient(ItemID.Obsidian, 50). + AddTile(TileID.Hellforge). + Register(); + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Plates/Onyxplate.png b/Items/Placeables/Plates/Onyxplate.png new file mode 100644 index 0000000000..3ed48d47bd Binary files /dev/null and b/Items/Placeables/Plates/Onyxplate.png differ diff --git a/Items/Placeables/Walls/OnyxplateWall.cs b/Items/Placeables/Walls/OnyxplateWall.cs new file mode 100644 index 0000000000..7d5abda420 --- /dev/null +++ b/Items/Placeables/Walls/OnyxplateWall.cs @@ -0,0 +1,34 @@ +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; +using Terraria.ID; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class OnyxplateWall : ModItem + { + public override void SetStaticDefaults() + { + SacrificeTotal = 400; + DisplayName.SetDefault("Onyxplate Wall"); + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 7; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createWall = ModContent.WallType(); + } + + public override void AddRecipes() + { + CreateRecipe(4).AddIngredient(ModContent.ItemType()).AddTile(TileID.WorkBenches).Register(); + } + } +} diff --git a/Items/Placeables/Walls/OnyxplateWall.png b/Items/Placeables/Walls/OnyxplateWall.png new file mode 100644 index 0000000000..f58c494058 Binary files /dev/null and b/Items/Placeables/Walls/OnyxplateWall.png differ diff --git a/Tiles/Plates/Onyxplate.cs b/Tiles/Plates/Onyxplate.cs new file mode 100644 index 0000000000..1742359986 --- /dev/null +++ b/Tiles/Plates/Onyxplate.cs @@ -0,0 +1,81 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; +using ReLogic.Content; + +namespace CalamityMod.Tiles.Plates +{ + public class Onyxplate : ModTile + { + internal static Texture2D GlowTexture; + internal static Texture2D PulseTexture; + internal static Color[] PulseColors; + public override void SetStaticDefaults() + { + if (!Main.dedServ) + { + PulseTexture = ModContent.Request("CalamityMod/Tiles/Plates/OnyxplatePulse", AssetRequestMode.ImmediateLoad).Value; + PulseColors = new Color[PulseTexture.Width]; + Main.QueueMainThreadAction(() => PulseTexture.GetData(PulseColors)); + GlowTexture = ModContent.Request("CalamityMod/Tiles/Plates/OnyxplateGlow", AssetRequestMode.ImmediateLoad).Value; + } + Main.tileSolid[Type] = true; + Main.tileMergeDirt[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + HitSound = SoundID.Tink; + MineResist = 1f; + DustType = 173; + ItemDrop = ModContent.ItemType(); + AddMapEntry(new Color(182, 28, 232)); + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + // If the cached textures don't exist for some reason, don't bother using them. + if (GlowTexture is null || PulseTexture is null) + return; + + int xPos = Main.tile[i, j].TileFrameX; + int yPos = Main.tile[i, j].TileFrameY; + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; + + // Glowmask 'pulse' effect + int factor = (int)Main.GameUpdateCount % PulseTexture.Width; + float brightness = PulseColors[factor].R / 255f; + int drawBrightness = (int)(80 * brightness) + 10; + Color drawColour = GetDrawColour(i, j, new Color(drawBrightness, drawBrightness, drawBrightness, drawBrightness)); + + // If these tiles cause lag, comment out the pulse effect code and uncomment this: + //Color drawColour = GetDrawColour(i, j, new Color(50, 50, 50, 50)); + + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + { + Main.spriteBatch.Draw(GlowTexture, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + else if (trackTile.IsHalfBlock) + { + Main.spriteBatch.Draw(GlowTexture, drawOffset + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } + + private Color GetDrawColour(int i, int j, Color colour) + { + int colType = Main.tile[i, j].TileColor; + Color paintCol = WorldGen.paintColor(colType); + if (colType >= 13 && colType <= 24) + { + colour.R = (byte)(paintCol.R / 255f * colour.R); + colour.G = (byte)(paintCol.G / 255f * colour.G); + colour.B = (byte)(paintCol.B / 255f * colour.B); + } + return colour; + } + } +} diff --git a/Tiles/Plates/Onyxplate.png b/Tiles/Plates/Onyxplate.png new file mode 100644 index 0000000000..4498318a7e Binary files /dev/null and b/Tiles/Plates/Onyxplate.png differ diff --git a/Tiles/Plates/OnyxplateGlow.png b/Tiles/Plates/OnyxplateGlow.png new file mode 100644 index 0000000000..a5d343aca4 Binary files /dev/null and b/Tiles/Plates/OnyxplateGlow.png differ diff --git a/Tiles/Plates/OnyxplatePulse.png b/Tiles/Plates/OnyxplatePulse.png new file mode 100644 index 0000000000..2dfaed8013 Binary files /dev/null and b/Tiles/Plates/OnyxplatePulse.png differ diff --git a/Walls/OnyxplateWall.cs b/Walls/OnyxplateWall.cs new file mode 100644 index 0000000000..1afbc3e1fd --- /dev/null +++ b/Walls/OnyxplateWall.cs @@ -0,0 +1,26 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class OnyxplateWall : ModWall + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + + ItemDrop = ModContent.ItemType(); + AddMapEntry(new Color(92, 7, 92)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 60, 0f, 0f, 1, new Color(255, 255, 255), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 1, 0f, 0f, 1, new Color(100, 100, 100), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/OnyxplateWall.png b/Walls/OnyxplateWall.png new file mode 100644 index 0000000000..65a52bcfb4 Binary files /dev/null and b/Walls/OnyxplateWall.png differ