using System; using System.Collections.Generic; using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.TileEntities; using CalamityMod.Tiles.DraedonSummoner; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.DraedonMisc { public class DecryptionComputer : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.DraedonItems"; public static readonly SoundStyle InstallSound = new("CalamityMod/Sounds/Custom/Codebreaker/DecryptionComputerInstall"); public override void SetDefaults() { Item.width = 42; Item.height = 40; Item.maxStack = 9999; Item.consumable = true; Item.useStyle = ItemUseStyleID.Swing; Item.rare = ItemRarityID.Orange; Item.useTime = Item.useAnimation = 15; } public override bool? UseItem(Player player) => true; public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); public override bool ConsumeItem(Player player) { Point placeTileCoords = Main.MouseWorld.ToTileCoordinates(); Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y); float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f; if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.HasTile && tile.TileType == ModContent.TileType()) { SoundEngine.PlaySound(InstallSound, Main.player[Main.myPlayer].Center); TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare); if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsDecryptionComputer) return false; codebreakerTileEntity.ContainsDecryptionComputer = true; codebreakerTileEntity.SyncConstituents((short)Main.myPlayer); return true; } return false; } public override void AddRecipes() { CreateRecipe(). AddIngredient(18). AddIngredient(10). AddIngredient(ItemID.Wire, 100). AddRecipeGroup("AnyCopperBar", 10). AddIngredient(ItemID.Glass, 15). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). AddTile(TileID.Anvils). Register(); } } }