Files
CalamityModPublic/Items/SummonItems/OldPowerCell.cs
T
Flowaria 3978b26a5f Netcode Fix: Boss Summon Item issue fixes (#55)
* Fixed Netcode Issues on BossSummon Items

* Replaced npc loop to ActiveNPCs iterator
2024-08-25 12:45:52 -04:00

59 lines
1.9 KiB
C#

using CalamityMod.Events;
using CalamityMod.Items.Materials;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.SummonItems
{
public class OldPowerCell : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.SummonItems";
public override string Texture => $"Terraria/Images/Item_{ItemID.LihzahrdPowerCell}";
public override void SetStaticDefaults()
{
NPCID.Sets.MPAllowedEnemies[NPCID.Golem] = true;
ItemID.Sets.SortingPriorityBossSpawns[Type] = 16; // Lihzahrd Power Cell
}
public override void SetDefaults()
{
Item.width = 28;
Item.height = 18;
Item.rare = ItemRarityID.Lime;
Item.useAnimation = 10;
Item.useTime = 10;
Item.useStyle = ItemUseStyleID.HoldUp;
Item.consumable = false;
}
public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup)
{
itemGroup = ContentSamples.CreativeHelper.ItemGroup.BossItem;
}
public override bool CanUseItem(Player player)
{
return player.ZoneLihzhardTemple && !NPC.AnyNPCs(NPCID.Golem) && !BossRushEvent.BossRushActive;
}
public override bool? UseItem(Player player)
{
int posX = (int)player.Center.X;
int posY = (int)(player.Center.Y - 150.0f);
CalamityUtils.SpawnBossOnPosUsingItem(player, NPCID.Golem, posX, posY, SoundID.Roar);
return true;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient(ItemID.LunarTabletFragment, 20).
AddIngredient<EssenceofSunlight>(10).
AddTile(TileID.MythrilAnvil).
Register();
}
}
}