using CalamityMod.Items.Materials; using CalamityMod.Tiles.DraedonSummoner; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; using Microsoft.Xna.Framework; using CalamityMod.TileEntities; using CalamityMod.CustomRecipes; using System.Collections.Generic; using System; namespace CalamityMod.Items.DraedonMisc { public class LongRangedSensorArray : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.DraedonItems"; public static readonly SoundStyle InstallSound = new("CalamityMod/Sounds/Custom/Codebreaker/LongRangeSensorArrayInstall"); public override void SetDefaults() { Item.width = 52; Item.height = 52; Item.maxStack = 9999; Item.consumable = true; Item.useStyle = ItemUseStyleID.Swing; Item.rare = ItemRarityID.Pink; Item.useTime = Item.useAnimation = 15; } public override bool? UseItem(Player player) => true; public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); 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.ContainsSensorArray) return false; codebreakerTileEntity.ContainsSensorArray = true; codebreakerTileEntity.SyncConstituents((short)Main.myPlayer); return true; } return false; } public override void AddRecipes() { CreateRecipe(). AddIngredient(10). AddIngredient(10). AddRecipeGroup("AnyMythrilBar", 10). AddIngredient(ItemID.Wire, 50). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). AddTile(TileID.MythrilAnvil). Register(); } } }