69 lines
2.8 KiB
C#
69 lines
2.8 KiB
C#
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 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.useAnimation = Item.useTime = 15;
|
|
}
|
|
|
|
public override bool? UseItem(Player player) => true;
|
|
|
|
public override void ModifyTooltips(List<TooltipLine> 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<CodebreakerTile>())
|
|
{
|
|
SoundEngine.PlaySound(InstallSound, Main.player[Main.myPlayer].Center);
|
|
|
|
TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity<TECodebreaker>(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<MysteriousCircuitry>(10).
|
|
AddIngredient<DubiousPlating>(10).
|
|
AddRecipeGroup("AnyMythrilBar", 10).
|
|
AddIngredient(ItemID.Wire, 50).
|
|
AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func<bool> condition), condition).
|
|
AddTile(TileID.MythrilAnvil).
|
|
Register();
|
|
}
|
|
}
|
|
}
|